diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 7d38adf36f..18081ec4c9 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -211,6 +211,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( } } // Static portion of gas + cost = operation.constantGas // For tracing if !contract.UseGas(operation.constantGas) { return nil, ErrOutOfGas } @@ -235,8 +236,10 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( // consume the gas and return an error if not enough gas is available. // cost is explicitly set so that the capture state defer method can get the proper cost if operation.dynamicGas != nil { - cost, err = operation.dynamicGas(in.evm, contract, stack, mem, memorySize) - if err != nil || !contract.UseGas(cost) { + var dynamicCost uint64 + dynamicCost, err = operation.dynamicGas(in.evm, contract, stack, mem, memorySize) + cost += dynamicCost // total cost, for debug tracing + if err != nil || !contract.UseGas(dynamicCost) { return nil, ErrOutOfGas } }