Skip to content

Commit

Permalink
core/state: pull the verkle trie from prefetcher for empty storage ro…
Browse files Browse the repository at this point in the history
…ot (ethereum#30369)

This pull request fixes a flaw in prefetcher.

In verkle tree world, both accounts and storage slots are committed into
a single tree instance for state hashing. If the prefetcher is activated, we will
try to pull the trie for the prefetcher for performance speedup. 

However, we had a special logic to skip pulling storage trie if the
storage root is empty. While it's true for merkle as we have nothing to
do with an empty storage trie, it's totally wrong for verkle. The consequences
for skipping pulling is the storage changes are committed into trie A, while the
account changes are committed into trie B (pulled from the prefetcher), boom.
  • Loading branch information
rjl493456442 committed Sep 2, 2024
1 parent 36a7134 commit 922eb03
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (s *stateObject) getTrie() (Trie, error) {
func (s *stateObject) getPrefetchedTrie() Trie {
// If there's nothing to meaningfully return, let the user figure it out by
// pulling the trie from disk.
if s.data.Root == types.EmptyRootHash || s.db.prefetcher == nil {
if (s.data.Root == types.EmptyRootHash && !s.db.db.TrieDB().IsVerkle()) || s.db.prefetcher == nil {
return nil
}
// Attempt to retrieve the trie from the prefetcher
Expand Down

0 comments on commit 922eb03

Please sign in to comment.