-
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 2 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@$(awk '/host.docker.internal/ {print $1; exit}' /etc/hosts):30303 ", 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.
Fragile host resolution and hardcoded port.
A few concerns with this approach:
Hardcoded port
30303: The TODO acknowledges this but it's worth noting that if the bootnode's port assignment changes, this will silently break peering.host.docker.internalvia/etc/hostsparsing: This awk command assumeshost.docker.internalis in/etc/hosts(Docker Desktop adds it, but on Linux Docker Engine it may not be present withoutextra_hostsin docker-compose). If the entry is missing,awksilently returns empty, producing a malformed enode URL (enode://<id>@:30303) which could cause op-geth to fail or behave unexpectedly at startup.Why not use the hostname directly? Other components use
ctx.Bootnode.Connect()which resolves via Docker DNS. The original TODO says geth doesn't allow hostnames in bootnode config — could this be worked around with--netrestrictor by using Docker'sextra_hoststo ensure a stable IP mapping, rather than runtime shell parsing?