-
Notifications
You must be signed in to change notification settings - Fork 49
fix: improve discovery via bootnode #395
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
|
@@ -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}}`, | ||
|
|
@@ -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") | ||
| } else { | ||
| service.WithArgs("--disable-discovery") | ||
| } | ||
|
|
||
| if o.Flashblocks { | ||
|
|
@@ -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}}`, | ||
|
|
@@ -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 | ||
|
|
@@ -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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The service name Additionally, embedding |
||
| } else { | ||
| trustedPeers = "--nodiscover " | ||
| } | ||
|
|
||
| svc := component.NewService("op-geth"). | ||
|
|
@@ -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 "+ | ||
|
|
@@ -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", | ||
|
|
@@ -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) | ||
|
|
@@ -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", | ||
|
|
@@ -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 | ||
|
|
@@ -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"). | ||
|
|
@@ -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", | ||
|
|
||
There was a problem hiding this comment.
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 likeapplyBootnodeArgs(svc, ctx, isRollup bool)to centralize this logic — it would make it easier to update in one place if the flags change again.