From cab1c19cd27fba0f07ac17dd5926e800efb1f6f7 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Sun, 31 Aug 2025 16:04:51 +0800 Subject: [PATCH] core/state: mark account as dirty when resetObject occurs #27339 (#1224) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changes the journal logic to mark the state object dirty immediately when it is reset. We're mostly adding this change to appease the fuzzer. Marking it dirty immediately makes no difference in practice because accounts will always be modified by EVM right after creation. Co-authored-by: rjl493456442 --- core/state/journal.go | 3 ++- core/state/statedb.go | 14 +++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/core/state/journal.go b/core/state/journal.go index ad0ed07951..7b3faba656 100644 --- a/core/state/journal.go +++ b/core/state/journal.go @@ -90,6 +90,7 @@ type ( account *common.Address } resetObjectChange struct { + account *common.Address prev *stateObject prevdestruct bool } @@ -162,7 +163,7 @@ func (ch resetObjectChange) revert(s *StateDB) { } func (ch resetObjectChange) dirtied() *common.Address { - return nil + return ch.account } func (ch selfDestructChange) revert(s *StateDB) { diff --git a/core/state/statedb.go b/core/state/statedb.go index 54d1f2145c..9cfe46538d 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -577,19 +577,15 @@ func (s *StateDB) GetOrNewStateObject(addr common.Address) *stateObject { // the given address, it is overwritten and returned as the second return value. func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) { prev = s.getDeletedStateObject(addr) // Note, prev might have been deleted, we need that! - - var prevdestruct bool - if prev != nil { - _, prevdestruct = s.stateObjectsDestruct[prev.address] - if !prevdestruct { - s.stateObjectsDestruct[prev.address] = struct{}{} - } - } newobj = newObject(s, addr, types.StateAccount{}) if prev == nil { s.journal.append(createObjectChange{account: &addr}) } else { - s.journal.append(resetObjectChange{prev: prev, prevdestruct: prevdestruct}) + _, prevdestruct := s.stateObjectsDestruct[prev.address] + if !prevdestruct { + s.stateObjectsDestruct[prev.address] = struct{}{} + } + s.journal.append(resetObjectChange{account: &addr, prev: prev, prevdestruct: prevdestruct}) } newobj.created = true