fix: skip storage entries with missing preimage keys (#32051)

When `GetKey`  is called, a missing preimage can cause the function to return a `nil`
key. This, in turn, makes `account.Storage` persist an incorrect value.
This commit is contained in:
cz 2025-06-17 20:13:03 +08:00 committed by GitHub
parent 65d77c5129
commit 05e199408f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -182,7 +182,11 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
log.Error("Failed to decode the value returned by iterator", "error", err)
continue
}
account.Storage[common.BytesToHash(s.trie.GetKey(storageIt.Key))] = common.Bytes2Hex(content)
key := s.trie.GetKey(storageIt.Key)
if key == nil {
continue
}
account.Storage[common.BytesToHash(key)] = common.Bytes2Hex(content)
}
}
c.OnAccount(address, account)