Repository navigation
fix(sponsord): re-send a hashless topUp once its nonce is vacant - #2573
Merged
Merged
Conversation
The keeper held further top-ups for a `topUp` whose submit returned no tx hash until the treasury's confirmed nonce passed the nonce it was sent with. When the transaction was never broadcast, or was dropped, nothing fills that nonce, so the hold lasted until an operator sent 0-value self-transfers, and the pool could drain meanwhile. `settle` now reads the pending nonce too for a hashless hold. When the confirmed and pending nonces both equal the top-up's nonce, no transaction holds it, so the keeper re-sends `topUp` at that nonce through `decdn_client::buyer_pool::send_top_up_at`, records the hash on the hold, and settles it by that receipt. Two transactions at one nonce cannot both mine, so the re-send cannot escrow twice. A re-send that reverts `PoolNotOpen` ends the hold; any other failure waits for the next sweep. This is the node daemon's vacant-nonce rule. `PoolChain` gains `pending_nonce` and `send_top_up_at`; `ChainPool` re-attaches the `PoolNotOpen` marker through its redaction. `FakePool` scripts the pending count and the re-send's outcome. Closes #2572 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…s hold The archived decdn/sponsord repository's issues 22 to 26 were deleted after their migration here, so the docs' links to them resolved to nothing. They now point at #2546 to #2550. Bare `(#38)` and `(#40)` references in the sponsord crates named issues of that repository; they now say so, since the same numbers name unrelated issues here. security.md said a top-up whose response was lost is not held. The keeper holds it, and re-sends it once its nonce is vacant. Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Treasury transaction recovery needs human confirmation of RPC and nonce-race behavior before approval.
No open issues 🎉
What changed in this PR
Fixes sponsord’s stalled refill recovery for #2572 by re-sending hashless top-ups at a vacant nonce.
Changes:
- Adds pending-nonce checks, same-nonce retries, and
PoolNotOpenhandling. - Extends test helpers and regression coverage for retries, settlement, races, and redaction.
- Updates recovery guidance and corrects issue references.
| File | Description |
|---|---|
| docs/sponsord/security.md | Clarifies hashless holds and restart risks. |
| docs/sponsord/operator.md | Documents automatic retries and manual recovery. |
| docs/sponsord/integrator.md | Corrects migrated issue links. |
| crates/sponsord/tests/startup_redacts_rpc_url.rs | Clarifies an issue reference in comments. |
| crates/sponsord/tests/api.rs | Clarifies an issue reference in comments. |
| crates/sponsord/src/main.rs | Clarifies issue references in comments. |
| crates/sponsord/src/config/tests.rs | Clarifies an issue reference in comments. |
| crates/sponsord-core/src/test_support.rs | Adds scripted pending nonces and retry outcomes. |
| crates/sponsord-core/src/sponsor.rs | Clarifies an issue reference in comments. |
| crates/sponsord-core/src/pool/tests.rs | Tests retry error redaction and marker preservation. |
| crates/sponsord-core/src/pool.rs | Exposes pending-nonce reads and same-nonce sends. |
| crates/sponsord-core/src/keeper/tests.rs | Covers retry, settlement, and nonce-race behavior. |
| crates/sponsord-core/src/keeper.rs | Implements vacant-nonce recovery for hashless top-ups. |
| CHANGELOG.md | Records the recovery fix. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 4 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
…same rule A held `topUp` whose hash the RPC node does not know stood where a hashless one did: its hold lasted until the nonce was used, so a re-send the node dropped in turn was held for an operator. The vacancy rule now covers both: when the node shows no transaction of the top-up and its nonce is next with nothing holding it, the keeper re-sends. The pending nonce is read only then; a queued top-up (an earlier nonce unfilled) gets its own log line instead of sharing the mempool-held one. A re-send that reverts `PoolNotOpen` counts as a failure, as the same revert on the first send does. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…nce remedy A re-send replaced the hold's hash, so a first send that mined after it went uncounted and the log named a hash that never mined. The hold keeps the earlier hashes, and a used nonce is checked against each before the top-up counts as unknown. The operator remedy for a held nonce said to send 0-value self-transfers; those take the pending nonce and queue behind the stuck transaction. The logs and the operator guide now say to replace it at that nonce with a higher fee, and the queued case says which nonces to fill. A re-send answered as possibly broadcast is told from a rejection (`ChainPool` attaches `TopUpUnconfirmed`), an allowance shortfall names its remedy, and every other re-send failure logs at error with the hold's age and what to check. The pending-nonce read failure has its own line, and `FakePool` can fail it alone. Co-Authored-By: Claude Fable 5.1 <[email protected]>
`KeeperStatus::record_topup` replaces the three copies of the counter and timestamp update; `Unconfirmed::record_resend` keeps the earlier hash cap beside the field it bounds. `FakePool::fail_resends` takes a `ResendFailure` in place of four switches that were never combined. Co-Authored-By: Claude Fable 5.1 <[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
Batch of sponsord fixes (the open
sponsord-labelled issues that are bugs or stale, not features).#2572, keeper re-send at a vacant nonce. The keeper held further top-ups for a
topUpwhose submit returned no tx hash until the treasury's confirmed nonce passed the nonce it was sent with. When that transaction was never broadcast or was dropped, nothing fills the nonce, so the hold lasted until an operator sent 0-value self-transfers, and the pool could drain meanwhile.settlenow reads the pending nonce for a top-up the node shows no transaction of (no hash, or a hash the node does not know); when the confirmed and pending nonces both equal the top-up's nonce, no transaction holds it, so the keeper re-sendstopUpat that nonce throughdecdn_client::buyer_pool::send_top_up_at, records the hash on the hold, and settles it by that receipt. Two transactions at one nonce cannot both mine, so the re-send cannot escrow twice. A re-send the node drops in turn is re-sent again; the hold keeps the earlier hashes, so a first send that mines after a re-send is still counted. A re-send that revertsPoolNotOpenends the hold and counts as a failure; one answered as possibly broadcast (already knownand friends) is held by its nonce like a first send; an allowance shortfall and any other failure log at error with the remedy and retry next sweep. A queued top-up (an earlier nonce unfilled) is held with its own log line. The operator remedy for a transaction stuck at the nonce is a same-nonce higher-fee replacement, since a plain self-transfer queues behind it. This mirrors the node daemon's vacant-nonce rule (resolve_unconfirmed_tx/TopUpSettling::resend), applied over the keeper'sPoolChainabstraction so its tests stay scripted againstFakePool.PoolChaingainspending_nonceandsend_top_up_at;ChainPoolre-attaches thePoolNotOpenmarker through its redaction.FakePoolscripts the pending count and the re-send's outcome (test-supportfeature; additive).keeper.rsmodule doc,docs/sponsord/operator.md§ 5 and the CHANGELOG describe the re-send and when self-transfers are still the remedy.Docs. The archived decdn/sponsord repository's issues 22 to 26 were deleted after migration, so five links in
docs/sponsord/resolved to nothing; they now point at #2546 to #2550. Bare(#38)/(#40)comments in the sponsord crates named that repository's issues and now say so.security.mdsaid a lost-response top-up is not held; the keeper holds it and re-sends it.Closed separately as stale, not by this PR: #2551 (the reclaim sweep and channel store left in the move to the shared
PaymentPool) and #2552 (the setting isONRAMP_PUBLIC_URLon both the decdn and devops sides).Closes #2572
Test plan
cargo nextest run -p sponsord-core: 46 passed. New keeper tests: re-send once vacant and clear on receipt (the issue's done-when), held while the mempool holds a transaction at the nonce, a known-but-unknown-to-the-node hash is re-sent under the same rule, a dropped re-send is re-sent again,PoolNotOpenends the hold, failed re-send keeps the hold and retries, queued nonce is not re-sent, a mine between the two reads is not re-sent, a pending-nonce read failure keeps the hold, a first send that mines after a re-send is counted, a possibly-broadcast re-send answer keeps a hashless hold, an allowance-short re-send names its remedy. New pool test:PoolNotOpensurvives redaction.pending <= nonce→pending < noncefails 3 tests; dropping thePoolNotOpenre-attach fails the redaction test; excluding the known-hash case from the vacancy rule fails 3; ignoring the earlier hashes on a used nonce fails 1.cargo nextest run -p sponsord -p sponsord-e2e: 28 passed./code-reviewand the pr-review-toolkit agents (code, tests, comments, silent failures) ran on the PR; their findings are addressed in the later commits.cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo fmt -- --check,CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items, pre-commit hooks on both commits.🤖 Generated with Claude Code