core, eth: fix tracer dirty finalization #16588 (#1172)

This commit is contained in:
Daniel Liu 2025-07-02 14:11:22 +08:00 committed by GitHub
parent 4c5d1bd95e
commit e24293a49c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 23 deletions

View file

@ -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]

View file

@ -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)
}