Skip to content

Commit 1da3302

Browse files
authored
Merge pull request #16588 from karalabe/tracer-dirty-fix
core, eth: fix tracer dirty finalization
2 parents cfe8f5f + 7a7428a commit 1da3302

3 files changed

Lines changed: 8 additions & 23 deletions

File tree

‎core/state/statedb.go‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -572,27 +572,6 @@ func (self *StateDB) Prepare(thash, bhash common.Hash, ti int) {
572572
self.txIndex = ti
573573
}
574574

575-
// DeleteSuicides flags the suicided objects for deletion so that it
576-
// won't be referenced again when called / queried up on.
577-
//
578-
// DeleteSuicides should not be used for consensus related updates
579-
// under any circumstances.
580-
func (s *StateDB) DeleteSuicides() {
581-
// Reset refund so that any used-gas calculations can use this method.
582-
s.clearJournalAndRefund()
583-
584-
for addr := range s.stateObjectsDirty {
585-
stateObject := s.stateObjects[addr]
586-
587-
// If the object has been removed by a suicide
588-
// flag the object as deleted.
589-
if stateObject.suicided {
590-
stateObject.deleted = true
591-
}
592-
delete(s.stateObjectsDirty, addr)
593-
}
594-
}
595-
596575
func (s *StateDB) clearJournalAndRefund() {
597576
s.journal = newJournal()
598577
s.validRevisions = s.validRevisions[:0]

‎core/vm/evm.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
160160
precompiles = PrecompiledContractsByzantium
161161
}
162162
if precompiles[addr] == nil && evm.ChainConfig().IsEIP158(evm.BlockNumber) && value.Sign() == 0 {
163+
// Calling a non existing account, don't do antything, but ping the tracer
164+
if evm.vmConfig.Debug && evm.depth == 0 {
165+
evm.vmConfig.Tracer.CaptureStart(caller.Address(), addr, false, input, gas, value)
166+
evm.vmConfig.Tracer.CaptureEnd(ret, 0, 0, nil)
167+
}
163168
return nil, gas, nil
164169
}
165170
evm.StateDB.CreateAccount(addr)

‎eth/api_tracer.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl
201201
log.Warn("Tracing failed", "hash", tx.Hash(), "block", task.block.NumberU64(), "err", err)
202202
break
203203
}
204-
task.statedb.DeleteSuicides()
204+
task.statedb.Finalise(true)
205205
task.results[i] = &txTraceResult{Result: res}
206206
}
207207
// Stream the result back to the user or abort on teardown
@@ -640,7 +640,8 @@ func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, ree
640640
if _, _, _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas())); err != nil {
641641
return nil, vm.Context{}, nil, fmt.Errorf("tx %x failed: %v", tx.Hash(), err)
642642
}
643-
statedb.DeleteSuicides()
643+
// Ensure any modifications are committed to the state
644+
statedb.Finalise(true)
644645
}
645646
return nil, vm.Context{}, nil, fmt.Errorf("tx index %d out of range for block %x", txIndex, blockHash)
646647
}

0 commit comments

Comments
 (0)