From 236192acfba6b1557484df6c89e2c6a8bf03c532 Mon Sep 17 00:00:00 2001 From: weiihann Date: Tue, 30 May 2023 19:47:38 +0800 Subject: [PATCH] consensus, core/rawdb, miner: downgrade logs consensus: allow validator error to print validator address --- consensus/parlia/parlia.go | 12 +++++++----- consensus/parlia/snapshot.go | 2 +- core/rawdb/chain_iterator.go | 2 +- miner/worker.go | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index b660217c17..836aa8c059 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -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") @@ -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) { @@ -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.Hex()) } // If we're amongst the recent signers, wait for the next block @@ -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 @@ -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 } diff --git a/consensus/parlia/snapshot.go b/consensus/parlia/snapshot.go index 74dd983be5..b34efed24f 100644 --- a/consensus/parlia/snapshot.go +++ b/consensus/parlia/snapshot.go @@ -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 { diff --git a/core/rawdb/chain_iterator.go b/core/rawdb/chain_iterator.go index 13e684a69c..7974210895 100644 --- a/core/rawdb/chain_iterator.go +++ b/core/rawdb/chain_iterator.go @@ -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))) } } diff --git a/miner/worker.go b/miner/worker.go index 9f4cce2988..e4a3e5a4ff 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -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 {