Commit 0b52e3fe authored by Mark Tyneway's avatar Mark Tyneway

op-chain-ops: add to L2 genesis gen

parent 301321f8
......@@ -23,6 +23,8 @@ const (
ProxyAdmin = "0x4200000000000000000000000000000000000018"
BaseFeeVault = "0x4200000000000000000000000000000000000019"
L1FeeVault = "0x420000000000000000000000000000000000001a"
SchemaRegistry = "0x4200000000000000000000000000000000000020"
EAS = "0x4200000000000000000000000000000000000021"
)
var (
......@@ -43,6 +45,8 @@ var (
ProxyAdminAddr = common.HexToAddress(ProxyAdmin)
BaseFeeVaultAddr = common.HexToAddress(BaseFeeVault)
L1FeeVaultAddr = common.HexToAddress(L1FeeVault)
SchemaRegistryAddr = common.HexToAddress(SchemaRegistry)
EASAddr = common.HexToAddress(EAS)
Predeploys = make(map[string]*common.Address)
)
......@@ -76,4 +80,6 @@ func init() {
Predeploys["ProxyAdmin"] = &ProxyAdminAddr
Predeploys["BaseFeeVault"] = &BaseFeeVaultAddr
Predeploys["L1FeeVault"] = &L1FeeVaultAddr
Predeploys["SchemaRegistry"] = &SchemaRegistryAddr
Predeploys["EAS"] = &EASAddr
}
......@@ -225,6 +225,16 @@ func checkPredeployConfig(client *ethclient.Client, name string) error {
if err := checkL2ToL1MessagePasser(p, client); err != nil {
return err
}
case predeploys.SchemaRegistryAddr:
if err := checkSchemaRegistry(p, client); err != nil {
return err
}
case predeploys.EASAddr:
if err := checkEAS(p, client); err != nil {
return err
}
}
return nil
})
......@@ -712,6 +722,43 @@ func checkDeployerWhitelist(addr common.Address, client *ethclient.Client) error
return nil
}
func checkSchemaRegistry(addr common.Address, client *ethclient.Client) error {
contract, err := bindings.NewSchemaRegistry(addr, client)
if err != nil {
return err
}
version, err := contract.Version(&bind.CallOpts{})
if err != nil {
return err
}
log.Info("SchemaRegistry version", "version", version)
return nil
}
func checkEAS(addr common.Address, client *ethclient.Client) error {
contract, err := bindings.NewEAS(addr, client)
if err != nil {
return err
}
registry, err := contract.GetSchemaRegistry(&bind.CallOpts{})
if err != nil {
return err
}
if registry != predeploys.SchemaRegistryAddr {
return fmt.Errorf("Incorrect registry address %s", registry)
}
log.Info("EAS", "registry", registry)
version, err := contract.Version(&bind.CallOpts{})
if err != nil {
return err
}
log.Info("EAS version", "version", version)
return nil
}
func getEIP1967AdminAddress(client *ethclient.Client, addr common.Address) (common.Address, error) {
slot, err := client.StorageAt(context.Background(), addr, util.EIP1967AdminSlot, nil)
if err != nil {
......
......@@ -61,6 +61,7 @@ func BuildL2Genesis(config *DeployConfig, l1StartBlock *types.Block) (*core.Gene
}
db.CreateAccount(codeAddr)
db.SetState(addr, ImplementationSlot, codeAddr.Hash())
log.Trace("Set proxy", "name", name, "address", addr)
} else {
db.DeleteState(addr, AdminSlot)
}
......
......@@ -81,7 +81,7 @@ func TestBuildL2DeveloperGenesis(t *testing.T) {
err = config.InitDeveloperDeployedAddresses()
require.NoError(t, err)
gen := testBuildL2Genesis(t, config)
require.Equal(t, 2342, len(gen.Alloc))
require.Equal(t, 2344, len(gen.Alloc))
}
func TestBuildL2MainnetGenesis(t *testing.T) {
......@@ -90,7 +90,7 @@ func TestBuildL2MainnetGenesis(t *testing.T) {
config.EnableGovernance = true
config.FundDevAccounts = false
gen := testBuildL2Genesis(t, config)
require.Equal(t, 2064, len(gen.Alloc))
require.Equal(t, 2066, len(gen.Alloc))
}
func TestBuildL2MainnetNoGovernanceGenesis(t *testing.T) {
......@@ -99,5 +99,5 @@ func TestBuildL2MainnetNoGovernanceGenesis(t *testing.T) {
config.EnableGovernance = false
config.FundDevAccounts = false
gen := testBuildL2Genesis(t, config)
require.Equal(t, 2064, len(gen.Alloc))
require.Equal(t, 2066, len(gen.Alloc))
}
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