Skip to content

Commit adbbd8c

Browse files
Steven Wangstevenrjl493456442
authored
core/state: prefetch account trie while starting a prefetcher (#29919)
Always prefetch the account trie while starting the prefetcher. Co-authored-by: steven <[email protected]> Co-authored-by: rjl493456442 <[email protected]>
1 parent a6751d6 commit adbbd8c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/state/statedb.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ func (s *StateDB) StartPrefetcher(namespace string) {
208208
}
209209
if s.snap != nil {
210210
s.prefetcher = newTriePrefetcher(s.db, s.originalRoot, namespace)
211+
212+
// With the switch to the Proof-of-Stake consensus algorithm, block production
213+
// rewards are now handled at the consensus layer. Consequently, a block may
214+
// have no state transitions if it contains no transactions and no withdrawals.
215+
// In such cases, the account trie won't be scheduled for prefetching, leading
216+
// to unnecessary error logs.
217+
//
218+
// To prevent this, the account trie is always scheduled for prefetching once
219+
// the prefetcher is constructed. For more details, see:
220+
// https://github.com/ethereum/go-ethereum/issues/29880
221+
if err := s.prefetcher.prefetch(common.Hash{}, s.originalRoot, common.Address{}, nil); err != nil {
222+
log.Error("Failed to prefetch account trie", "root", s.originalRoot, "err", err)
223+
}
211224
}
212225
}
213226

0 commit comments

Comments
 (0)