Commit 3fd7b11f authored by Mark Tyneway's avatar Mark Tyneway

op-chain-ops: add legacy eth migration check

Very simple one for now
parent 62eaab9f
......@@ -21,6 +21,10 @@ func getOVMETHTotalSupplySlot() common.Hash {
return key
}
func GetOVMETHTotalSupplySlot() common.Hash {
return getOVMETHTotalSupplySlot()
}
// getOVMETHBalance gets a user's OVM ETH balance from state by querying the
// appropriate storage slot directly.
func getOVMETHBalance(db *state.StateDB, addr common.Address) *big.Int {
......
package genesis
import (
"errors"
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/ether"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
......@@ -41,6 +43,10 @@ func CheckMigratedDB(ldb ethdb.Database) error {
return err
}
if err := CheckLegacyETH(db); err != nil {
return err
}
return nil
}
......@@ -78,3 +84,14 @@ func CheckPredeploys(db vm.StateDB) error {
}
return nil
}
// CheckLegacyETH checks that the legacy eth migration was successful.
// It currently only checks that the total supply was set to 0.
func CheckLegacyETH(db vm.StateDB) error {
// Ensure total supply is set to 0
slot := db.GetState(predeploys.LegacyERC20ETHAddr, ether.GetOVMETHTotalSupplySlot())
if slot != (common.Hash{}) {
return errors.New("total supply not set to 0")
}
return nil
}
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