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 <akhounov@gmail.com>
This commit is contained in:
Martin Holst Swende 2020-05-07 15:06:31 +02:00 committed by GitHub
parent dd88bd82c9
commit 1152f45849
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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) {
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))
}