Commit 818bc9f4 authored by OptimismBot's avatar OptimismBot Committed by GitHub

Merge pull request #6390 from ethereum-optimism/rollup-config-warning

op-node: log error when op-node is configured with conflicting network and rollup-config
parents 417612ac 9f1dcbc7
...@@ -44,7 +44,7 @@ func Main(cliCtx *cli.Context) error { ...@@ -44,7 +44,7 @@ func Main(cliCtx *cli.Context) error {
m := metrics.NewMetrics("default") m := metrics.NewMetrics("default")
ctx := context.Background() ctx := context.Background()
config, err := opnode.NewRollupConfig(cliCtx) config, err := opnode.NewRollupConfig(logger, cliCtx)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -30,7 +30,7 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*node.Config, error) { ...@@ -30,7 +30,7 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*node.Config, error) {
return nil, err return nil, err
} }
rollupConfig, err := NewRollupConfig(ctx) rollupConfig, err := NewRollupConfig(log, ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -168,9 +168,16 @@ func NewDriverConfig(ctx *cli.Context) *driver.Config { ...@@ -168,9 +168,16 @@ func NewDriverConfig(ctx *cli.Context) *driver.Config {
} }
} }
func NewRollupConfig(ctx *cli.Context) (*rollup.Config, error) { func NewRollupConfig(log log.Logger, ctx *cli.Context) (*rollup.Config, error) {
network := ctx.String(flags.Network.Name) network := ctx.String(flags.Network.Name)
rollupConfigPath := ctx.String(flags.RollupConfig.Name)
if network != "" { if network != "" {
if rollupConfigPath != "" {
log.Error(`Cannot configure network and rollup-config at the same time.
Startup will proceed to use the network-parameter and ignore the rollup config.
Conflicting configuration is deprecated, and will stop the op-node from starting in the future.
`, "network", network, "rollup_config", rollupConfigPath)
}
config, err := chaincfg.GetRollupConfig(network) config, err := chaincfg.GetRollupConfig(network)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -179,7 +186,6 @@ func NewRollupConfig(ctx *cli.Context) (*rollup.Config, error) { ...@@ -179,7 +186,6 @@ func NewRollupConfig(ctx *cli.Context) (*rollup.Config, error) {
return &config, nil return &config, nil
} }
rollupConfigPath := ctx.String(flags.RollupConfig.Name)
file, err := os.Open(rollupConfigPath) file, err := os.Open(rollupConfigPath)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read rollup config: %w", err) return nil, fmt.Errorf("failed to read rollup config: %w", err)
......
...@@ -63,7 +63,7 @@ func run(args []string, action ConfigAction) error { ...@@ -63,7 +63,7 @@ func run(args []string, action ConfigAction) error {
} }
logger.Info("Starting fault proof program", "version", VersionWithMeta) logger.Info("Starting fault proof program", "version", VersionWithMeta)
cfg, err := config.NewConfigFromCLI(ctx) cfg, err := config.NewConfigFromCLI(logger, ctx)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"github.com/ethereum-optimism/optimism/op-program/host/flags" "github.com/ethereum-optimism/optimism/op-program/host/flags"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
...@@ -110,11 +111,11 @@ func NewConfig(rollupCfg *rollup.Config, l2Genesis *params.ChainConfig, l1Head c ...@@ -110,11 +111,11 @@ func NewConfig(rollupCfg *rollup.Config, l2Genesis *params.ChainConfig, l1Head c
} }
} }
func NewConfigFromCLI(ctx *cli.Context) (*Config, error) { func NewConfigFromCLI(log log.Logger, ctx *cli.Context) (*Config, error) {
if err := flags.CheckRequired(ctx); err != nil { if err := flags.CheckRequired(ctx); err != nil {
return nil, err return nil, err
} }
rollupCfg, err := opnode.NewRollupConfig(ctx) rollupCfg, err := opnode.NewRollupConfig(log, ctx)
if err != nil { if err != nil {
return nil, err return nil, 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