Repository navigation
feat(client-pull,cli): range-minimized decdn fetch via gap-driven driver (P3-client of #1621) - #1631
Conversation
…n driver Defines the substrate-agnostic driver axes (#1608): BlobSource (dumb raw-bao source), Funder (injected top-up seam), Pacer/BudgetPacer (pure draw/top-up/wait decision). Scripted test doubles + pure BudgetPacer unit tests. No PeerSource or driver yet. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ests open_progressive_pull now threads byte_len into StreamRequest so a middle gap [offset,len) can be requested (wire already carried the field). PeerSource wraps the paid progressive pull behind BlobSource (Reader=PullReader, finish drains to the voucher watermark). Existing callers pass byte_len=0 (to-end, unchanged). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Consumes a gap's raw bao stream into positioned .partial + accumulating .obao4 at O(chunk-group) memory, checkpointing present-ranges durably (fsync-before-record) so a mid-gap fault resumes without re-paying the received prefix. Evolves decode_to_sink: Leaf written positioned, Parent persisted to the outboard. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…_ranges drive(store, source, pacer, funder, ...) fills each gap of missing_ranges(R) via a paced PeerSource pull streamed through ingest_stream, folding the resume/ top-up/settle-wait/reseed loop behind the Pacer+Funder axes. Held ranges are read locally, never pulled, never re-paid. Money-assertion test: opened ranges == the gaps exactly. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…tRangedStore decdn fetch now pulls only missing_ranges(R): the single-cursor stream loop is replaced by drive() over a ClientRangedStore + PeerSource + BudgetPacer + a CLI Funder. Channel context is shared (interior-mutable) so the driver's top-up/reseed and the source's pull see one state. Whole-file resume re-hash dropped (the store bao-verifies every byte + valid_ranges sweep). Held ranges never re-paid. Co-Authored-By: Claude Opus 4.8 <[email protected]>
… settle-wait constants The mid-gap-fault re-pay window is up to one 4 MiB checkpoint interval (~4 default voucher intervals) x MAX_RESUME_ATTEMPTS, not "under one interval" — checkpointed bytes are still never re-paid. Relocate MAX_TOPUP_SETTLE_WAITS/TOPUP_SETTLE_BACKOFF to client-pull so drive() and bundle pull's legacy loop share one definition. Co-Authored-By: Claude Opus 4.8 <[email protected]>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis change adds a gap-driven ranged pull pipeline for blob fetches. It introduces source, pacing, driver, and ranged-store layers, wires them into CLI fetch, updates bounded range opens, and validates checkpointed resume, corruption recovery, foreign checkpoints, and free promotion. ChangesGap-driven pull pipeline
Estimated code review effort: 5 (Critical) | ~100 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as decdn fetch
participant Driver as drive
participant Source as PeerSource
participant Store as ClientRangedStore
participant Funder as CliFunder
CLI->>Driver: start fetch
Driver->>Source: open missing gap
Source-->>Driver: header and reader
Driver->>Store: ingest_stream(range, reader)
Store-->>Driver: checkpointed progress
Driver->>Funder: top_up(additional) when required
Driver->>Source: finish(reader)
Driver-->>CLI: finalize complete blob or keep resumable state
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Pull request overview
Implements Phase A of the range-minimized, gap-driven fetch path: decdn fetch now fills only missing_ranges for a requested blob by driving a new client-pull fetch driver over ClientRangedStore, using a bounded byte_len progressive pull for mid-gap requests.
Changes:
- Add the gap-driven fetch driver (
drive) with injectedBlobSource/Funder/Paceraxes and associated test doubles. - Introduce streaming, checkpointed ranged-store ingest (
ClientRangedStore::ingest_stream) and plumbbyte_lenthrough progressive pulls to support bounded gap requests. - Route
decdn fetchthrough the new driver and store, retaining the legacy streaming loop forbundle pull(for now).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/node_origin/resume.rs | Passes byte_len=0 explicitly for whole-tail node resume pulls. |
| crates/node/src/node_origin/mod.rs | Passes byte_len=0 explicitly for whole-tail node candidate-fallback pulls. |
| crates/client-pull/src/source.rs | Adds BlobSource/Funder axes and PeerSource adapter (bounded range open via byte_len). |
| crates/client-pull/src/sink.rs | Exposes PullReader/StashedFault and an into_inner path needed by the new source/driver plumbing. |
| crates/client-pull/src/ranged_store.rs | Adds open_or_create and streaming ingest with durability checkpoints for resumable gap fills. |
| crates/client-pull/src/pacer.rs | Introduces pure pacing axis (Pacer, BudgetPacer) for driver decisions. |
| crates/client-pull/src/lib.rs | Exports new driver/pacer/source APIs; plumbs byte_len through progressive pull open and wire-cost sizing. |
| crates/client-pull/src/driver.rs | New gap-driven driver (drive) coordinating store gaps, pulls, top-ups, settle-waits, and reseed logic. |
| crates/cli/src/commands/fetch.rs | Switches decdn fetch to the new driver + ranged store; keeps legacy loop for bundle pull. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
BudgetPacer returned Wait whenever awaiting_settle, and fill_gap set it after every top-up, so the driver slept the full settle budget (30x500ms) before retrying. Retry the open immediately after a top-up; the bounded settle-wait now fires only when a re-open actually fails resume_may_be_stale, matching the legacy CLI loop. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…edStore The resume journeys seeded a raw .partial (old model); the gap-driven fetch resumes only from its sidecar record. Add ClientRangedStore::seed_checkpointed_prefix (test-util) and rewrite the journeys to construct a real checkpointed on-disk state: resume-saves, corrupt-caught-by-finalize-sweep, foreign-no-wedge, and the #1622 complete-partial free-finish, all under new-model semantics. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 80.52% (was 80.46%, ▲ +0.05%) — 59359/73723 lines
History
|
…ion + paid-frontier resume The node delivers the whole blob within its credit window (ADR 003/037), so ingest_stream checkpoints bytes the vouchers haven't paid for yet. BudgetPacer returned Done on delivered>=requested, stopping before the delivered-but-unpaid tail was billed (under-pay). Done now requires PAID(wire) >= the range's wire cost; an unpaid tail tops up and re-opens at content_paid_frontier(leg_start, total, paid_wire) to re-deliver and bill it, terminating when paid catches up. A fresh/cross-invocation resume (paid_wire==0) still resumes from the disk frontier with no re-pay. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 90.07% (2629/2919 lines) |
What
Phase A (P3-client) of #1621 / #1608.
decdn fetchnow satisfies rangeRof blobHby pulling and paying for onlymissing_ranges(R)— held ranges are read locally, never re-pulled, never re-paid. Introduces the four substrate-agnostic driver axes, built node-capable so the node serve-miss (Phase B) is adoption, not a retrofit.Six commits:
BlobSource(dumb source of raw bao bytes) +Funder(injected top-up seam) +Pacer/BudgetPacer(pure decision; error classification lifted to the driver asexhaustion_confirmed).client-pull.PeerSource— wraps the paid progressive pull behindBlobSource; threads a boundedbyte_lenthroughopen_progressive_pull→StreamRequestso a middle gap[offset,len)can be requested (the wire already carried the field).ClientRangedStore::ingest_stream— streams a gap's raw bao into positioned.partial+ accumulating.obao4at O(chunk-group) memory, with 4 MiB fsync-before-record checkpoints so a mid-gap fault resumes without re-paying the received prefix.drive(...)— the gap loop, folding the resume / top-up / settle-wait / reseed logic behind thePacer+Funderaxes. Money-assertion test: opened ranges == the gaps exactly.decdn fetchthroughdriveover aClientRangedStore; channel context shared viaArc<Mutex<ChannelContext>>(no lock across.await); CLIFunder; the whole-file resume re-hash is dropped (subsumed by the store's per-byte bao verify +finalize'svalid_rangessweep).client-pull.For your conscious ratification (from the final review)
Mid-gap-fault re-pay window. On a mid-gap fault, content received since the last 4 MiB checkpoint is re-pulled and re-paid on resume — up to ~one 4 MiB checkpoint interval (≈4 default 1 MiB voucher intervals) ×
MAX_RESUME_ATTEMPTS. Checkpointed bytes are never re-paid, and faults are rare + bounded, so on large files this is <0.1%. The knob isINGEST_CHECKPOINT_BYTES(4 MiB): smaller = fewer re-paid bytes on fault but more fsyncs; aligning to the voucher interval (1 MiB) drives it toward the payment granularity. Kept at 4 MiB — flagging so you can decide the cadence.Deferred to later phases (non-blocking, tracked)
PaceDecision::Draw{up_to_bytes}is currently ignored (TODOindriver.rs) — benign withBudgetPacer(full remainder); the nodeWindowPacer(Phase B) must honor it (a localized clamp)..rangesfrom a different hash at the same--outputfails the first run opaquely (no money lost —finalize's sweep catches it). Cheap root sanity-check is a follow-up.total_bytes(pays nothing).bundle pullstill uses the legacyfetch_blob_streamingloop — P4 migrates it and deletes the second path.Not in this PR
NodeRangedStore→ServeStorewithobserve/encode_range,WindowPacer). Prereq: refactor(cache): unify blob ingest behind a range-aware cache API with retained partials #1607 retained partials.bundle pullonto the driver + delete the residual single-cursor path.Verification
cargo build && cargo clippy --all-targets --all-features -- -D warnings— cleancargo nextest run -p decdn-client-pull -p decdn-cli— 601/601 (incl. the money-assertion + all gap scenarios + mid-gap-fault-resume)cargo fmt -- --check— cleancargo test --no-run -p decdn-e2e --features anvil-e2e— compilescargo tree -p decdn-cli -e normal -i iroh-blobs— nothing (CLI binary-split regression: publisher links cache crate (iroh-blobs/AWS SDK) #578 holds)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
decdn fetchnow downloads only missing byte ranges, improving resume efficiency.Bug Fixes