-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
op-chain-ops/interopgen: experimental interop genesis-state generation
- Loading branch information
1 parent
f20b92d
commit 12b253c
Showing
15 changed files
with
1,196 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package interopgen | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/log" | ||
|
||
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis" | ||
) | ||
|
||
type L1Config struct { | ||
ChainID *big.Int | ||
genesis.DevL1DeployConfig | ||
Prefund map[common.Address]*big.Int | ||
} | ||
|
||
func (c *L1Config) Check(log log.Logger) error { | ||
if c.ChainID == nil { | ||
return errors.New("missing L1 chain ID") | ||
} | ||
// nothing to check on c.DevL1DeployConfig | ||
return nil | ||
} | ||
|
||
type SuperchainConfig struct { | ||
Deployer common.Address | ||
|
||
FinalSystemOwner common.Address | ||
ProxyAdminOwner common.Address | ||
|
||
genesis.SuperchainL1DeployConfig | ||
} | ||
|
||
func (c *SuperchainConfig) Check(log log.Logger) error { | ||
if c.Deployer == (common.Address{}) { | ||
return errors.New("missing superchain deployer address") | ||
} | ||
if c.ProxyAdminOwner == (common.Address{}) { | ||
return errors.New("missing superchain ProxyAdminOwner address") | ||
} | ||
if err := c.SuperchainL1DeployConfig.Check(log); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
type L2Config struct { | ||
Deployer common.Address // account used to deploy contracts to L2 | ||
genesis.L2InitializationConfig | ||
genesis.FaultProofDeployConfig | ||
Prefund map[common.Address]*big.Int | ||
} | ||
|
||
func (c *L2Config) Check(log log.Logger) error { | ||
if c.Deployer == (common.Address{}) { | ||
return errors.New("missing L2 deployer address") | ||
} | ||
if err := c.L2InitializationConfig.Check(log); err != nil { | ||
return err | ||
} | ||
if !c.FaultProofDeployConfig.UseFaultProofs { | ||
return errors.New("must set UseFaultProofs: legacy output oracle is not supported") | ||
} | ||
if err := c.FaultProofDeployConfig.Check(log); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
type WorldConfig struct { | ||
L1 *L1Config | ||
Superchain *SuperchainConfig | ||
L2s map[string]*L2Config | ||
} | ||
|
||
func (c *WorldConfig) Check(log log.Logger) error { | ||
if err := c.L1.Check(log); err != nil { | ||
return fmt.Errorf("invalid L1 config: %w", err) | ||
} | ||
if err := c.Superchain.Check(log); err != nil { | ||
return fmt.Errorf("invalid Superchain config: %w", err) | ||
} | ||
for l2ChainID, l2Cfg := range c.L2s { | ||
if err := l2Cfg.Check(log.New("l2", &l2ChainID)); err != nil { | ||
return fmt.Errorf("invalid L2 (chain ID %s) config: %w", l2ChainID, err) | ||
} | ||
} | ||
return nil | ||
} |
Oops, something went wrong.