more cleanup

This commit is contained in:
Jared Wasinger 2025-11-13 01:44:32 +08:00
parent 74ca164123
commit b3d8591cb0
2 changed files with 5 additions and 64 deletions

View file

@ -104,36 +104,6 @@ func (r *BALReader) initObjFromDiff(db *StateDB, addr common.Address, a *types.S
return obj
}
func (s *BALReader) initMutatedObjFromDiff(db *StateDB, addr common.Address, a *types.StateAccount, diff *bal.AccountMutations) *stateObject {
var acct *types.StateAccount
if a == nil {
acct = &types.StateAccount{
Nonce: 0,
Balance: uint256.NewInt(0),
Root: types.EmptyRootHash,
CodeHash: types.EmptyCodeHash[:],
}
} else {
acct = a.Copy()
}
obj := newObject(db, addr, acct)
if diff.Nonce != nil {
obj.SetNonce(*diff.Nonce)
}
if diff.Balance != nil {
obj.SetBalance(new(uint256.Int).Set(diff.Balance))
}
if diff.Code != nil {
obj.SetCode(crypto.Keccak256Hash(diff.Code), diff.Code)
}
if diff.StorageWrites != nil {
for key, val := range diff.StorageWrites {
obj.SetState(key, val)
}
}
return obj
}
// BALReader provides methods for reading account state from a block access
// list. State values returned from the Reader methods must not be modified.
type BALReader struct {

View file

@ -931,31 +931,16 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
}
var updatedAddrs []common.Address
if s.blockAccessList != nil {
updatedAddrs = s.blockAccessList.ModifiedAccounts()
} else {
for addr, op := range s.mutations {
if op.applied || op.isDelete() {
continue
}
updatedAddrs = append(updatedAddrs, addr)
for addr, op := range s.mutations {
if op.applied || op.isDelete() {
continue
}
updatedAddrs = append(updatedAddrs, addr)
}
var m sync.Mutex
for _, addr := range updatedAddrs {
workers.Go(func() error {
var obj *stateObject
if s.blockAccessList != nil {
lastIdx := len(s.blockAccessList.block.Transactions()) + 1
diff := s.blockAccessList.readAccountDiff(addr, lastIdx)
acct := s.blockAccessList.prestateReader.account(addr)
m.Lock()
obj = s.blockAccessList.initMutatedObjFromDiff(s, addr, acct, diff)
m.Unlock()
} else {
obj = s.stateObjects[addr] // closure for the task runner below
}
obj := s.stateObjects[addr] // closure for the task runner below
if s.db.TrieDB().IsVerkle() {
obj.updateTrie()
} else {
@ -1081,20 +1066,6 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
// Track the amount of time wasted on hashing the account trie
defer func(start time.Time) { s.AccountHashes += time.Since(start) }(time.Now())
hash := s.trie.Hash()
/*
it, err := s.trie.NodeIterator([]byte{})
if err != nil {
panic(err)
}
fmt.Println("state trie")
for it.Next(true) {
if it.Leaf() {
fmt.Printf("%x: %x\n", it.Path(), it.LeafBlob())
} else {
fmt.Printf("%x: %x\n", it.Path(), it.Hash())
}
}
*/
// If witness building is enabled, gather the account trie witness
if s.witness != nil {
witness := s.trie.Witness()