From 326b20e1233e7cc9cdf53808e5155422b02ec2e1 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 19 Jun 2019 11:41:56 +0200 Subject: [PATCH] interpreter: make tracing count constant+dynamic gas --- core/vm/interpreter.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 } }