Repository navigation
fix: hold the open slot until an unconfirmed openPool resolves - #2419
Merged
Merged
Conversation
When the openPool receipt read failed, or its submit failed in
transport, run_open returned and freed the open slot. The next cache
miss re-checked only the local store and sent a second openPool while
the first could still mine, escrowing a second deposit.
open_pool now sends with an explicit pending nonce and, when the
outcome is unknown, returns OpenUnconfirmed { tx, nonce }. The node's
open task keeps the slot and polls the chain: a receipt yields the
pool (opened_from_receipt), a spent nonce asks getPools and adopts the
pool that appeared, and a nonce no transaction holds ends the open so
the next one is sent on that same nonce. The CLI treats
OpenUnconfirmed as fatal to the command, as it does TopUpUnconfirmed.
Closes #2415
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The vacancy check can release the slot while a higher-nonce open remains queued, allowing duplicate deposits.
3 open findings
What changed in this PR
This PR prevents duplicate openPool deposits by retaining the node’s open slot until an uncertain transaction resolves.
Changes:
- Adds nonce-aware
OpenUnconfirmederrors and receipt reconstruction. - Polls receipts/nonces and reconciles mined pools before releasing the slot.
- Adds client, node, and fault-classification coverage.
| File | Description |
|---|---|
CHANGELOG.md |
Documents the fix. |
crates/client/src/buyer_pool.rs |
Adds nonce tracking and unconfirmed-open handling. |
crates/client/src/buyer_pool/tests.rs |
Tests uncertain and rejected submissions. |
crates/client/src/fault.rs |
Makes uncertain opens fatal to CLI operations. |
crates/client/src/fault/tests.rs |
Tests fault classification. |
crates/client/tests/snapshots/public_api__public_api.snap |
Updates the public API snapshot. |
crates/cli/src/commands/fetch/adoption_tests.rs |
Updates RPC expectations for nonce reads. |
crates/node/src/buyer_pool.rs |
Holds the slot and reconciles uncertain opens. |
crates/node/src/buyer_pool/tests.rs |
Tests settlement and slot retention. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit b325190 in the Show a line coverage summary of the most impacted files.
Updated |
Review of #2419 found two paths that still released the open slot while the first openPool could mine: a "vacant" nonce read from one lagging backend, after which the next open read a later pending nonce; and a spent nonce answered "no new pool" by a getPools read on a backend behind the nonce read. - A vacant nonce now re-sends openPool at that same nonce (send_open_pool), so at most one of the two mines; the slot is released only on a receipt or a spent nonce. - A spent nonce is read at one block B, and getPools / getPool read at B (enumerate_owned_pools_at), so "adopted" and "holds no pool" answer about the same chain state. - reconcile_with_chain returns Adopted / KeptTracked / NoneHeld / Unknown / Unrecorded; only NoneHeld ends the open as "escrowed nothing", and an unrecordable pool fails as escrowed-but-untracked. A settle run meters no adoption failure and logs at debug. - While the slot is held, open_or_reuse_pool and open_replacement fail at once as a LocalPullFault, decdn_buyer_pool_open_unresolved reads 1, and a warning repeats every minute with the elapsed time. - Resolved errors drop the OpenUnconfirmed marker; the CLI message says what to wait for. Co-Authored-By: Claude Opus 5.5 <[email protected]>
open_or_reuse_pool and open_replacement share one unless_held select; open_pool builds its submit error the way top_up does; the #2415 tests share reply helpers; two test docs name the Reconciled answer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gauge Co-Authored-By: Claude Opus 5.5 <[email protected]>
Addresses the Copilot review on #2419: - A confirmed nonce below the open's now reads as Queued, not Vacant. The pending count stops at the first gap, so it cannot say whether a transaction waits at the open's nonce; re-sending into the gap does nothing. - A reconciliation that cannot answer doubles the wait before the next one, from 5 s up to 5 min, since each walks every pool the owner has opened. - Funder::recover documents OpenUnconfirmed for a transport-failed or receipt-less openPool. - The settle test helper runs under a paused-time bound, so a loop that never settles fails in seconds instead of timing out the test run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thiras
added a commit
that referenced
this pull request
Oct 12, 2026
* fix: warn when a failed pool send may have broadcast (#2416) A `closePool` or `reclaim` send that fails in transport may have reached the node and broadcast the tx with no hash returned. Route both sends through `send_failed`, which adds the #1577 warning when `send_broadcast_unknown` says the broadcast is unknown, and add a mocked-provider test pair per site. `open_pool` already carries `OpenUnconfirmed` for this case (#2419); its transport test now also asserts the rendered warning. Closes #2416 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: warn when a failed USDC approve send may have broadcast The `approve` in `ensure_allowance` was the last hand-rolled send in the pool flows without the #1577 classification. It now adds the same broadcast-unknown note as `closePool` / `reclaim`, with a mocked-provider test pair. Review follow-ups: state the `send_failed` doc in the classifier's terms, drop the ambiguous "warns" from the `# Errors` docs, and pin the transport tests to `eth_sendTransaction`. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- 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
run_openreturned on anopenPoolRpcErrorand freed the open slot. The next cache miss could then send a secondopenPoolwhile the first could still mine (#2415). Two cases lead there: a receipt read that fails after broadcast, and a submit that fails in transport with no hash.Invariant: the open slot is released only when a receipt is in hand, or the open's nonce is confirmed spent at a pinned block. No timer decides.
crates/client/src/buyer_pool.rs)open_poolreads the pending nonce and sendsopenPoolwith it, astop_updoes. When the outcome is unknown, the error carriesOpenUnconfirmed { tx: Option<TxHash>, nonce }.send_open_poolsends at a fixed nonce and returns the hash without waiting for a receipt.opened_from_receiptbuilds theOpenedPoolfrom a receipt read later.OpenUnconfirmedas fatal to the command, and its message says what to wait for.crates/node/src/buyer_pool.rs,settle_unconfirmed_open)Bpassing the open's runsreconcile_with_chainwithgetPools/getPoolpinned toB. Adopted means the pool is recorded;NoneHeldmeans it escrowed nothing;Unrecordedmeans escrowed but untracked;Queued), a failed read, a failed re-send, or a reconciliation that cannot answer all mean wait. A reconciliation that cannot answer backs the next one off from 5 s to 5 min.open_or_reuse_poolandopen_replacementfail at once asLocalPullFault;decdn_buyer_pool_open_unresolvedreads 1;reconcile_with_chainreturnsAdopted/KeptTracked/NoneHeld/Unknown/Unrecorded, and bootstrap logs which one.buyer_pool_adoption_failuresand logs atdebug.enumerate_owned_pools_atpins the enumeration to a block.Not covered
open_pool(Unbounded open_or_reuse_channel: a wedged on-chain RPC starves the candidate fallback loop #1143). If another tx from the same key takes the nonce first, that first receipt wait does not end.Test plan
getPoolsfault and an unreadable pool, with a backed-off tick that reads no pools;RpcErrorwith no marker;ContractRevert;LocalPullFault;Unknown;Reconciledvariant.Queuedcheck each fail a test. The settle test helper runs under a paused-time bound, so a loop that never settles fails in seconds. DroppingKeptTrackedfrom the settle match fails to compile.send_open_pool, and the fault classifier.cargo nextest run -p decdn-client -p decdn-node -p decdn-cli -p decdn-incentive: 3515 passed.cli_fetch_topup,pool_floor_ceiling_aggregate,node_to_node_coalesce,node_pull_pool_adopt,node_pull_pool_redeploy(9 passed).--all-targets --all-features -D warnings), rustdoc (-D warnings), fmt, and the regenerateddecdn-clientpublic-api snapshot..block(B)pinning and the explicit.nonce(n)on re-send. Both are visible in the code.Closes #2415
🤖 Generated with Claude Code