diff --git a/op-chain-ops/ether/migrate.go b/op-chain-ops/ether/migrate.go index 370262ea222aea865ded9b4f7f34602a63a1b4e1..85870c09ffc46bca9fef3d6f0bf06ea895aa3d36 100644 --- a/op-chain-ops/ether/migrate.go +++ b/op-chain-ops/ether/migrate.go @@ -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") } diff --git a/op-chain-ops/ether/migrate_test.go b/op-chain-ops/ether/migrate_test.go index 53f3620814bfc8bf9b6ca87296b8f6b70f2f3692..be20f8b4734a461e608a422f82fbd8e3906ce0ef 100644 --- a/op-chain-ops/ether/migrate_test.go +++ b/op-chain-ops/ether/migrate_test.go @@ -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) }) }