Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable starting monomer apps in verifier mode #320

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
natebeauregard marked this conversation as resolved.
Show resolved Hide resolved
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)
natebeauregard marked this conversation as resolved.
Show resolved Hide resolved

verifierOpConfig, err := opdevnet.BuildOPConfig(
natebeauregard marked this conversation as resolved.
Show resolved Hide resolved
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)
natebeauregard marked this conversation as resolved.
Show resolved Hide resolved
}

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