Skip to content

Commit 185d86a

Browse files
dvushcanercidam
andauthored
fix: improve discovery via bootnode (#395)
Discovery with bootnodes did not work for l2 nodes, this fixes it but there are some todos left. * we were using "--disable-discovery" and "--bootnode" at the same time which does not make sense so now when bootnode is set we enable discovery * bootnode is now set to enable v5 protocol by default just in case, v4 still works (always enabled) * I added --rollup.discovery.v4 to op-reth based nodes because for some reason v5 discovery does not work for them. This is low priority todo to figure this out. * op-geth discovery does not work because we use hostname instead of ip and geth does not support it for bootnodes. it never worked but because we were disabling discovery it was never run. This is todo. * I used "--nat", "none" for the reth nodes otherwise it will advertise external IP of the machine to its peers --------- Co-authored-by: Caner Çıdam <canercidam01@gmail.com>
1 parent 1c3c297 commit 185d86a

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

docs/recipes/opstack.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ graph LR
3535
beacon -->|authrpc| el
3636
beacon_healthmon -->|http| beacon
3737
validator -->|http| beacon
38-
op_geth -->|rpc| bootnode
3938
op_geth_healthmon -->|http| op_geth
4039
op_node -->|http| el
4140
op_node -->|http| beacon

playground/components.go

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ package playground
22

33
import (
44
"context"
5+
_ "embed"
56
"fmt"
67
"os"
78
"strconv"
89
"strings"
910
"time"
1011

11-
_ "embed"
12-
1312
"github.com/ethereum/go-ethereum/common/hexutil"
1413
mevboostrelay "github.com/flashbots/builder-playground/mev-boost-relay"
1514
"github.com/flashbots/go-boost-utils/bls"
@@ -81,7 +80,6 @@ func (o *OpRbuilder) Apply(ctx *ExContext) *Component {
8180
"--http.port", `{{Port "http" 8545}}`,
8281
"--chain", "/data/l2-genesis.json",
8382
"--datadir", "/data_op_reth",
84-
"--disable-discovery",
8583
"--color", "never",
8684
"--metrics", `0.0.0.0:{{Port "metrics" 9090}}`,
8785
"--port", `{{Port "rpc" 30303}}`,
@@ -100,7 +98,9 @@ func (o *OpRbuilder) Apply(ctx *ExContext) *Component {
10098
})
10199

102100
if ctx.Bootnode != nil {
103-
service.WithArgs("--bootnodes", ctx.Bootnode.Connect())
101+
service.WithArgs("--bootnodes", ctx.Bootnode.Connect(), "--nat", "none", "--rollup.discovery.v4")
102+
} else {
103+
service.WithArgs("--disable-discovery")
104104
}
105105

106106
if o.Flashblocks {
@@ -159,7 +159,6 @@ func (f *FlashblocksRPC) Apply(ctx *ExContext) *Component {
159159
"--http.port", `{{Port "http" 8545}}`,
160160
"--chain", "/data/l2-genesis.json",
161161
"--datadir", "/data_op_reth",
162-
"--disable-discovery",
163162
"--color", "never",
164163
"--metrics", `0.0.0.0:{{Port "metrics" 9090}}`,
165164
"--port", `{{Port "rpc" 30303}}`,
@@ -171,7 +170,11 @@ func (f *FlashblocksRPC) Apply(ctx *ExContext) *Component {
171170
if ctx.Bootnode != nil {
172171
service.WithArgs(
173172
"--bootnodes", ctx.Bootnode.Connect(),
173+
"--nat", "none",
174+
"--rollup.discovery.v4",
174175
)
176+
} else {
177+
service.WithArgs("--disable-discovery")
175178
}
176179

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

379382
var trustedPeers string
380383
if ctx.Bootnode != nil {
381-
trustedPeers = fmt.Sprintf("--bootnodes %s ", ctx.Bootnode.Connect())
384+
// TODO: Figure out the port dynamically.
385+
trustedPeers = fmt.Sprintf("--bootnodes enode://%s@$(getent hosts bootnode | awk '{print $1}'):30303 --discovery.v4 ", ctx.Bootnode.ID)
386+
} else {
387+
trustedPeers = "--nodiscover "
382388
}
383389

384390
svc := component.NewService("op-geth").
@@ -404,7 +410,6 @@ func (o *OpGeth) Apply(ctx *ExContext) *Component {
404410
"--ws.origins \"*\" "+
405411
"--ws.api debug,eth,txpool,net,engine,miner "+
406412
"--syncmode full "+
407-
"--nodiscover "+
408413
"--maxpeers 5 "+
409414
"--rpc.allow-unprotected-txs "+
410415
"--authrpc.addr 0.0.0.0 "+
@@ -483,7 +488,6 @@ func (r *RethEL) Apply(ctx *ExContext) *Component {
483488
"--color", "never",
484489
"--addr", "0.0.0.0",
485490
"--port", `{{Port "rpc" 30303}}`,
486-
// "--disable-discovery",
487491
"--ipcpath", "/data_reth/reth.ipc",
488492
// http config
489493
"--http",
@@ -510,7 +514,9 @@ func (r *RethEL) Apply(ctx *ExContext) *Component {
510514
WithVolume("data", "/data_reth", true)
511515

512516
if ctx.Bootnode != nil {
513-
svc.WithArgs("--bootnodes", ctx.Bootnode.Connect())
517+
svc.WithArgs("--bootnodes", ctx.Bootnode.Connect(), "--nat", "none")
518+
} else {
519+
svc.WithArgs("--disable-discovery")
514520
}
515521

516522
UseHealthmon(component, svc, healthmonExecution)
@@ -691,7 +697,6 @@ func (o *OpReth) Apply(ctx *ExContext) *Component {
691697
"--http.port", `{{Port "http" 8545}}`,
692698
"--chain", "/data/l2-genesis.json",
693699
"--datadir", "/data_op_reth",
694-
"--disable-discovery",
695700
"--color", "never",
696701
"--metrics", `0.0.0.0:{{Port "metrics" 9090}}`,
697702
"--addr", "0.0.0.0",
@@ -701,6 +706,12 @@ func (o *OpReth) Apply(ctx *ExContext) *Component {
701706
WithArtifact("/data/l2-genesis.json", "l2-genesis.json").
702707
WithVolume("data", "/data_op_reth")
703708

709+
if ctx.Bootnode != nil {
710+
svc.WithArgs("--bootnodes", ctx.Bootnode.Connect(), "--nat", "none", "--rollup.discovery.v4")
711+
} else {
712+
svc.WithArgs("--disable-discovery")
713+
}
714+
704715
UseHealthmon(component, svc, healthmonExecution)
705716

706717
return component
@@ -1057,22 +1068,15 @@ func registerBuilderHook(ctx context.Context, exCtx *ExContext, manifest *Manife
10571068
return nil
10581069
}
10591070

1060-
type BootnodeProtocol string
1061-
1062-
const (
1063-
BootnodeProtocolV5 BootnodeProtocol = "v5"
1064-
)
1065-
10661071
type Bootnode struct {
1067-
Protocol BootnodeProtocol
1068-
Enode *EnodeAddr
1072+
Enode *EnodeAddr
10691073
}
10701074

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

10741078
b.Enode = ctx.Output.GetEnodeAddr()
1075-
svc := component.NewService("bootnode").
1079+
component.NewService("bootnode").
10761080
WithImage("ghcr.io/paradigmxyz/reth").
10771081
WithTag("v1.9.3").
10781082
WithEntrypoint("/usr/local/bin/reth").
@@ -1082,13 +1086,11 @@ func (b *Bootnode) Apply(ctx *ExContext) *Component {
10821086
"--p2p-secret-key", "/data/p2p_key.txt",
10831087
"-vvvv",
10841088
"--color", "never",
1089+
"--nat", "none",
1090+
"--v5",
10851091
).
10861092
WithArtifact("/data/p2p_key.txt", b.Enode.Artifact)
10871093

1088-
if b.Protocol == BootnodeProtocolV5 {
1089-
svc.WithArgs("--v5")
1090-
}
1091-
10921094
// Mutate the execution context by setting the bootnode.
10931095
ctx.Bootnode = &BootnodeRef{
10941096
Service: "bootnode",

0 commit comments

Comments
 (0)