Skip to content

Commit

Permalink
Enable starting monomer apps in verifier mode
Browse files Browse the repository at this point in the history
Introduces the --monomer.sequencer-mode flag to start the Monomer
application in sequencer mode. Otherwise, the Monomer application will
be started in verifier mode.
  • Loading branch information
natebeauregard committed Dec 16, 2024
1 parent 780a117 commit 9ede6c1
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 3 deletions.
10 changes: 8 additions & 2 deletions docs/docs/build/create-an-app-with-monomer.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ If using a Go version `>=1.23.0`, run:
go build -ldflags=-checklinkname=0 -o testappd ./cmd/testappd
````

Now that our application is configured, we can start the Monomer application by running the following command.
Now that our application is configured, we can start the Monomer application in sequencer mode by running the following command.

```bash
./testappd monomer start --minimum-gas-prices 0.01wei --monomer.dev-start --api.enable
./testappd monomer start --minimum-gas-prices 0.01wei --monomer.sequencer-mode --monomer.dev-start --api.enable
````
To run the application in verifier mode, omit the `--monomer.sequencer-mode` flag:
```bash
./testappd monomer start --minimum-gas-prices 0.01wei --monomer.dev-start --api.enable
```

Congratulations! You've successfully integrated Monomer into your Cosmos SDK application.
2 changes: 1 addition & 1 deletion docs/docs/build/interact.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ We will need to have an account on L1 with funds.
To give yourself funds on the devnet at genesis, run the devnet start command specified in the last tutorial with the `--monomer.dev.l1-user-address` flag:

```bash
./testappd monomer start --minimum-gas-prices 0.01wei --monomer.dev-start --api.enable --monomer.dev.l1-user-address "<address>"
./testappd monomer start --minimum-gas-prices 0.01wei --monomer.sequencer-mode --monomer.dev-start --api.enable --monomer.dev.l1-user-address "<address>"
```

## Configuring L1 and L2 Wallets
Expand Down
1 change: 1 addition & 0 deletions e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func Run(
"monomer",
"start",
"--minimum-gas-prices", "0.001wei",
"--monomer.sequencer-mode",
"--monomer.dev-start",
))
appCmd.Dir = appDirPath
Expand Down
3 changes: 3 additions & 0 deletions integrations/integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (

const (
flagEngineURL = "monomer.engine-url"
flagSequencerMode = "monomer.sequencer-mode"
flagDev = "monomer.dev-start"
flagL1AllocsPath = "monomer.dev.l1-allocs"
flagL1DeploymentsPath = "monomer.dev.l1-deployments"
Expand All @@ -78,6 +79,7 @@ func AddMonomerCommand(rootCmd *cobra.Command, appCreator servertypes.AppCreator
StartCommandHandler: startCommandHandler,
AddFlags: func(cmd *cobra.Command) {
cmd.Flags().String(flagEngineURL, "ws://127.0.0.1:9000", "url of Monomer's Engine API endpoint")
cmd.Flags().Bool(flagSequencerMode, false, "enable sequencer mode for the Monomer node")
cmd.Flags().Bool(flagDev, false, "run the OP Stack devnet in-process for testing")
cmd.Flags().String(flagL1URL, "ws://127.0.0.1:9001", "")
cmd.Flags().String(flagOPNodeURL, "http://127.0.0.1:9002", "")
Expand Down Expand Up @@ -302,6 +304,7 @@ func startOPDevnet(
if err != nil {
return fmt.Errorf("build op config: %v", err)
}
opConfig.Node.Driver.SequencerEnabled = v.GetBool(flagSequencerMode)
if err := opConfig.Run(ctx, env, logger); err != nil {
return fmt.Errorf("run op: %v", err)
}
Expand Down
5 changes: 5 additions & 0 deletions opdevnet/op.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ func (cfg *OPConfig) Run(ctx context.Context, env *environment.Env, logger log.L
return opNode.Stop(context.Background())
})

// Do not start the batcher and proposer if the node is running in verifier mode
if !cfg.Node.Driver.SequencerEnabled {
return nil
}

// Proposer
proposerService, err := proposer.ProposerServiceFromCLIConfig(ctx, "v0.1", cfg.Proposer, newLogger(logger, "proposer"))
if err != nil {
Expand Down
54 changes: 54 additions & 0 deletions opdevnet/opdevnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,60 @@ func TestOPDevnet(t *testing.T) {
}
time.Sleep(l2SlotDuration)
}

// Set up and run a verifier node
verifierL2EngineURL, err := e2eurl.ParseString("ws://127.0.0.1:8894")
require.NoError(t, err)
verifierOpNodeURL, err := e2eurl.ParseString("http://127.0.0.1:8895")
require.NoError(t, err)
verifierL2EthURL, err := e2eurl.ParseString("ws://127.0.0.1:8896")
require.NoError(t, err)

verifierL2Node, verifierL2Backend, err := geth.InitL2("l2-verifier", l2Genesis.Config.ChainID, l2Genesis, writeJWT(t, jwtSecret), func(_ *ethconfig.Config, nodeCfg *node.Config) error {
nodeCfg.AuthAddr = verifierL2EngineURL.Hostname()
nodeCfg.AuthPort = int(verifierL2EngineURL.PortU16())
nodeCfg.WSHost = verifierL2EthURL.Hostname()
nodeCfg.WSPort = int(verifierL2EthURL.PortU16())
return nil
})
require.NoError(t, err)
require.NoError(t, verifierL2Node.Start())
defer func() {
require.NoError(t, verifierL2Node.Close())
}()
l2EngineURL.IsReachable(ctx)

verifierOpConfig, err := opdevnet.BuildOPConfig(
deployConfig,
secrets.Batcher,
secrets.Proposer,
l1GenesisBlock,
l1Deployments.L2OutputOracleProxy,
eth.HeaderBlockID(l2Genesis.ToBlock().Header()),
l1URL,
verifierOpNodeURL,
verifierL2EngineURL,
verifierL2EthURL,
jwtSecret,
)
require.NoError(t, err)
verifierOpConfig.Node.Driver.SequencerEnabled = false
require.NoError(t, verifierOpConfig.Run(ctx, env, log.NewLogger(log.NewTerminalHandler(openLogFile(t, env, "op-verifier"), false))))

// Wait for the verifier node to sync to block 10
for i := 0; i < 30; i++ {
verifierBlockNum := verifierL2Backend.BlockChain().CurrentHeader().Number
if verifierBlockNum.Uint64() >= 10 {
break
}
if i == 29 {
t.Fatalf("Verifier failed to sync to block 10. Current block: %v", verifierBlockNum)
}
time.Sleep(time.Second)
}

// Assert that the verifier and sequencer state roots at block 10 are equal
require.Equal(t, verifierL2Backend.BlockChain().GetHeaderByNumber(10).Root, l2Backend.BlockChain().GetHeaderByNumber(10).Root)
}

// Copied and slightly modified from optimism/op-e2e.
Expand Down

0 comments on commit 9ede6c1

Please sign in to comment.