From fd96101af72335f80017605dc6467edc6a6a863d Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Sat, 26 Jul 2025 18:17:48 +0800 Subject: [PATCH] eth: make tracers respect pre-EIP158/161 rules #18503 (#1250) --- eth/api_tracer.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 34ade2dac1..e476e7e162 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -259,7 +259,8 @@ 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.Finalise(true) + // Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect + task.statedb.Finalise(api.eth.blockchain.Config().IsEIP158(task.block.Number())) task.results[i] = &txTraceResult{Result: res} } // Stream the result back to the user or abort on teardown @@ -523,7 +524,8 @@ func (api *DebugAPI) traceBlock(ctx context.Context, block *types.Block, config break } // Finalize the state so any modifications are written to the trie - statedb.Finalise(true) + // Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect + statedb.Finalise(vmenv.ChainConfig().IsEIP158(block.Number())) } close(jobs) pend.Wait() @@ -820,6 +822,7 @@ func (api *DebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, reexec uin } } // Ensure any modifications are committed to the state - statedb.Finalise(true) + // Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect + statedb.Finalise(api.eth.blockchain.Config().IsEIP158(block.Number())) return nil, vm.BlockContext{}, nil, fmt.Errorf("tx index %d out of range for block %x", txIndex, blockHash) }