Repository navigation
fix(client): let sibling bundle entries finish their lane-build drain - #2518
Merged
Merged
Conversation
When one entry ended a bundle pull, run_groups dropped every other entry's fetch where it stood. An entry in the middle of a topUp or openPool lane build lost it before the receipt read and the local record, which left a tx to reconcile by hand. first_open dropped an in-flight lane build and a recovery step on a give-up the same way. The pull now halts the other entries through a per-pass halt on StopPolicy. Each stops at its next wait or loop pass, starts no new lane build or recovery step, and drains its builds (30 s); run_groups waits up to 40 s for them all. A build that may have escrowed USDC no record credits wins over the stop, so a give-up does not exit 75. Halted entries are NotRun: not counted, not recorded, and a pass merge keeps their earlier outcome. A pass that ends on a halt it did not set fails instead of ending complete. Closes #2509 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Dropping a draining pull leaves a stale halt that can break subsequent manifest fetches on the same puller.
1 open issue
What changed in this PR
This PR lets stopped bundle pulls drain sibling lane builds, reducing interrupted funding transactions and preserving late escrow errors.
Changes:
- Adds per-pass halting and bounded sibling draining.
- Makes initial opens drain builds and finish recovery steps.
- Adds halted-entry handling and regression tests.
| File | Description |
|---|---|
| crates/client/src/stop/tests.rs | Tests halt isolation between passes. |
| crates/client/src/stop.rs | Adds shared per-pass halt state. |
| crates/client/src/scheduler/tests.rs | Tests halting and build draining. |
| crates/client/src/scheduler.rs | Handles halts and shares drain helpers. |
| crates/client/src/first_open/tests.rs | Tests stops during builds and recovery. |
| crates/client/src/first_open.rs | Drains builds before returning. |
| crates/client/src/fault.rs | Detects wrapped escrow errors. |
| crates/client/src/bundle/engine/tests.rs | Tests sibling draining and outcome handling. |
| crates/client/src/bundle/engine.rs | Coordinates halting, draining, and pass outcomes. |
| CHANGELOG.md | Documents changed stop behavior. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 9 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
A caller that drops BundlePuller::pull during the sibling drain leaves the pull's halt set: the re-arm after the pass never runs. A later fetch_manifest on the same puller went through acquire_entry on that policy and failed at once with Halted, since it never reaches run. acquire_entry and fetch_to_staging now take the stop policy. An entry passes the pull's own policy, which a sibling halts; a manifest passes an unhalted copy on the same progress clock. Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 tasks done
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 one entry ended a bundle pull (a give-up, a pool replacement, a fault that stops every entry),
run_groupsdropped every other entry's fetch where it stood. An entry in the middle of atopUporopenPoollane build lost it before the receipt read and the local record. #2516 names such a tx at the end of the command; this PR stops dropping the build in the first place.first_openhad the same shape: its give-up dropped an in-flight lane build and a recovery step.StopPolicy. A privateCancellationToken(halt,is_halted,ensure_running,halted,next_pass) and a crate-privateHaltederror.PullCtx::runclears it as each pass starts and ends, so it reaches neither the next pass, nor a later manifest fetch or pull of the same puller.run_groupshalts and waits. On the first fault that ends the pull, it starts no further item, callshalt, and keeps settling items for up toGROUP_DRAIN(40 s =BUILD_DRAIN+ 10 s). A later fault that may have escrowed USDC no record credits (carries_untracked_escrow, which sees throughLaneBuildFault) is folded in withfold_late_escrow: the escrow wins, so a give-up does not exit 75. Every other later fault is logged at WARN and dropped. An item still running at the bound is dropped as before, with a WARN that counts them.acquirestops at its loop top (ensure_running) and in itsselect!(halted), so it starts no lane build after the halt, and checks again right before a funding recovery step. Its existing tail drains the builds.first_opentakes the stop into its loop'sselect!. A recovery step runs to its outcome, and the build in flight drains through the shareddrain_builds/fold_late_escrow(now generic andpub(crate)).EntryOutcome::NotRun. The summary does not count them, the skip-cache does not record them, andmerge_passeskeeps an entry's first-pass outcome when the second pass did not run it. A pass that ends with no fault on a halt it did not set fails (pass_stop) instead of ending complete with nothing pulled.Closes #2509
Reviewer notes
run_groups,pass_stopandPullCtx::runincrates/client/src/bundle/engine.rs;StopPolicyincrates/client/src/stop.rs;first_open/open_loopincrates/client/src/first_open.rs.StopPolicygains a private field, so it can no longer be built with a struct literal outside the crate; every caller usesStopPolicy::new. The decdn-client public-api snapshot is unchanged.first_opencan land after its limit while a recovery step finishes.GROUP_DRAINis shorter thanRECEIPT_TIMEOUT, so a slow recovery step can still be dropped mid-receipt. The CLI names its pending tx, butpull_enddoes not fold it for library callers.topUpif that step failed and a byte was verified in between. Closing it means changing theRecoveryGate::stepsignature, which the node also uses.bundle/engine/tests.rs:NotRunoutcomes and the merge;scheduler/tests.rs: a halt awaits the build in flight and its escrow wins; a pre-set halt starts no build.first_open/tests.rs:stop/tests.rs:next_pass.select!arms inacquireandfirst_open, the escrow fold,take_while, theLaneBuildFaultlook-through, theNotRunmapping and merge arm, andpass_stop.acquire, which guards a timing window, and the re-arm calls inPullCtx::run, which have no harness.pass_stopmakes a regression there loud.Verification
cargo fmt -- --checkCARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features(run as-- -D warnings)cargo nextest run --workspace: 5135 passed. One flaky retry,decdn-node::client_loopback a_closing_pool_is_unfunded_to_its_lane_and_not_found_to_anyone_else("both refusals must count as pool_closing"). It passed 8 of 8 runs on its own and does not touch the changed code.CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemscargo nextest run -p decdn-client --features public-api-test --test public_api): unchangedcontracts/changed: n/aCHANGELOG.mdentry added🤖 Generated with Claude Code