-
Notifications
You must be signed in to change notification settings - Fork 49
Add bootnode component #327
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 7 commits
b1a092f
416f55b
8d94922
3390c6e
a384c76
66c87a3
95d6cae
c0d5908
ede65ae
ab2822f
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 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -96,7 +96,7 @@ func (o *OpRbuilder) Apply(ctx *ExContext) *Component { | |||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if ctx.Bootnode != nil { | ||||||||||||||||||||||||||
| service.WithArgs("--trusted-peers", ctx.Bootnode.Connect()) | ||||||||||||||||||||||||||
| service.WithArgs("--bootnodes", ctx.Bootnode.Connect()) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if o.Flashblocks { | ||||||||||||||||||||||||||
|
|
@@ -166,7 +166,7 @@ func (f *FlashblocksRPC) Apply(ctx *ExContext) *Component { | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if ctx.Bootnode != nil { | ||||||||||||||||||||||||||
| service.WithArgs( | ||||||||||||||||||||||||||
| "--trusted-peers", ctx.Bootnode.Connect(), | ||||||||||||||||||||||||||
| "--bootnodes", ctx.Bootnode.Connect(), | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -505,6 +505,10 @@ func (r *RethEL) Apply(ctx *ExContext) *Component { | |||||||||||||||||||||||||
| WithArtifact("/data/jwtsecret", "jwtsecret"). | ||||||||||||||||||||||||||
| WithVolume("data", "/data_reth") | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if ctx.Bootnode != nil { | ||||||||||||||||||||||||||
| svc.WithArgs("--bootnodes", ctx.Bootnode.Connect()) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| UseHealthmon(component, svc, healthmonExecution) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if r.UseNativeReth { | ||||||||||||||||||||||||||
|
|
@@ -1003,6 +1007,41 @@ func registerBuilderHook(ctx *ExContext, s *Service, b *BuilderHub) error { | |||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| type BootnodeProtocol string | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const ( | ||||||||||||||||||||||||||
| BootnodeProtocolV5 BootnodeProtocol = "v5" | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| type Bootnode struct { | ||||||||||||||||||||||||||
| Protocol BootnodeProtocol | ||||||||||||||||||||||||||
| Enode *EnodeAddr | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| func (b *Bootnode) Apply(ctx *ExContext) *Component { | ||||||||||||||||||||||||||
| component := NewComponent("bootnode") | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| b.Enode = ctx.Output.GetEnodeAddr() | ||||||||||||||||||||||||||
|
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. Bug: This unconditionally calls This means:
Clients will connect to the NodeID from key #1, but the bootnode will be running with key #2. Fix: Only generate if
Suggested change
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. Bug: This unconditionally overwrites Since
Suggested change
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. Bug: Enode key mismatch This unconditionally overwrites Since
Impact: Clients (like
Suggested change
|
||||||||||||||||||||||||||
| svc := component.NewService("bootnode"). | ||||||||||||||||||||||||||
| WithImage("ghcr.io/paradigmxyz/reth"). | ||||||||||||||||||||||||||
| WithTag("v1.9.3"). | ||||||||||||||||||||||||||
| WithEntrypoint("/usr/local/bin/reth"). | ||||||||||||||||||||||||||
| WithArgs( | ||||||||||||||||||||||||||
| "p2p", "bootnode", | ||||||||||||||||||||||||||
| "--addr", `0.0.0.0:{{Port "rpc" 30303}}`, | ||||||||||||||||||||||||||
| "--p2p-secret-key", "/data/p2p_key.txt", | ||||||||||||||||||||||||||
| "-vvvv", | ||||||||||||||||||||||||||
| "--color", "never", | ||||||||||||||||||||||||||
| ). | ||||||||||||||||||||||||||
| WithArtifact("/data/p2p_key.txt", b.Enode.Artifact) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if b.Protocol == BootnodeProtocolV5 { | ||||||||||||||||||||||||||
| svc.WithArgs("--v5") | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| return component | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const ( | ||||||||||||||||||||||||||
| healthmonBeacon = "beacon" | ||||||||||||||||||||||||||
| healthmonExecution = "execution" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -66,8 +66,8 @@ func (p *Component) AddComponent(ctx *ExContext, gen ComponentGen) { | |||||||
| p.Inner = append(p.Inner, gen.Apply(ctx)) | ||||||||
| } | ||||||||
|
|
||||||||
| func (p *Component) AddService(srv ComponentGen) { | ||||||||
| p.Inner = append(p.Inner, srv.Apply(nil)) | ||||||||
| func (p *Component) AddService(ctx *ExContext, srv ComponentGen) { | ||||||||
| p.Inner = append(p.Inner, srv.Apply(ctx)) | ||||||||
| } | ||||||||
|
|
||||||||
| func componentToManifest(p *Component) []*Service { | ||||||||
|
|
@@ -177,6 +177,18 @@ type ExContext struct { | |||||||
| Contender *ContenderContext | ||||||||
| } | ||||||||
|
|
||||||||
| func (e *ExContext) UseBootnode() ComponentGen { | ||||||||
| bootnode := &Bootnode{} | ||||||||
|
||||||||
| bootnode := &Bootnode{} | |
| bootnode := &Bootnode{} | |
| bootnode.Enode = e.Output.GetEnodeAddr() |
Outdated
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.
🔴 Critical Bug: Nil pointer dereference
This line calls bootnode.Enode.NodeID(), but at this point bootnode.Enode is nil. The Enode field is only initialized inside the Apply() method (in components.go:1024), which hasn't been called yet.
This will cause a panic at runtime when UseBootnode() is invoked.
Suggested fix: The UseBootnode() method needs to eagerly initialize the EnodeAddr, similar to how the old code in recipe_opstack.go worked. Consider something like:
func (e *ExContext) UseBootnode() ComponentGen {
bootnode := &Bootnode{}
bootnode.Enode = e.Output.GetEnodeAddr() // Initialize eagerly
e.Bootnode = &BootnodeRef{
Service: "bootnode",
ID: bootnode.Enode.NodeID(),
}
return bootnode
}Then update Bootnode.Apply() to check if Enode is already set before calling ctx.Output.GetEnodeAddr():
func (b *Bootnode) Apply(ctx *ExContext) *Component {
component := NewComponent("bootnode")
if b.Enode == nil {
b.Enode = ctx.Output.GetEnodeAddr()
}
// ... rest of the method
}
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.
Note: This initialization needs to be conditional to support the
UseBootnode()helper method. WhenUseBootnode()is used, theEnodeis pre-initialized to establish theBootnodeRefbeforeApply()runs.