core: no need to check zero codehash

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2023-10-31 19:27:37 +08:00
parent 8d4f78c540
commit 2da6edc1a8
2 changed files with 2 additions and 3 deletions

View file

@ -281,8 +281,7 @@ func (st *StateTransition) preCheck() error {
msg.From.Hex(), stNonce) msg.From.Hex(), stNonce)
} }
// Make sure the sender is an EOA // Make sure the sender is an EOA
codeHash := st.state.GetCodeHash(msg.From) if codeHash := st.state.GetCodeHash(msg.From); codeHash != types.EmptyCodeHash {
if codeHash != (common.Hash{}) && codeHash != types.EmptyCodeHash {
return fmt.Errorf("%w: address %v, codehash: %s", ErrSenderNoEOA, return fmt.Errorf("%w: address %v, codehash: %s", ErrSenderNoEOA,
msg.From.Hex(), codeHash) msg.From.Hex(), codeHash)
} }

View file

@ -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 // Ensure there's no existing contract already at the designated address
contractHash := evm.StateDB.GetCodeHash(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 != types.EmptyCodeHash {
return nil, common.Address{}, 0, ErrContractAddressCollision return nil, common.Address{}, 0, ErrContractAddressCollision
} }
// Create a new account on the state // Create a new account on the state