From cede7f081369a72255e785701b0cde8b7c53bb36 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Mon, 13 May 2024 14:08:07 +0800 Subject: [PATCH] core/state: fix prefetcher for verkle --- core/state/statedb.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 0ef52a88f6ea7..fd906c72a911c 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -875,9 +875,12 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash { // Now we're about to start to write changes to the trie. The trie is so far // _untouched_. We can check with the prefetcher, if it can give us a trie // which has the same root, but also has some content loaded into it. + // + // Don't check prefetcher if verkle Trie has been used. In the context of verkle, + // only a single trie is used for state hashing. Replacing a non-nil verkle tree + // here could result in losing uncommitted changes from storage. start = time.Now() - - if s.prefetcher != nil { + if s.prefetcher != nil && (s.trie == nil || !s.trie.IsVerkle()) { if trie, err := s.prefetcher.trie(common.Hash{}, s.originalRoot); err != nil { log.Error("Failed to retrieve account pre-fetcher trie", "err", err) } else if trie != nil {