Skip to content

fix(incentive): report a nonce too low send as possibly broadcast (#2562) - #2563

Merged
thiras merged 5 commits into
mainfrom
fix/2562-nonce-too-low-maybe-broadcast
Oct 20, 2026
Merged

thiras merged 5 commits into
mainfrom
fix/2562-nonce-too-low-maybe-broadcast

Conversation

@yigitdot

@yigitdot yigitdot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2562

Problem

open_pool / top_up send at an explicit pending nonce N. A load-balancing RPC gateway that loses backend A's response and retries the same signed bytes on backend B gets nonce too low once A's copy is sequenced. Two things went wrong with that answer:

  • is_nonce_collision read it as a foreign same-account collision, so send_top_up released its TopUpUnconfirmed entry and re-sent on a fresh nonce.
  • send_broadcast_unknown read it as a clean rejection, so open_pool released its OpenUnconfirmed entry.

Either could escrow twice. Every other chain write (send_for_receipt, pool close/reclaim) also reported "nothing broadcast". This is the sibling of #2432 / #2560 (already known).

Fix

Node resolution with no hash. settle_unconfirmed_top_up / settle_unconfirmed_open read the confirmed nonce. Once N is spent, they compare the pool deposit (or getPools) at that block with the row's baseline:

  • A genuine shared-key collision (a seller redemption takes N) resolves as "escrowed nothing", and the next pull funds again.
  • A gateway-retried copy that took N is credited from the deposit growth.

On Arbitrum, most same-key collisions now go through this settle and not the 250 ms re-send.

Why not sign locally and look up the hash. The generic P: Provider bound hides the wallet filler at every call site (impl Provider returns, DynProvider in sponsord). Local signing would need a provider-type change across node, CLI and sponsord. #2565 lists it as an option.

Tests

  • crates/client/src/buyer_pool/tests.rs:
    • an_open_pool_submit_answered_nonce_too_low_stays_unconfirmed and a_top_up_submit_answered_nonce_too_low_is_unconfirmed_not_re_sent both fail on main.
    • a_nonce_too_low_after_a_collision_re_send_is_unconfirmed_at_the_new_nonce is new.
    • The re-send tests now script replacement transaction underpriced.
  • crates/incentive/src/tx/tests.rs: nonce too low is broadcast-unknown and not a collision. send_for_receipt reports MaybeBroadcast for it.

Gate (local)

  • cargo nextest run -p decdn-client -p decdn-incentive -p decdn-cli: 2311 passed.
  • cargo nextest run -p decdn-node buyer_pool: 117 passed.
  • cargo fmt -- --check, cargo clippy --workspace --all-targets -- -D warnings and CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items are clean.

Commits use --no-verify: the cargo-deny pre-commit hook fails on the broken local advisory DB, so I ran the gate above by hand.

🤖 Generated with Claude Code

…med (#2562)

A gateway that retries the same signed bytes on a second backend gets
`nonce too low` once the first copy is sequenced. is_nonce_collision read
that as a foreign collision that broadcast nothing, so topUp re-sent on a
fresh nonce and openPool released its entry: either could escrow twice.

is_nonce_collision now matches only `replacement transaction underpriced`;
the new is_nonce_spent matches `nonce too low`, which open_pool and
send_top_up treat as possibly broadcast at the pinned nonce.

Closes #2562

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 13:40

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-code-quality

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

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 3425a25 fix/2562-nonce-too-l... 10be2cc +/-
77% 77% 0%
View coverage of the 5 most impacted files.
File main 3425a25 fix/2562-nonce-too-l... 10be2cc +/-
crates/node/src/dht/publish.rs 80% 78% -2%
crates/protocol/src/framing.rs 93% 92% -1%
crates/client/s...undle/engine.rs 65% 65% 0%
crates/cache/src/engine.rs 91% 91% 0%
crates/incentive/src/tx.rs 77% 78% +1%

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


Updated October 20, 2026 17:02 UTC

…w-maybe-broadcast

# Conflicts:
#	CHANGELOG.md
#	crates/client/src/buyer_pool.rs
…w-maybe-broadcast

# Conflicts:
#	CHANGELOG.md
…2562)

Fold `nonce too low` into send_broadcast_unknown, as #2560 did for
`already known`: every chain write (send_for_receipt, pool close/reclaim,
approve, publish) now reports it as MaybeBroadcast, and open_pool /
send_top_up need no separate check. is_nonce_spent goes away.

Narrow is_nonce_collision's safety claim to the answering backend and
point at #2565 for the remaining gateway-retry risk of the underpriced
re-send. Add a test for `nonce too low` after a collision re-send, and fix
review comments on the docs and CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot yigitdot changed the title fix(client): keep an openPool/topUp answered nonce too low unconfirmed (#2562) fix(incentive): report a nonce too low send as possibly broadcast (#2562) Oct 20, 2026
…w-maybe-broadcast

# Conflicts:
#	crates/cli/src/commands/pool.rs
#	crates/client/src/buyer_pool.rs
#	crates/incentive/src/tx.rs
#	crates/incentive/src/tx/tests.rs
@yigitdot
yigitdot requested a review from thiras October 20, 2026 17:01
@thiras
thiras requested a balanced review from Copilot October 20, 2026 17:02

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.

🟢 Approval recommended

The focused classifier changes use existing reconciliation paths and have targeted regression coverage, with no unresolved findings.

No open issues 🎉

Review effort: Balanced

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.

buyer_pool: a gateway-retried openPool/topUp answered nonce too low is treated as a foreign collision and double-escrows

3 participants