mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
core/state: better detection of dirty storage mismatches
This commit is contained in:
parent
1861642001
commit
37b712eae6
1 changed files with 20 additions and 10 deletions
|
|
@ -584,16 +584,6 @@ 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -628,6 +618,26 @@ func (test *snapshotTest) checkEqual(state, checkstate *StateDB) error {
|
||||||
forEachStorage(checkstate, addr, func(key, value common.Hash) bool {
|
forEachStorage(checkstate, addr, func(key, value common.Hash) bool {
|
||||||
return checkeq("GetState("+key.Hex()+")", checkstate.GetState(addr, key), value)
|
return checkeq("GetState("+key.Hex()+")", checkstate.GetState(addr, key), value)
|
||||||
})
|
})
|
||||||
|
other := checkstate.getStateObject(addr)
|
||||||
|
// Check dirty storage which is not in trie
|
||||||
|
if !maps.Equal(obj.dirtyStorage, other.dirtyStorage) {
|
||||||
|
print := func(dirty map[common.Hash]common.Hash) string {
|
||||||
|
var keys []common.Hash
|
||||||
|
out := new(strings.Builder)
|
||||||
|
for key := range dirty {
|
||||||
|
keys = append(keys, key)
|
||||||
|
}
|
||||||
|
slices.SortFunc(keys, common.Hash.Cmp)
|
||||||
|
for i, key := range keys {
|
||||||
|
fmt.Fprintf(out, " %d. %v %v\n", i, key, dirty[key])
|
||||||
|
}
|
||||||
|
return out.String()
|
||||||
|
}
|
||||||
|
return fmt.Errorf("dirty storage err, have\n%v\nwant\n%v",
|
||||||
|
print(obj.dirtyStorage),
|
||||||
|
print(other.dirtyStorage))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Check transient storage.
|
// Check transient storage.
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue