Repository navigation
feat(node): multi-relay config + reachability-gated endpoint bring-up (#795) - #817
Conversation
…#795) Wire the node's iroh endpoint to honor multiple self-hosted relays for isolated/production deployments (scope 1 of #795). Until now the `network.relay_url` config field existed end-to-end but was dead config — `build_endpoint` ignored it and always used `presets::N0`. This makes it take effect and widens it to a list. Config surface: - `NetworkConfig` gains `relay_urls: Vec<String>`; `relay_url` kept as a deprecated singular alias folded into the list. - `ResolvedNetwork.relay_url` -> `relay_urls: Vec<String>` (empty => n0 defaults). `resolve_network` precedence: CLI `--relay-url` > file `relay_urls` > file `relay_url` alias > empty. - `expand_env` expands `${VAR}` in each list entry; `config validate` prints one line per relay; DEFAULT_CONFIG documents both keys. Endpoint wiring (crates/node/src/runtime/mod.rs): - `build_endpoint` parses the list and, when non-empty, swaps only the relay leg via `RelayMode::Custom(RelayMap::from_iter(..))`, leaving the presets::N0 DNS address-lookup leg intact (full self-hosted discovery is out of scope here). Gossip shares this endpoint, so it inherits relays. - TCP reachability probe gates bring-up: hard-fail only when >=1 relay was actually probed and none were reachable. Relays with no derivable host/port (unprobeable) are excluded from the gate rather than counted as failures, so an all-unprobeable set proceeds on trust. Probe reports host:port only, never the full URL, to avoid userinfo leaking into logs. Tests cover the precedence ladder, per-element env expansion, the probe outcomes (reachable/unreachable/unprobeable/IPv6), and the bring-up gate. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request transitions the network configuration from a single relay_url to a list of relay_urls to support multiple relays for redundancy and failover, while maintaining backward compatibility with the deprecated singular alias. It also introduces a reachability probe at node startup to ensure at least one configured relay is reachable. The reviewer suggested optimizing the reachability check by probing the relays in parallel rather than sequentially to prevent significant startup delays when multiple relays are unreachable.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR implements scope 1 of #795 by making the node honor configured relay URLs and supporting a multi-relay configuration, including a reachability-gated endpoint bring-up when custom relays are provided.
Changes:
- Add
network.relay_urls(with deprecatednetwork.relay_urlalias) and implement precedence/merge logic in config resolution. - Wire relay configuration into node endpoint construction with per-relay TCP probing and a “≥1 reachable (among probeable relays)” bring-up gate.
- Update CLI
config validateoutput and add unit tests covering precedence, env expansion, probing outcomes, and endpoint gating.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/common/src/config/types.rs | Adds relay_urls config field and documents deprecated relay_url alias. |
| crates/common/src/config/resolved.rs | Switches resolved network relay config to a (possibly empty) list. |
| crates/common/src/config/mod.rs | Implements relay precedence/alias-folding and per-entry ${VAR} expansion, with tests. |
| crates/node/src/runtime/mod.rs | Wires relay_urls into endpoint building, adds parsing + probe/gate logic, and tests. |
| crates/node/src/runtime/reload.rs | Updates resolved defaults and “ignored on reload” messaging for new fields. |
| crates/node/tests/sighup_signal.rs | Updates test seed config to the new resolved relay list field. |
| crates/cli/src/commands/config.rs | Prints one validate-summary line per relay and updates default config template text. |
| crates/cli/tests/config_validate.rs | Adjusts/extends validate-summary tests for relay list behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 87.33% (was 87.18%, ▲ +0.14%) — 29167/33400 lines
History
|
…oc fixes Address PR #817 review feedback (gemini-code-assist, copilot): - Probe configured relays concurrently via JoinSet instead of serially. A serial loop added ~8s per unreachable relay to bring-up; a few down relays could stall startup for tens of seconds. Concurrency bounds the wait to ~one relay's probe time. A failed join is treated as "unprobeable" (excluded from the gate) so an internal error can't hard-fail bring-up. - Redact `user:pass@` userinfo from the `parse_relay_urls` error message. A malformed relay URL can still carry credentials, and this node never lets relay userinfo reach logs (same invariant the probe upholds). Non-credential values still appear verbatim so the offending entry is identifiable. - Correct three doc strings (NetworkConfig.relay_urls, ResolvedNetwork. relay_urls, DEFAULT_CONFIG) that still said "requires >=1 reachable": the gate fails only when every *probeable* relay is unreachable; an all-unprobeable set proceeds. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A second review pass found that the userinfo redaction added for parse errors could still leak credentials in two reachable cases — both reach the redaction path because they fail URL parse: - A password containing a literal `@` (`user:p@ss@host`) was split on the first `@`, leaking the tail of the password. - A credentialed entry with no `://` scheme separator was returned verbatim, leaking the whole userinfo. Rework `redact_userinfo` to anchor the authority after the first `://` (or at the start when absent) and redact to the *last* `@` before the host delimiter. Verified against well-formed, no-scheme, empty-userinfo, IPv6-host, password-with-`@`, and path-`@` shapes; non-credential values still pass through borrowed (no copy). Also: extend the redaction tests to cover the leak shapes, and correct the now-stale `RelayProbeTally.unprobeable` doc (it also covers a probe task that fails to join). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
alpergundogdu
left a comment
There was a problem hiding this comment.
Review — multi-relay config + reachability-gated bring-up
The config surface is well-built: precedence (CLI --relay-url > file relay_urls > deprecated relay_url alias > empty⇒n0), per-element ${VAR} expansion, empty-list-as-unset, and only swapping the relay leg (RelayMode::Custom) while leaving the n0 DNS leg intact are all the right calls, and the precedence ladder is thoroughly tested. redact_userinfo handling last-@ so an @ in the password is fully redacted is a nice security detail. My main concern is a design one on the gate itself:
1. (Discussion) Hard-failing bring-up when all probeable relays are down turns a transient relay outage into a node outage. The gate's premise is "0 reachable ⇒ almost certainly misconfiguration, fail loud." But it can't distinguish misconfiguration from a transient outage of correctly-configured relays — and for the latter the code's own comment notes iroh "keeps retrying them in the background." So a brief relay blip during a deploy/restart now prevents the node from starting at all, whereas a node that was already up would ride it out. For a system aiming at production shape with tens of nodes, a correlated relay outage during a rolling restart could wedge the fleet. Two softer options worth considering: (a) warn-and-proceed even on all-unreachable (trust iroh's background retry, matching the all-unprobeable path), or (b) gate it behind a config knob (relay_require_reachable_at_startup, default false). At minimum, the failure message could suggest clearing the relay config to fall back to n0. I'd lean toward (a)/(b) — keep the loud warn!, drop the hard bail! — but flagging rather than blocking since it's a deliberate choice.
2. (Minor) TCP-connect liveness ≠ relay-protocol health. relay_connect_once proves the host:port accepts a TCP connection, which a fronting LB / reverse proxy will happily do even if the relay behind it is unhealthy. So the gate can pass on a relay that won't actually relay, and (per #1) hard-fail on a healthy relay that briefly refuses TCP. That's an inherent limit of a cheap probe — fine to keep, but it slightly undercuts the "fail loud on misconfig" justification for making the gate fatal. Worth a one-line caveat in the comment.
3. (Nit) redact_userinfo drops leading non-scheme text. For an entry with no :// like "relay user:s3cret@host", everything before the last authority @ becomes ***, yielding "***@host" (the literal relay is gone). Over-redaction is safe, but it means the error no longer shows the malformed prefix that might help diagnose the typo. Minor; the current behavior is defensible.
Tests are comprehensive (reachable/unreachable/unprobeable/IPv6, tally, and the three build_endpoint gate outcomes). Nice work. CI status currently shows no completed checks — worth confirming the Solidity/clippy jobs are green before merge.
Generated by Claude Code
A configured network.relay_urls set that is entirely unreachable at bring-up no longer hard-fails the node. The startup probe couldn't tell misconfiguration from a transient relay outage, so a correlated relay blip during a rolling restart could wedge the fleet — whereas an already-up node rides it out via iroh's background retry. The probe is now advisory: an all-probeable-unreachable set logs a loud warn! (and points the operator at clearing network.relay_urls to fall back to n0), then proceeds. Malformed-URL parse failures stay fatal. Also notes in the build_endpoint comment that the bare TCP probe proves host:port liveness, not relay-protocol health (a fronting LB accepts even when the relay behind it is down), and realigns the relay_urls docstrings + DEFAULT_CONFIG template, which still claimed bring-up fails. Renames the all-unreachable test to assert it binds. Addresses review feedback on #817. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Implements scope 1 of #795 — multi-relay support for the node's iroh endpoint, so isolated/production deployments get relay redundancy/failover instead of a single point of failure.
Important context: PR #794 (which the issue assumed had landed single-relay wiring) was closed unmerged. On
main, thenetwork.relay_urlfield existed end-to-end but was dead config —build_endpointignored it and always usedpresets::N0. This PR makes it take effect and goes straight to multi-relay.Config surface
NetworkConfiggainsrelay_urls: Vec<String>;relay_urlkept as a deprecated singular alias folded into the list.ResolvedNetwork.relay_url→relay_urls: Vec<String>(empty ⇒ n0 defaults).resolve_networkprecedence: CLI--relay-url> filerelay_urls> filerelay_urlalias > empty.expand_envexpands${VAR}per entry;config validateprints one line per relay;DEFAULT_CONFIGdocuments both keys.Endpoint wiring (
crates/node/src/runtime/mod.rs)build_endpointswaps only the relay leg viaRelayMode::Custom(RelayMap::from_iter(..))when the list is non-empty, leaving thepresets::N0DNS address-lookup leg intact. Gossip shares this endpoint (build_gossip(ep.clone())), so it inherits relays for free.host:portonly, never the full URL (no userinfo leak).Out of scope (follow-up)
MemoryLookuppeer map).contracts/localrig.config validatetime (currently caught at bring-up, which already names the offending entry) — also tracked in iroh: self-hosted discovery (replace n0 DNS/pkarr) + validate-time relay URL checks #818.Test plan
cargo fmt --check✅ ·cargo clippy --workspace --all-targets✅ ·cargo nextest run(common+node+cli) 934 passed ✅${VAR}expansion + error-context, probe outcomes (reachable/unreachable/unprobeable/IPv6),probe_relaystally, andbuild_endpointgate (one-reachable binds, all-unreachable hard-fails, all-unprobeable proceeds).This PR was reviewed by the pr-review-toolkit agents (code/tests/comments/silent-failure); their findings on the reachability gate and env-expansion coverage are addressed in the commit.
🤖 Generated with Claude Code