From cae472418acba329873834431760b0b2c908a9d0 Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "core/vm: use types.EmptyCodeHash (#27729)" This reverts commit 31689cb6ad800bb0dd4bea7aa915e5d33bf81bf9. --- core/vm/evm.go | 7 +++++-- core/vm/instructions_test.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index 3f3c3751f88f..36336d8cbd4c 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -21,12 +21,15 @@ import ( "sync/atomic" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/holiman/uint256" ) +// emptyCodeHash is used by create to ensure deployment is disallowed to already +// deployed contract addresses (relevant after the account abstraction). +var emptyCodeHash = crypto.Keccak256Hash(nil) + type ( // CanTransferFunc is the signature of a transfer guard function CanTransferFunc func(StateDB, common.Address, *big.Int) bool @@ -435,7 +438,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, } // Ensure there's no existing contract already at the designated address contractHash := evm.StateDB.GetCodeHash(address) - if evm.StateDB.GetNonce(address) != 0 || (contractHash != (common.Hash{}) && contractHash != types.EmptyCodeHash) { + if evm.StateDB.GetNonce(address) != 0 || (contractHash != (common.Hash{}) && contractHash != emptyCodeHash) { return nil, common.Address{}, 0, ErrContractAddressCollision } // Create a new account on the state diff --git a/core/vm/instructions_test.go b/core/vm/instructions_test.go index 807073336d6d..36886cb9ed8e 100644 --- a/core/vm/instructions_test.go +++ b/core/vm/instructions_test.go @@ -725,7 +725,7 @@ func TestRandom(t *testing.T) { for _, tt := range []testcase{ {name: "empty hash", random: common.Hash{}}, {name: "1", random: common.Hash{0}}, - {name: "emptyCodeHash", random: types.EmptyCodeHash}, + {name: "emptyCodeHash", random: emptyCodeHash}, {name: "hash(0x010203)", random: crypto.Keccak256Hash([]byte{0x01, 0x02, 0x03})}, } { var (