From 1152f458499b4d91b95a873d9d33c923397a2184 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 7 May 2020 15:06:31 +0200 Subject: [PATCH] core/state: include zero-address in state dump if present (#21038) * Include 0x0000 address into the dump if it is present * core/state: go fmt Co-authored-by: Alexey Akhunov --- core/state/dump.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/state/dump.go b/core/state/dump.go index ded9298ee..8224e160b 100644 --- a/core/state/dump.go +++ b/core/state/dump.go @@ -103,7 +103,6 @@ func (d iterativeDump) onRoot(root common.Hash) { } func (s *StateDB) dump(c collector, excludeCode, excludeStorage, excludeMissingPreimages bool, start []byte, maxResults int) (nextKey []byte) { - emptyAddress := (common.Address{}) missingPreimages := 0 c.onRoot(s.trie.Hash()) @@ -114,15 +113,14 @@ func (s *StateDB) dump(c collector, excludeCode, excludeStorage, excludeMissingP if err := rlp.DecodeBytes(it.Value, &data); err != nil { panic(err) } - addr := common.BytesToAddress(s.trie.GetKey(it.Key)) - obj := newObject(nil, addr, data) account := DumpAccount{ Balance: data.Balance.String(), Nonce: data.Nonce, Root: common.Bytes2Hex(data.Root[:]), CodeHash: common.Bytes2Hex(data.CodeHash), } - if emptyAddress == addr { + addrBytes := s.trie.GetKey(it.Key) + if addrBytes == nil { // Preimage missing missingPreimages++ if excludeMissingPreimages { @@ -130,6 +128,8 @@ func (s *StateDB) dump(c collector, excludeCode, excludeStorage, excludeMissingP } account.SecureKey = it.Key } + addr := common.BytesToAddress(addrBytes) + obj := newObject(nil, addr, data) if !excludeCode { account.Code = common.Bytes2Hex(obj.Code(s.db)) }