Repository navigation
feat(probe): cdn/probe/v1 content-availability + EIP-712 slash_sig (#318) - #569
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements content-availability probing and slashing evidence for the cdn/probe/v1 protocol. Key changes include the introduction of probe-triggered eviction holds in the cache engine to prevent slashing, the implementation of EIP-712 signatures for probe responses, and updates to the CLI and node configuration. Review feedback highlights misleading documentation regarding the signing process, which incorrectly suggested Postcard serialization instead of EIP-712. Suggestions were also provided to enforce strict signature length validation, optimize the eviction hold logic to minimize map scans, and eliminate redundant cache lookups in the probe handler.
There was a problem hiding this comment.
Pull request overview
Extends cdn/probe/v1 into a signed content-availability probe with cache eviction holds, EIP-712 slash evidence, and matching runtime/config/CLI support.
Changes:
- Adds signed probe request/response protocol shapes and EIP-712 probe signing helpers.
- Wires node probe handling to cache availability, probe holds, rate clamping, metrics, and SlashJudge domain config.
- Updates CLI/config/test coverage and documents the breaking probe/config changes.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
crates/protocol/src/message.rs |
Defines new probe wire types and validation/tests. |
crates/protocol/src/lib.rs |
Re-exports new probe protocol types/constants. |
crates/protocol/src/framing.rs |
Updates framing roundtrip test fixtures. |
crates/node/tests/sighup_signal.rs |
Updates resolved config/payment fixtures. |
crates/node/tests/probe_loopback.rs |
Adds loopback tests for signed availability probes. |
crates/node/src/runtime/reload.rs |
Updates reload test fixtures for new config fields. |
crates/node/src/runtime/mod.rs |
Wires SlashJudge domain, signer, cache, and hold budget. |
crates/node/src/metrics.rs |
Adds probe hold/rate-clamp metrics. |
crates/node/src/handlers/probe.rs |
Implements availability lookup, hold admission, clamping, and signing. |
crates/incentive/src/probe_sig.rs |
Adds EIP-712 probe signing/recovery helpers and tests. |
crates/incentive/src/lib.rs |
Exposes probe signature module/types. |
crates/common/src/config/types.rs |
Adds TOML fields for SlashJudge, holds, and delivery bounds. |
crates/common/src/config/resolved.rs |
Adds resolved config fields. |
crates/common/src/config/mod.rs |
Resolves/validates new config options and updates tests. |
crates/common/src/cli/run.rs |
Adds daemon CLI/env args for new config fields. |
crates/common/src/cli/probe.rs |
Adds required probe hash CLI argument. |
crates/cli/tests/config_validate.rs |
Updates validation fixtures. |
crates/cli/src/commands/probe.rs |
Sends content probes and renders signed responses. |
crates/cache/src/probe_hold.rs |
Adds probe hold constants. |
crates/cache/src/lib.rs |
Re-exports probe hold constants. |
crates/cache/src/engine.rs |
Adds probe hold tracking and eviction filtering. |
CHANGELOG.md |
Documents breaking probe/config changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e0aa2d1 to
c5d94c0
Compare
|
Addressed all gemini + Copilot review feedback and rebased onto current Highlights:
804 tests pass; |
Coverage reportTotal: 89.25% (was 88.91%, ▲ +0.34%) — 15571/17446 lines
History
|
c5d94c0 to
a1b3588
Compare
) Extend cdn/probe/v1 from a latency/rate probe into a signed content-availability query per ADR 005 / ADR 014. - protocol: ProbeRequest{hash,timestamp_us}; ProbeResponse split into a frozen signed ProbeResponseBody{hash,has_blob,rate_per_mb,timestamp_us} plus unsigned total_bytes + mandatory 65-byte slash_sig. Establishes the v1 signed baseline (not an ALPN bump). - incentive: new probe_sig module — deCDN SlashJudge EIP-712 domain + ProbeResponse typed data, sign/recover/verify, type-hash locked to ADR 014. - cache: probe-triggered eviction hold (try_probe_hold / max_probe_holds, 35s per-blob hold above LRU; operator evict still wins). - node: handler gates has_blob on the hold, clamps rate to delivery bounds, signs slash_sig; new probe_hold/rate_bounds metrics; runtime wires the SlashJudge domain + eth signer + cache. - config: required blockchain.slash_judge_address; optional chain_id, cache.max_probe_holds, payment.delivery_floor/ceiling (+ env vars). - cli: `decdn probe` requires --hash, correlates on echoed hash/timestamp, rejects missing/short slash_sig; reworked JSON/pretty. BREAKING: cdn/probe/v1 wire shapes, `decdn probe --json` keys, and new required config — see CHANGELOG. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
a1b3588 to
acbb11b
Compare
Comprehensive review round (code / tests / comments / error-handling / type-design)Ran a 5-aspect review and verified each load-bearing finding against the ADRs before acting. Fixed (verified-correct):
Acknowledged, intentionally deferred (reasoned, not blocking): a deterministic TOCTOU-under-lock test and a SIGHUP 813 tests pass; |
Independent review — recommend approveDid a fresh deep review of the security-sensitive paths plus a breadth pass over the rest. All 24 prior automated threads are resolved and the fixes hold up under independent inspection. Verified directly:
Minor — all explicitly non-blocking (no change required to merge)
None of these block merge. Well-tested (813 green, +0.34% coverage) and the design matches ADR 005/013/014. Generated by Claude Code |
Address PR review of the #569↔#576 merge resolution: - probe_0rtt.rs: add warm_0rtt_serves_signed_has_blob_true, closing the one real coverage seam — the 0-RTT-accepted early-data response path carrying a verified EIP-712 slash_sig and has_blob:true was previously unexercised (every 0-RTT test used an empty cache + throwaway signer). Refactor spawn_server onto a shared spawn_core so the new test can use a blob-backed cache + known signer. - probe_client.rs: correct the probe_once / module docs — the response is returned without correlation/slash_sig validation (caller's job), but the Response-vs-Request variant check IS performed internally; note the reused mechanism is transport-only. - probe.rs: drop the misleading MAX_RATE_PER_MB parenthetical (that validate() branch is dead for wire-decoded responses; the serde hook enforces it at decode time) — slash_sig length is the only live check. - probe_0rtt.rs: spawn_server doc now documents the TempDir return guard; PROBE_HASH doc scoped to the empty-cache tests. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
* feat(node): QUIC 0-RTT for cdn/probe/v1 (#325, ADR 015) Implements 0-RTT connection establishment for the cdn/probe/v1 ALPN so a warm probe skips the TLS 1.3 handshake round trip, per ADR 015. iroh 0.98.2 differs from ADR 015's original assumptions, so the ADR was rewritten to match reality (CLAUDE.md: ADRs are source of truth): - Session-ticket storage is iroh/rustls-owned, sized via Endpoint::builder().max_tls_tickets(SESSION_TICKET_CACHE_SIZE) — no hand-rolled (node_id, ALPN) LRU. New shared const in decdn-protocol is the single source of truth for the cache size and the gauge ceiling. - Per-ALPN 0-RTT gating is structural: only ProbeHandler overrides on_accepting; cdn/client/v1 and cdn/dht/v1 keep the default full-handshake path. Master switch network.enable_0rtt (default true, restart-required) falls back to the pre-ADR-015 1-RTT path. Components: - Reusable client helper crates/cli/src/commands/probe_client.rs (connect_with_opts → into_0rtt → accepted/rejected fallback + bounded ticket linger), consumed by `decdn probe`; structured for the future node cache-miss probe loop to reuse. - ProbeHandler.on_accepting accepts 0-RTT (gated) and feeds the approximate decdn_quic_session_ticket_cache_size gauge. - Metrics: decdn_quic_0rtt_{attempts,accepted,rejected}_total counters + the session-ticket gauge (distinct-peer upper bound, saturating). - Config: network.enable_0rtt plumbed through types/resolved/resolver. Tests: deterministic 0-RTT accepted, rejected-fallback (same-key server restart), master-switch-off, config resolution, metrics. Existing 1-RTT loopback suite preserved (enable_0rtt=false). Typed AcceptError chain preserved on the server 0-RTT path. 566 tests pass; clippy/fmt/deny/doc clean. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(node): bound session-ticket peer set against untrusted input note_session_ticket_peer is driven by the unauthenticated probe handler; the prior `.min(CEILING)` only saturated the gauge while the underlying HashSet grew per distinct node id — a slow memory-exhaustion vector since node ids are cheap to generate (Sybil). Cap the set itself at SESSION_TICKET_CACHE_CEILING: once full, new peers are no longer tracked and the gauge sits at the ceiling, still a valid upper bound on the rustls LRU (also capped there). Adds a regression test asserting the set length stays bounded under CEILING+50 distinct peers. Addresses gemini-code-assist review on #576. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(adr): correct 0-RTT safety model to client-side; doc accuracy + obs Review round 2 surfaced findings; an added test empirically disproved a claim this PR introduced. - ADR/comment truth (CRITICAL): the "per-ALPN 0-RTT gating is structural via on_accepting / the QUIC stack drops early data for non-overriding handlers" claim is FALSE. iroh sets crypto.max_early_data_size=u32::MAX on every server TLS config, so 0-RTT is accepted for any ALPN regardless of handler. Real replay safety is client-side: probe_once is the only into_0rtt/early-data path and is hard-wired to ALPN_PROBE (idempotent). Rewrote ADR 015 §Server-Side Controls -> §"Replay Safety Is Client-Side", added a Consequences defense-in-depth-gap note, and corrected probe.rs/types.rs comments. New characterization test default_on_accepting_still_accepts_0rtt_safety_is_client_side pins iroh's real behavior so the model can't silently drift. - Cache conflation (multi-agent): max_tls_tickets sizes only the client-side rustls ClientSessionMemoryCache; the server store is rustls-internal default. Removed false "gauge is an upper bound on the real rustls LRU capped at CEILING" claims from metrics.rs, protocol const, runtime builder comment, ADR §Session Ticket Mgmt + §Observ. - Observability (silent-failure): added decdn_quic_session_ticket_peers_dropped_total so a Sybil-style saturation of the bounded peer set is distinguishable from organic growth; regression test asserts 50 drops at CEILING+50. 568 tests pass; clippy/fmt/doc/deny/markdownlint clean. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(node): cover 0-RTT + signed slash_sig + has_blob:true; doc fixes Address PR review of the #569↔#576 merge resolution: - probe_0rtt.rs: add warm_0rtt_serves_signed_has_blob_true, closing the one real coverage seam — the 0-RTT-accepted early-data response path carrying a verified EIP-712 slash_sig and has_blob:true was previously unexercised (every 0-RTT test used an empty cache + throwaway signer). Refactor spawn_server onto a shared spawn_core so the new test can use a blob-backed cache + known signer. - probe_client.rs: correct the probe_once / module docs — the response is returned without correlation/slash_sig validation (caller's job), but the Response-vs-Request variant check IS performed internally; note the reused mechanism is transport-only. - probe.rs: drop the misleading MAX_RATE_PER_MB parenthetical (that validate() branch is dead for wire-decoded responses; the serde hook enforces it at decode time) — slash_sig length is the only live check. - probe_0rtt.rs: spawn_server doc now documents the TempDir return guard; PROBE_HASH doc scoped to the empty-cache tests. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Closes #318.
Extends
cdn/probe/v1from a latency/rate probe into a signedcontent-availability query, per the canonical ADRs (ADR 005 §
cdn/probe/v1,ADR 014 §1–2, ADR 013 §Signed Field Freezing). Single coherent change
spanning protocol → handler/signing → cache hold.
ADR-vs-issue reconciliation
The issue body listed a separate Ed25519
signatureand an EIP-712slash_sig. ADR 005/014 are the source of truth and specify onlyslash_sig(QUIC handshake already authenticates the Ed25519 NodeId), sothe redundant Ed25519 field is dropped. This is not an ALPN bump — it
establishes the
cdn/probe/v1signed baseline (the priorProbeResponsewas explicitly documented as "currently unsigned"). Flagged in the module
docs for reviewer sign-off.
Changes
ProbeRequest{hash,timestamp_us};ProbeResponsesplitinto a frozen signed
ProbeResponseBody{hash,has_blob,rate_per_mb, timestamp_us}+ unsignedtotal_bytes: Option<u64>+ mandatory 65-byteslash_sig(mirrors theNodeAnnounce/NodeAnnounceBodypattern).Wire-stability test recomputed.
probe_sigmodule:deCDN SlashJudgeEIP-712domain +
ProbeResponsetyped data, sign/recover/verify, type-hashlocked to ADR 014 (modeled on
voucher.rs).try_probe_hold/probe_hold_slots_used/set_max_probe_holds, 35s per-blob holdcomposed above LRU (
PROBE_SLASH_WINDOW-derived constants), bounded bymax_probe_holds; operatorevict()still wins (DMCA).has_blobon the hold, clampsrate_per_mbto delivery bounds before signing, produces the mandatory
slash_sig;new
probe_hold_violations/probe_hold_slots_used/rate_bounds_clamp_eventsmetrics; runtime wires the SlashJudge domainblockchain.slash_judge_address; optionalblockchain.chain_id(default 421614),cache.max_probe_holds(default 256),
payment.delivery_floor/delivery_ceiling(PoC-localrate-bounds stand-in, default no-op); matching CLI flags +
DECDN_*env vars.
decdn probenow requires--hash, correlates on theechoed hash + timestamp, rejects missing/short
slash_sig; reworkedJSON/pretty output.
BREAKING
cdn/probe/v1wire shapes,decdn probe --jsonkey set, and newrequired
blockchain.slash_judge_addressconfig — documented in CHANGELOG.Verification
cargo nextest runacross protocol/incentive/cache/node/cli/common:759 passed, 0 failed.
cargo clippy --workspace --all-targetsandcargo fmt --checkclean (pre-commitcargo doc/cargo denypassed).New tests: EIP-712 sign/verify + type-hash-vs-ADR-014; protocol
signed-body/Tier-1-trailing-bytes; cache hold true/false/budget-exhausted/
shared-per-blob/operator-evict-overrides/expiry-sweep; loopback
has_blob-true/rate-clamp/roundtrip slash_sig verification; CLI JSON/pretty
shape + mandatory-sig rejection.
Follow-ups (not blocking)
SlashJudgeaddress is a prerequisite for areal testnet run (
slash_judge_addressis required, no default).getRateBounds().is the on-chain
SlashJudge's job (no registry client at PoC).🤖 Generated with Claude Code