Skip to content

Commit

Permalink
Merge pull request #8063 from ethereum-optimism/feat/dump-rollup-config
Browse files Browse the repository at this point in the history
op-node: Add command to dump rollup configs
  • Loading branch information
trianglesphere authored Nov 9, 2023
2 parents c3b1744 + 622780a commit 88d1b38
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions op-node/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
opnode "github.com/ethereum-optimism/optimism/op-node"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/cmd/genesis"
"github.com/ethereum-optimism/optimism/op-node/cmd/networks"
"github.com/ethereum-optimism/optimism/op-node/cmd/p2p"
"github.com/ethereum-optimism/optimism/op-node/flags"
"github.com/ethereum-optimism/optimism/op-node/metrics"
Expand Down Expand Up @@ -57,6 +58,10 @@ func main() {
Name: "doc",
Subcommands: doc.NewSubcommands(metrics.NewMetrics("default")),
},
{
Name: "networks",
Subcommands: networks.Subcommands,
},
}

ctx := opio.WithInterruptBlocker(context.Background())
Expand Down
43 changes: 43 additions & 0 deletions op-node/cmd/networks/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package networks

import (
"encoding/json"
"errors"
"fmt"

opnode "github.com/ethereum-optimism/optimism/op-node"
"github.com/ethereum-optimism/optimism/op-node/flags"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/urfave/cli/v2"
)

var Subcommands = []*cli.Command{
{
Name: "dump-rollup-config",
Usage: "Dumps network configs",
Flags: []cli.Flag{
flags.Network,
},
Action: func(ctx *cli.Context) error {
logCfg := oplog.ReadCLIConfig(ctx)
logger := oplog.NewLogger(oplog.AppOut(ctx), logCfg)

network := ctx.String(flags.Network.Name)
if network == "" {
return errors.New("must specify a network name")
}

rCfg, err := opnode.NewRollupConfig(logger, ctx)
if err != nil {
return err
}

out, err := json.MarshalIndent(rCfg, "", " ")
if err != nil {
return err
}
fmt.Println(string(out))
return nil
},
},
}

0 comments on commit 88d1b38

Please sign in to comment.