|
|
|
@ -448,6 +448,18 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, |
|
|
|
|
} |
|
|
|
|
evm.StateDB.SetNonce(caller.Address(), nonce+1) |
|
|
|
|
|
|
|
|
|
// Charge the contract creation init gas in verkle mode
|
|
|
|
|
if evm.chainRules.IsEIP4762 { |
|
|
|
|
statelessGas := evm.AccessEvents.ContractCreatePreCheckGas(address) |
|
|
|
|
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
|
|
|
|
|
// creation fails, the access-list change should not be rolled back.
|
|
|
|
|
if evm.chainRules.IsEIP2929 { |
|
|
|
@ -484,6 +496,17 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, |
|
|
|
|
if evm.chainRules.IsEIP158 { |
|
|
|
|
evm.StateDB.SetNonce(address, 1) |
|
|
|
|
} |
|
|
|
|
// Charge the contract creation init gas in verkle mode
|
|
|
|
|
if evm.chainRules.IsEIP4762 { |
|
|
|
|
statelessGas := evm.AccessEvents.ContractCreateInitGas(address) |
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
// Initialise a new contract and set the code that is to be used by the EVM.
|
|
|
|
@ -505,13 +528,6 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, |
|
|
|
|
// initNewContract runs a new contract's creation code, performs checks on the
|
|
|
|
|
// resulting code that is to be deployed, and consumes necessary gas.
|
|
|
|
|
func (evm *EVM) initNewContract(contract *Contract, address common.Address, value *uint256.Int) ([]byte, error) { |
|
|
|
|
// Charge the contract creation init gas in verkle mode
|
|
|
|
|
if evm.chainRules.IsEIP4762 { |
|
|
|
|
if !contract.UseGas(evm.AccessEvents.ContractCreateInitGas(address, value.Sign() != 0), evm.Config.Tracer, tracing.GasChangeWitnessContractInit) { |
|
|
|
|
return nil, ErrOutOfGas |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ret, err := evm.interpreter.Run(contract, nil, false) |
|
|
|
|
if err != nil { |
|
|
|
|
return ret, err |
|
|
|
@ -533,11 +549,6 @@ func (evm *EVM) initNewContract(contract *Contract, address common.Address, valu |
|
|
|
|
return ret, ErrCodeStoreOutOfGas |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// Contract creation completed, touch the missing fields in the contract
|
|
|
|
|
if !contract.UseGas(evm.AccessEvents.AddAccount(address, true), evm.Config.Tracer, tracing.GasChangeWitnessContractCreation) { |
|
|
|
|
return ret, ErrCodeStoreOutOfGas |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if len(ret) > 0 && !contract.UseGas(evm.AccessEvents.CodeChunksRangeGas(address, 0, uint64(len(ret)), uint64(len(ret)), true), evm.Config.Tracer, tracing.GasChangeWitnessCodeChunk) { |
|
|
|
|
return ret, ErrCodeStoreOutOfGas |
|
|
|
|
} |
|
|
|
|