Commit 1743dba4 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #4132 from ethereum-optimism/fix/no-check-migrate-eth

op-chain-ops: add no check to eth migration
parents 1c83162b c69870c7
...@@ -34,7 +34,7 @@ var ( ...@@ -34,7 +34,7 @@ var (
} }
) )
func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances []*migration.Allowance, chainID int, commit bool) (common.Hash, error) { func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances []*migration.Allowance, chainID int, commit, noCheck bool) (common.Hash, error) {
// Set of addresses that we will be migrating. // Set of addresses that we will be migrating.
addressesToMigrate := make(map[common.Address]bool) addressesToMigrate := make(map[common.Address]bool)
// Set of storage slots that we expect to see in the OVM ETH contract. // Set of storage slots that we expect to see in the OVM ETH contract.
...@@ -125,9 +125,13 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances ...@@ -125,9 +125,13 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances
default: default:
// Check if this slot is a variable. If it isn't, abort. // Check if this slot is a variable. If it isn't, abort.
if !ignoredSlots[k] { if !ignoredSlots[k] {
if noCheck {
log.Error("missed storage key", "k", k.String(), "v", v.String())
} else {
log.Crit("missed storage key", "k", k.String(), "v", v.String()) log.Crit("missed storage key", "k", k.String(), "v", v.String())
} }
} }
}
logProgress() logProgress()
} }
...@@ -137,6 +141,15 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances ...@@ -137,6 +141,15 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances
// had supply bugs. // had supply bugs.
delta := new(big.Int).Sub(totalSupply, totalFound) delta := new(big.Int).Sub(totalSupply, totalFound)
if delta.Cmp(params.ExpectedSupplyDelta) != 0 { if delta.Cmp(params.ExpectedSupplyDelta) != 0 {
if noCheck {
log.Error(
"supply mismatch",
"migrated", totalFound.String(),
"supply", totalSupply.String(),
"delta", delta.String(),
"exp_delta", params.ExpectedSupplyDelta.String(),
)
} else {
log.Crit( log.Crit(
"supply mismatch", "supply mismatch",
"migrated", totalFound.String(), "migrated", totalFound.String(),
...@@ -145,6 +158,7 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances ...@@ -145,6 +158,7 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances
"exp_delta", params.ExpectedSupplyDelta.String(), "exp_delta", params.ExpectedSupplyDelta.String(),
) )
} }
}
log.Info( log.Info(
"supply verified OK", "supply verified OK",
...@@ -181,8 +195,12 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances ...@@ -181,8 +195,12 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances
// No accounts should have a balance in state. If they do, bail. // No accounts should have a balance in state. If they do, bail.
if data.Balance.Sign() > 0 { if data.Balance.Sign() > 0 {
if noCheck {
log.Error("account has non-zero balance in state - should never happen", "addr", addr)
} else {
log.Crit("account has non-zero balance in state - should never happen", "addr", addr) log.Crit("account has non-zero balance in state - should never happen", "addr", addr)
} }
}
// Actually perform the migration by setting the appropriate values in state. // Actually perform the migration by setting the appropriate values in state.
stateDB.SetBalance(addr, ovmBalance) stateDB.SetBalance(addr, ovmBalance)
...@@ -214,12 +232,20 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances ...@@ -214,12 +232,20 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances
// Make sure that the amount we migrated matches the amount in // Make sure that the amount we migrated matches the amount in
// our original state. // our original state.
if totalMigrated.Cmp(totalFound) != 0 { if totalMigrated.Cmp(totalFound) != 0 {
if noCheck {
log.Debug(
"total migrated does not equal total OVM eth found",
"migrated", totalMigrated,
"found", totalFound,
)
} else {
log.Crit( log.Crit(
"total migrated does not equal total OVM eth found", "total migrated does not equal total OVM eth found",
"migrated", totalMigrated, "migrated", totalMigrated,
"found", totalFound, "found", totalFound,
) )
} }
}
// Set the total supply to 0 // Set the total supply to 0
stateDB.SetState(predeploys.LegacyERC20ETHAddr, getOVMETHTotalSupplySlot(), common.Hash{}) stateDB.SetState(predeploys.LegacyERC20ETHAddr, getOVMETHTotalSupplySlot(), common.Hash{})
......
...@@ -119,7 +119,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m ...@@ -119,7 +119,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
log.Info("Starting to migrate ERC20 ETH") log.Info("Starting to migrate ERC20 ETH")
addrs := migrationData.Addresses() addrs := migrationData.Addresses()
newRoot, err := ether.MigrateLegacyETH(ldb, addrs, migrationData.OvmAllowances, int(config.L1ChainID), commit) newRoot, err := ether.MigrateLegacyETH(ldb, addrs, migrationData.OvmAllowances, int(config.L1ChainID), commit, noCheck)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot migrate legacy eth: %w", err) return nil, fmt.Errorf("cannot migrate legacy eth: %w", 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