Repository navigation
fix: unstall bundle pull (runtime I/O, lane credit, ingest fsync, probe limits, boundary legs) - #2124
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
bundle_pull.rs can over-report paid bytes for resumed fetches and stale or incorrect manifest sizes.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR improves large bundle-pull performance and payment liveness across runtime I/O, probe retries, lane crediting, ingest checkpoints, and donor-range handling.
Changes:
- Moves blocking bundle I/O off runtime workers and closes endpoints cleanly.
- Retries rate-limited probes, corrects voucher crediting, and pipelines ingest fsyncs.
- Coalesces adjacent donor ranges and updates related ADR documentation.
| File | Summary |
|---|---|
crates/node/tests/client_loopback.rs |
Adds rollover-credit regression coverage. |
crates/node/src/handlers/client/voucher.rs |
Prevents metering vouchers from claiming whole chunks. |
crates/node/src/handlers/client/serve_leg.rs |
Adds proof failure context. |
crates/node/src/handlers/client/mod.rs |
Updates proof-budget documentation. |
crates/node/src/handlers/client/delivery.rs |
Updates delivery proof context and documentation. |
crates/client-pull/src/scheduler.rs |
Updates checkpoint bounds. |
crates/client-pull/src/ranged_store.rs |
Adds bounded asynchronous checkpoint processing. |
crates/cli/src/commands/fetch.rs |
Retries rate-limited probes and closes endpoints. |
crates/cli/src/commands/bundle_pull.rs |
Moves I/O off-runtime and coalesces donor runs; paid-byte accounting needs correction for resumed fetches and stale manifest sizes. |
adr/appendix-bundles.md |
Documents spliced-run behavior. |
adr/005-protocol.md |
Clarifies payment-lane protocol rules. |
adr/003-payments.md |
Documents metering-voucher credit rules. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 84.12% (was 84.04%, ▲ +0.08%) — 92237/109648 lines
History
|
…o place, report paid bytes Every group of a bundle pull is a future polled by one task (`buffer_unordered`). `materialize` copied each finished blob (up to 13 GB) plus an fsync synchronously on that task, so every other group's streams stopped reading and paying; serving nodes then ended them at their 10s voucher-read timeout and the client saw `early eof`. - Run the first write, links, staging removal and the run-end donor sweep on the blocking pool. - Move a non-donor staging blob into its first destination with a rename (copy only across filesystems) instead of writing it again; hard-link a donor's first destination so its staging name survives. - Report `downloaded` as the content bytes paid for: a range-dedup blob no longer counts the bytes it spliced from disk, and an already-finalized staging blob counts nothing. - Close the iroh endpoint on every exit of `bundle pull` and `fetch`, so the run no longer ends with "Endpoint dropped without calling Endpoint::close". Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…y it A bundle pull probes every candidate for every entry, so its first seconds send each node more probes than the ADR 005 per-peer limit (5/s, burst 5) admits. The node sheds the extra ones with APP_ERR_RATE_LIMITED, and `probe_and_order` dropped the error and counted the node as "did not answer" — an entry then failed with "none of the 3 probed node(s) could serve the blob (3 did not answer)" and waited for a retry round. - Probe a candidate that sheds the probe again after 250 ms, 500 ms and 1 s; the per-peer bucket refills one probe every 200 ms. - Count a candidate that still sheds as rate-limited and name it in the terminal error, apart from the silent ones. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Every proof credited a stream's outstanding chunk from lane-shared headroom, including rooted open, re-anchor, and rollover vouchers. A rollover folds every reveal the payer released, including one a sibling stream carries and the node has not read yet. When the rolling stream's task read its voucher first, it took that reveal's headroom for its own chunk. The sibling's reveal then landed on the retired root, credited nothing, and the sibling waited for a proof the payer never sends, until the 10s proof-read timeout killed the stream. Multi-stream bundle pulls hit this as `proof read timed out after 10s: peer-side fault`. A voucher that carries a live chain_root now credits nothing against a whole chunk. It still advances the watermark and anchors its stream, and the stream waits for its reveal. Reveals, sealed vouchers, and vouchers that settle a partial closing chunk keep crediting from headroom. The recoup loops add the proof attempt, the chunk size, and the pending count to a failed proof read. The loopback tests cover the wedge and the anchor voucher that credits nothing. ADR 003 and ADR 005 state the rule. They also describe the per-stream preimage cadence and the rolling closing voucher that the payer uses. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…t stop payment ingest_stream checkpoints every 4 MiB, and before it queued the next checkpoint it waited for the previous one's write and fsync. While it waited the decode loop pulled no bytes, so the paid pull sent no vouchers. A slow fsync (several multi-GB partials, writeback throttling) held payment past the serving node's 10 s voucher timeout, and the node ended the stream. The decode loop now queues each verified batch and keeps decoding. It waits only when INGEST_MAX_QUEUED_CHECKPOINTS (3) checkpoints are not yet durable. A spawn_blocking worker runs while checkpoints are queued, takes them in order, folds the queued ones into one fsync, and only then extends `present`, so the fsync-before-record rule holds. The worker exits when the queue is empty, so an idle ingest holds no blocking-pool thread and does not stop a paused test clock. A stream fault now also checkpoints the verified batch it holds, so a fault re-pays only bytes past the last verified chunk group. A crash or dropped future re-pays at most INGEST_MAX_QUEUED_CHECKPOINTS + 1 intervals. Checkpoints use sync_data: fdatasync persists the size growth and block allocation that reading the data back needs. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… are not fetched Range-dedup aligned each donor chunk inward to 16 KiB chunk groups on its own, so wherever two spliced chunks met inside a group that group was left uncovered and driven as its own paid request. A large entry has thousands of chunk boundaries; Tempo showed them as a stream of `byte_len=16384` legs of ~110 ms each, mostly run one after another. Donor and deferred chunks that touch now form one spliced run, and only the run's two ends round inward to group boundaries. A boundary between two spliced chunks is spliced from both sides. A donor that fails its hash check, and a deferred chunk whose fetcher never produces it, are fetched over every group their span touches, so a shared boundary group ends up whole. The ranged store's finalize verify still drops any group a lying placement corrupted, so a bad hint costs a re-fetch, never a corrupt output. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
thiras
force-pushed
the
fix/bundle-pull-unstall
branch
from
September 23, 2026 13:15
cf1a7a3 to
f6b258e
Compare
The job ran every decdn-client test beside the rustdoc render, and the CPU contention failed a different timing-sensitive scheduler test on each run. The `test` job already owns those tests, so each step now runs the snapshot target alone. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 90.63% (2399/2647 lines) |
The plain whole-file path never checks the manifest's optional `size`, so a wrong declared size still fetches and verifies the real blob. The paid count now reads the finalized staging file's length instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
thiras
added a commit
that referenced
this pull request
Sep 23, 2026
#2132) (#2133) A proof credits at most the lane headroom it finds, so a sealed voucher that moves the watermark by a sliver pays a sliver of the chunk. Both recoup loops added that sliver to `paid` but popped the whole chunk, so the unpaid rest was tracked nowhere. On a cache hit, once it filled the credit window, `deliver` looped without awaiting and held one tokio worker per stream; two such streams wedged a 2-vCPU testnet node. - `OwedChunk { len, remaining }` replaces the bare delta in both queues. A chunk leaves the queue only when proofs have paid all of it, and `MAX_PROOFS_PER_CHUNK` counts every proof that leaves it unsettled. - `voucher_credit_delta` classifies by the chunk's delivered length, so a metering voucher still pays no part of a whole chunk (#2124). - Both loops check after each recoup that `delivered - paid` equals the bytes not yet cut into a chunk, and `settle` refuses an over-credit. Either break fails the stream as a node fault. - The no-progress guard in both loops is a node fault. The miss path filed it as a client abandon; `ServeStop::ClientAbandoned` is gone. - ADR 003/005: the payer anchors a stream immediately before its first reveal, not at stream open, and an honest payer never gets a partial credit. Both statements match the client and are now load-bearing. - `two_hashes_reuse_one_warm_connection` reused a zero-based context for a second fetch on one lane and relied on the leak; it now seeds the second fetch from the lane's totals. Tests: sliver credit, proof budget and last-proof settle on the cache hit; sliver credit and proof budget on the miss path; a sub-chunk stream on a live chain sends only its closing voucher (mutation-checked). Closes #2132 Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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
A
decdn bundle pullsmoke test of the gpt-oss bundle (27.6 GB,--exclude 'metal/*') exited 0, but it only got there through failover and one retry round. Big entries fell to 100 KiB/s – 3 MiB/s, and the nodes loggedproof read timed out after 10s. This PR fixes each cause. One commit per fix:fix(cli): keep bundle pull file I/O off the runtime, move staging into place, report paid bytes.buffer_unordered).materializecopied each finished blob, up to 13 GB, and fsynced it on that task, so every other stream stopped reading and paying.downloadednow counts bytes actually paid for.Endpoint dropped without calling Endpoint::closeis gone.fix(cli): tell a rate-limited probe apart from a silent node and retry it.0x10, andprobe_and_orderreported those nodes as "did not answer".fix(node): a metering voucher pays no whole chunk.fix(client-pull): pipeline ingest checkpoints so a slow fsync does not stop payment.ingest_streamwaited for every 4 MiB fsync before it decoded more, so payment stopped while the disk was slow.presentstill updated only after the fsync.perf(cli): splice adjacent donor chunks as one run so boundary groups are not fetched.adr/appendix-bundles.mdis updated to match.Test plan
cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --check,RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemscargo nextest run --workspace --all-features: 3937/3937 passedfirst_write_*andgroup_transfer_downloads_only_the_paid_bytes_of_a_spliced_blobprobe_candidate_*(loopback server that sheds probes) andno_serve_target_error_*a_sibling_roll_does_not_take_a_retired_reveals_credit; checked that it fails with the fix revertedingest_stream_decodes_past_a_slow_fsync,…_bounds_undurable_bytes,…_coalesces_queued_checkpointsplan_dedup_adjacent_donors_*,reassemble_dedup_refetches_the_outward_group_span_of_a_failed_donor,reconcile_deferred_falls_back_to_the_outward_group_spanearly eof,all sources failed,did not answer)proof read timed outserve_streamlegs (Tempo)downloaded 27.6 GBdownloaded 14.8 GB → reconstructed 27.6 GBDeploy note
Commit 3 changes node crediting, so it only takes effect after the testnet nodes are redeployed. Until then, the loopback test is the proof for it.
🤖 Generated with Claude Code