Skip to content

fix(cache,node): announce ranged-fill partials to the DHT - #2188

Merged
thiras merged 2 commits into
mainfrom
fix/2186-announce-ranged-fills
Sep 28, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/2186-announce-ranged-fills

Conversation

@thiras

@thiras thiras commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

What

A node that filled its cache only through ranged serve-miss pulls published no DHT provider records. On the testnet, ash1, hel1 and hil1 showed decdn_dht_store_published_total at 0 for 26 h, while ash1 was serving ranges from its own cache. The republisher learned about content from two sources only: whole-blob pull-through commits, and a boot walk of Complete blobs. So partial holders never entered its schedule. ADR 022 §STORE Flow and AC 21 require a STORE once a node verifies its first 64 MiB block.

  • Cache (engine.rs). A ranged admit (admit_bao, admit_bao_stream) that touches a fully present discovery block announces the hash on subscribe_inserts. It also announces when the admit fails partway, because the store keeps the items it verified and a gap-fill retry never touches those blocks again. If the coverage query faults, it announces anyway and lets the consumer decide. The block math (discovery_block_span, covered_blocks) is shared with coverage() and reads the same overridable block size as num_blocks.
  • Boot and lag seeds. iter_hashes lists partial blobs, so the cold-start seed and the lag sweep reach them. It reads only status(), because an observe() per partial at boot costs an fsync each. The due-time gate cache_still_holds drops a partial that covers no block.
  • Republisher (publish.rs).
    • The eager publish on a cache event runs only for a hash that has not announced yet. A new announced set tracks this, kept apart from scheduling, so a seeded partial still publishes at once when its first block verifies.
    • An eager publish that reaches no peer stays unannounced, so the next event retries it.
    • An empty coverage sends no Store.
  • Stale doc removed. The "known limitation" on cache_still_holds about front-only partials was stale: coverage() already reads the size from the observe() bitfield. A test now pins that.

Closes #2186

Reviewer notes

  • Read first: announce_completed_blocks and the restructured tail of admit_bao_stream in crates/cache/src/engine.rs. Then the Ok(hash) arm of run_republish and the announced set in crates/node/src/dht/publish.rs.
  • Behaviour change for pull-through commits. The eager Store also skips a hash that has already announced. Before this PR, every commit published. The wider coverage now goes out on the next cycle, as ADR 022 §Content Records and TTL describes.
  • Cost per admit. One extra status() + observe() call per admit, on a store entry the admit just touched. It is skipped when no subscriber exists. A front-to-back fill announces about once per 64 MiB block, so the channel does not come under new pressure.
  • Seed contents. Under relay_foreign_namespaces = false, the seeds now put partials through origin_probe_presence too. The probe memo bounds that cost.
  • Not added: no new metric. With the fail-open event, a coverage fault no longer loses a hash. No ADR change: ADR 022 already requires this behaviour.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run (workspace: 4164 passed)
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • User-visible change: CHANGELOG.md entry added
  • PR title type fix, lowercase subject

Regression tests:

  • End-to-end (crates/node/tests/dht_bootstrap.rs), through the real admit_bao → subscribe_inserts → run_republish → Store → RecordStore chain:
    • A ranged partial publishes once block 0 verifies, and does not publish again on block 1. This test fails if the announce hook or the dedupe is removed.
    • A seeded partial publishes as soon as its first block verifies. This test fails if the dedupe keys on the schedule.
    • A hash that covers no block gets no record.
  • Cache (crates/cache/src/engine.rs):
    • Block 0, the short last block, and an interior block each announce.
    • A sub-block admit, and a small blob before it completes, announce nothing.
    • A truncated streamed admit still announces the block it completed.
    • iter_hashes includes partials.
  • Republisher (publish.rs unit tests):
    • A front-only partial is held.
    • A partial with no whole block is not held.
    • holder_snapshot includes partials.
    • The announced mark is independent of scheduling.

After deploy: hel1's cold-start log shows cold_start_count > 0, and decdn_dht_store_published_total rises on ash1, hel1 and hil1.

🤖 Generated with Claude Code

A node that filled its cache only through ranged serve-miss pulls
published no DHT provider records. The republisher learned about content
from whole-blob pull-through commits and from a boot walk of Complete
blobs only, so partial holders never entered its schedule (ADR 022
§STORE Flow, AC 21).

- A ranged admit (admit_bao, admit_bao_stream) that touches a fully
  present 64 MiB discovery block announces the hash on subscribe_inserts,
  on failure too, because the store keeps the items it verified. A
  coverage-query fault announces anyway and the consumer decides.
- iter_hashes lists partial blobs, so the cold-start seed and the lag
  sweep reach them. The due-time gate drops a partial with no whole block.
- The republisher publishes eagerly only for a hash that has not
  announced yet, tracked apart from scheduling so a seeded partial still
  publishes at once when its first block verifies. An empty coverage
  sends no Store.

Closes #2186

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras thiras added kind:bug Something does not behave as documented rust Dependabot: a Cargo update; use area: labels for Rust code otherwise area:node decdn-node daemon: runtime, handlers, admin RPC, serve path labels Sep 28, 2026
Copilot AI lite review requested due to automatic review settings September 28, 2026 00:37
@thiras thiras self-assigned this Sep 28, 2026

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Unresolved issues remain around protection-failure announcements, failed publish retries, empty batch entries, and cold-start rescheduling.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates cache and DHT republishing so ranged partial blobs become discoverable after completing verified blocks.

Changes:

  • Announces completed ranged blocks through cache insert events.
  • Seeds partial blobs during cold starts and lag sweeps.
  • Adds publish deduplication, scheduling updates, regression tests, and changelog documentation.
File Summary
crates/​node/​tests/​dht_bootstrap.rs Adds end-to-end partial-publication tests.
crates/​node/​src/​runtime/​mod.rs Seeds complete and partial cache entries.
crates/​node/​src/​dht/​publish.rs Updates partial seeding, eager publishing, scheduling, and deduplication.
crates/​node/​src/​dht/​client.rs Updates publishing documentation.
crates/​cache/​src/​engine.rs Adds block coverage detection and ranged-admit announcements.
CHANGELOG.md Documents the ranged-fill announcement fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/node/src/dht/publish.rs Resolved
@github-code-quality

github-code-quality Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit c122757 in the fix/2186-announce-ra... branch remains at 86%, unchanged from commit 0502e2d in the main branch.

Show a line coverage summary of the most impacted files.
File main 0502e2d fix/2186-announce-ra... c122757 +/-
crates/client/src/ledger.rs 99% 98% -1%
crates/cache/src/engine.rs 94% 94% 0%
crates/node/src...gin/pull_leg.rs 89% 89% 0%
crates/node/src...s/client/mod.rs 96% 96% 0%
crates/client/src/scheduler.rs 95% 95% 0%
crates/node/src/dht/publish.rs 92% 92% 0%

Updated September 28, 2026 00:58 UTC

The drain cycle marked every held hash announced before its detached
BatchStore ran. A cycle with no routing peers, or one every receiver
refused, still marked the hash, so its next cache event skipped the
eager retry. publish_batch now reports the hashes a peer accepted with
non-empty coverage, and only those are marked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit 8d27ddf into main Sep 28, 2026
30 checks passed
@thiras
thiras deleted the fix/2186-announce-ranged-fills branch September 28, 2026 01:03
thiras added a commit that referenced this pull request Sep 28, 2026
…ial-only (#2201)

Since #2188 a DHT answer can name only partial holders. `discover` read the
on-chain origin directory only when the DHT answer was empty, so the ranged
assembly ran out of candidates for the blocks no partial held and the client
got a truncated stream after `ok: true`.

On the ranged pull leg, a probe round whose holders do not span the blob is
followed by a round over the origin-directory candidates it did not probe,
an origin past the `probe_fanout` cut among them. A probe-cache entry that
does not span the blob counts as a miss there. A partial holder's probe now
carries the blob size (`CacheEngine::coverage_sized`), so a set of partials
that covers every block counts as spanning.

Before signing `ok: true` the serve leg checks, against the signed size, that
its candidates cover the part of the pull range it does not hold, and refuses
with a signed miss when they do not. `AssembleOutcome::Unavailable` carries
its cause, logged with a `warn!`. ADR 022 gains the partial-coverage fallback
and the refusal-before-commit rule; ADRs 001 and 039, architecture.md and the
observability appendix follow.

Closes #2195

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:node decdn-node daemon: runtime, handlers, admin RPC, serve path kind:bug Something does not behave as documented rust Dependabot: a Cargo update; use area: labels for Rust code otherwise

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ranged-fill cache content is never announced to the DHT; partial holders publish zero provider records

2 participants