mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
some upgrades relate to pathdb
This commit is contained in:
parent
263aef9cc4
commit
3a25fea6da
2 changed files with 20 additions and 32 deletions
|
|
@ -1052,9 +1052,9 @@ func (s *StateDB) deleteStorage(addr common.Address, addrHash common.Hash, root
|
||||||
// with their values be tracked as original value.
|
// with their values be tracked as original value.
|
||||||
func (s *StateDB) handleDestruction(noStorageWiping bool) (map[common.Hash]*accountDelete, []*trienode.NodeSet, error) {
|
func (s *StateDB) handleDestruction(noStorageWiping bool) (map[common.Hash]*accountDelete, []*trienode.NodeSet, error) {
|
||||||
var (
|
var (
|
||||||
nodes []*trienode.NodeSet
|
nodes = make([]*trienode.NodeSet, 0, len(s.stateObjectsDestruct))
|
||||||
buf = crypto.NewKeccakState()
|
hasher = crypto.NewKeccakState()
|
||||||
deletes = make(map[common.Hash]*accountDelete)
|
deletes = make(map[common.Hash]*accountDelete, len(s.stateObjectsDestruct))
|
||||||
)
|
)
|
||||||
for addr, prevObj := range s.stateObjectsDestruct {
|
for addr, prevObj := range s.stateObjectsDestruct {
|
||||||
prev := prevObj.origin
|
prev := prevObj.origin
|
||||||
|
|
@ -1063,12 +1063,12 @@ func (s *StateDB) handleDestruction(noStorageWiping bool) (map[common.Hash]*acco
|
||||||
// of block. It can be either case (a) or (b) and will be interpreted as
|
// of block. It can be either case (a) or (b) and will be interpreted as
|
||||||
// null->null state transition.
|
// null->null state transition.
|
||||||
// - for (a), skip it without doing anything
|
// - for (a), skip it without doing anything
|
||||||
// - for (b), the resurrected account with nil as original will be handled afterwards
|
// - for (b), the resurrected account with nil as original will be handled afterward
|
||||||
if prev == nil {
|
if prev == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// The account was existent, it can be either case (c) or (d).
|
// The account was existent, it can be either case (c) or (d).
|
||||||
addrHash := crypto.HashData(buf, addr.Bytes())
|
addrHash := crypto.HashData(hasher, addr.Bytes())
|
||||||
op := &accountDelete{
|
op := &accountDelete{
|
||||||
address: addr,
|
address: addr,
|
||||||
origin: types.SlimAccountRLP(*prev),
|
origin: types.SlimAccountRLP(*prev),
|
||||||
|
|
|
||||||
|
|
@ -338,12 +338,10 @@ func (s *stateSet) encode(w io.Writer) error {
|
||||||
AddrHashes []common.Hash
|
AddrHashes []common.Hash
|
||||||
Accounts [][]byte
|
Accounts [][]byte
|
||||||
}
|
}
|
||||||
var enc accounts
|
if err := rlp.Encode(w, accounts{
|
||||||
for addrHash, blob := range s.accountData {
|
AddrHashes: slices.Collect(maps.Keys(s.accountData)),
|
||||||
enc.AddrHashes = append(enc.AddrHashes, addrHash)
|
Accounts: slices.Collect(maps.Values(s.accountData)),
|
||||||
enc.Accounts = append(enc.Accounts, blob)
|
}); err != nil {
|
||||||
}
|
|
||||||
if err := rlp.Encode(w, enc); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Encode storages
|
// Encode storages
|
||||||
|
|
@ -354,16 +352,10 @@ func (s *stateSet) encode(w io.Writer) error {
|
||||||
}
|
}
|
||||||
storages := make([]Storage, 0, len(s.storageData))
|
storages := make([]Storage, 0, len(s.storageData))
|
||||||
for addrHash, slots := range s.storageData {
|
for addrHash, slots := range s.storageData {
|
||||||
keys := make([]common.Hash, 0, len(slots))
|
|
||||||
vals := make([][]byte, 0, len(slots))
|
|
||||||
for key, val := range slots {
|
|
||||||
keys = append(keys, key)
|
|
||||||
vals = append(vals, val)
|
|
||||||
}
|
|
||||||
storages = append(storages, Storage{
|
storages = append(storages, Storage{
|
||||||
AddrHash: addrHash,
|
AddrHash: addrHash,
|
||||||
Keys: keys,
|
Keys: slices.Collect(maps.Keys(slots)),
|
||||||
Vals: vals,
|
Vals: slices.Collect(maps.Values(slots)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return rlp.Encode(w, storages)
|
return rlp.Encode(w, storages)
|
||||||
|
|
@ -498,12 +490,10 @@ func (s *StateSetWithOrigin) encode(w io.Writer) error {
|
||||||
Addresses []common.Address
|
Addresses []common.Address
|
||||||
Accounts [][]byte
|
Accounts [][]byte
|
||||||
}
|
}
|
||||||
var accounts Accounts
|
if err := rlp.Encode(w, Accounts{
|
||||||
for address, blob := range s.accountOrigin {
|
Addresses: slices.Collect(maps.Keys(s.accountOrigin)),
|
||||||
accounts.Addresses = append(accounts.Addresses, address)
|
Accounts: slices.Collect(maps.Values(s.accountOrigin)),
|
||||||
accounts.Accounts = append(accounts.Accounts, blob)
|
}); err != nil {
|
||||||
}
|
|
||||||
if err := rlp.Encode(w, accounts); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Encode storages
|
// Encode storages
|
||||||
|
|
@ -514,13 +504,11 @@ func (s *StateSetWithOrigin) encode(w io.Writer) error {
|
||||||
}
|
}
|
||||||
storages := make([]Storage, 0, len(s.storageOrigin))
|
storages := make([]Storage, 0, len(s.storageOrigin))
|
||||||
for address, slots := range s.storageOrigin {
|
for address, slots := range s.storageOrigin {
|
||||||
keys := make([]common.Hash, 0, len(slots))
|
storages = append(storages, Storage{
|
||||||
vals := make([][]byte, 0, len(slots))
|
Address: address,
|
||||||
for key, val := range slots {
|
Keys: slices.Collect(maps.Keys(slots)),
|
||||||
keys = append(keys, key)
|
Vals: slices.Collect(maps.Values(slots)),
|
||||||
vals = append(vals, val)
|
})
|
||||||
}
|
|
||||||
storages = append(storages, Storage{Address: address, Keys: keys, Vals: vals})
|
|
||||||
}
|
}
|
||||||
return rlp.Encode(w, storages)
|
return rlp.Encode(w, storages)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue