From b3d8591cb059c87a524b70b5c587ef2c230132ab Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Thu, 13 Nov 2025 01:44:32 +0800 Subject: [PATCH] more cleanup --- core/state/bal_reader.go | 30 ------------------------------ core/state/statedb.go | 39 +++++---------------------------------- 2 files changed, 5 insertions(+), 64 deletions(-) diff --git a/core/state/bal_reader.go b/core/state/bal_reader.go index 7a8278088b..daaec20a9c 100644 --- a/core/state/bal_reader.go +++ b/core/state/bal_reader.go @@ -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 { diff --git a/core/state/statedb.go b/core/state/statedb.go index d02cbafb20..29cb3f65a4 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -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()