mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
core/vm: use types.EmptyCodeHash (#27729)
This commit is contained in:
parent
ebb2c3b2ea
commit
186d49b1f3
3 changed files with 4 additions and 7 deletions
|
|
@ -23,15 +23,12 @@ import (
|
|||
|
||||
"github.com/XinFinOrg/XDPoSChain/XDCx/tradingstate"
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/types"
|
||||
"github.com/XinFinOrg/XDPoSChain/crypto"
|
||||
"github.com/XinFinOrg/XDPoSChain/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
|
||||
|
|
@ -440,7 +437,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 != 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
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ func opRandom(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
|
|||
if interpreter.evm.Context.Random != nil {
|
||||
v = new(uint256.Int).SetBytes((interpreter.evm.Context.Random.Bytes()))
|
||||
} else { // if context random is not set, use emptyCodeHash as default
|
||||
v = new(uint256.Int).SetBytes(emptyCodeHash.Bytes())
|
||||
v = new(uint256.Int).SetBytes(types.EmptyCodeHash.Bytes())
|
||||
}
|
||||
scope.Stack.push(v)
|
||||
return nil, nil
|
||||
|
|
|
|||
|
|
@ -732,7 +732,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: emptyCodeHash},
|
||||
{name: "emptyCodeHash", random: types.EmptyCodeHash},
|
||||
{name: "hash(0x010203)", random: crypto.Keccak256Hash([]byte{0x01, 0x02, 0x03})},
|
||||
} {
|
||||
var (
|
||||
|
|
|
|||
Loading…
Reference in a new issue