Skip to content

Commit 874bd08

Browse files
ferranbtcanercidam
andauthored
Add bootnode component (#327)
This PR adds a custom bootnode component instead of having to use one of the nodes as bootnode. --------- Co-authored-by: Caner Çıdam <canercidam01@gmail.com>
1 parent 47fd55f commit 874bd08

File tree

5 files changed

+54
-11
lines changed

5 files changed

+54
-11
lines changed

docs/recipes/opstack.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Deploy an OP stack.
1919

2020
```mermaid
2121
graph LR
22+
bootnode["bootnode<br/>rpc:30303"]
2223
el["el<br/>rpc:30303<br/>http:8545<br/>ws:8546<br/>authrpc:8551<br/>metrics:9090"]
2324
el_healthmon["el_healthmon"]
2425
beacon["beacon<br/>p2p:9000<br/>p2p:9000<br/>quic-p2p:9100<br/>http:3500"]
@@ -29,10 +30,12 @@ graph LR
2930
op_node["op-node<br/>metrics:7300<br/>http:8549<br/>p2p:9003<br/>p2p:9003"]
3031
op_batcher["op-batcher"]
3132
33+
el -->|rpc| bootnode
3234
el_healthmon -->|http| el
3335
beacon -->|authrpc| el
3436
beacon_healthmon -->|http| beacon
3537
validator -->|http| beacon
38+
op_geth -->|rpc| bootnode
3639
op_geth_healthmon -->|http| op_geth
3740
op_node -->|http| el
3841
op_node -->|http| beacon

playground/catalog.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ func init() {
2626
register(&WebsocketProxy{})
2727
register(&BuilderHub{})
2828
register(&ChainMonitor{})
29+
register(&Bootnode{})
2930
}

playground/components.go

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (o *OpRbuilder) Apply(ctx *ExContext) *Component {
100100
})
101101

102102
if ctx.Bootnode != nil {
103-
service.WithArgs("--trusted-peers", ctx.Bootnode.Connect())
103+
service.WithArgs("--bootnodes", ctx.Bootnode.Connect())
104104
}
105105

106106
if o.Flashblocks {
@@ -170,7 +170,7 @@ func (f *FlashblocksRPC) Apply(ctx *ExContext) *Component {
170170

171171
if ctx.Bootnode != nil {
172172
service.WithArgs(
173-
"--trusted-peers", ctx.Bootnode.Connect(),
173+
"--bootnodes", ctx.Bootnode.Connect(),
174174
)
175175
}
176176

@@ -509,6 +509,10 @@ func (r *RethEL) Apply(ctx *ExContext) *Component {
509509
WithArtifact("/data/jwtsecret", "jwtsecret").
510510
WithVolume("data", "/data_reth", true)
511511

512+
if ctx.Bootnode != nil {
513+
svc.WithArgs("--bootnodes", ctx.Bootnode.Connect())
514+
}
515+
512516
UseHealthmon(component, svc, healthmonExecution)
513517

514518
if r.UseNativeReth {
@@ -1053,6 +1057,47 @@ func registerBuilderHook(ctx context.Context, exCtx *ExContext, manifest *Manife
10531057
return nil
10541058
}
10551059

1060+
type BootnodeProtocol string
1061+
1062+
const (
1063+
BootnodeProtocolV5 BootnodeProtocol = "v5"
1064+
)
1065+
1066+
type Bootnode struct {
1067+
Protocol BootnodeProtocol
1068+
Enode *EnodeAddr
1069+
}
1070+
1071+
func (b *Bootnode) Apply(ctx *ExContext) *Component {
1072+
component := NewComponent("bootnode")
1073+
1074+
b.Enode = ctx.Output.GetEnodeAddr()
1075+
svc := component.NewService("bootnode").
1076+
WithImage("ghcr.io/paradigmxyz/reth").
1077+
WithTag("v1.9.3").
1078+
WithEntrypoint("/usr/local/bin/reth").
1079+
WithArgs(
1080+
"p2p", "bootnode",
1081+
"--addr", `0.0.0.0:{{Port "rpc" 30303}}`,
1082+
"--p2p-secret-key", "/data/p2p_key.txt",
1083+
"-vvvv",
1084+
"--color", "never",
1085+
).
1086+
WithArtifact("/data/p2p_key.txt", b.Enode.Artifact)
1087+
1088+
if b.Protocol == BootnodeProtocolV5 {
1089+
svc.WithArgs("--v5")
1090+
}
1091+
1092+
// Mutate the execution context by setting the bootnode.
1093+
ctx.Bootnode = &BootnodeRef{
1094+
Service: "bootnode",
1095+
ID: b.Enode.NodeID(),
1096+
}
1097+
1098+
return component
1099+
}
1100+
10561101
const (
10571102
healthmonBeacon = "beacon"
10581103
healthmonExecution = "execution"

playground/components_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func (tt *testFramework) test(component ComponentGen, args []string) *Manifest {
228228

229229
exCtx := &ExContext{
230230
Output: o,
231-
LogLevel: LevelDebug,
231+
LogLevel: LevelTrace,
232232
Contender: &ContenderContext{
233233
Enabled: false,
234234
},

playground/recipe_opstack.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func (o *OpRecipe) Artifacts() *ArtifactsBuilder {
8181

8282
func (o *OpRecipe) Apply(ctx *ExContext) *Component {
8383
component := NewComponent("op-recipe")
84+
component.AddComponent(ctx, &Bootnode{})
8485

8586
component.AddComponent(ctx, &RethEL{})
8687
component.AddComponent(ctx, &LighthouseBeaconNode{
@@ -94,14 +95,6 @@ func (o *OpRecipe) Apply(ctx *ExContext) *Component {
9495
externalBuilderRef := o.externalBuilder
9596
peers := []string{}
9697

97-
opGeth := &OpGeth{}
98-
component.AddComponent(ctx, opGeth)
99-
100-
ctx.Bootnode = &BootnodeRef{
101-
Service: "op-geth",
102-
ID: opGeth.Enode.NodeID(),
103-
}
104-
10598
if o.externalBuilder == "op-reth" {
10699
// Add a new op-reth service and connect it to Rollup-boost
107100
component.AddComponent(ctx, &OpReth{})
@@ -176,6 +169,7 @@ func (o *OpRecipe) Apply(ctx *ExContext) *Component {
176169
})
177170
}
178171

172+
component.AddService(ctx, &OpGeth{})
179173
component.AddComponent(ctx, &OpNode{
180174
L1Node: "el",
181175
L1Beacon: "beacon",

0 commit comments

Comments
 (0)