Repository navigation
fix(client): fail an acquire whose late lane build escrowed untracked USDC - #2510
Merged
Merged
Conversation
… USDC When acquire returns, it drains the lane builds still in flight for up to 30 s. A late build could mine a topUp or openPool and then fail its local record. The drain logged that EscrowUntracked at debug and dropped it, so decdn get exited 0 (or 75 on a give-up) and nothing named the tx. - drain_builds returns every late build whose topUp or openPool may have escrowed USDC no record credits (fault::escrow_untracked), wrapped in LaneBuildFault: the first as the error, later ones as text context. Other late build errors stay at debug, fatal or not: the fetch no longer needs the lane. - fold_late_escrow makes that error win over the acquire's own outcome. A completed fetch fails. A failed fetch keeps its error only as text, so a GaveUp cannot exit 75 and a PoolReplaced cannot start a second pass. - StreamDrive::finish runs a stream's drive to its end and returns the fetch's error. The reader's end of stream does not carry an error that comes after the last byte, and decdn get -o - and the entry-URI manifest fetch dropped the drive mid-drain. stream_out, the stream example and the Streamer doc example now call it. Closes #2500 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The scoped error propagation and stream completion changes have focused regression coverage and no identified blocking issues.
No open issues 🎉
What changed in this PR
This PR makes single-fetch completion report late lane-build errors that may leave USDC escrowed without a local record.
Changes:
- Preserves late escrow errors and makes them override the fetch outcome.
- Adds
StreamDrive::finishso streaming callers await cleanup and receive its errors. - Adds regression tests and updates API snapshots and documentation.
| File | Description |
|---|---|
crates/client/tests/snapshots/public_api__public_api.snap |
Records the new public finish method. |
crates/client/src/streamer/tests.rs |
Tests clean and late-error completion. |
crates/client/src/streamer.rs |
Adds and documents StreamDrive::finish. |
crates/client/src/scheduler/tests.rs |
Tests escrow precedence, multiple errors, and drain timeout. |
crates/client/src/scheduler.rs |
Collects late escrow errors and preserves them in the result. |
crates/client/src/fault.rs |
Makes escrow detection available within the crate. |
crates/client/examples/stream.rs |
Awaits stream completion before reporting success. |
crates/cli/src/commands/fetch.rs |
Awaits the drive after successful stream copying. |
CHANGELOG.md |
Documents the error-propagation fix and completion API. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 5 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are 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.
What
When
acquirereturns, it drains the lane builds still in flight for up to 30 s. A late build could mine atopUporopenPooland then fail its local record. The drain logged thatEscrowUntrackedat debug and dropped it.decdn getexited 0 (or 75 on a give-up), and nothing named the tx.drain_buildsreturns every late build whosetopUp/openPoolmay have escrowed USDC no record credits (fault::escrow_untracked), wrapped inLaneBuildFault. The first is the error and later ones are text context.fold_late_escrowmakes that error win over the acquire's own outcome. A completed fetch fails. A failed fetch keeps its error only as text, so aGaveUpcannot exit 75 and aPoolReplacedcannot start a second pass. Both would invite a rerun that escrows again.StreamDrive::finish(public API, snapshot updated): it runs a stream's drive to its end and returns the fetch's error.decdn get -o -and the entry-URI manifest fetch dropped the drive mid-drain once the reader hit EOF, so they lost both the drain and its error.stream_out, thestreamexample and theStreamerdoc example call it.Closes #2500
Reviewer notes
Fault::Fatal. A latePoolReplaced,FundingNeededor disk fault from a lane the completed fetch no longer needs must not fail it. A latePoolReplacedwould make the caller redo finished work.a_late_lane_build_that_fails_otherwise_leaves_the_acquire_okpins this with a fatalBlobTooLarge.GaveUpstays downcastable andstop_exitreturns 75.LateBuildsfixture: completed fetch, non-escrow late failure, give-up, two escrows both named, and an escrow that survives a sibling build past the 30 s bound. Two streamer tests coverfinish. Each guarantee was mutation-checked: drop the second escrow, surface fatal errors too, loselateat the bound,finishwithout awaiting. Each mutation fails its own test.topUpafter an untracked escrow), fix(client): a mined openPool with no PoolOpened event is an untyped error, not EscrowUntracked #2507 (missingPoolOpenedis an untyped error), fix(client): a fatal lane build drops the rest of its batch, and an escrow in it goes unnamed #2508 (a fatal batch drops the rest of its batch), fix(client): a bundle pull drops sibling entries mid-drain, losing a late escrow and allowing exit 75 #2509 (a bundle pull drops siblings mid-drain, so a late escrow is lost and exit 75 is still possible). The CHANGELOG claim is scoped to a single fetch because of fix(client): a bundle pull drops sibling entries mid-drain, losing a late escrow and allowing exit 75 #2509.Verification
cargo fmt -- --checkCARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features(run as-- -D warnings)cargo nextest run: 5089 passedCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items;cargo test --doc -p decdn-client StreamerINSTA_UPDATE=always cargo nextest run -p decdn-client --features public-api-test: snapshot gainsStreamDrive::finishonlycontracts/changed: n/aCHANGELOG.mdentry added🤖 Generated with Claude Code