Repository navigation
Description
Summary
The decdn CLI (decdn fetch, #391; decdn probe) has no node discovery — it must be handed an explicit --node-id + --addr/relay and (for fetch) --provider-address. This is an implementation gap, not a missing design: client node discovery is already specified and consistent across ADRs 001/003/012/016/022.
The design already exists
- Canonical source:
CapacityBond.getActiveNodes(offset, limit)(contracts/src/CapacityBond.sol:1337) returnsNodeInfo[]—nodeId,ethAddress,active,multiaddrs,lastMultiaddrUpdate,regionHint. - ADR 012 §Bootstrap Procedure: clients query
getActiveNodes(paginated) on first start, then gossipNodeAnnounce; cache to~/.decdn/peers.json. - ADR 022: the DHT (
cdn/dht/v1) is the content layer ("which of those nodes holds blob H"), itself bootstrapped fromgetActiveNodes.
How a discovered node gets dialed — NodeId + iroh discovery (primary)
The node already dials peers by NodeId and lets iroh's discovery resolve the address: its endpoint uses presets::N0 (n0-hosted pkarr/DNS — it publishes its own NodeId→address record and resolves others'), or operator-configured [network.discovery] legs. The CLI's probe/fetch currently use presets::Minimal (no discovery), which is the only reason they need an explicit --addr today.
So the lazy first cut is to build the CLI endpoint with discovery enabled (presets::N0, or honor [network.discovery]) and dial the discovered NodeId — the exact mechanism the node uses, ~no new transport code. The registry multiaddrs field is not required for this.
Security: dialing by NodeId is authenticated by the QUIC handshake (the NodeId is the ed25519 key), so a wrong resolved address simply fails to connect — no MITM — regardless of whether the address came from iroh discovery or the registry. The choice is purely availability/infra-dependence vs self-containment, not safety.
Work (implementation only — no ADR changes)
- Add an alloy binding + read path for
CapacityBond.getActiveNodes(uses the existing blockchain RPC config). decdn fetch/probe: when--node-id/--addr/--provider-addressare omitted, readgetActiveNodes, pick a node (regionHint-aware + probe-and-rank by RTT / holds-the-blob), derive--provider-addressfromNodeInfo.ethAddress, and dial itsNodeIdvia a discovery-enabled endpoint.- Channel-aware ranking: prefer a provider the client already has a usable open channel with (reads Client-side buyer channel management: auto-open, track, reuse PaymentChannels for decdn fetch #940's
BuyerChannelStore); else open one with the best-by-locality node. Default: reuse if it holds the blob and RTT is within tolerance, else open new.
Optional fallback — registry multiaddrs decoder (drop the n0 dependency later)
Option B above depends on n0's hosted pkarr/DNS discovery. To make the client self-contained / not reliant on n0, decode NodeInfo.multiaddrs (a packed (uint16 len, bytes) array, ADR 003) into an explicit EndpointAddr — addresses the operator committed on-chain, no discovery infra needed. This is the more-decentralized path and the planned follow-up to drop the n0 dependency; it is not a prerequisite for the first cut. (Nothing decodes multiaddrs today — the node dials by NodeId+discovery — so this is the only genuinely new transport code, and it's deferred.)
Dependencies / out of scope
- Client-side buyer channel management: auto-open, track, reuse PaymentChannels for decdn fetch #940 (client buyer-channel management) lands before the channel-aware ranking in step 3.
- Out of scope: latency-aware routing/anycast beyond
regionHint+ probe-rank; the--probe-firstknob (deferred separately); the long-lived-client gossip/peers.jsonmachinery (a one-shot fetch needs only the registry read).
Order: #940 (channel mgmt) → #936 (this) → #391 (bundle pull).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
alpergundogdu commentedon Jun 17, 2026
Dependency + weave note (channel management): node selection here must be channel-aware, but channel open/track/reuse is a separate layer — filed as #940 (client-side buyer channel management, extracting #744's
BuyerChannelService).Ranking should read #940's channel store and apply the agreed default: reuse an existing-channel provider if it holds the blob and RTT is within tolerance; otherwise open a new channel with the best-by-locality node (probe-and-rank). So #940 lands before the channel-aware ranking in this issue; the multiaddr decoder +
getActiveNodesread here are independent of it and can proceed in parallel.Order: #940 (channel mgmt) → #936 (channel-aware discovery) → #391 (
bundle pull).alpergundogdu commentedon Jun 17, 2026
Reframing (supersedes my earlier "multiaddr decoder is the linchpin" note): the node dials peers by
NodeId+ iroh discovery (presets::N0pkarr/DNS), and the CLI only needs--addrtoday becauseprobe/fetchusepresets::Minimal(no discovery). So the first cut is just to enable discovery on the CLI endpoint and dial the discoveredNodeId— ~no new transport code, same mechanism as the node. Themultiaddrsdecoder is demoted to an optional, more-decentralized fallback to drop the n0 dependency later, not a prerequisite. Body updated accordingly.feat(cli): client-side node discovery for decdn fetch/probe (#936)
feat(cli): client-side node discovery for decdn fetch/probe (#936) (#943
feat(cli): decdn bundle pull — fetch a bundle's blobs (#391) (#945)