Skip to content

Commit 29ef67c

Browse files
committed
core/state: check dirty storage in post-check
1 parent 3380364 commit 29ef67c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

core/state/statedb_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,14 @@ func forEachStorage(s *StateDB, addr common.Address, cb func(key, value common.H
558558
if err != nil {
559559
return err
560560
}
561-
it := trie.NewIterator(trieIt)
561+
var (
562+
it = trie.NewIterator(trieIt)
563+
visited = make(map[common.Hash]bool)
564+
)
562565

563566
for it.Next() {
564567
key := common.BytesToHash(s.trie.GetKey(it.Key))
568+
visited[key] = true
565569
if value, dirty := so.dirtyStorage[key]; dirty {
566570
if !cb(key, value) {
567571
return nil
@@ -579,6 +583,16 @@ func forEachStorage(s *StateDB, addr common.Address, cb func(key, value common.H
579583
}
580584
}
581585
}
586+
// Now visit any remaining dirty storage which is not in trie
587+
for key, value := range so.dirtyStorage {
588+
if visited[key] {
589+
continue
590+
}
591+
if !cb(key, value) {
592+
return nil
593+
}
594+
}
595+
582596
return nil
583597
}
584598

0 commit comments

Comments
 (0)