Skip to content

fix(sponsord): re-send a hashless topUp once its nonce is vacant - #2573

Merged
thiras merged 5 commits into
mainfrom
fix/sponsord-batch
Oct 21, 2026
Merged

thiras merged 5 commits into
mainfrom
fix/sponsord-batch

Conversation

@thiras

@thiras thiras commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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 topUp whose 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. settle now 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-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 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 reverts PoolNotOpen ends the hold and counts as a failure; one answered as possibly broadcast (already known and 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's PoolChain abstraction so its tests stay scripted against FakePool.

  • 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 (test-support feature; additive).
  • keeper.rs module 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.md said 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 is ONRAMP_PUBLIC_URL on 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, PoolNotOpen ends 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: PoolNotOpen survives redaction.
  • Mutation checks, one at a time: pending <= nonce → pending < nonce fails 3 tests; dropping the PoolNotOpen re-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-review and 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

thiras and others added 2 commits October 21, 2026 05:08
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]>
Copilot AI balanced review requested due to automatic review settings October 21, 2026 02:10
@thiras thiras self-assigned this Oct 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 PoolNotOpen handling.
  • 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

@github-code-quality

github-code-quality Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 617a3bf fix/sponsord-batch 54287d0 +/-
77% 77% 0%
View coverage of the 4 most impacted files.
File main 617a3bf fix/sponsord-batch 54287d0 +/-
crates/sponsord...e/src/keeper.rs 97% 94% -3%
crates/cli/src/...ommands/node.rs 60% 59% -1%
crates/client/src/lib.rs 89% 89% 0%
crates/sponsord...ore/src/pool.rs 82% 83% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 21, 2026 02:57 UTC

thiras and others added 3 commits October 21, 2026 05:21
…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]>
@thiras
thiras merged commit f2c9082 into main Oct 21, 2026
34 checks passed
@thiras
thiras deleted the fix/sponsord-batch branch October 21, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sponsord: the keeper never re-sends a hashless topUp at a vacant nonce, so an underpriced answer can hold refills until an operator acts

2 participants