From d54ec960e6068c6ed5ee2adc93e1e7d33bb1664b Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Fri, 3 Nov 2023 15:54:58 +0800 Subject: [PATCH] core/state: make stateobject.create selfcontain --- core/state/state_object.go | 6 +++++- core/state/statedb.go | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/state/state_object.go b/core/state/state_object.go index fc66b48114b4..9383b98e4497 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -98,7 +98,10 @@ func (s *stateObject) empty() bool { // newObject creates a state object. func newObject(db *StateDB, address common.Address, acct *types.StateAccount) *stateObject { - origin := acct + var ( + origin = acct + created = acct == nil // true if the account was not existent + ) if acct == nil { acct = types.NewEmptyStateAccount() } @@ -111,6 +114,7 @@ func newObject(db *StateDB, address common.Address, acct *types.StateAccount) *s originStorage: make(Storage), pendingStorage: make(Storage), dirtyStorage: make(Storage), + created: created, } } diff --git a/core/state/statedb.go b/core/state/statedb.go index 674227857c19..905944cbb5b9 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -658,9 +658,6 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) delete(s.accountsOrigin, prev.address) delete(s.storagesOrigin, prev.address) } - - newobj.created = true - s.setStateObject(newobj) if prev != nil && !prev.deleted { return newobj, prev