Repository: ethereum/go-ethereum (language: go)

Issue:
Unexpected trie missing in prefetcher
Geth will occasionally report this kind of log during the full sync.

```
ERROR[05-30|10:43:55.896] Prefetcher missed to load trie           owner=000000..000000 root=223db5..e44945
```

It denotes the specific account trie is not scheduled for prefetching, but it's required for state rehashing.


Discussion / hints:
This tuned out to be post-merge but pre-withdrawals when there's an empty block with no txs, so the account trie never gets prefetched. So no issue, but scary warning.
https://etherscan.io/block/15537454
I guess the fix would be to *always* inject a prefetch() call for the account trie whenever we create a statedb / start a prefetcher. It's a bit overkill, but it's cleaner than trying to be smart about avoiding accessing the account trie in statedb.Commit.
I can consistently repeat the issue using the latest docker image in the https://github.com/ivy-net/iv1 (or any other derivative of https://github.com/OffchainLabs/eth-pos-devnet).

Fix patch:
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 659c500c3bf1..bb2a87b17294 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -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)
+		}
 	}
 }
 


Test patch: