Repository navigation
feat: range-keyed partial-holder discovery — data layer (#1506 PR1) - #1894
Merged
Merged
Conversation
…ll-serve >=1 block (#1506)
…advertise any partial (#1506)
…DR 022 bandwidth for coverage (#1506)
Adds the partial-serve gate to serve_stream's miss path: when the requested byte range is already fully present in a not-Complete blob's local cache, serve it straight from cache (CacheHit shed class, same size gate + deliver as an ordinary hit) instead of running the miss path's fill legs. A partial holder can now serve the ranges it advertises via probe/DHT coverage; an uncovered range still falls through to the existing fill legs unchanged.
…ace (#1506) The public-api-test feature is out of the default nextest run, so the coverage additions (protocol::coverage module, Provider, StoreRequest/ BatchStoreRequest/FindValueResponse/ProbeResponseExt fields) did not update the committed snapshot during implementation. DhtMessage and the signed ProbeResponseBody are absent from the diff — frozen surfaces stayed frozen. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR implements the data-layer plumbing for range-keyed partial-holder discovery (#1506) by introducing a 64 MiB discovery-block coverage bitmap into the protocol, carrying it through probe and DHT surfaces, and enabling nodes to serve byte ranges directly from cached partials when the requested span is fully present.
Changes:
- Add
protocol::Coverage(bit-packed discovery-block bitmap) and thread it through probe extensions and DHT provider records / STORE messages. - Redefine probe
has_blobto mean “will serve ≥1 discovery block” and enforce thehas_blob ⟺ !coverage.is_empty()consistency check at consumers. - Relax advertise + serve gates to support partial holders: DHT publish now admits any verified block, and client serving can short-circuit to direct cache serve for fully-present requested ranges on partial blobs.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/protocol/src/message.rs | Extends ProbeResponseExt with Coverage and adds a signed/unsigned consistency helper + tests. |
| crates/protocol/src/lib.rs | Exposes the new coverage module and re-exports Coverage/helpers. |
| crates/protocol/src/framing.rs | Updates framing tests for the new probe extension field. |
| crates/protocol/src/dht.rs | Adds per-provider coverage on FIND_VALUE responses and coverage in STORE / BATCH_STORE payloads. |
| crates/protocol/src/coverage.rs | Introduces the Coverage bitmap type, encoding semantics, and unit tests. |
| crates/cache/src/engine.rs | Implements CacheEngine::coverage by deriving covered discovery blocks from present chunk ranges + tests. |
| crates/node/src/handlers/probe.rs | Derives final “will-serve” coverage (origin/all-ones vs cache-derived) and re-derives has_blob from it. |
| crates/node/src/node_origin/mod.rs | Drops probe candidates whose signed has_blob disagrees with unsigned coverage emptiness. |
| crates/node/src/handlers/dht.rs | Plumbs coverage through STORE and BATCH_STORE admission into the record store. |
| crates/node/src/dht/records.rs | Stores per-holder Coverage in the record store and returns it in provider listings. |
| crates/node/src/dht/lookup.rs | Returns Vec<(NodeId, Coverage)> from lookups and preserves per-node coverage through folding/dedup. |
| crates/node/src/dht/client.rs | Sends coverage in STORE and (hash, coverage) entries in BATCH_STORE. |
| crates/node/src/dht/publish.rs | Switches republish eligibility to coverage-non-empty and publishes coverage snapshots in STORE/BATCH_STORE. |
| crates/node/src/handlers/client/fill.rs | Adds a partial-hit size gate to detect fully-cached requested spans on non-Complete blobs. |
| crates/node/src/handlers/client/dispatch.rs | Uses the partial-serve gate to route fully-present spans to the cache-hit serve path (no fill). |
| crates/node/tests/probe_loopback.rs | Adds loopback tests for cached-partial coverage + origin all-ones coverage. |
| crates/node/tests/partial_serve.rs | New end-to-end tests for serving within cached partial ranges and falling through on mixed spans. |
| crates/node/tests/node_origin_pull.rs | Updates probe responses in tests to include full coverage. |
| crates/node/tests/dht_loopback.rs | Updates DHT loopback tests for coverage-carrying STORE/BATCH_STORE and provider assertions. |
| crates/node/tests/dht_lookup.rs | Updates lookup tests to assert (NodeId, Coverage) results. |
| crates/node/tests/dht_integration.rs | Updates integration tests to assert coverage is propagated with providers. |
| crates/node/tests/dht_bootstrap.rs | Updates bootstrap test helpers to store coverage. |
| crates/node/src/admin.rs | Updates admin test fixture record insertion to include coverage. |
| crates/cli/tests/admin_rpc.rs | Updates CLI admin RPC test fixture record insertion to include coverage. |
| crates/cli/src/commands/probe.rs | Updates CLI probe command tests to build consistent coverage with has_blob. |
| crates/cli/src/commands/fetch.rs | Drops probe candidates on has_blob/coverage mismatch in the CLI’s ordering path. |
| adr/022-content-discovery.md | Updates DHT bandwidth analysis to reflect provider coverage overhead. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… factor bao chunk const (#1506) Address PR #1894 review: - Coverage doc now states that a deserialized-from-wire bitmap may carry spurious trailing high bits, so covers/covered_blocks report raw bits and consumers MUST clamp to the blob's own num_blocks(total_bytes). - CacheEngine::coverage factors the duplicated bao leaf chunk size (1024) into a single BAO_CHUNK_BYTES const. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 82.64% (was 82.59%, ▲ +0.05%) — 71235/86197 lines
History
|
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.
First of two implementation PRs for #1506 (design merged in #1885/#1887). This is the data layer: it makes partial holders discoverable and serveable by byte range. No consumer/scheduler changes — that's PR2.
What lands
protocol::Coverage— a 64 MiB block bitmap (bit-packed), withCacheEngine::coveragederiving cached-block coverage from the iroh-blobs bitfield (af54128c).ProbeResponseExt), andhas_blobis redefined as "will serve ≥1 block" — biconditional with coverage (has_blob == !coverage.is_empty()). Origin-serve-capable nodes emit all-ones from the size they already read; a requester drops a probe whosehas_blob/coverage disagree (4123c50f).FIND_VALUEcarry per-provider coverage; the advertise gate relaxes fromCompleteto any verified block;find_providers → Vec<(NodeId, Coverage)>(47420d85,140c00c4).cb4281ed), the counterpart to the advertise relax.Coverage semantic = "blocks the sender WILL serve": cached blocks for a cache holder, all-ones for an origin.
has_blob ⟺ non-empty coverage.Frozen surfaces (verified byte-identical)
The signed probe set
{hash, has_blob, rate_per_mb, timestamp_us}and theDhtMessagevariant order are unchanged (only unsigned/payload fields grew). No contract change.Known limitation (accepted, deferred — safe)
iroh-blobs doesn't expose a partial blob's total size until its last chunk lands, so a non-origin front-prefix partial (blocks 0..N, no tail) derives empty coverage → it isn't advertised and answers
has_blob:false. This is safe (under-advertises, never mis-advertises) and inert in PR1 (no consumer). Follow-up before PR2's node-assembly leans on abandoned-prefix supply: persisttotal_bytesat fill time (FillSessionalready holds it).Deferred nits (none block merge)
Coverage::fullbit-by-bit fill (perf).cache.coverage()per-probe store round-trip (not hot path);cli/probe.rsstandalone command left unwired (print-only, moot).find_providersIndexMapdedup: last-fold-wins coverage on a duplicate NodeId — harmless in PR1 (coverage unused here), note for PR2.debug_assertin the probe handler.Tests
New:
Coverageunit tests, probe cached-partial + origin-all-ones loopback tests + requester-drop,cache_still_holdspartial-holder test, DHT STORE→FIND_VALUE partial-coverage round-trip,partial_serve.rs(serve-from-cache + mixed-range-falls-through-to-origin). Full node suite green (1078), clippy/fmt/deny/ADR-hygiene clean, anvil-e2e compiles.🤖 Generated with Claude Code