Skip to content

fix(cli,client,node)!: bound receipt waits so a dropped tx cannot hang - #2490

Merged
thiras merged 3 commits into
mainfrom
fix/bound-cli-receipt-waits
Oct 17, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/bound-cli-receipt-waits

Conversation

@thiras

@thiras thiras commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What

alloy's get_receipt() has no timeout. A transaction dropped from the mempool hung the CLI command that sent it. Under pool close --all / reclaim --all it also blocked every later pool, so the summary never printed. On the node, a dropped openPool held the open slot forever.

Every CLI receipt wait and the node's openPool wait now lapse after RECEIPT_TIMEOUT (3 min). A lapse ends in the existing "unconfirmed" outcome, keeps the tx hash, and warns that the tx may still mine.

  • decdn-incentive: RECEIPT_TIMEOUT and await_receipt, a tokio::time::timeout wrapper (alloy's with_timeout checks a std Instant, so it never fires under a paused clock). send / send_for_receipt use it, which covers register, deregister, bond, unbond, appeal, publish and the other plain-send commands.
  • CLI: pool close / reclaim (and their --all sweeps) bound their waits and count a lapse as unconfirmed; pool open / top-up pass the bound.
  • decdn-client (BREAKING): open_pool and top_up take receipt_timeout: Option<Duration>. open_pool refuses a second open while the run's UnconfirmedOpens holds one, so a lapsed decdn get cannot escrow twice. Likewise, the run sends one topUp at a time (escrow_top_up holds a run-wide lock in RunFunding from its check to its outcome, since a refill under open_lock and a recovery step under the step lock do not exclude each other), and after one goes unconfirmed every later refill or recovery step in the run refuses with it. The approve wait uses the shared bound.
  • Node: openPool is bounded; a lapse goes to settle_unconfirmed_open, which holds the slot and re-sends a dropped open at the same nonce. top_up stays unbounded (None) because its task holds the top-up slot and nothing yet settles an unconfirmed topUp. That gap is fix(node): settle an unconfirmed topUp instead of freeing the top-up slot #2489.
  • Tests: decdn-incentive's test-util gains ScriptedRpc, a transport that parks a receipt wait, used by paused-clock tests in incentive, client, cli and node. Each bounded-wait test was mutation-checked by swapping its bound out.

Closes #2433

Reviewer notes

  • Start at crates/incentive/src/tx.rs (await_receipt), then crates/client/src/buyer_pool.rs (open_pool guard and the receipt-bound doc section).
  • The node's top_up: None is deliberate; a_top_up_that_never_mines_keeps_the_top_up_slot pins it.
  • Not pinned by a test: the funding recover top-up and open_replacement sites, and the CLI pool open / top-up command sites (each passes Some(RECEIPT_TIMEOUT)).
  • A topUp that may still mine is refused within the run but not yet named on exit (give-up, Ctrl-C, a dropped sibling, drain_builds) the way a pending open is. That gap predates this PR and is fix(cli): name a topUp that may still mine on every decdn get exit #2491.
  • sponsord calls open_pool (tests) and top_up (sponsord-core/src/pool.rs); its next decdn bump needs the new argument, and its keeper should choose the bound the way the node does.

Verification

  • cargo fmt -- --check
  • CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features
  • cargo nextest run -p decdn-incentive -p decdn-client -p decdn-cli -p decdn-node -p decdn-common: 4219 passed
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items (plus incentive --features test-util)
  • decdn-client public-API snapshot regenerated
  • pre-commit run on every changed file
  • User-visible change: CHANGELOG.md entry added
  • PR title uses an allowed type with a lowercase subject

🤖 Generated with Claude Code

alloy's get_receipt() has no timeout, so a transaction dropped from the
mempool left the waiting command (or the node's open slot) blocked forever.

- decdn-incentive: RECEIPT_TIMEOUT (3 min) and await_receipt, a
  tokio::time::timeout wrapper; send/send_for_receipt use it, and a lapse
  reports InFlight with the tx hash and a "may still mine" warning.
- CLI: pool close/reclaim (and --all sweeps) bound their waits and count a
  lapse as unconfirmed; pool open/top-up pass the bound.
- decdn-client: open_pool and top_up take a receipt_timeout; open_pool
  refuses a second open while UnconfirmedOpens holds one; the approve wait
  uses the shared bound.
- Node: openPool is bounded and a lapse settles through
  settle_unconfirmed_open, which re-sends a dropped open; top_up stays
  unbounded because its task holds the top-up slot (#2489).
- decdn-incentive test-util: ScriptedRpc, a transport that parks a receipt
  wait, for paused-clock tests across incentive, client, cli and node.

Closes #2433

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 22:00
@thiras thiras self-assigned this Oct 16, 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.

🟡 Changes recommended

A timed-out refill can allow a concurrent bundle entry to submit another top-up before the fatal error stops the run.

1 open issue
What changed in this PR

Bounds receipt waits so dropped transactions cannot indefinitely stall CLI commands or node pool opening.

Changes:

  • Adds a shared three-minute timeout while preserving transaction hashes and unconfirmed outcomes.
  • Updates client APIs and callers; deliberately leaves node top-ups unbounded pending #2489.
  • Adds paused-clock regression tests and updates documentation.
File Description
crates/​node/​src/​runtime/​mod.rs Updates timeout comments.
crates/​node/​src/​buyer_pool/​tests.rs Tests open and top-up wait behavior.
crates/​node/​src/​buyer_pool.rs Bounds opens while retaining settlement handling.
crates/​incentive/​src/​tx/​tests.rs Tests bounded and unbounded waits.
crates/​incentive/​src/​tx.rs Adds shared receipt timeout helper.
crates/​incentive/​src/​test_rpc.rs Adds scripted test transport.
crates/​incentive/​src/​lib.rs Exposes test transport.
crates/​incentive/​Cargo.toml Configures test transport dependencies.
crates/​e2e/​tests/​pool_floor_ceiling_aggregate.rs Updates open API call.
crates/​e2e/​tests/​cli_fetch_topup.rs Updates funding API calls.
crates/​e2e/​src/​client.rs Updates fixture API call.
crates/​common/​src/​identity.rs Documents timeout-related key preservation.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Records breaking API changes.
crates/​client/​src/​funding/​adoption_tests.rs Tests funding receipt timeouts.
crates/​client/​src/​funding.rs Bounds client funding waits.
crates/​client/​src/​buyer_pool/​tests.rs Tests timeouts and duplicate-open refusal.
crates/​client/​src/​buyer_pool.rs Adds configurable bounds and open guard.
crates/​client/​examples/​common/​mod.rs Bounds example pool opening.
crates/​client/​Cargo.toml Uses shared test transport.
crates/​cli/​src/​commands/​publish.rs Documents unconfirmed timeout outcome.
crates/​cli/​src/​commands/​pool/​tests.rs Tests close and reclaim timeouts.
crates/​cli/​src/​commands/​pool.rs Bounds pool command receipt waits.
CHANGELOG.md Documents behavior and API changes.
Cargo.toml Updates dependency comments.
Cargo.lock Records dependency changes.
adr/​appendix-operator-key-rotation.md Documents receipt timeout scenario.

Review effort: Balanced

Comment thread crates/client/src/funding.rs Resolved
@github-code-quality

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

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 3cb8411 fix/bound-cli-receip... 408adf7 +/-
75% 75% 0%
View coverage of the 10 most impacted files.
File main 3cb8411 fix/bound-cli-receip... 408adf7 +/-
crates/cli/src/...ommands/pool.rs 69% 68% -1%
crates/node/src...s/client/mod.rs 90% 89% -1%
crates/node/src...gin/pull_leg.rs 85% 85% 0%
crates/protocol/src/framing.rs 93% 93% 0%
crates/node/src/buyer_pool.rs 73% 74% +1%
crates/client/src/funding.rs 76% 78% +2%
crates/node/src/dht/publish.rs 78% 80% +2%
crates/client/s...c/buyer_pool.rs 83% 89% +6%
crates/incentive/src/tx.rs 29% 55% +26%
crates/incentiv...src/test_rpc.rs 0% 97% +97%

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


Updated October 16, 2026 23:59 UTC

thiras and others added 2 commits October 17, 2026 01:22
A refill whose topUp lapsed at RECEIPT_TIMEOUT released open_lock before
its fatal fault reached run_groups (acquire_entry awaits
persist_watermarks first), so a sibling bundle entry queued on the lock
could read the unchanged deposit and escrow a second topUp. A recovery
step queued on the step lock could do the same.

The refill and the recovery step now escrow through one helper,
escrow_top_up. It holds the first unconfirmed topUp in RunFunding before
the caller's lock is released, and every later call in the run refuses
with that TopUpUnconfirmed, which the acquire loop treats as fatal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The refill holds open_lock and the recovery step holds RecoveryGate's
step lock, and neither excludes the other. Both could send a topUp
before either lapsed; with the receipt bound, one could then mine past
its window and stay uncredited while the other was credited.

RunFunding's held topUp becomes a tokio mutex that escrow_top_up holds
from its check to its outcome, so a second caller waits for the first
topUp to resolve and refuses if it went unconfirmed. top_up logs the
tx hash at broadcast, as open_pool does; its nonce-retry send loop moves
into send_top_up to keep it under the complexity lint.

Tests: a recovery-step lapse refuses a later refill, and a concurrent
refill and recovery step send one topUp between them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit 8127fe6 into main Oct 17, 2026
33 checks passed
@thiras
thiras deleted the fix/bound-cli-receipt-waits branch October 17, 2026 00:23
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.

fix: CLI tx paths wait for a receipt with no timeout

2 participants