Skip to content

Commit

Permalink
core/state: prefetch account trie while starting a prefetcher (#29919)
Browse files Browse the repository at this point in the history
Always prefetch the account trie while starting the prefetcher.

Co-authored-by: steven <steven@stevendeMacBook-Pro.local>
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
  • Loading branch information
3 people authored Jun 4, 2024
1 parent a6751d6 commit adbbd8c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ func (s *StateDB) StartPrefetcher(namespace string) {
}
if s.snap != nil {
s.prefetcher = newTriePrefetcher(s.db, s.originalRoot, namespace)

// 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, "err", err)
}
}
}

Expand Down

0 comments on commit adbbd8c

Please sign in to comment.