mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-08 09:11:34 +00:00
core/vm: burn gas on contract address collision
This commit is contained in:
parent
6c1d9e0c66
commit
ed2f476da8
2 changed files with 10 additions and 1 deletions
|
|
@ -603,7 +603,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
||||||
// tx_state = adjusted_intrinsic_state + exec_state_used (spec: set_delegation adjusts intrinsic)
|
// tx_state = adjusted_intrinsic_state + exec_state_used (spec: set_delegation adjusts intrinsic)
|
||||||
// tx_regular = total_dimensional_used - tx_state
|
// tx_regular = total_dimensional_used - tx_state
|
||||||
txState := (gas.StateGas - authRefund) + st.gasRemaining.StateGasCharged
|
txState := (gas.StateGas - authRefund) + st.gasRemaining.StateGasCharged
|
||||||
txRegular := (msg.GasLimit - preRefundRemaining) - txState
|
txRegular := (msg.GasLimit - preRefundRemaining) - txState - st.evm.CollisionBurned
|
||||||
txRegular = max(txRegular, floorDataGas)
|
txRegular = max(txRegular, floorDataGas)
|
||||||
if err := st.gp.ReturnGasAmsterdam(returned, txRegular, txState, st.gasUsed()); err != nil {
|
if err := st.gp.ReturnGasAmsterdam(returned, txRegular, txState, st.gasUsed()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,14 @@ type EVM struct {
|
||||||
|
|
||||||
readOnly bool // Whether to throw on stateful modifications
|
readOnly bool // Whether to throw on stateful modifications
|
||||||
returnData []byte // Last CALL's return data for subsequent reuse
|
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
|
// 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 {
|
if evm.Config.Tracer != nil && evm.Config.Tracer.OnGasChange != nil {
|
||||||
evm.Config.Tracer.OnGasChange(gas.RegularGas, 0, tracing.GasChangeCallFailedExecution)
|
evm.Config.Tracer.OnGasChange(gas.RegularGas, 0, tracing.GasChangeCallFailedExecution)
|
||||||
}
|
}
|
||||||
|
evm.CollisionBurned += gas.RegularGas
|
||||||
gas.RegularGas = 0
|
gas.RegularGas = 0
|
||||||
return nil, common.Address{}, gas, ErrContractAddressCollision
|
return nil, common.Address{}, gas, ErrContractAddressCollision
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue