Skip to content

docs(adr): pin cdn/dht/v1 stake check, provider ordering, and stream cap - #431

Merged
alpergundogdu merged 3 commits into
mainfrom
claude/frosty-montalcini-4fdf23
May 6, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
claude/frosty-montalcini-4fdf23

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Three small ADR additions surfaced while reviewing #320 for implementation readiness. Decisions made in conversation; this PR pins them in the source of truth.

  • ADR 022 §1.5 — receivers MUST verify the STORE publisher is in the cached active-staker set (from StakingRegistry.getActiveNodes()) before accepting the record. Non-staked publishers get StoreAck { accepted: false }. PoC implementations MAY no-op the check until the on-chain reader lands.
  • ADR 022 §1.6 — provider ordering in FindValueResponse.providers SHOULD be randomized to spread probe traffic. The wire protocol can't enforce per-responder ordering (operators can run modified implementations), so this is recommended default rather than protocol invariant.
  • ADR 005 stream-limits table — cdn/dht/v1 joins at 1 stream/connection, matching probe. Each Kademlia RPC is short request/response, connection-reused for sequential queries; the existing ConnectionLimiter global + per-source caps cover the rest.

Reputation feedback for false STORE publishers explicitly punted to later — out of scope here.

Test plan

  • ADR text reads cleanly in context
  • Cross-references to ADR 019 § Bootstrap and ADR 022 resolve
  • No factual conflicts with adjacent paragraphs in §1.5 / §1.6 / ADR 005 stream-limits table

Three small additions surfaced while reviewing #320 implementation
readiness:

- ADR 022 §1.5: receivers MUST verify the STORE publisher is in the
  cached active-staker set before accepting a record; rejected
  publishers get `StoreAck { accepted: false }`. PoC implementations
  MAY no-op the check until the on-chain reader lands.
- ADR 022 §1.6: provider ordering in `FindValueResponse.providers`
  SHOULD be randomized to spread probe traffic. Per-responder ordering
  is not wire-enforceable (modified implementations can do whatever
  they want) — this is recommended default, not protocol invariant.
- ADR 005 stream-limits table: `cdn/dht/v1` is 1 stream/connection
  (matches probe — each Kademlia RPC is short request/response).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the cdn/dht/v1 protocol specification and updates the content discovery process with staker verification and provider randomization. Reviewers recommended standardizing terminology to use 'node' consistently, strengthening security by enforcing mandatory signature and NodeId verification for storage requests, and stripping historical or non-normative context from the ADRs to ensure clarity.

Comment thread adr/005-protocol.md Outdated
| --- | --- | --- |
| `cdn/client/v1` | 100 | Enough parallelism for bulk fetching (e.g., video manifest + segments) without exhausting server resources |
| `cdn/probe/v1` | 1 | Single request-response; the connection is reused for sequential probes to the same node |
| `cdn/dht/v1` | 1 | Single request-response per Kademlia RPC (FIND_VALUE / STORE / FIND_NODE); the connection is reused for sequential queries to the same peer ([ADR 022](022-content-discovery.md)) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the preceding row (line 175) and the terminology established in ADR 001, use the term node instead of peer when referring to network participants in the rationale column.

Suggested change
| `cdn/dht/v1` | 1 | Single request-response per Kademlia RPC (FIND_VALUE / STORE / FIND_NODE); the connection is reused for sequential queries to the same peer ([ADR 022](022-content-discovery.md)) |
| cdn/dht/v1 | 1 | Single request-response per Kademlia RPC (FIND_VALUE / STORE / FIND_NODE); the connection is reused for sequential queries to the same node (ADR 022) |
References
  1. In dense formats like tables, rely on convention and contextual descriptions instead of overly descriptive parameter names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b2d6d0e — peer → node to match the probe row.

Comment thread adr/022-content-discovery.md Outdated
3. Schedule re-publish at T+45 minutes while blob remains cached.

The `StoreRequest` signature (ed25519 over `hash || published_at_us`) lets receiving nodes verify the record was created by the claimed holder. Receiving nodes do **not** verify that the holder actually has the blob — that is the probe step's job. A false STORE publisher (a node claiming to hold a blob it does not) fails at probe time, degrading its reputation. **Note:** the term "publisher" in this ADR refers to a node publishing a DHT STORE record (an act of advertising). It is distinct from the on-chain *content publisher* identity defined in [ADR 002 § Publisher Identity and Namespaces](002-content-addressing.md#publisher-identity-and-namespaces), which is an Ethereum address registered in `PublisherRegistry`. Where confusion is possible this ADR uses "STORE publisher" or "holder" for the DHT-record sender.
The `StoreRequest` signature (ed25519 over `hash || published_at_us`) lets receiving nodes verify the record was created by the claimed holder. Receiving nodes MUST additionally verify that `holder` is in the cached active-staker set (populated from `StakingRegistry.getActiveNodes()` per [ADR 019 § Bootstrap](019-node-onboarding.md)) before accepting the record; non-staked publishers are rejected with `StoreAck { accepted: false }`. Implementations MAY use a permissive no-op stake check during the early PoC bootstrap window before the on-chain reader lands — the check is normative for production. Receiving nodes do **not** verify that the holder actually has the blob — that is the probe step's job. A false STORE publisher (a node claiming to hold a blob it does not) fails at probe time, degrading its reputation. **Note:** the term "publisher" in this ADR refers to a node publishing a DHT STORE record (an act of advertising). It is distinct from the on-chain *content publisher* identity defined in [ADR 002 § Publisher Identity and Namespaces](002-content-addressing.md#publisher-identity-and-namespaces), which is an Ethereum address registered in `PublisherRegistry`. Where confusion is possible this ADR uses "STORE publisher" or "holder" for the DHT-record sender.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This section should be strengthened in three ways:

  1. Normative Verification: Change the description of signature verification to a "MUST" requirement to ensure protocol security.
  2. Impersonation Protection: Explicitly require that the holder field matches the authenticated NodeId of the QUIC connection. This prevents a malicious node from publishing false records on behalf of other nodes to grief their reputation, aligning with the principle of deriving identity from the communication context where possible.
  3. Clean Documentation: Remove iteration-specific details like the PoC bootstrap window from the canonical ADR text. Such context is better suited for issue discussions or merge commit messages.
Suggested change
The `StoreRequest` signature (ed25519 over `hash || published_at_us`) lets receiving nodes verify the record was created by the claimed holder. Receiving nodes MUST additionally verify that `holder` is in the cached active-staker set (populated from `StakingRegistry.getActiveNodes()` per [ADR 019 § Bootstrap](019-node-onboarding.md)) before accepting the record; non-staked publishers are rejected with `StoreAck { accepted: false }`. Implementations MAY use a permissive no-op stake check during the early PoC bootstrap window before the on-chain reader lands — the check is normative for production. Receiving nodes do **not** verify that the holder actually has the blob — that is the probe step's job. A false STORE publisher (a node claiming to hold a blob it does not) fails at probe time, degrading its reputation. **Note:** the term "publisher" in this ADR refers to a node publishing a DHT STORE record (an act of advertising). It is distinct from the on-chain *content publisher* identity defined in [ADR 002 § Publisher Identity and Namespaces](002-content-addressing.md#publisher-identity-and-namespaces), which is an Ethereum address registered in `PublisherRegistry`. Where confusion is possible this ADR uses "STORE publisher" or "holder" for the DHT-record sender.
The StoreRequest signature (ed25519 over hash || published_at_us) MUST be verified by receiving nodes to ensure the record was created by the claimed holder. Receiving nodes MUST also verify that the holder field matches the NodeId of the peer on the QUIC connection. Receiving nodes MUST additionally verify that holder is in the cached active-staker set (populated from StakingRegistry.getActiveNodes() per ADR 019 Bootstrap) before accepting the record; non-staked publishers are rejected with StoreAck { accepted: false }. Receiving nodes do not verify that the holder actually has the blob — that is the probe step's job. A false STORE publisher (a node claiming to hold a blob it does not) fails at probe time, degrading its reputation. Note: the term publisher in this ADR refers to a node publishing a DHT STORE record (an act of advertising). It is distinct from the on-chain content publisher identity defined in ADR 002 Publisher Identity and Namespaces, which is an Ethereum address registered in PublisherRegistry. Where confusion is possible this ADR uses STORE publisher or holder for the DHT-record sender.
References
  1. Avoid including historical narratives, iteration details, or information about dropped features in canonical documentation (e.g., ADRs).
  2. When using terminology that differs from the underlying implementation context, add a parenthetical note to clarify the mapping for readers.
  3. In technical documentation, be precise about which cryptographic key is used for each specific signature type (e.g., Ed25519 wire vs secp256k1 on-chain).
  4. Explicitly distinguish between Ed25519 wire-key ownership and secp256k1 on-chain signatures to maintain a consistent security model.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted (1) and (2) in b2d6d0e:

  • (1) Signature verification is now an explicit MUST.
  • (2) Added the holder == authenticated QUIC NodeId precheck. Framed honestly: the ed25519 signature already binds holder to the key-holder (NodeIds are ed25519 public keys per §1.3, so an attacker cannot open a connection as a NodeId whose private key they do not have). The equality check is a fast precheck that lets mismatched records fail before the signature work, not a new security boundary.

Keeping the PoC bootstrap-window carve-out. The no-op accommodation is explicit user guidance from the readiness review for #320 — the contract reader does not exist yet and removing this line would leave the implementer stuck at "MUST verify against StakingRegistry" with no contracts deployed. ADR 022 already references "PoC scale (30 nodes)" in §1.3, §1.7, and §5; stripping this one carve-out would create internal inconsistency.

On the secp256k1 vs ed25519 distinction: the StoreRequest signature is unambiguously ed25519 (§1.5 says so explicitly, and the holder field is a NodeId which §1.3 defines as an ed25519 public key). No on-chain signature is involved at this point in the flow.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reversed course on the PoC carve-out in d29c645 — dropped it. Contracts will be deployed before this ships, so the ADR should describe the final design without implementation-sequencing language. Stake-check MUST is now unqualified.

Comment thread adr/022-content-discovery.md Outdated
5. Probe the returned `NodeId` set via `cdn/probe/v1` to confirm live availability and measure latency.
6. Select provider by unified node selection score ([ADR 001](001-network.md#node-selection-algorithm)); deliver via `cdn/client/v1`.

**Provider ordering.** When a responder returns multiple providers in `FindValueResponse.providers`, the order SHOULD be randomized so probe traffic spreads across the set rather than concentrating on whichever provider was inserted first. The wire protocol does not enforce per-responder ordering — operators can run modified implementations — but randomization is the recommended default and the basis on which load distribution is reasoned about elsewhere in this ADR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid including justifications or historical context (such as the reasoning basis for load distribution) within the decision section of the ADR. The documentation should focus on the normative requirements of the current design.

Suggested change
**Provider ordering.** When a responder returns multiple providers in `FindValueResponse.providers`, the order SHOULD be randomized so probe traffic spreads across the set rather than concentrating on whichever provider was inserted first. The wire protocol does not enforce per-responder ordering — operators can run modified implementations — but randomization is the recommended default and the basis on which load distribution is reasoned about elsewhere in this ADR.
Provider ordering. When a responder returns multiple providers in FindValueResponse.providers, the order SHOULD be randomized so probe traffic spreads across the set rather than concentrating on whichever provider was inserted first.
References
  1. Avoid including historical narratives, iteration details, or information about dropped features in canonical documentation (e.g., ADRs).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial fix in b2d6d0e. Dropped the "basis on which load distribution is reasoned about elsewhere" clause — checked, the ADR does not actually do that load-distribution reasoning anywhere downstream, so the back-reference was hand-wavy.

Kept the "operators can run modified implementations" caveat: it is the protocol-honest framing of why this is SHOULD rather than MUST. Per-responder ordering is local policy that the wire spec cannot enforce, and that property is load-bearing for understanding why the spec only recommends randomization.

alpergundogdu and others added 2 commits May 6, 2026 15:38
- ADR 022 §1.5: signature verification is now an explicit MUST. Added a
  fast precheck that holder MUST match the authenticated NodeId of the
  inbound QUIC connection — the ed25519 signature already binds holder
  to the key-holder (NodeIds are ed25519 public keys), but the equality
  check lets mismatched records fail before the signature work.
- ADR 022 §1.6: dropped the hand-wavy "basis on which load distribution
  is reasoned about elsewhere" claim — kept the recommended-randomization
  SHOULD and the modified-implementations caveat.
- ADR 005 stream-limits row: peer → node for terminology consistency
  with the adjacent probe row.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contracts will be deployed before this ships, so the ADR should describe
the final design — no implementation-sequencing language about no-op
stubs. The stake-check MUST is unqualified.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alpergundogdu
alpergundogdu merged commit ff44444 into main May 6, 2026
9 checks passed
@alpergundogdu
alpergundogdu deleted the claude/frosty-montalcini-4fdf23 branch May 6, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant