From 29ef67ccfc80eae8a07ce17c2e89224d01c1a091 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 24 Apr 2024 13:10:23 +0200 Subject: [PATCH] core/state: check dirty storage in post-check --- core/state/statedb_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/state/statedb_test.go b/core/state/statedb_test.go index f26059e21b..8f5b1abcdd 100644 --- a/core/state/statedb_test.go +++ b/core/state/statedb_test.go @@ -558,10 +558,14 @@ func forEachStorage(s *StateDB, addr common.Address, cb func(key, value common.H if err != nil { return err } - it := trie.NewIterator(trieIt) + var ( + it = trie.NewIterator(trieIt) + visited = make(map[common.Hash]bool) + ) for it.Next() { key := common.BytesToHash(s.trie.GetKey(it.Key)) + visited[key] = true if value, dirty := so.dirtyStorage[key]; dirty { if !cb(key, value) { return nil @@ -579,6 +583,16 @@ func forEachStorage(s *StateDB, addr common.Address, cb func(key, value common.H } } } + // Now visit any remaining dirty storage which is not in trie + for key, value := range so.dirtyStorage { + if visited[key] { + continue + } + if !cb(key, value) { + return nil + } + } + return nil }