diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index aa66dc49ff..4ac4e0c8c5 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -306,6 +306,8 @@ const ( GasChangeWitnessContractCreation GasChangeReason = 16 // GasChangeWitnessCodeChunk is the amount charged for touching one or more contract code chunks GasChangeWitnessCodeChunk GasChangeReason = 17 + // GasChangeWitnessContractCollisionCheck the amount charged for checking a contract collision + GasChangeWitnessContractCollisionCheck GasChangeReason = 17 // GasChangeIgnored is a special value that can be used to indicate that the gas change should be ignored as // it will be "manually" tracked by a direct emit of the gas change event. diff --git a/core/vm/evm.go b/core/vm/evm.go index 6c8b243ebf..616668d565 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -454,6 +454,10 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, if statelessGas > gas { return nil, common.Address{}, 0, ErrOutOfGas } + if evm.Config.Tracer != nil && evm.Config.Tracer.OnGasChange != nil { + evm.Config.Tracer.OnGasChange(gas, gas-statelessGas, tracing.GasChangeWitnessContractCollisionCheck) + } + gas = gas - statelessGas } // We add this to the access list _before_ taking a snapshot. Even if the @@ -498,6 +502,9 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, if statelessGas > gas { return nil, common.Address{}, 0, ErrOutOfGas } + if evm.Config.Tracer != nil && evm.Config.Tracer.OnGasChange != nil { + evm.Config.Tracer.OnGasChange(gas, gas-statelessGas, tracing.GasChangeWitnessContractInit) + } gas = gas - statelessGas } evm.Context.Transfer(evm.StateDB, caller.Address(), address, value)