Include 0x0000 address into the dump if it is present

This commit is contained in:
Alexey Akhunov 2020-04-25 15:22:44 +01:00 committed by Martin Holst Swende
parent 292570ad6c
commit aba2659f5a
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -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) { func (s *StateDB) dump(c collector, excludeCode, excludeStorage, excludeMissingPreimages bool, start []byte, maxResults int) (nextKey []byte) {
emptyAddress := (common.Address{})
missingPreimages := 0 missingPreimages := 0
c.onRoot(s.trie.Hash()) c.onRoot(s.trie.Hash())
@ -114,22 +113,23 @@ func (s *StateDB) dump(c collector, excludeCode, excludeStorage, excludeMissingP
if err := rlp.DecodeBytes(it.Value, &data); err != nil { if err := rlp.DecodeBytes(it.Value, &data); err != nil {
panic(err) panic(err)
} }
addr := common.BytesToAddress(s.trie.GetKey(it.Key))
obj := newObject(nil, addr, data)
account := DumpAccount{ account := DumpAccount{
Balance: data.Balance.String(), Balance: data.Balance.String(),
Nonce: data.Nonce, Nonce: data.Nonce,
Root: common.Bytes2Hex(data.Root[:]), Root: common.Bytes2Hex(data.Root[:]),
CodeHash: common.Bytes2Hex(data.CodeHash), CodeHash: common.Bytes2Hex(data.CodeHash),
} }
if emptyAddress == addr { addrBytes := s.trie.GetKey(it.Key)
if addrBytes == nil {
// Preimage missing // Preimage missing
missingPreimages++ missingPreimages++
if excludeMissingPreimages { if excludeMissingPreimages {
continue continue
} }
account.SecureKey = it.Key account.SecureKey = it.Key
} }
addr := common.BytesToAddress(addrBytes)
obj := newObject(nil, addr, data)
if !excludeCode { if !excludeCode {
account.Code = common.Bytes2Hex(obj.Code(s.db)) account.Code = common.Bytes2Hex(obj.Code(s.db))
} }