Commit 169329cf authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge pull request #4579 from ethereum-optimism/fix/deploy-config-validation-2

op-chain-ops: better deploy config validation
parents 899e3b94 722ee120
......@@ -108,6 +108,9 @@ type DeployConfig struct {
// Check will ensure that the config is sane and return an error when it is not
func (d *DeployConfig) Check() error {
if d.L1StartingBlockTag == nil {
return fmt.Errorf("%w: L2StartingBlockTag cannot be nil", ErrInvalidDeployConfig)
}
if d.L1ChainID == 0 {
return fmt.Errorf("%w: L1ChainID cannot be 0", ErrInvalidDeployConfig)
}
......@@ -327,7 +330,7 @@ func NewDeployConfig(path string) (*DeployConfig, error) {
var config DeployConfig
if err := json.Unmarshal(file, &config); err != nil {
return nil, err
return nil, fmt.Errorf("cannot unmarshal deploy config: %w", err)
}
return &config, nil
......
......@@ -3,7 +3,6 @@ package genesis
import (
"context"
"encoding/json"
"errors"
"fmt"
"math/big"
"os"
......@@ -114,16 +113,24 @@ var Subcommands = cli.Commands{
return err
}
if config.L1StartingBlockTag == nil {
return errors.New("must specify a starting block tag in genesis")
depPath, network := filepath.Split(ctx.String("deployment-dir"))
hh, err := hardhat.New(network, nil, []string{depPath})
if err != nil {
return err
}
// Read the appropriate deployment addresses from disk
if err := config.GetDeployedAddresses(hh); err != nil {
return err
}
if config.L2GenesisBlockGasLimit == 0 { // TODO: this is a hotfix, need to set default values in more clean way + sanity check the config
config.L2GenesisBlockGasLimit = 15_000_000
// Sanity check the config
if err := config.Check(); err != nil {
return err
}
client, err := ethclient.Dial(ctx.String("l1-rpc"))
if err != nil {
return err
return fmt.Errorf("cannot dial %s: %w", ctx.String("l1-rpc"), err)
}
var l1StartBlock *types.Block
......@@ -136,20 +143,6 @@ var Subcommands = cli.Commands{
return fmt.Errorf("error getting l1 start block: %w", err)
}
depPath, network := filepath.Split(ctx.String("deployment-dir"))
hh, err := hardhat.New(network, nil, []string{depPath})
if err != nil {
return err
}
// Read the appropriate deployment addresses from disk
if err := config.GetDeployedAddresses(hh); err != nil {
return err
}
// Sanity check the config
if err := config.Check(); err != nil {
return err
}
// Build the developer L2 genesis block
l2Genesis, err := genesis.BuildL2DeveloperGenesis(config, l1StartBlock)
if err != 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