Repository navigation
fix(client): report an underpriced-replacement answer as possibly broadcast, not re-send - #2571
Merged
Merged
Conversation
…adcast, not re-send (#2565) `send_top_up` re-sent a `topUp` on a fresh nonce when the submit was answered `replacement transaction underpriced`. That answer speaks for one backend only: a load-balancing gateway that lost backend A's response and retried the signed bytes on B gets it while A's copy can still win the nonce, so the re-send at N+1 could escrow twice with the first `topUp` untracked. `send_broadcast_unknown` now reads the answer as uncertain, as it does `nonce too low` and `already known`. `topUp` fails with `TopUpUnconfirmed` at its nonce and `openPool` with `OpenUnconfirmed`, which the node settles against the chain; the collision re-send loop, its constants and `is_nonce_collision` are gone. A node whose seller redemption took the nonce resolves the settle as "escrowed nothing" and funds again on the next refill. Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The focused change preserves uncertain escrows for settlement, has regression coverage, and has no unresolved findings.
No open issues 🎉
What changed in this PR
Prevents duplicate payment-pool escrow when a gateway answers a submission with replacement transaction underpriced, addressing #2565.
Changes:
- Classifies underpriced replacements as possibly broadcast.
- Removes fresh-nonce top-up retries, retaining uncertain submissions for existing settlement.
- Updates regression tests and operational documentation.
| File | Description |
|---|---|
| docs/runbook.md | Documents additional unresolved top-up causes. |
| crates/incentive/src/tx/tests.rs | Tests uncertain classification and receipt outcomes. |
| crates/incentive/src/tx/send_leg/tests.rs | Updates underpriced-send expectations. |
| crates/incentive/src/tx.rs | Classifies underpriced replacements as uncertain. |
| crates/client/src/source_set.rs | Removes obsolete retry documentation. |
| crates/client/src/scheduler.rs | Updates drain documentation. |
| crates/client/src/funding.rs | Updates cancellation documentation. |
| crates/client/src/buyer_pool/tests.rs | Tests escrow retention, no retry, and cancellation. |
| crates/client/src/buyer_pool.rs | Removes collision retries while preserving escrow tracking. |
| CHANGELOG.md | Describes payment safety and cancellation behavior. |
| adr/appendix-observability.md | Updates unresolved-escrow gauge descriptions. |
Review effort: Balanced
… is described Every doc site that enumerated the answers `send_broadcast_unknown` reads as uncertain stopped at `already known` / `nonce too low`; some now stated the opposite of the code. Outer layers (`publish`, `pool`, the keeper, `source`) now point at the classifier instead of re-listing, and the `SendOutcome`, `send_for_receipt`, `open_pool`, `ensure_allowance` and `*Unconfirmed` docs name all three. The runtime comment that said a racing collision "gets a fresh nonce on the next attempt" now says an `openPool` or `topUp` is held at its nonce and settled. Tests: a bare `transaction underpriced` fee rejection stays a rejection; the open-pool underpriced test asserts the `RpcError` reason and the exact RPC consumption; the node settle has a composition test for a hashless `topUp` that waits out the colliding transaction and ends "escrowed nothing". 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.
What
Closes #2565
send_top_up(crates/client/src/buyer_pool.rs) re-sent atopUpon a fresh nonce when the submit was answeredreplacement transaction underpriced. That answer speaks for the answering backend only: a load-balancing gateway that lost backend A's response and retried the same signed bytes on B gets it while A's copy can still win nonce N. The re-send at N+1 then escrows twice and the firsttopUpis untracked.This is the issue's Option 1.
decdn_incentive::tx::send_broadcast_unknownnow readsreplacement transaction underpricedas uncertain, as it already doesnonce too low(#2563) andalready known(#2560). So:topUpfails withTopUpUnconfirmedat its nonce andopenPoolwithOpenUnconfirmed, both held inescrows. The node's existingsettle_unconfirmed_top_up/settle_unconfirmed_openresolve them against the chain:Pendingwaits, a spent nonce with no deposit growth ends as "escrowed nothing" and releases the slot, a vacant nonce re-sends at the same nonce.TOPUP_NONCE_RETRIES,TOPUP_NONCE_BACKOFF, theendedselect andis_nonce_collisionare deleted.refuse_after_end(ended)still gates the one send (fix(client): a drained lane build can still re-send a topUp, or wait on locks, after its fetch ended #2520).send_for_receiptreportsMaybeBroadcastfor the answer, sopool close/reclaim,publish, key rotation andapprovewarn that the tx may still mine, as they do fornonce too low.The classifier change is global rather than local to
send_top_upbecause the gateway-retry argument is the same foropenPool, which until now released its entry on this answer and let a later open escrow a second deposit.Reviewer notes
Read
send_broadcast_unknownincrates/incentive/src/tx.rsfirst, then the shortenedsend_top_up. Nothing incrates/nodechanges: the settle paths already handle a hashless entry.Accepted behaviour changes, the same ones #2563 accepted for
nonce too low:decdn_buyer_topup_unresolved= 1) until that redemption mines, about one 5 s settle tick, then funds again on the next low-water refill. Previously a 250 ms re-send. Arbitrum answers most such collisions withnonce too lowalready, so this path was rarely the one taken there.TopUpUnconfirmedisFault::Fatal, so a CLItopUpanswered underpriced ends the run naming the nonce instead of re-sending. The CLI has no chain settle; a named fatal beats an untracked double escrow.nonce too low.Tests:
an_open_pool_submit_answered_underpriced_stays_unconfirmedanda_top_up_submit_answered_underpriced_is_unconfirmed_not_re_sentfail onmain.a_top_up_after_the_fetch_ended_is_refused_before_its_sendreplaces the #2520 coverage the deleted backoff test gave. The incentive side gets a classifier test and asend_for_receipt→MaybeBroadcasttest.Mutation check: with the new
is_underpriced_replacementarm disabled, the two buyer_pool tests, the two new incentive tests anda_rejected_send_passes_through_unmarkedall fail (5/5).Second commit (review pass). Every doc site that enumerated the uncertain answers stopped at
already known/nonce too low, and some stated the opposite of the code:SendOutcomevariant docs, thesend_for_receiptcomment and its uncertainty text,open_pool,ensure_allowance,send_open_pool,send_top_up_at, theOpenUnconfirmed/TopUpUnconfirmeddocs, CLIpool.rssend_failedandTxUnconfirmed,publish.rsMaybeBroadcastvariants, the keeper module doc,source.rs, the runbook'sopenPoolparagraph anddocs/sponsord/operator.md. Outer layers now point atsend_broadcast_unknowninstead of re-listing. Theruntime/mod.rscomment that said a racing collision "gets a fresh nonce on the next attempt" now says anopenPool/topUpis held at its nonce and settled. Added tests: a baretransaction underpricedfee rejection stays a rejection (guards thereplacementprefix); the open-pool underpriced test asserts theRpcErrorreason and exact RPC consumption; the node settle has a composition test for a hashlesstopUpthat waits out the colliding transaction and ends "escrowed nothing" (a_hashless_top_up_waits_out_the_colliding_tx_then_escrowed_nothing).Follow-ups filed, not in this PR:
topUpat a vacant nonce (the node does), so an underpriced answer whose blocking transaction is later dropped holds refills until an operator sends self-transfers. Pre-existing for transport failures; this PR extends it to one more answer.*_unresolvedalert comment and panel description list only the transport and receipt causes.Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run --workspace --no-fail-fast— 5505 passed, 0 failed (first commit);-p decdn-incentive -p decdn-client -p decdn-cli -p sponsord-core2367 passed and-p decdn-node buyer_pool119 passed after the review passcargo nextest run -p decdn-client --features public-api-test public_api— snapshot unchangedCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemspre-commit run --files <changed>— all hooks pass;cargo denyreports the pre-existing rustls-webpki / webpki-roots emSign advisories (non-blocking, unrelated)contracts/changed: not applicableCHANGELOG.md— the buyer_pool: a gateway-retried openPool/topUp answerednonce too lowis treated as a foreign collision and double-escrows #2562 entry now covers both answers, the fix(client): a drained lane build can still re-send a topUp, or wait on locks, after its fetch ended #2520 entry no longer describes the backoffadr/appendix-observability.md*_unresolvedgauge rows anddocs/runbook.mdlist the new no-hash causefixand a lowercase subject🤖 Generated with Claude Code