Commit 711ebbe8 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

Merge pull request #5125 from ethereum-optimism/feat/swap-bool

op-chain-ops: Fix dry run param
parents 27546118 d76a3275
......@@ -36,7 +36,7 @@ var (
// 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
// 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.
params := crossdomain.ParamsByChainID[chainID]
if params == nil {
......@@ -46,10 +46,10 @@ func MigrateLegacyETH(db *state.StateDB, addresses []common.Address, allowances
// Log the chain params for debugging purposes.
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
// slots based on the witness data.
slotsAddrs := make(map[common.Hash]common.Address)
......@@ -113,7 +113,7 @@ func doMigration(db *state.StateDB, addresses []common.Address, allowances []*cr
}
}
if dryRun {
if !commit {
return true
}
......@@ -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
// 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.
if !dryRun {
if commit {
db.SetState(predeploys.LegacyERC20ETHAddr, getOVMETHTotalSupplySlot(), common.Hash{})
log.Info("Set the totalSupply to 0")
}
......
......@@ -185,7 +185,7 @@ func TestMigrateLegacyETH(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
db := makeLegacyETH(t, tt.totalSupply, tt.stateBalances, tt.stateAllowances)
err := doMigration(db, tt.inputAddresses, tt.inputAllowances, tt.expDiff, false, false)
err := doMigration(db, tt.inputAddresses, tt.inputAllowances, tt.expDiff, false, true)
tt.check(t, db, err)
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment