From 8377d6e503a7d2f4ea3cff2722ab13c11e41efea Mon Sep 17 00:00:00 2001 From: ramtinms Date: Wed, 17 Jan 2024 17:38:23 -0800 Subject: [PATCH] clean up --- core/vm/evm.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index b3a178269f..f271136ddf 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -421,7 +421,6 @@ func (evm *EVM) create( value *big.Int, address common.Address, typ OpCode, - updateCallerNonce bool, ) ([]byte, common.Address, uint64, error) { // Depth check execution. Fail if we're trying to execute above the // limit. @@ -431,13 +430,13 @@ func (evm *EVM) create( if value.Sign() > 0 && !evm.Context.CanTransfer(evm.StateDB, caller.Address(), value) { return nil, common.Address{}, gas, ErrInsufficientBalance } - if updateCallerNonce { - nonce := evm.StateDB.GetNonce(caller.Address()) - if nonce+1 < nonce { - return nil, common.Address{}, gas, ErrNonceUintOverflow - } - evm.StateDB.SetNonce(caller.Address(), nonce+1) + + nonce := evm.StateDB.GetNonce(caller.Address()) + if nonce+1 < nonce { + return nil, common.Address{}, gas, ErrNonceUintOverflow } + evm.StateDB.SetNonce(caller.Address(), nonce+1) + // 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.IsBerlin { @@ -520,7 +519,7 @@ func (evm *EVM) create( // Create creates a new contract using code as deployment code. func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error) { contractAddr = crypto.CreateAddress(caller.Address(), evm.StateDB.GetNonce(caller.Address())) - return evm.create(caller, &codeAndHash{code: code}, gas, value, contractAddr, CREATE, true) + return evm.create(caller, &codeAndHash{code: code}, gas, value, contractAddr, CREATE) } // Create2 creates a new contract using code as deployment code. @@ -530,7 +529,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I func (evm *EVM) Create2(caller ContractRef, code []byte, gas uint64, endowment *big.Int, salt *uint256.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error) { codeAndHash := &codeAndHash{code: code} contractAddr = crypto.CreateAddress2(caller.Address(), salt.Bytes32(), codeAndHash.Hash().Bytes()) - return evm.create(caller, codeAndHash, gas, endowment, contractAddr, CREATE2, true) + return evm.create(caller, codeAndHash, gas, endowment, contractAddr, CREATE2) } // CreateAt creates a new contract using code as deployment code at the given address @@ -538,7 +537,7 @@ func (evm *EVM) Create2(caller ContractRef, code []byte, gas uint64, endowment * // the behaviour is similar to Create2 execpt we don't compute the address // using hash and it doesn't increment the nonce for the caller func (evm *EVM) CreateAt(caller ContractRef, to common.Address, code []byte, gas uint64, endowment *big.Int, salt *uint256.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error) { - return evm.create(caller, &codeAndHash{code: code}, gas, endowment, to, CREATE2, false) + return evm.create(caller, &codeAndHash{code: code}, gas, endowment, to, CREATE2) } // ChainConfig returns the environment's chain configuration