Repository navigation
fix(protocol,node)!: advertise and accept the empty blob over cdn/probe/v1 - #2528
Merged
Merged
Conversation
…be/v1 The empty (0-byte) blob spans zero discovery blocks, so its coverage bitmap is empty on every holder. The probe handler derived `has_blob` from the bitmap and signed `has_blob: false` for a blob every store holds and serves (iroh-blobs reports the empty root complete at size 0 on any backend), and the requester's consistency rule (`has_blob ⟺ non-empty coverage`) rejected a `has_blob: true` answer for it as malformed. A client saw no holder, dropped the size hint and opened a paid lane for zero bytes; a node pulling through for the empty root found no provider. - `ProbeResponseExt::consistent_with` takes the signed body. For the empty root the bitmap must be empty and `has_blob` alone decides; every other hash keeps the biconditional. The rule keys on the signed hash, never on the unsigned `total_bytes` hint. - `decdn_protocol::EMPTY_ROOT` names the hash; the client's two local computations of it read the constant. - The probe handler signs `has_blob: true` for the empty root when its presence check passes. The suppressing arms (chain-stale, holds disabled, origin-only miss) still answer `false`. - ADR 022 § Consistency rule records the exception and that the empty blob is never announced to the DHT, because every node serves it. Tests: protocol unit tests for both hashes; probe loopback for the held empty blob and its chain-stale twin; node-origin `Origin::fetch` of the empty root through a probe at cap 0 and under a cap; a client `classify_probe` unit test. The public-API snapshot of decdn-protocol is regenerated for the signature change and the new constant. Closes #2471 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…idy the rule's docs (#2471) Review follow-ups on the empty-blob probe change. - ADR 022 § Consistency rule: the empty-blob exception moves to the end of the paragraph so "such a response" keeps its referent, and the DHT sentence states the real reason (an empty bitmap), not "every node serves it", which the chain-stale arm contradicts. The origin paragraph qualifies its biconditional the same way. - CHANGELOG: the `consistent_with` signature change is listed under Changed (BREAKING), and the Fixed entry points there. - Comment precision: `EMPTY_ROOT`'s doc says what `consistent_with` checks for it; the `coverage` field doc names both signed fields; the two consumer comments no longer call `has_blob` unsigned; the handler names the coverage-read fault arm and qualifies the chain-stale arm; `publish_hash` lists the empty blob among the empty-coverage cases. - Tests pin every suppressing handler arm for the empty root: a chain-denied hash, `max_probe_holds == 0` (with the disabled counter proving the arm ran), the origin-only policy with no origin object, and the origin-only policy with a 0-byte origin object (the one path that builds `Coverage::full(0)`). The client `classify_probe` test also covers `has_blob: false` for the empty root as a non-holder. Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The empty-root fallback can override a concurrent refusal and sign an advertisement for denied content.
1 open issue
What changed in this PR
Fixes empty-blob discovery over cdn/probe/v1 by making coverage validation depend on the signed hash.
Changes:
- Adds
EMPTY_ROOTand updates probe validation and consumers. - Advertises eligible empty-blob holders and adds regression tests.
- Updates protocol documentation, changelog, and API snapshot.
| File | Description |
|---|---|
| crates/protocol/tests/snapshots/public_api__public_api.snap | Records public API changes. |
| crates/protocol/src/message/tests.rs | Tests empty-root consistency and hash literal. |
| crates/protocol/src/message.rs | Adds constant and hash-aware validation. |
| crates/protocol/src/lib.rs | Exports EMPTY_ROOT. |
| crates/protocol/Cargo.toml | Adds test-only hashing dependency. |
| crates/node/tests/probe_loopback.rs | Tests advertisements and suppression cases. |
| crates/node/tests/node_origin_pull.rs | Tests probe-driven empty-blob discovery. |
| crates/node/src/node_origin/mod.rs | Updates node probe validation. |
| crates/node/src/handlers/probe.rs | Enables empty-root advertisements. |
| crates/node/src/dht/publish.rs | Clarifies empty-blob publishing behavior in comments. |
| crates/client/src/targets/tests.rs | Tests empty-root response classification. |
| crates/client/src/targets.rs | Updates client probe validation. |
| crates/client/src/ranged_store.rs | Uses the shared empty-root constant. |
| crates/client/src/lib.rs | Uses the constant for empty-claim checks. |
| crates/client/src/discovery.rs | Documents empty holder coverage. |
| crates/client/examples/common/mod.rs | Updates example probe validation. |
| CHANGELOG.md | Documents the fix and breaking API change. |
| Cargo.lock | Records the test dependency. |
| adr/022-content-discovery.md | Specifies the empty-root exception. |
Review effort: Balanced
The empty-root term reads the presence verdict settled before the `inspect_size` and coverage awaits. A denial or eviction that lands in that window empties the coverage for every other blob through `coverage_sized`'s own refusal gate, but the empty root's coverage is empty anyway, so the stale verdict would sign `has_blob: true` for a hash the node refuses to serve. Signing that for a blacklisted hash is a blacklist-violation offense (ADR 014). The term now re-checks `cache.refuses(hash)` so the later refusal wins, the same narrowing the stake-lane branch applies. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
The empty (0-byte) blob spans zero discovery blocks, so its coverage bitmap is empty on every holder. iroh-blobs reports the empty root complete at size 0 on every backend, so every node holds and serves it. The probe handler derived
has_blobfrom the bitmap and signedhas_blob: falsefor it, and the requester's consistency rule (has_blob ⟺ non-empty coverage) rejected ahas_blob: trueanswer for it as malformed. A client saw no holder, dropped the size hint and opened a paid lane for zero bytes; a node pulling through for the empty root found no provider.ProbeResponseExt::consistent_withtakes the signed&ProbeResponseBody. For the empty root the bitmap must be empty andhas_blobalone decides; every other hash keeps the biconditional. The rule keys on the signed hash, never on the unsignedtotal_byteshint.decdn_protocol::EMPTY_ROOTnames the hash (blake3 is a dev-dependency only, to prove the literal). The client's two local computations of it read the constant.has_blob: truefor the empty root when its presence check passes. The suppressing arms (chain-stale,max_probe_holds == 0, origin-only miss, refused hash) still answerfalse.Closes #2471
Review follow-ups (second commit)
Three review agents found no critical issue. Applied: ADR paragraph order and wording, the Changed (BREAKING) entry, comment precision in the protocol docs, both consumers, the handler and
publish_hash, and five tests that pin every suppressing handler arm for the empty root plus the clientNonHoldercase.Filed, not fixed here: #2526 (the coverage-union probe round never spans for a zero-block target; latency only, unreachable in production) and #2527 (pre-existing: ADR 022 says a node requester scores a mismatch, the code drops it without scoring).
Test plan
EMPTY_ROOT == blake3("")false; a 0-byte fs origin object advertises throughCoverage::full(0)Origin::fetchof the empty root through a probe returnsAlreadyAdmittedat cap 0 and under a cap (fails withNotFoundunder the old rule; mutation-checked)classify_probetakes the empty-root holder, takeshas_blob: falseas a non-holder, drops the pairing for any other hash (mutation-checked)cargo nextest run --workspace(5186 passed), clippy--all-targets --all-features -D warnings,cargo docwith warnings denied,pre-commit run --all-files🤖 Generated with Claude Code