good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
e0e0e534
Commit
e0e0e534
authored
Aug 14, 2018
by
Gary Rong
Committed by
Péter Szilágyi
Aug 14, 2018
Browse files
Options
Downloads
Patches
Plain Diff
crypto: change formula for create2 (#17393)
parent
97887d98
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/vm/evm.go
+1
-1
1 addition, 1 deletion
core/vm/evm.go
crypto/crypto.go
+2
-2
2 additions, 2 deletions
crypto/crypto.go
with
3 additions
and
3 deletions
core/vm/evm.go
+
1
−
1
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
)
...
...
This diff is collapsed.
Click to expand it.
crypto/crypto.go
+
2
−
2
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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment