Skip to content

fix(cli,client)!: name a topUp that may still mine on every decdn get exit - #2499

Merged
thiras merged 2 commits into
mainfrom
fix/name-unconfirmed-top-up
Oct 17, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/name-unconfirmed-top-up

Conversation

@thiras

@thiras thiras commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Summary

decdn get named an openPool that may still mine on every exit, but never a topUp. A refill or recovery topUp whose receipt wait was dropped left no record. Four exits did this: a give-up, a Ctrl-C, a fault in a sibling bundle entry, and the 30 s drain_builds cutoff after a fetch that succeeded. The command then exited 75 or 0, and a rerun could escrow a second top-up.

  • UnconfirmedOpens → UnconfirmedEscrows, which holds EscrowUnconfirmed::{Open, TopUp}. pending() returns both kinds; opens() and top_ups() return one kind each.
  • top_up takes Option<&UnconfirmedEscrows> and holds the topUp the same way open_pool holds an open: {tx: None, nonce} across the submit (and after a transport failure), then {Some(tx), nonce} until the receipt is read.
  • RunFunding's in-run refusal (fix(cli,client,node)!: bound receipt waits so a dropped tx cannot hang #2490) reads the same handle. Its tokio mutex now only serializes topUps. The handle is shared across passes and fetches, so the refusal now covers them too.
  • CLI: name_unconfirmed_escrows, stop_message/stop_exit and the second-Ctrl-C print all report topUps. A carried TopUpUnconfirmed is not named twice, and it also rules out exit 75.
  • open_pool still refuses only on a held open. The node and decdn pool top-up pass None, so their behavior is unchanged.

BREAKING (SDK): top_up gains an argument before receipt_timeout. Renames: UnconfirmedOpens → UnconfirmedEscrows, BundlePullerBuilder::unconfirmed_opens → unconfirmed_escrows, RunFunding::reporting_opens_to/opens → reporting_escrows_to/escrows. The CHANGELOG is updated, and the public-api snapshot is regenerated.

Out of scope: decdn pool top-up installs no Ctrl-C watch. That gap predates this PR, and the handle can close it in a one-line follow-up.

Test plan

  • buyer_pool tests: a topUp dropped in its receipt wait or in its submit stays held; a read receipt and a rejected submit leave nothing held; a held topUp does not refuse an open.
  • adoption_tests: a recovery step dropped mid-wait leaves the topUp in the run's handle, and a later refill refuses with it. The two existing refusal tests now read the handle.
  • interrupt tests: a give-up with a pending topUp names the tx and is not 75; Ok plus a pending topUp is an error; an interrupt names opens and topUps one per line; a carried topUp is not named twice.
  • Mutation checks done by hand: removing the post-broadcast insert fails 6 tests, removing the pre-submit insert fails 1, and removing the carried-topUp downcast fails 1.
  • cargo nextest run -p decdn-client -p decdn-cli -p decdn-node (3461 passed), clippy --all-targets --all-features -D warnings, cargo doc with warnings denied, the public-api test.

Closes #2491

🤖 Generated with Claude Code

https://claude.ai/code/session_0123DU1V2G3UnrwF2o9g4XHa

… exit

A refill or recovery topUp whose receipt wait was dropped (a give-up, a
Ctrl-C, a sibling bundle fault, the late-build drain) left no record, so
decdn get exited 75 or 0 and a rerun could escrow a second top-up.

UnconfirmedOpens becomes UnconfirmedEscrows, which holds both openPool and
topUp entries (EscrowUnconfirmed). top_up takes the handle and holds the
topUp from before its submit until its receipt is read, as open_pool does.
RunFunding refuses a second topUp from the same handle, and the CLI's
name_unconfirmed_escrows, stop_exit and second-Ctrl-C print read it, so a
pending topUp is named, rules out exit 75 and fails an Ok exit.

Closes #2491

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0123DU1V2G3UnrwF2o9g4XHa
Copilot AI balanced review requested due to automatic review settings October 17, 2026 14:58
@thiras thiras self-assigned this Oct 17, 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

Tracking gaps and removal of equal entries can still hide potentially broadcast top-ups.

2 open issues
What changed in this PR

Extends pending-transaction tracking to top-ups so decdn get reports escrow that may still occur after cancellation or completion.

Changes:

  • Shares open and top-up tracking across fetches and passes.
  • Updates exit reporting, SDK APIs, regression tests, and release notes.
File Description
crates/​node/​src/​buyer_pool.rs Adapts the top-up call signature.
crates/​e2e/​tests/​cli_fetch_topup.rs Updates the integration-test call.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Records SDK API changes.
crates/​client/​src/​funding/​adoption_tests.rs Tests dropped recovery top-ups.
crates/​client/​src/​funding.rs Uses shared tracking for funding refusal.
crates/​client/​src/​buyer_pool/​tests.rs Tests top-up tracking lifecycle.
crates/​client/​src/​buyer_pool.rs Tracks unconfirmed opens and top-ups.
crates/​client/​src/​bundle/​engine.rs Preserves tracking between passes.
crates/​client/​src/​bundle.rs Exposes shared escrow tracking.
crates/​cli/​src/​commands/​pool.rs Adapts pool commands to updated APIs.
crates/​cli/​src/​commands/​interrupt/​tests.rs Tests escrow reporting and exit status.
crates/​cli/​src/​commands/​interrupt.rs Reports pending top-ups on interruption.
crates/​cli/​src/​commands/​fetch.rs Shares tracking across fetches.
crates/​cli/​src/​commands/​bundle_pull.rs Reports unresolved bundle funding.
CHANGELOG.md Documents behavior and SDK changes.

Review effort: Balanced

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

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

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 4dd5306 fix/name-unconfirmed... 7996df3 +/-
76% 76% 0%
View coverage of the 8 most impacted files.
File main 4dd5306 fix/name-unconfirmed... 7996df3 +/-
crates/cli/src/...ommands/pool.rs 68% 67% -1%
crates/node/src...s/client/mod.rs 90% 89% -1%
crates/cli/src/main.rs 76% 75% -1%
crates/cache/src/engine.rs 91% 91% 0%
crates/client/src/funding.rs 78% 78% 0%
crates/node/src/buyer_pool.rs 80% 80% 0%
crates/client/s...c/buyer_pool.rs 95% 96% +1%
crates/cli/src/...ds/interrupt.rs 84% 85% +1%

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


Updated October 17, 2026 15:31 UTC

- A topUp submit with no hash reads "returned no tx hash", not "failed in
  transport": a submit dropped in flight holds no hash either.
- UnconfirmedEscrows::remove releases one entry, so two calls that hold
  equal entries each release their own.
- A submit that returns a hash is swapped for the broadcast entry under one
  lock (open_pool and top_up), so a second Ctrl-C never reads it as held
  neither way.
- EscrowUnconfirmed is a list entry, not an error marker; opens/top_ups are
  crate-private; RunFunding's lock is top_up_serial.
- decdn pool top-up watches Ctrl-C and names its topUp, as pool open does.
- Docs that named only openPool now name topUp too.
- Tests: a transport-failed submit stays held, a nonce collision releases
  its entry before the re-send, retries that run out hold nothing, equal
  entries release one at a time, a later pass is refused, and a mid-submit
  topUp line names its nonce.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0123DU1V2G3UnrwF2o9g4XHa
@thiras

thiras commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 7996df3 to address the multi-agent review:

  • A topUp with no hash now reads "returned no tx hash" instead of "failed in transport".
  • remove now releases one entry instead of every equal one.
  • The broadcast entry now replaces the submit entry under one lock.
  • Public API trimmed: opens and top_ups are crate-private, and EscrowUnconfirmed no longer implements Error.
  • decdn pool top-up now names its topUp on Ctrl-C.
  • Stale comments that named only openPool are fixed.
  • 6 new tests. I broke each new code path in turn, and a test failed every time.

Not fixed here:

🤖 Generated with Claude Code

@thiras
thiras merged commit d29e788 into main Oct 17, 2026
31 checks passed
@thiras
thiras deleted the fix/name-unconfirmed-top-up branch October 17, 2026 15:34
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): name a topUp that may still mine on every decdn get exit

2 participants