interpreter: make tracing count constant+dynamic gas

This commit is contained in:
Martin Holst Swende 2019-06-19 11:41:56 +02:00
parent 34fd5ca4f4
commit 326b20e123
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

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