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
e0e0e534
Commit
e0e0e534
authored
Aug 14, 2018
by
gary rong
Committed by
Péter Szilágyi
Aug 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto: change formula for create2 (#17393)
parent
97887d98
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
evm.go
core/vm/evm.go
+1
-1
crypto.go
crypto/crypto.go
+2
-2
No files found.
core/vm/evm.go
View file @
e0e0e534
...
@@ -427,7 +427,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I
...
@@ -427,7 +427,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I
// Create2 creates a new contract using code as deployment code.
// Create2 creates a new contract using code as deployment code.
//
//
// The different between Create2 with Create is Create2 uses sha3(
msg.sender ++ salt ++ init_code
)[12:]
// The different between Create2 with Create is Create2 uses sha3(
0xff ++ msg.sender ++ salt ++ sha3(init_code)
)[12:]
// instead of the usual sender-and-nonce-hash as the address where the contract is initialized at.
// instead of the usual sender-and-nonce-hash as the address where the contract is initialized at.
func
(
evm
*
EVM
)
Create2
(
caller
ContractRef
,
code
[]
byte
,
gas
uint64
,
endowment
*
big
.
Int
,
salt
*
big
.
Int
)
(
ret
[]
byte
,
contractAddr
common
.
Address
,
leftOverGas
uint64
,
err
error
)
{
func
(
evm
*
EVM
)
Create2
(
caller
ContractRef
,
code
[]
byte
,
gas
uint64
,
endowment
*
big
.
Int
,
salt
*
big
.
Int
)
(
ret
[]
byte
,
contractAddr
common
.
Address
,
leftOverGas
uint64
,
err
error
)
{
contractAddr
=
crypto
.
CreateAddress2
(
caller
.
Address
(),
common
.
BigToHash
(
salt
),
code
)
contractAddr
=
crypto
.
CreateAddress2
(
caller
.
Address
(),
common
.
BigToHash
(
salt
),
code
)
...
...
crypto/crypto.go
View file @
e0e0e534
...
@@ -78,8 +78,8 @@ func CreateAddress(b common.Address, nonce uint64) common.Address {
...
@@ -78,8 +78,8 @@ func CreateAddress(b common.Address, nonce uint64) common.Address {
// CreateAddress2 creates an ethereum address given the address bytes, initial
// CreateAddress2 creates an ethereum address given the address bytes, initial
// contract code and a salt.
// contract code and a salt.
func
CreateAddress2
(
b
common
.
Address
,
salt
common
.
Hash
,
code
[]
byte
)
common
.
Address
{
func
CreateAddress2
(
b
common
.
Address
,
salt
[
32
]
byte
,
code
[]
byte
)
common
.
Address
{
return
common
.
BytesToAddress
(
Keccak256
([]
byte
{
0xff
},
b
.
Bytes
(),
salt
.
Bytes
(),
code
)[
12
:
])
return
common
.
BytesToAddress
(
Keccak256
([]
byte
{
0xff
},
b
.
Bytes
(),
salt
[
:
],
Keccak256
(
code
)
)[
12
:
])
}
}
// ToECDSA creates a private key with the given D value.
// ToECDSA creates a private key with the given D value.
...
...
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