Repository navigation
feat(node): operator-configurable self-hosted discovery (#818) - #829
Conversation
Replace the n0-hosted DNS/pkarr address-lookup leg with operator-configurable discovery (scope 1 of #818; scope 2 landed in #828). Two operator-selectable, combinable mechanisms: - Custom pkarr + DNS: `network.discovery.pkarr_url` (publish this node's signed address record) + `network.discovery.dns_origin` (resolve peers via DNS TXT). - Static peer map: `network.discovery.peers.<NodeId>` -> {relay_url, addrs} seeded into a `MemoryLookup` for fully n0-independent, offline networks. Wiring follows the discovery-provider seam (adr/appendix-poc-production-seams.md): `common` config holds plain shape-validated Strings; the `node` runtime parses them into iroh providers. `build_endpoint` keeps `presets::N0` when no discovery is configured (back-compat) and builds on `presets::Minimal` + the configured `address_lookup` legs otherwise, restoring the n0 relay default when no custom relay map is set (relay and discovery are orthogonal seams). Config resolution shape-validates every entry with the same parsers the node uses at bring-up — peer NodeId via `iroh::PublicKey`, pkarr URL via `url::Url`, socket addrs via `SocketAddr` — so `decdn config validate` fails fast and names the offending field with credentials redacted, never deferring to a late startup failure. `pkarr_url` without `dns_origin` is rejected (publish with no resolver); `dns_origin` alone is valid. Surfaces the knob across the config schema, resolver+validation, `config validate` summary (pkarr_url redacted, peer entries shown only as a count), and the DEFAULT_CONFIG template. Adds an appendix note for the seam. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request implements operator-configurable address discovery (network.discovery) under issue #818, allowing nodes to configure custom pkarr + DNS discovery or a static peer map instead of relying solely on the default n0-hosted discovery. The changes span configuration types, resolution and shape-validation logic, and endpoint building in the node runtime, accompanied by extensive unit and integration tests. The review feedback suggests two key improvements: redacting only the sensitive userinfo of pkarr_url using redact_userinfo (rather than completely hiding the URL) to preserve the host for diagnostics, and using sort_unstable_by instead of sort_by when sorting unique peer keys to optimize performance.
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
Implements operator-configurable, n0-independent discovery for node endpoints by introducing a network.discovery config surface and wiring it in the node runtime to compose iroh address-lookup providers. This follows the “discovery-provider seam” approach: common performs shape validation and carries plain strings, while node constructs concrete iroh providers at bring-up.
Changes:
- Add
[network.discovery]to the config schema + resolved types, including pkarr publish URL, DNS origin, and an optional static peer map. - Resolve/shape-validate discovery config at
decdn config validatetime (including redaction behavior in summaries) and add CLI/integration tests. - Update node runtime endpoint construction to select
presets::N0when discovery is empty, otherwisepresets::Minimalplus configured lookup legs, while preserving relay behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/tests/sighup_signal.rs | Updates test fixture ResolvedNetwork construction to include default discovery. |
| crates/node/src/runtime/reload.rs | Extends reload fixtures and “ignored sections” logging to include network.discovery. |
| crates/node/src/runtime/mod.rs | Adds discovery-provider wiring to build_endpoint, plus helper add_discovery_lookups and tests. |
| crates/common/src/config/types.rs | Introduces DiscoveryConfig / DiscoveryPeer schema under network.discovery. |
| crates/common/src/config/resolved.rs | Adds ResolvedDiscovery / ResolvedDiscoveryPeer into ResolvedNetwork. |
| crates/common/src/config/mod.rs | Adds resolve_discovery_into + validation rules and extensive unit tests. |
| crates/cli/tests/config_validate.rs | Adds CLI validation test for malformed discovery peer socket address + summary redaction test. |
| crates/cli/src/commands/config.rs | Prints discovery in validate summary (with redactions) and documents discovery in DEFAULT_CONFIG. |
| adr/appendix-poc-production-seams.md | Documents the new discovery-provider seam in the ADR appendix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 87.58% (was 87.46%, ▲ +0.12%) — 30297/34594 lines
History
|
- Validate-summary: redact only the pkarr_url userinfo via redact_userinfo (keeping the host visible for diagnostics) instead of fully hiding it — a pkarr relay's only credential vector is `user:pass@`, unlike rpc_url whose secret commonly lives in the path/query. Update the summary test to a credential-bearing URL asserting host-preservation + userinfo redaction. - Sort resolved peers with sort_unstable_by (node_ids are unique HashMap keys, so stable ordering is unnecessary and this avoids the aux allocation). - Fix stale "64-hex NodeId" doc wording (resolved peer field, resolve_discovery doc, DEFAULT_CONFIG template, ADR appendix): validation accepts any iroh NodeId — lowercase hex or z-base-32 — since it parses with iroh::PublicKey. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…818) Second-pass review fixes: - The peer NodeId accepted form was documented as "lowercase hex or z-base-32", but `iroh::PublicKey::from_str` decodes lowercase hex (HEXLOWER) or RFC-4648 base32 — NOT z-base-32 (a separate to_z32/from_z32 path FromStr never calls). The canonical Display form is lowercase hex, which is what operators copy and what the validator round-trips. Correct all sites in this PR to the canonical lowercase-hex wording (types.rs, resolved.rs, mod.rs doc + error string, DEFAULT_CONFIG, ADR appendix). - Soften the pkarr_url summary-redaction comment: drop the "only credential vector" overclaim and the misleading "same treatment the relay path uses" (the relay summary line prints unredacted; redaction is on the error-echo path). State the path/query caveat of redact_userinfo explicitly. Behavior (userinfo-redacted, host visible) is unchanged — appropriate for an infra relay endpoint whose auth is the signed packet, and stricter than the relay-URL summary precedent. - Add two summary test guards: pkarr_url label is emitted; no discovery.* lines appear when discovery is unset. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`expand_env` expanded `network.relay_url`/`relay_urls` but had no leg for the `[network.discovery]` knobs added in #818/#829. An operator reusing the documented single-TOML-template-across-deployments pattern with `dns_origin = "${DNS_ORIGIN}"` got the literal string through resolution (only checked non-empty) and into bring-up, silently breaking peer resolution; `pkarr_url = "${PKARR_URL}"` failed with a confusing URL-parse error. Add a discovery block to `expand_env` mirroring the relay loop — `pkarr_url`, `dns_origin`, and each peer's `relay_url` + `addrs` — with indexed ctx labels `network.discovery.peers[<id>].{relay_url,addrs[idx]}`. While here, thread the entry index into the `relay_urls` ctx label (`network.relay_urls[idx]`), matching the `cache.origins[i]` convention (the #843 diagnosability nit). Closes #863 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… without n0 fallback (#967) (#983) * test(node): cover self-hosted discovery two-node NodeAnnounce + probe without n0 fallback (#967) Adds `crates/node/tests/self_hosted_discovery.rs`, an integration test that stands up two nodes using ONLY the operator-configured discovery seam from #829 — a `MemoryLookup` static peer map on `presets::Minimal` with relays disabled, i.e. no n0 DNS/pkarr/relay anywhere — and proves: - two nodes exchange a real `NodeAnnounce` over the production `GossipService` publisher/subscriber path and each lands the other in its `PeerTable`, and - a `cdn/probe/v1` round-trip completes where the client resolves the server by `NodeId` alone, so a successful connect can only mean operator discovery (not n0 infra) resolved the address. Both endpoints are built on `presets::Minimal` + `RelayMode::Disabled` with a single `MemoryLookup` leg, mirroring `runtime::add_discovery_lookups` for a static-peer-map config, so the tests cannot pass via a silent n0 fallback. Deterministic and loopback-only (no external network). Coverage caveat documented in the test: `GossipService::spawn` subscribes with an empty iroh-gossip bootstrap set, so the two-node mesh is seeded explicitly via one extra `subscribe_and_join` handle whose bootstrap addr is resolved through the same `MemoryLookup`. Mesh self-bootstrap by `GossipService` alone and the live `PkarrPublisher`/`DnsAddressLookup` legs (which need real pkarr/DNS infra) are called out as out-of-scope future work. Co-Authored-By: Claude Opus 4.8 <[email protected]> * test(node): assert mutual NodeAnnounce discovery and add client-side timeouts (#967) Make the two-node NodeAnnounce test prove MUTUAL discovery instead of only A->B: give node B a region ("DE") so its GossipService publisher is enabled, seed the mesh with a bootstrap-join in both directions (A toward B and B toward A, each resolved only via the operator MemoryLookup), and assert both saw_a (B learned A) and saw_b (A learned B). Seed A's MemoryLookup with B's addr out-of-band after B binds; return the lookup handle from bind_discovery_endpoint to do so. Harden the probe round-trip against hangs: wrap connect, open_bi, and read_frame in 5s tokio timeouts. Propagate background-task panics during teardown via join_gossip_tasks (resume_unwind on a JoinError panic) instead of dropping JoinHandle results with `let _ =`. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
Closes #818 (scope 1; scope 2 landed in #828).
Summary
Implements scope 1 of #818 — replaces the n0-hosted DNS/pkarr address-lookup leg with operator-configurable discovery, so a network can be fully n0-independent. (Scope 2, validate-time relay URL checks, landed separately in #828.)
Two operator-selectable, combinable mechanisms, selected by which config keys are present:
network.discovery.pkarr_url(publish this node's signed address record to an operator-run pkarr relay) +network.discovery.dns_origin(resolve peers via DNS TXT). Closest to n0's model; supports dynamic addresses.[network.discovery.peers.<NodeId>]→{ relay_url, addrs }seeded into aMemoryLookup. Fully offline/isolated; no discovery infra to run.How it works
Follows the discovery-provider seam (
adr/appendix-poc-production-seams.md): thecommonconfig crate holds plain, shape-validated Strings; thenoderuntime parses them into iroh providers.build_endpoint:presets::N0(unchanged back-compat),presets::Minimal+ the configuredaddress_lookuplegs (PkarrPublisher/DnsAddressLookup/MemoryLookup), restoring the n0 relay default when no custom relay map is set.Relay selection (
network.relay_urls) stays an independent, orthogonal seam — dropping the n0 discovery leg never silently disables relays. Gossip shares the node endpoint (build_gossip(ep.clone())), so it inherits discovery for free.Validation
Config resolution shape-validates every entry with the same parsers the node uses at bring-up (peer NodeId via
iroh::PublicKey, pkarr URL viaurl::Url, socket addrs viaSocketAddr), sodecdn config validatefails fast and names the offending field with credentials redacted — no deferral to a late startup failure.pkarr_urlwithoutdns_originis rejected (publish with no resolver);dns_originalone is valid.Surfaces the knob across all five sites of the config-knob convention: schema (
types.rs), resolved type (resolved.rs), resolver+validation (mod.rs),config validatesummary (pkarr_url redacted, peer entries shown only as a count), and theDEFAULT_CONFIGtemplate.Testing
cargo clippy --all-targetsclean (-D warnings),cargo fmt --checkclean.decdn-common/decdn-node/decdn-cli, including 14resolve_discovery_*unit tests, 3build_endpoint_*tests, and 2 CLI integration tests (validate failure naming the bad field; summary redaction).decdn config validateend-to-end: valid config redacts pkarr creds and hides peer addrs; a bad peer addr fails fast namingnetwork.discovery.peers[<id>].addrs[0].A comprehensive multi-agent review (code/tests/errors/types/comments) was run pre-PR; its main finding — a NodeId validate-vs-bring-up parser divergence (uppercase / non-curve-point ids passing validate then failing startup) — is fixed by validating with
iroh::PublicKeyat resolution, with regression tests.🤖 Generated with Claude Code