Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion docs/recipes/opstack.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ graph LR
beacon -->|authrpc| el
beacon_healthmon -->|http| beacon
validator -->|http| beacon
op_geth -->|rpc| bootnode
op_geth_healthmon -->|http| op_geth
op_node -->|http| el
op_node -->|http| beacon
Expand Down
48 changes: 25 additions & 23 deletions playground/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package playground

import (
"context"
_ "embed"
"fmt"
"os"
"strconv"
"strings"
"time"

_ "embed"

"github.com/ethereum/go-ethereum/common/hexutil"
mevboostrelay "github.com/flashbots/builder-playground/mev-boost-relay"
"github.com/flashbots/go-boost-utils/bls"
Expand Down Expand Up @@ -81,7 +80,6 @@ func (o *OpRbuilder) Apply(ctx *ExContext) *Component {
"--http.port", `{{Port "http" 8545}}`,
"--chain", "/data/l2-genesis.json",
"--datadir", "/data_op_reth",
"--disable-discovery",
"--color", "never",
"--metrics", `0.0.0.0:{{Port "metrics" 9090}}`,
"--port", `{{Port "rpc" 30303}}`,
Expand All @@ -100,7 +98,9 @@ func (o *OpRbuilder) Apply(ctx *ExContext) *Component {
})

if ctx.Bootnode != nil {
service.WithArgs("--bootnodes", ctx.Bootnode.Connect())
service.WithArgs("--bootnodes", ctx.Bootnode.Connect(), "--nat", "none", "--rollup.discovery.v4")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bootnode discovery pattern is repeated across 4 components (OpRbuilder, FlashblocksRPC, RethEL, OpReth) with slight variations (some include --rollup.discovery.v4, some don't). Consider extracting a helper like applyBootnodeArgs(svc, ctx, isRollup bool) to centralize this logic — it would make it easier to update in one place if the flags change again.

} else {
service.WithArgs("--disable-discovery")
}

if o.Flashblocks {
Expand Down Expand Up @@ -159,7 +159,6 @@ func (f *FlashblocksRPC) Apply(ctx *ExContext) *Component {
"--http.port", `{{Port "http" 8545}}`,
"--chain", "/data/l2-genesis.json",
"--datadir", "/data_op_reth",
"--disable-discovery",
"--color", "never",
"--metrics", `0.0.0.0:{{Port "metrics" 9090}}`,
"--port", `{{Port "rpc" 30303}}`,
Expand All @@ -171,7 +170,11 @@ func (f *FlashblocksRPC) Apply(ctx *ExContext) *Component {
if ctx.Bootnode != nil {
service.WithArgs(
"--bootnodes", ctx.Bootnode.Connect(),
"--nat", "none",
"--rollup.discovery.v4",
)
} else {
service.WithArgs("--disable-discovery")
}

return component
Expand Down Expand Up @@ -378,7 +381,10 @@ func (o *OpGeth) Apply(ctx *ExContext) *Component {

var trustedPeers string
if ctx.Bootnode != nil {
trustedPeers = fmt.Sprintf("--bootnodes %s ", ctx.Bootnode.Connect())
// TODO: Figure out the port dynamically.
trustedPeers = fmt.Sprintf("--bootnodes enode://%s@$(getent hosts bootnode | awk '{print $1}'):30303 --discovery.v4 ", ctx.Bootnode.ID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The service name bootnode is hardcoded here while other components use ctx.Bootnode.Service (via ctx.Bootnode.Connect()). If the bootnode service name ever changes, this will silently break. Also, port 30303 is hardcoded — consider using the template port syntax to stay consistent with the rest of the codebase.

Additionally, embedding $(getent hosts bootnode | awk '{print $1}') in the shell string works because op-geth uses /bin/sh -c, but it couples this component to a shell entrypoint. A comment noting this dependency would help future readers.

} else {
trustedPeers = "--nodiscover "
}

svc := component.NewService("op-geth").
Expand All @@ -404,7 +410,6 @@ func (o *OpGeth) Apply(ctx *ExContext) *Component {
"--ws.origins \"*\" "+
"--ws.api debug,eth,txpool,net,engine,miner "+
"--syncmode full "+
"--nodiscover "+
"--maxpeers 5 "+
"--rpc.allow-unprotected-txs "+
"--authrpc.addr 0.0.0.0 "+
Expand Down Expand Up @@ -483,7 +488,6 @@ func (r *RethEL) Apply(ctx *ExContext) *Component {
"--color", "never",
"--addr", "0.0.0.0",
"--port", `{{Port "rpc" 30303}}`,
// "--disable-discovery",
"--ipcpath", "/data_reth/reth.ipc",
// http config
"--http",
Expand All @@ -510,7 +514,9 @@ func (r *RethEL) Apply(ctx *ExContext) *Component {
WithVolume("data", "/data_reth", true)

if ctx.Bootnode != nil {
svc.WithArgs("--bootnodes", ctx.Bootnode.Connect())
svc.WithArgs("--bootnodes", ctx.Bootnode.Connect(), "--nat", "none")
} else {
svc.WithArgs("--disable-discovery")
}

UseHealthmon(component, svc, healthmonExecution)
Expand Down Expand Up @@ -691,7 +697,6 @@ func (o *OpReth) Apply(ctx *ExContext) *Component {
"--http.port", `{{Port "http" 8545}}`,
"--chain", "/data/l2-genesis.json",
"--datadir", "/data_op_reth",
"--disable-discovery",
"--color", "never",
"--metrics", `0.0.0.0:{{Port "metrics" 9090}}`,
"--addr", "0.0.0.0",
Expand All @@ -701,6 +706,12 @@ func (o *OpReth) Apply(ctx *ExContext) *Component {
WithArtifact("/data/l2-genesis.json", "l2-genesis.json").
WithVolume("data", "/data_op_reth")

if ctx.Bootnode != nil {
svc.WithArgs("--bootnodes", ctx.Bootnode.Connect(), "--nat", "none", "--rollup.discovery.v4")
} else {
svc.WithArgs("--disable-discovery")
}

UseHealthmon(component, svc, healthmonExecution)

return component
Expand Down Expand Up @@ -1057,22 +1068,15 @@ func registerBuilderHook(ctx context.Context, exCtx *ExContext, manifest *Manife
return nil
}

type BootnodeProtocol string

const (
BootnodeProtocolV5 BootnodeProtocol = "v5"
)

type Bootnode struct {
Protocol BootnodeProtocol
Enode *EnodeAddr
Enode *EnodeAddr
}

func (b *Bootnode) Apply(ctx *ExContext) *Component {
component := NewComponent("bootnode")

b.Enode = ctx.Output.GetEnodeAddr()
svc := component.NewService("bootnode").
component.NewService("bootnode").
WithImage("ghcr.io/paradigmxyz/reth").
WithTag("v1.9.3").
WithEntrypoint("/usr/local/bin/reth").
Expand All @@ -1082,13 +1086,11 @@ func (b *Bootnode) Apply(ctx *ExContext) *Component {
"--p2p-secret-key", "/data/p2p_key.txt",
"-vvvv",
"--color", "never",
"--nat", "none",
"--v5",
).
WithArtifact("/data/p2p_key.txt", b.Enode.Artifact)

if b.Protocol == BootnodeProtocolV5 {
svc.WithArgs("--v5")
}

// Mutate the execution context by setting the bootnode.
ctx.Bootnode = &BootnodeRef{
Service: "bootnode",
Expand Down