feat(cli): add the --discovery.* option group - #580
Conversation
The discv5 work needs three operator knobs, and landing them on their own keeps the implementation PR to the p2p crate. The flags parse and validate here; nothing reads them yet. `--discovery.enable` is off by default: nothing else on the lean network speaks discv5 yet. `--discovery.port` is the discv5 UDP socket, separate from the QUIC port `--gossipsub-port` binds, and `validate_discovery` rejects the two colliding rather than letting it surface at bind time as an EADDRINUSE on whichever socket loses the race. Both default to 9000, so enabling discovery means moving one of them. `--discovery.advertise-ip` separates what the node binds from what it publishes, for a host whose reachable address is not the wildcard it listens on.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
🤖 Claude Code ReviewGood, this confirms nothing else reads the new fields yet, matching the PR's stated intent. Now let's look at the review findings. Review:
|
🤖 Kimi Code ReviewThe diff adds CLI configuration for discv5 peer discovery with proper validation to prevent UDP port collisions. This is networking infrastructure code and does not touch consensus-critical paths (fork choice, attestation processing, state transition, or XMSS). General Assessment Minor Suggestions
Code Quality Notes
Security Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Codex Code Review
No other correctness, security, performance, or consensus-layer concerns stood out in this PR. The actual check in cli.rs:156 is sensible and prevents an otherwise opaque I could not run a compile check in this environment because Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
What
Adds the three operator-facing flags the discv5 work needs, on their own, so
the implementation PR (#579) is confined to the p2p crate.
--discovery.enablefalse--discovery.port9000--discovery.advertise-ipThe flags parse and validate here. Nothing reads them yet, which is the
point of splitting them out: this is reviewable on its own and cannot change
runtime behaviour of a node that does not pass them.
Why the port validation
--discovery.portand--gossipsub-portare both UDP and both default to9000, so enabling discovery without moving one of them collides. Left
unchecked, that surfaces at bind time as an opaque
EADDRINUSEon whicheversocket loses the race, pointing at neither flag.
CliOptions::validate_discoveryrejects it at startup with a message naming both flags and their values.
The check only fires when discovery is enabled, so the shared default is
harmless for every existing deployment.
Why
--discovery.advertise-ipThe node binds the wildcard
0.0.0.0, which is not dialable as published. Anode whose reachable address differs from what it listens on (a devnet on
127.0.0.1, or a host behind NAT) needs to say so explicitly. discv5'sPONG-based IP voting may still learn and substitute the real external address
at runtime; this only sets what the ENR carries at startup.
Testing
make lintclean.--helpwith its dotted prefixes intact.Relationship to #579
#579 carries the discv5 implementation and currently includes these same
flags. If this lands first, #579 rebases onto it and drops the
cli.rshunk.