From edec80c08f63fef82d329cc71b0d20b6e6f58e77 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Tue, 24 Feb 2026 16:18:29 +0800 Subject: [PATCH] refactor(core): make stateobject.create selfcontain #28459 (#2074) --- core/state/state_object.go | 6 +++++- core/state/statedb.go | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/state/state_object.go b/core/state/state_object.go index 67e0e97466..1bf8a01f6a 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -96,7 +96,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() } @@ -109,6 +112,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 29f81829b2..84bb04cda8 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -691,8 +691,6 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) delete(s.storagesOrigin, prev.addrHash) } - newobj.created = true - s.setStateObject(newobj) if prev != nil && !prev.deleted { return newobj, prev