Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
exchain
nebula
Commits
711ebbe8
Unverified
Commit
711ebbe8
authored
Mar 13, 2023
by
Matthew Slipper
Committed by
GitHub
Mar 13, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5125 from ethereum-optimism/feat/swap-bool
op-chain-ops: Fix dry run param
parents
27546118
d76a3275
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
migrate.go
op-chain-ops/ether/migrate.go
+5
-5
migrate_test.go
op-chain-ops/ether/migrate_test.go
+1
-1
No files found.
op-chain-ops/ether/migrate.go
View file @
711ebbe8
...
@@ -36,7 +36,7 @@ var (
...
@@ -36,7 +36,7 @@ var (
// this method will migrate into state. This method does the checking as part of the migration loop
// this method will migrate into state. This method does the checking as part of the migration loop
// in order to avoid having to iterate over state twice. This saves approximately 40 minutes during
// in order to avoid having to iterate over state twice. This saves approximately 40 minutes during
// the mainnet migration.
// the mainnet migration.
func
MigrateLegacyETH
(
db
*
state
.
StateDB
,
addresses
[]
common
.
Address
,
allowances
[]
*
crossdomain
.
Allowance
,
chainID
int
,
noCheck
bool
,
dryRun
bool
)
error
{
func
MigrateLegacyETH
(
db
*
state
.
StateDB
,
addresses
[]
common
.
Address
,
allowances
[]
*
crossdomain
.
Allowance
,
chainID
int
,
noCheck
bool
,
commit
bool
)
error
{
// Chain params to use for integrity checking.
// Chain params to use for integrity checking.
params
:=
crossdomain
.
ParamsByChainID
[
chainID
]
params
:=
crossdomain
.
ParamsByChainID
[
chainID
]
if
params
==
nil
{
if
params
==
nil
{
...
@@ -46,10 +46,10 @@ func MigrateLegacyETH(db *state.StateDB, addresses []common.Address, allowances
...
@@ -46,10 +46,10 @@ func MigrateLegacyETH(db *state.StateDB, addresses []common.Address, allowances
// Log the chain params for debugging purposes.
// Log the chain params for debugging purposes.
log
.
Info
(
"Chain params"
,
"chain-id"
,
chainID
,
"supply-delta"
,
params
.
ExpectedSupplyDelta
)
log
.
Info
(
"Chain params"
,
"chain-id"
,
chainID
,
"supply-delta"
,
params
.
ExpectedSupplyDelta
)
return
doMigration
(
db
,
addresses
,
allowances
,
params
.
ExpectedSupplyDelta
,
noCheck
,
dryRun
)
return
doMigration
(
db
,
addresses
,
allowances
,
params
.
ExpectedSupplyDelta
,
noCheck
,
commit
)
}
}
func
doMigration
(
db
*
state
.
StateDB
,
addresses
[]
common
.
Address
,
allowances
[]
*
crossdomain
.
Allowance
,
expSupplyDiff
*
big
.
Int
,
noCheck
bool
,
dryRun
bool
)
error
{
func
doMigration
(
db
*
state
.
StateDB
,
addresses
[]
common
.
Address
,
allowances
[]
*
crossdomain
.
Allowance
,
expSupplyDiff
*
big
.
Int
,
noCheck
bool
,
commit
bool
)
error
{
// We'll need to maintain a list of all addresses that we've seen along with all of the storage
// We'll need to maintain a list of all addresses that we've seen along with all of the storage
// slots based on the witness data.
// slots based on the witness data.
slotsAddrs
:=
make
(
map
[
common
.
Hash
]
common
.
Address
)
slotsAddrs
:=
make
(
map
[
common
.
Hash
]
common
.
Address
)
...
@@ -113,7 +113,7 @@ func doMigration(db *state.StateDB, addresses []common.Address, allowances []*cr
...
@@ -113,7 +113,7 @@ func doMigration(db *state.StateDB, addresses []common.Address, allowances []*cr
}
}
}
}
if
dryRun
{
if
!
commit
{
return
true
return
true
}
}
...
@@ -180,7 +180,7 @@ func doMigration(db *state.StateDB, addresses []common.Address, allowances []*cr
...
@@ -180,7 +180,7 @@ func doMigration(db *state.StateDB, addresses []common.Address, allowances []*cr
// different than the sum of all balances since we no longer track balances inside the contract
// different than the sum of all balances since we no longer track balances inside the contract
// itself. The total supply is going to be weird no matter what, might as well set it to zero
// itself. The total supply is going to be weird no matter what, might as well set it to zero
// so it's explicitly weird instead of implicitly weird.
// so it's explicitly weird instead of implicitly weird.
if
!
dryRun
{
if
commit
{
db
.
SetState
(
predeploys
.
LegacyERC20ETHAddr
,
getOVMETHTotalSupplySlot
(),
common
.
Hash
{})
db
.
SetState
(
predeploys
.
LegacyERC20ETHAddr
,
getOVMETHTotalSupplySlot
(),
common
.
Hash
{})
log
.
Info
(
"Set the totalSupply to 0"
)
log
.
Info
(
"Set the totalSupply to 0"
)
}
}
...
...
op-chain-ops/ether/migrate_test.go
View file @
711ebbe8
...
@@ -185,7 +185,7 @@ func TestMigrateLegacyETH(t *testing.T) {
...
@@ -185,7 +185,7 @@ func TestMigrateLegacyETH(t *testing.T) {
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
db
:=
makeLegacyETH
(
t
,
tt
.
totalSupply
,
tt
.
stateBalances
,
tt
.
stateAllowances
)
db
:=
makeLegacyETH
(
t
,
tt
.
totalSupply
,
tt
.
stateBalances
,
tt
.
stateAllowances
)
err
:=
doMigration
(
db
,
tt
.
inputAddresses
,
tt
.
inputAllowances
,
tt
.
expDiff
,
false
,
fals
e
)
err
:=
doMigration
(
db
,
tt
.
inputAddresses
,
tt
.
inputAllowances
,
tt
.
expDiff
,
false
,
tru
e
)
tt
.
check
(
t
,
db
,
err
)
tt
.
check
(
t
,
db
,
err
)
})
})
}
}
...
...
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