From 38664ef4603e1a58bdfa2baf89912d6cc694e8fa Mon Sep 17 00:00:00 2001 From: jsvisa Date: Tue, 7 Nov 2023 08:33:26 +0800 Subject: [PATCH] Revert "core: no need to check zero codehash" This reverts commit 2da6edc1a834d0c03630435faa46abf32a0b18bb. Signed-off-by: jsvisa --- core/state_transition.go | 3 ++- core/vm/evm.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index e96b99de50..fb03c48aab 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -281,7 +281,8 @@ func (st *StateTransition) preCheck() error { msg.From.Hex(), stNonce) } // Make sure the sender is an EOA - if codeHash := st.state.GetCodeHash(msg.From); codeHash != types.EmptyCodeHash { + codeHash := st.state.GetCodeHash(msg.From) + if codeHash != (common.Hash{}) && codeHash != types.EmptyCodeHash { return fmt.Errorf("%w: address %v, codehash: %s", ErrSenderNoEOA, msg.From.Hex(), codeHash) } diff --git a/core/vm/evm.go b/core/vm/evm.go index 6e832c262f..2c6cc7d484 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -436,7 +436,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 != types.EmptyCodeHash { + if evm.StateDB.GetNonce(address) != 0 || (contractHash != (common.Hash{}) && contractHash != types.EmptyCodeHash) { return nil, common.Address{}, 0, ErrContractAddressCollision } // Create a new account on the state