Skip to content

fix(client): fail an acquire whose late lane build escrowed untracked USDC - #2510

Merged
thiras merged 1 commit into
mainfrom
fix/late-build-escrow-2500
Oct 17, 2026
Merged

thiras merged 1 commit into
mainfrom
fix/late-build-escrow-2500

Conversation

@thiras

@thiras thiras commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

What

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. decdn get exited 0 (or 75 on a give-up), and nothing named the tx.

  • drain_builds returns every late build whose topUp/openPool may have escrowed USDC no record credits (fault::escrow_untracked), wrapped in LaneBuildFault. The first is the error and later ones are text context.
  • 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. Both would invite a rerun that escrows again.
  • New 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, the stream example and the Streamer doc example call it.

Closes #2500

Reviewer notes

Verification

  • cargo fmt -- --check
  • CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features (run as -- -D warnings)
  • cargo nextest run: 5089 passed
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items; cargo test --doc -p decdn-client Streamer
  • INSTA_UPDATE=always cargo nextest run -p decdn-client --features public-api-test: snapshot gains StreamDrive::finish only
  • contracts/ changed: n/a
  • User-visible change: CHANGELOG.md entry added
  • Design change: n/a
  • PR title uses an allowed type with a lowercase subject

🤖 Generated with Claude Code

… 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]>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 18:36
@thiras thiras added kind:bug Something does not behave as documented rust Dependabot: a Cargo update; use area: labels for Rust code otherwise area:payments Pools, vouchers, redeem, reclaim, staking (incentive crate and chain) labels Oct 17, 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.

🟢 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::finish so 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

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main d24dd05 fix/late-build-escro... e6479e3 +/-
76% 76% 0%
View coverage of the 5 most impacted files.
File main d24dd05 fix/late-build-escro... e6479e3 +/-
crates/protocol/src/framing.rs 93% 92% -1%
crates/client/src/scheduler.rs 94% 94% 0%
crates/cache/src/engine.rs 91% 91% 0%
crates/client/src/streamer.rs 84% 84% 0%
crates/cli/src/...mmands/fetch.rs 50% 50% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@thiras
thiras merged commit c600cda into main Oct 17, 2026
32 checks passed
@thiras
thiras deleted the fix/late-build-escrow-2500 branch October 17, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:payments Pools, vouchers, redeem, reclaim, staking (incentive crate and chain) 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.

fix(client): a late lane build's untracked escrow is dropped at debug by drain_builds

2 participants