Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
99e000cb
Unverified
Commit
99e000cb
authored
Jul 15, 2023
by
ucwong
Committed by
GitHub
Jul 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/vm: use types.EmptyCodeHash (#27729)
parent
d233b6b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
6 deletions
+3
-6
evm.go
core/vm/evm.go
+2
-5
instructions_test.go
core/vm/instructions_test.go
+1
-1
No files found.
core/vm/evm.go
View file @
99e000cb
...
...
@@ -21,15 +21,12 @@ 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
...
...
@@ -438,7 +435,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
!=
e
mptyCodeHash
)
{
if
evm
.
StateDB
.
GetNonce
(
address
)
!=
0
||
(
contractHash
!=
(
common
.
Hash
{})
&&
contractHash
!=
types
.
E
mptyCodeHash
)
{
return
nil
,
common
.
Address
{},
0
,
ErrContractAddressCollision
}
// Create a new account on the state
...
...
core/vm/instructions_test.go
View file @
99e000cb
...
...
@@ -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
:
e
mptyCodeHash
},
{
name
:
"emptyCodeHash"
,
random
:
types
.
E
mptyCodeHash
},
{
name
:
"hash(0x010203)"
,
random
:
crypto
.
Keccak256Hash
([]
byte
{
0x01
,
0x02
,
0x03
})},
}
{
var
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment