From 05e199408fa23f22a1958853d2629df96da77ee4 Mon Sep 17 00:00:00 2001 From: cz Date: Tue, 17 Jun 2025 20:13:03 +0800 Subject: [PATCH] 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. --- core/state/dump.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/state/dump.go b/core/state/dump.go index 11b5c32782..3af9133f5b 100644 --- a/core/state/dump.go +++ b/core/state/dump.go @@ -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)