From 7d5b8feedc2563dc2d55b7dd35b36e58ec40daa4 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Tue, 4 Jun 2024 10:03:09 +0800 Subject: [PATCH] Update statedb.go --- core/state/statedb.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 9c965689f5..be2b8346fa 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -208,8 +208,18 @@ func (s *StateDB) StartPrefetcher(namespace string) { } if s.snap != nil { s.prefetcher = newTriePrefetcher(s.db, s.originalRoot, namespace) - if err := s.prefetcher.prefetch(common.Hash{}, s.originalRoot, common.Address{}, [][]byte{}); err != nil { - log.Error("Failed to prefetch account trie", "pre-state root", s.originalRoot.String(), "err", err) + + // With the switch to the Proof-of-Stake consensus algorithm, block production + // rewards are now handled at the consensus layer. Consequently, a block may + // have no state transitions if it contains no transactions and no withdrawals. + // In such cases, the account trie won't be scheduled for prefetching, leading + // to unnecessary error logs. + // + // To prevent this, the account trie is always scheduled for prefetching once + // the prefetcher is constructed. For more details, see: + // https://github.com/ethereum/go-ethereum/issues/29880 + if err := s.prefetcher.prefetch(common.Hash{}, s.originalRoot, common.Address{}, nil); err != nil { + log.Error("Failed to prefetch account trie", "root", s.originalRoot.String(), "err", err) } } }