Repository navigation
fix(node): stop a top-up for one pool from joining a topUp for another - #2498
Merged
Merged
Conversation
The top-up slot did not record which pool its topUp funds, so join_or_spawn_topup joined any topUp in flight. When the store replaced the pool while a topUp for the old one waited for its receipt, a recovery top-up for the new pool joined it, counted the old pool's escrow as its own headroom, and then failed as EscrowedUntracked. A fill could also wait on a sibling's recovery top-up for the old pool and take that pool's deposit as its own. InFlightTopUp now records its pool. join_or_spawn_topup refuses a caller for another pool with TopUpForOtherPool, marked LocalPullFault, so a recovery step fails at once and a low-water refill skips. recovery_in_flight only hands a fill a sibling's top-up for the same pool. The settle hold check still runs first, so a settling topUp still answers TopUpHeld. Closes #2496 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0123DU1V2G3UnrwF2o9g4XHa
TopUpForOtherPool now carries the caller's pool and the slot's pool, so the recovery step's warning names both: the only other line that did was a debug!. The docs that said a refill or recovery joins any in-flight topUp now say the same pool, and the join_or_spawn_topup and top_up_pool_by Errors no longer assume the slot's pool is the stale one. The recovery-step-refused metric doc lists the new cause. A test assertion on an empty mock queue that could not fail now checks that no replacement open began. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0123DU1V2G3UnrwF2o9g4XHa
There was a problem hiding this comment.
🟢 Approval recommended
The focused guards preserve same-pool behavior, and regression tests cover both cross-pool recovery paths with no unresolved findings.
No open issues 🎉
What changed in this PR
Prevents node funding recovery from joining a top-up for the wrong pool while preserving the single-wallet transaction slot.
Changes:
- Records pool identity and rejects cross-pool joins without changing slot ownership or claims.
- Restricts sibling recovery waits to the same pool.
- Adds regression tests and updates funding documentation.
| File | Description |
|---|---|
| crates/node/src/metrics.rs | Documents cross-pool recovery refusals. |
| crates/node/src/buyer_pool/tests.rs | Tests immediate refusal and preservation of the existing slot. |
| crates/node/src/buyer_pool.rs | Adds pool-aware join and recovery guards. |
| CHANGELOG.md | Describes the cross-pool funding fix. |
Review effort: Balanced
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
The node's single top-up slot did not record which pool its
topUpfunds, sojoin_or_spawn_topup(pool_id, ..)joined atopUpfor any pool.#2497 already refuses a recovery while a settle holds the slot. The window it leaves open is the normal receipt wait (up to
RECEIPT_TIMEOUT). If the store replaced the pool in that window:topUpand claimed its refill amount as headroom. When thattopUpescrowed, the credit found the row replaced, and the recovery failed asEscrowedUntracked, which is final.topUprevertedPoolNotOpen, calledreplace_poolon the new pool, which was still open.The fix (option 1 from the issue):
InFlightTopUprecords itspool_id.join_or_spawn_topupreturnsResult. A caller for another pool getsTopUpForOtherPool { pool_id, in_flight }, markedLocalPullFault, and the slot is untouched. A recovery step fails at once, andNodeFundermeters it ondecdn_node_pull_recovery_step_refused_total. A low-water refill skips.recovery_in_flight(pool_id)hands a fill only a sibling's recovery for the same pool.top_up_pool_bystill runs first, so a settlingtopUpfor any pool still answersTopUpHeld.topUp, so a secondtopUpbeside it could not mine before the first one's nonce is spent.Docs that said a refill or recovery joins any in-flight
topUpnow say "the same pool". The metric doc lists the new refusal cause. The CHANGELOG has a Fixed entry.Tests
New tests in
buyer_pool/tests.rs. Each puts a never-resolvingtopUpfor another pool in the slot:a_recovery_does_not_join_a_top_up_for_another_pool:top_up_pool_byfails on its first poll withTopUpForOtherPool, which names both pools, plusLocalPullFault. The slot keeps the old pool's entry, and itsunclaimedstays at the refill's full amount.a_fill_does_not_wait_on_a_siblings_recovery_for_another_pool:recover_poolreturns at once with the same error, and no replacement open begins.Mutation checks by hand: removing the pool check in
join_or_spawn_topupfails both tests, and removing therecovery_in_flightfilter fails the second. There is no refill test, because a refill join claims nothing, so it would pass with or without the guard.cargo nextest run -p decdn-node --all-features: 1690 passed. Workspace clippy--all-features -D warnings,cargo docwith warnings denied,cargo fmt --checkand pre-commit are green.Not in this PR
LocalPullFaultis added twice on the recovery path, once inbuyer_pooland once infunder.rs, so the warning repeats "local buyer-side fault".TopUpHeldonmaindoes the same.fund_poolhave no time limit, so a hung call holds the slot with no gauge set. That predates this branch. It is now more visible, because recovery fails at once with a warning instead of hanging.Closes #2496
🤖 Generated with Claude Code
https://claude.ai/code/session_0123DU1V2G3UnrwF2o9g4XHa