Repository navigation
fix(client,cli)!: escrow and drain follow-ups (#2508, #2513, #2515, #2517) - #2523
Merged
Merged
Conversation
The acquire loop returned on the first fatal result in a batch of ready lane builds and dropped the rest. Those builds were already out of `connecting`, so the drain never saw an escrow among them. Each one is now folded into the error the fetch ends with, as the drain folds a late build's, with the escrow as the root. Closes #2508 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ch ended A lane build still in flight as a fetch ended could reach its refill in the drain and send a recorded topUp, or open a pool, for a lane that never runs. Each acquire (and first open) now hands its builds a token it cancels as its drain starts. A build that reaches its openPool or topUp afterwards refuses with FetchEnded, which the drain logs at debug; a build already past its send runs to its receipt. The token is per acquire, since one LaneSources serves the first open, the acquire, and a hash-mismatch refetch. Closes #2513 Co-Authored-By: Claude Opus 5.5 <[email protected]>
open_pool and top_up released a mined transaction from the UnconfirmedEscrows handle as soon as they read its receipt, before the caller's synchronous record write. A second Ctrl-C (process::exit) during that write named no escrow, and a re-run escrowed again. Both now return an UnrecordedEscrow beside the outcome. The handle keeps the transaction pending until the caller resolves it: recorded() once the write commits, or untracked(err) once it fails, which holds the escrow as untracked before it releases the pending entry, so the handle names the tx at every moment. open_pool holds an open with no PoolOpened event itself. RunFunding::note_untracked is gone; every site resolves through the guard. decdn pool open / top-up hold their failures on the handle too. BREAKING CHANGE: buyer_pool::open_pool and buyer_pool::top_up return (OpenedPool, UnrecordedEscrow) and (ToppedUpPool, UnrecordedEscrow). Closes #2515 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…entries and pending escrows Three gaps at the end of a pull one entry ended: - The replacement came only from the pull's stop, so a sibling's replacement during the drain, or one a late escrow folded over, went unreported and the CLI printed no reclaim note. The pull now reports the replacement the recovery gate holds (RecoveryGate::replaced), ignoring one carried from before the pull. Only a replacement that ended the first pass runs the rest again or calls observer.pool_replaced. - BundleReport::not_run counts the entries the pull did not run, including groups it never settled, so the counts add up; the CLI summary and --json show it. - pull_end folds the handle's pending escrows into a non-interrupted end, as it folds untracked ones, so a BundlePuller caller hears of an entry dropped mid receipt read. The CLI dedupes pending escrows the error already names as text. Closes #2517 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- UnrecordedEscrow::untracked keeps the transaction pending unless the handle holds the error's escrow, so a non-EscrowUntracked error cannot leave a tx named nowhere. A private release() covers a reverted receipt in open_pool and top_up. - A bundle pull clears a replacement the gate holds from before it, so a later pull on the same puller runs no extra pass and reports it again. pass_replacement returns a PassReplacement enum, and every group starts not run, which drops fill_not_run. - Pending escrows read "was broadcast and no local record credits it", true before and after the receipt read; the docs that said "receipt not read" now say what the pending list holds since #2515. The fetch end docs say a build already inside its openPool or topUp call runs to its receipt. - Tests: the second fetch-end check (after the allowance leg) for a refill and an open, via a new ScriptedRpc::after_calls hook; first open's fetch end; an unheld record error keeps the escrow pending. - CHANGELOG: name `decdn get` (there is no `decdn bundle pull`), reflow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Reusing a puller after a replacement retains stale funding state and can unnecessarily fund another pool.
1 open issue
What changed in this PR
Improves escrow tracking and shutdown handling in the shared client and CLI, addressing four follow-ups from the escrow and drain series.
Changes:
- Preserves escrow reporting across fatal build batches and local record writes.
- Prevents ended fetches from starting new funding calls.
- Reports pending escrows, pool replacements, and unrun bundle entries.
| File | Description |
|---|---|
| crates/node/src/buyer_pool.rs | Adapts funding callers to tuple returns. |
| crates/incentive/src/test_rpc.rs | Adds a scripted-call completion hook. |
| crates/e2e/tests/pool_floor_ceiling_aggregate.rs | Updates pool-open return handling. |
| crates/e2e/tests/cli_fetch_topup.rs | Updates funding return handling. |
| crates/e2e/src/client.rs | Adapts fixture pool opening. |
| crates/client/tests/snapshots/public_api__public_api.snap | Records public API changes. |
| crates/client/src/streamer/tests.rs | Forwards fetch cancellation tokens. |
| crates/client/src/source_set/tests.rs | Updates the mock provider signature. |
| crates/client/src/source_set.rs | Adds cancellation tokens to lane builds. |
| crates/client/src/scheduler/tests.rs | Tests batch escrow reporting and cancellation. |
| crates/client/src/scheduler.rs | Cancels ended builds and preserves batch escrows. |
| crates/client/src/recovery/tests.rs | Tests replacement visibility. |
| crates/client/src/recovery.rs | Exposes the current replacement internally. |
| crates/client/src/lib.rs | Documents escrow guard handling. |
| crates/client/src/lanes.rs | Passes cancellation into funding setup. |
| crates/client/src/lane_sources.rs | Propagates fetch cancellation tokens. |
| crates/client/src/funding/adoption_tests.rs | Tests cancellation and record-write escrow visibility. |
| crates/client/src/funding.rs | Guards funding calls and resolves recorded escrows. |
| crates/client/src/first_open/tests.rs | Tests cancellation during build draining. |
| crates/client/src/first_open.rs | Cancels builds before draining. |
| crates/client/src/fault/tests.rs | Updates untracked-escrow setup. |
| crates/client/src/fault.rs | Shares escrow error folding. |
| crates/client/src/buyer_pool/tests.rs | Tests escrow guard lifecycle. |
| crates/client/src/buyer_pool.rs | Keeps escrows pending until records resolve. |
| crates/client/src/bundle/engine/tests.rs | Tests replacements, pending escrows, and unrun counts. |
| crates/client/src/bundle/engine.rs | Updates replacement handling and final reporting. |
| crates/client/src/bundle.rs | Adds unrun counts and documents outcomes. |
| crates/client/examples/common/mod.rs | Updates example pool opening. |
| crates/cli/src/commands/pool.rs | Resolves escrow guards after store writes. |
| crates/cli/src/commands/interrupt/tests.rs | Tests duplicate escrow suppression. |
| crates/cli/src/commands/interrupt.rs | Recognizes escrows already named in errors. |
| crates/cli/src/commands/fetch.rs | Updates escrow lifecycle comments. |
| crates/cli/src/commands/bundle_pull/tests.rs | Tests unrun summary and JSON output. |
| crates/cli/src/commands/bundle_pull.rs | Includes unrun entries in reports. |
| CHANGELOG.md | Documents fixes and breaking API changes. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Clearing a replacement the gate held from before a pull kept the pull's RunFunding, whose pool (a OnceLock, set by the first lane) was the closed one. The next recovery step topped that pool up, hit PoolNotOpen, and opened yet another pool instead of funding the one the lanes reuse. The pull now starts as a pass against the new pool: fresh ledgers and funding facts on the same escrow handle, as the rerun branch does, through one start_pass_on_new_pool helper; paid_before is read after the reset. Co-Authored-By: Claude Opus 5.5 <[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
This PR closes the four open follow-ups from the #2500–#2518 escrow and drain series, one commit each, plus a commit with the review fixes.
[disk fault, EscrowUntracked]case from the issue comment is covered.fault::fold_escrow, shared withrun_groups.openPoolortopUpafter its fetch ended.SourceProvider::connecttakes anended: &CancellationToken.acquireandfirst_opencreate one token per acquire and cancel it as their drain starts.escrow_top_upand the fresh-open path check the token before the allowance leg and again before the call. A build that has ended fails withFetchEnded, which is logged at debug and makes no wallet read.openPoolortopUpcall runs to its receipt.LaneSources, because oneLaneSourcesserves the first open, the acquire, and a re-fetch after a hash mismatch.decdn-client).open_poolandtop_upnow return anUnrecordedEscrowbeside the outcome. The handle keeps the transaction pending until the caller callsrecorded()oruntracked(err).untracked(err)holds the escrow as untracked before it releases the pending entry, so a second Ctrl-C during the record fsync still names the tx. An error that is not anEscrowUntrackedkeeps the entry pending.RunFunding::note_untrackedis gone.decdn pool openanddecdn pool top-uphold their failures on the handle too.RecoveryGate::replaced,PassReplacement). Only a replacement that ended the first pass runs the rest again.BundleReport::not_runmakes the counts add up. The CLI summary and--jsonshow it.pull_endfolds pending escrows into the end of a pull that was not interrupted. The CLI no longer names a pending escrow twice when the error already names it in its text.The review commit also adds
ScriptedRpc::after_calls(decdn-incentive test util). It is a hook that runs as the last scriptedeth_callis answered, so a test can end the fetch between the allowance read and the send.Closes #2508
Closes #2513
Closes #2515
Closes #2517
Follow-ups filed
decdn getpath and a second-pass replacement.topUpafter a nonce collision, and it waits on the open and top-up locks before it sees that the fetch ended.pool openandpool top-upkeep the escrow named during the record write.decdn bundle pullname throughout the CHANGELOG.Test plan
cargo nextest run -p decdn-client -p decdn-cli -p decdn-node -p decdn-incentive: 3873 passedcargo clippy --workspace --all-targets --all-features -- -D warningsCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemsUnrecordedEscrow, theopen_pool/top_upreturn types andBundleReport::not_run.ended.cancel()FetchEndedshort-circuit inrefill_if_lowcli_fetch_topupandpool_floor_ceiling_aggregate: 4 passed (these drive theopen_pool/top_upcallers that changed). They ran on the four fix commits, before the review commit.🤖 Generated with Claude Code