From ad2ff23e6de8fd4a32449fc00b7c7ba2846a003e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Horacio=20Mijail=20Ant=C3=B3n=20Quiles?= <4139546+hmijail@users.noreply.github.com> Date: Thu, 29 Oct 2020 22:44:11 +1000 Subject: [PATCH] Add the missing CaptureStart and CaptureEnd (#1316) * Add the missing CaptureStart and CaptureEnd * gofmt --- core/vm/evm.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/vm/evm.go b/core/vm/evm.go index e9fdac9b99..221bd2b32d 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -301,6 +301,14 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte, snapshot = evm.IntraBlockState.Snapshot() ) + // Capture the tracer start/end events in debug mode + if evm.vmConfig.Debug { + _ = evm.vmConfig.Tracer.CaptureStart(evm.depth, caller.Address(), addr, false, input, gas, value.ToBig()) + defer func(startGas uint64, startTime time.Time) { // Lazy evaluation of the parameters + evm.vmConfig.Tracer.CaptureEnd(evm.depth, ret, startGas-gas, time.Since(startTime), err) //nolint:errcheck + }(gas, time.Now()) + } + // It is allowed to call precompiles, even via delegatecall if p, isPrecompile := evm.precompile(addr); isPrecompile { ret, gas, err = RunPrecompiledContract(p, input, gas) @@ -337,6 +345,14 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by } snapshot := evm.IntraBlockState.Snapshot() + // Capture the tracer start/end events in debug mode + if evm.vmConfig.Debug { + _ = evm.vmConfig.Tracer.CaptureStart(evm.depth, caller.Address(), addr, false, input, gas, big.NewInt(-1)) + defer func(startGas uint64, startTime time.Time) { // Lazy evaluation of the parameters + evm.vmConfig.Tracer.CaptureEnd(evm.depth, ret, startGas-gas, time.Since(startTime), err) //nolint:errcheck + }(gas, time.Now()) + } + // It is allowed to call precompiles, even via delegatecall if p, isPrecompile := evm.precompile(addr); isPrecompile { ret, gas, err = RunPrecompiledContract(p, input, gas) @@ -382,6 +398,14 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte // future scenarios evm.IntraBlockState.AddBalance(addr, u256.Num0) + // Capture the tracer start/end events in debug mode + if evm.vmConfig.Debug { + _ = evm.vmConfig.Tracer.CaptureStart(evm.depth, caller.Address(), addr, false, input, gas, big.NewInt(-2)) + defer func(startGas uint64, startTime time.Time) { // Lazy evaluation of the parameters + evm.vmConfig.Tracer.CaptureEnd(evm.depth, ret, startGas-gas, time.Since(startTime), err) //nolint:errcheck + }(gas, time.Now()) + } + if p, isPrecompile := evm.precompile(addr); isPrecompile { ret, gas, err = RunPrecompiledContract(p, input, gas) } else { -- GitLab