diff --git a/core/state_transition.go b/core/state_transition.go index 4b2cd7989f..614e279e4e 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -603,7 +603,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) { // tx_state = adjusted_intrinsic_state + exec_state_used (spec: set_delegation adjusts intrinsic) // tx_regular = total_dimensional_used - tx_state txState := (gas.StateGas - authRefund) + st.gasRemaining.StateGasCharged - txRegular := (msg.GasLimit - preRefundRemaining) - txState + txRegular := (msg.GasLimit - preRefundRemaining) - txState - st.evm.CollisionBurned txRegular = max(txRegular, floorDataGas) if err := st.gp.ReturnGasAmsterdam(returned, txRegular, txState, st.gasUsed()); err != nil { return nil, err diff --git a/core/vm/evm.go b/core/vm/evm.go index eb4a854fc8..a7e252dd9f 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -129,6 +129,14 @@ type EVM struct { readOnly bool // Whether to throw on stateful modifications returnData []byte // Last CALL's return data for subsequent reuse + + // CollisionBurned accumulates regular gas burned in CREATE/CREATE2 address + // collisions. The spec burns this gas (deducts from gas_left) but does NOT + // count it in regular_gas_used, so it must be excluded from txRegular in + // 2D block gas accounting. + // TODO (MariusVanDerWijden) this seems to be the best way to conform to the current + // spec, I wonder if it makes sense to change the spec. + CollisionBurned uint64 } // NewEVM constructs an EVM instance with the supplied block context, state @@ -549,6 +557,7 @@ func (evm *EVM) create(caller common.Address, code []byte, gas GasCosts, value * if evm.Config.Tracer != nil && evm.Config.Tracer.OnGasChange != nil { evm.Config.Tracer.OnGasChange(gas.RegularGas, 0, tracing.GasChangeCallFailedExecution) } + evm.CollisionBurned += gas.RegularGas gas.RegularGas = 0 return nil, common.Address{}, gas, ErrContractAddressCollision }