-
Notifications
You must be signed in to change notification settings - Fork 49
Fix op-geth bootnode peering #396
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 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -379,12 +379,13 @@ func (o *OpGeth) Apply(ctx *ExContext) *Component { | |||||||||||||||||||||||||
| component := NewComponent("op-geth") | ||||||||||||||||||||||||||
| o.Enode = ctx.Output.GetEnodeAddr() | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // TODO: this does not work for op-geth because hostnames are not allowed | ||||||||||||||||||||||||||
| // in geth bootnode config (node will break on startup if we remove --nodiscover below) | ||||||||||||||||||||||||||
| // var trustedPeers string | ||||||||||||||||||||||||||
| // if ctx.Bootnode != nil { | ||||||||||||||||||||||||||
| // trustedPeers = fmt.Sprintf("--bootnodes %s ", ctx.Bootnode.Connect()) | ||||||||||||||||||||||||||
| // } | ||||||||||||||||||||||||||
| var trustedPeers string | ||||||||||||||||||||||||||
| if ctx.Bootnode != nil { | ||||||||||||||||||||||||||
| // TODO: Figure out the port dynamically. | ||||||||||||||||||||||||||
| trustedPeers = fmt.Sprintf("--bootnodes enode://%s@$(getent hosts bootnode | awk '{print $1}'):30303 --discovery.v4 ", ctx.Bootnode.ID) | ||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||
| trustedPeers = "--nodiscover " | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+382
to
+388
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: Missing When
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| svc := component.NewService("op-geth"). | ||||||||||||||||||||||||||
| WithImage("us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth"). | ||||||||||||||||||||||||||
|
|
@@ -409,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 "+ | ||||||||||||||||||||||||||
|
|
@@ -420,7 +420,7 @@ func (o *OpGeth) Apply(ctx *ExContext) *Component { | |||||||||||||||||||||||||
| "--state.scheme hash "+ | ||||||||||||||||||||||||||
| "--port "+`{{Port "rpc" 30303}} `+ | ||||||||||||||||||||||||||
| "--nodekey /data/p2p_key.txt "+ | ||||||||||||||||||||||||||
| // trustedPeers+ | ||||||||||||||||||||||||||
| trustedPeers+ | ||||||||||||||||||||||||||
| "--metrics "+ | ||||||||||||||||||||||||||
| "--metrics.addr 0.0.0.0 "+ | ||||||||||||||||||||||||||
| "--metrics.port "+`{{Port "metrics" 6061}}`, | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.
Nit: Hardcoded
30303is correct today but fragile.Since both op-geth and bootnode are Docker services, the container port is used (not the host port), and the bootnode's default is
30303(components.go:1085). So this works. However, if someone changes the bootnode's default port, this will silently break.Consider extracting the bootnode default port as a constant shared between the bootnode component and this line, or using the
{{Bootnode}}template and performing hostname-to-IP resolution in the shell (since/bin/shis already the entrypoint):This way the port comes from the template system automatically.