Skip to content

fix(cli): name an in-flight openPool when a command ends before its receipt - #2452

Merged
thiras merged 3 commits into
mainfrom
fix/2418-name-inflight-open
Oct 13, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/2418-name-inflight-open

Conversation

@thiras

@thiras thiras commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Summary

open_pool waits for the openPool receipt with no time limit, by design. If the CLI future was dropped first (a Ctrl-C, a give-up, or a fault elsewhere in the run), no error named the tx. The user was told to "run the same command again". A re-run before the tx confirmed opened a second pool and escrowed a second deposit.

The rule now: a command never exits without naming an openPool whose receipt it did not read.

  • Client: open_pool takes Option<&UnconfirmedOpens>.
    • The open is recorded from before its submit until its receipt is read. A receipt that is read clears it, and so does a submit rejected without a broadcast.
    • A dropped submit or receipt wait leaves the record, and so does a failed receipt read.
    • The handle reaches the CLI through RunFunding::reporting_opens_to and BundlePullerBuilder::unconfirmed_opens. A bundle pass reset keeps it.
  • CLI: fetch, bundle pull and pool open name every pending open when they end (name_unconfirmed_open).
    • Ctrl-C: still exits 130, with the tx hash and nonce in place of the rerun hint. A second Ctrl-C prints the pending opens before it exits.
    • Give-up during an open: names it and exits 1, not 75 (EX_TEMPFAIL tells a wrapper that a re-run is safe).
    • A command that otherwise succeeded: exits nonzero, the same rule as escrowed_but_untracked.
    • pool open: now handles Ctrl-C around the open.
    • bundle pull --hash: the Ctrl-C watch now starts before the paid manifest fetch.
  • Message: OpenUnconfirmed now points to decdn pool list --all, because the plain pool list reads only the local store, which never recorded a dropped open.
  • Node: passes None. The open runs in a detached task, so its own handling covers it (fix: daemon can escrow a second deposit after an openPool receipt failure #2415).

Out of scope

  • top_up has the same Ctrl-C exposure, but the deposit goes into a pool the user already owns. fix: CLI tx paths wait for a receipt with no timeout #2433 tracks its unbounded wait.
  • The scheduler's drain still drops two other escrow errors at debug level: "escrowed but untracked" and an unconfirmed top-up. This is older than this PR and worth its own issue.

Test plan

  • buyer_pool tests, on a scripted transport:
    • an open dropped in its receipt wait, or in its submit, is still recorded
    • a receipt that is read clears the record
    • a failed receipt read, or a submit that failed in transport, keeps it
    • a rejected submit does not record it
  • Each new client test catches a mutation of the code it covers.
  • adoption_tests pin both open sites in funding.rs to the run's handle. Each test fails if its site passes None.
  • CLI interrupt tests: stop message and exit code for an interrupt or give-up, with and without a pending open; every pending open is named; an open the error already carries is not named twice.
  • cargo clippy --workspace --all-targets --all-features -D warnings, cargo doc with warnings denied, fmt, pre-commit
  • cargo nextest run -p decdn-client -p decdn-cli -p decdn-node -p decdn-e2e: 3325 passed
  • Public-API snapshot for decdn-client regenerated
  • Anvil e2e (CI). The only change there is the extra None argument.
  • Manual check: press Ctrl-C in decdn pool open on Arbitrum Sepolia just after the broadcast

Closes #2418

🤖 Generated with Claude Code

thiras and others added 2 commits October 13, 2026 15:44
…eceipt

A Ctrl-C during the openPool receipt wait dropped the future with no
error. `decdn fetch` and `decdn bundle pull` printed only the resume
hint, and `decdn pool open` died with no output. The tx could still
mine, and a re-run before it confirmed opened a second pool.

`open_pool` now holds its broadcast in an `UnconfirmedOpens` handle
until the receipt wait returns. The handle is threaded through
`RunFunding`, which both client open sites already hold. Each CLI
command reads the handle when it ends. An open that is still
unconfirmed is attached to the result, so the command names the tx
and nonce. An interrupt still exits 130. A run that would otherwise
succeed exits nonzero instead. `decdn pool open` now watches Ctrl-C
around the open.

The OpenUnconfirmed message now points to `decdn pool list --all`.
Only the on-chain list shows a pool the local store never recorded.

Closes #2418

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-ups for #2418. The first change named an open only when
its receipt wait was dropped and the command returned through
`name_unconfirmed_open`. Several ends still lost the tx:

- A give-up printed only "rerun to resume" and exited 75. It now names
  the open and exits 1, because 75 tells a wrapper a re-run is safe.
- `bundle pull --hash` opened in its manifest fetch with no Ctrl-C
  watch and returned before the naming. The watch now starts before the
  manifest, and the naming covers both phases.
- A second Ctrl-C exited before main printed. The watcher now names the
  pending opens before the immediate exit.
- A receipt read that failed during the scheduler's drain was removed
  from the handle, and its error was dropped at debug. Only a read
  receipt now releases an entry.
- A Ctrl-C during the submit itself recorded nothing. The entry is now
  held by nonce from before the submit.
- A bundle pass reset dropped the handle. The builder now takes the
  caller's handle, and each pass keeps it.
- Only the first pending open was named. All of them are now.

New tests pin the open sites in funding.rs to the run's handle.

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

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

The new public tuple field lacks required documentation and can fail the warnings-denied documentation gate.

1 open finding
What changed in this PR

Ensures CLI commands report unresolved openPool transactions before exiting, preventing unsafe retries and duplicate deposits.

Changes:

  • Adds shared tracking for unconfirmed pool opens.
  • Integrates tracking with fetch, bundle pull, and pool open interruption handling.
  • Adds regression tests and updates public API documentation.
File Description
crates/​node/​src/​buyer_pool.rs Adapts the node open call.
crates/​e2e/​tests/​pool_floor_ceiling_aggregate.rs Adapts E2E pool setup.
crates/​e2e/​tests/​cli_fetch_topup.rs Adapts fetch/top-up fixtures.
crates/​e2e/​src/​client.rs Adapts the client fixture.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Records the new public API.
crates/​client/​src/​funding/​adoption_tests.rs Tests funding-path tracking.
crates/​client/​src/​funding.rs Propagates the tracking handle.
crates/​client/​src/​buyer_pool/​tests.rs Tests dropped and failed opens.
crates/​client/​src/​buyer_pool.rs Implements unconfirmed-open tracking.
crates/​client/​src/​bundle/​engine.rs Preserves tracking across passes.
crates/​client/​src/​bundle.rs Adds bundle tracking configuration.
crates/​client/​examples/​common/​mod.rs Adapts the client example.
crates/​client/​Cargo.toml Adds the test transport dependency.
crates/​cli/​src/​main.rs Centralizes stop messages and exit codes.
crates/​cli/​src/​commands/​pool.rs Handles interruption during pool opening.
crates/​cli/​src/​commands/​interrupt/​tests.rs Tests reporting and exit behavior.
crates/​cli/​src/​commands/​interrupt.rs Reports pending opens on termination.
crates/​cli/​src/​commands/​fetch.rs Tracks opens throughout fetches.
crates/​cli/​src/​commands/​bundle_pull.rs Tracks opens during manifests and pulls.
CHANGELOG.md Documents behavior and API changes.
Cargo.lock Records the dependency update.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/cli/src/commands/interrupt.rs Resolved
Only the interrupt module and its tests build or read it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 96c34cf in the fix/2418-name-inflig... branch remains at 75%, unchanged from commit 738214f in the main branch.

Show a line coverage summary of the most impacted files.
File main 738214f fix/2418-name-inflig... 96c34cf +/-
crates/cli/src/main.rs 82% 78% -4%
crates/cli/src/...ommands/pool.rs 69% 68% -1%
crates/cli/src/.../bundle_pull.rs 48% 47% -1%
crates/client/src/bundle.rs 17% 16% -1%
crates/cli/src/...mmands/fetch.rs 50% 50% 0%
crates/protocol/src/framing.rs 93% 93% 0%
crates/node/src...s/client/mod.rs 89% 90% +1%
crates/client/src/funding.rs 74% 76% +2%
crates/client/s...c/buyer_pool.rs 82% 84% +2%
crates/cli/src/...ds/interrupt.rs 62% 84% +22%

@thiras
thiras merged commit 377f3dd into main Oct 13, 2026
33 checks passed
@thiras
thiras deleted the fix/2418-name-inflight-open branch October 13, 2026 13:25
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: Ctrl-C during an openPool receipt wait loses the tx hash and re-opens on re-run

2 participants