Skip to content

Commit

Permalink
consensus, core/rawdb, miner: downgrade logs
Browse files Browse the repository at this point in the history
consensus: allow validator error to print validator address

change Hex() to String()
  • Loading branch information
weiihann committed May 31, 2023
1 parent 1b8ec07 commit 0b0eef7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ var (
errBlockHashInconsistent = errors.New("the block hash is inconsistent")

// errUnauthorizedValidator is returned if a header is signed by a non-authorized entity.
errUnauthorizedValidator = errors.New("unauthorized validator")
errUnauthorizedValidator = func(val string) error {
return errors.New("unauthorized validator: " + val)
}

// errCoinBaseMisMatch is returned if a header's coinbase do not match with signature
errCoinBaseMisMatch = errors.New("coinbase do not match with signature")
Expand Down Expand Up @@ -752,7 +754,7 @@ func (p *Parlia) verifySeal(chain consensus.ChainHeaderReader, header *types.Hea
}

if _, ok := snap.Validators[signer]; !ok {
return errUnauthorizedValidator
return errUnauthorizedValidator(signer.String())
}

if snap.SignRecently(signer) {
Expand Down Expand Up @@ -1298,7 +1300,7 @@ func (p *Parlia) Seal(chain consensus.ChainHeaderReader, block *types.Block, res

// Bail out if we're unauthorized to sign a block
if _, authorized := snap.Validators[val]; !authorized {
return errUnauthorizedValidator
return errUnauthorizedValidator(val.String())
}

// If we're amongst the recent signers, wait for the next block
Expand Down Expand Up @@ -1408,7 +1410,7 @@ func (p *Parlia) SignRecently(chain consensus.ChainReader, parent *types.Block)

// Bail out if we're unauthorized to sign a block
if _, authorized := snap.Validators[p.val]; !authorized {
return true, errUnauthorizedValidator
return true, errUnauthorizedValidator(p.val.String())
}

return snap.SignRecently(p.val), nil
Expand Down Expand Up @@ -1864,7 +1866,7 @@ func (p *Parlia) backOffTime(snap *Snapshot, header *types.Header, val common.Ad
}
}
if idx < 0 {
log.Info("The validator is not authorized", "addr", val)
log.Debug("The validator is not authorized", "addr", val)
return 0
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/parlia/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (s *Snapshot) apply(headers []*types.Header, chain consensus.ChainHeaderRea
return nil, err
}
if _, ok := snap.Validators[validator]; !ok {
return nil, errUnauthorizedValidator
return nil, errUnauthorizedValidator(validator.String())
}
for _, recent := range snap.Recents {
if recent == validator {
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/chain_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func unindexTransactions(db ethdb.Database, from uint64, to uint64, interrupt ch
case <-interrupt:
log.Debug("Transaction unindexing interrupted", "blocks", blocks, "txs", txs, "tail", to, "elapsed", common.PrettyDuration(time.Since(start)))
default:
log.Info("Unindexed transactions", "blocks", blocks, "txs", txs, "tail", to, "elapsed", common.PrettyDuration(time.Since(start)))
log.Debug("Unindexed transactions", "blocks", blocks, "txs", txs, "tail", to, "elapsed", common.PrettyDuration(time.Since(start)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
if p, ok := w.engine.(*parlia.Parlia); ok {
signedRecent, err := p.SignRecently(w.chain, head.Block)
if err != nil {
log.Info("Not allowed to propose block", "err", err)
log.Debug("Not allowed to propose block", "err", err)
continue
}
if signedRecent {
Expand Down

0 comments on commit 0b0eef7

Please sign in to comment.