From e24293a49c3c29b89e115b9b8c2c6d601aa04c5b Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Wed, 2 Jul 2025 14:11:22 +0800 Subject: [PATCH] core, eth: fix tracer dirty finalization #16588 (#1172) --- core/state/statedb.go | 21 --------------------- eth/api_tracer.go | 5 +++-- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index fe393ff74b..ebd948137a 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -789,27 +789,6 @@ func (s *StateDB) SetTxContext(thash common.Hash, ti int) { s.txIndex = ti } -// DeleteSuicides flags the self-destructed objects for deletion so that it -// won't be referenced again when called / queried up on. -// -// DeleteSuicides should not be used for consensus related updates -// under any circumstances. -func (s *StateDB) DeleteSuicides() { - // Reset refund so that any used-gas calculations can use this method. - s.clearJournalAndRefund() - - for addr := range s.stateObjectsDirty { - stateObject := s.stateObjects[addr] - - // If the object has been removed by a suicide - // flag the object as deleted. - if stateObject.selfDestructed { - stateObject.deleted = true - } - delete(s.stateObjectsDirty, addr) - } -} - func (s *StateDB) clearJournalAndRefund() { s.journal = newJournal() s.validRevisions = s.validRevisions[:0] diff --git a/eth/api_tracer.go b/eth/api_tracer.go index aed8781c78..2785b68450 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -259,7 +259,7 @@ func (api *DebugAPI) traceChain(ctx context.Context, start, end *types.Block, co log.Warn("Tracing failed", "hash", tx.Hash(), "block", task.block.NumberU64(), "err", err) break } - task.statedb.DeleteSuicides() + task.statedb.Finalise(true) task.results[i] = &txTraceResult{Result: res} } // Stream the result back to the user or abort on teardown @@ -818,6 +818,7 @@ func (api *DebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, reexec uin totalFeeUsed = totalFeeUsed.Add(totalFeeUsed, fee) } } - statedb.DeleteSuicides() + // Ensure any modifications are committed to the state + statedb.Finalise(true) return nil, vm.BlockContext{}, nil, fmt.Errorf("tx index %d out of range for block %x", txIndex, blockHash) }