Repository navigation
fix(cli): pre-check reclaim --pool and name the cause and deadline - #2238
Merged
Merged
Conversation
…2237) `pool reclaim --pool` now reads the pool on a wallet-free provider and runs it through plan_reclaim before the keystore unlock. An Open, in-window, Closed, or nonexistent pool fails with its own cause (the in-window case prints the deadline and time remaining) and sends no transaction. A revert after the pre-check names the remaining race causes. reclaim --all renders its in-window deadline the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 0f1c9e7 in the Show a line coverage summary of the most impacted files.
Updated |
…d to end The reclaim --pool pre-check, the reclaim --all sweep, and the pool list Reclaimable column now compare the dispute deadline against the head block's timestamp, the clock the contract uses, instead of the local clock. A machine whose clock trails the chain no longer refuses a pool the chain would reclaim. The three private head_timestamp copies move to chain_ctx as one shared helper. The post-check revert message names the causes that remain (a concurrent reclaim, or the USDC refund transfer). Docs and the --pool help describe the pre-check. The client public-API snapshot lists build_read_provider. Tests: the pre-check runs before the store opens and the keystore unlocks; both provider builders redact an invalid rpc_url; an anvil journey walks missing, Open, in-window, chain-time-elapsed, and Closed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
alpergundogdu
approved these changes
Sep 30, 2026
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.
Closes #2237.
Problem
decdn pool reclaim --poolsentreclaimwithout reading the pool first. Any revert became one fixed message naming two possible causes ("not closed, or its dispute window has not elapsed yet"). The message gave no deadline, and the keystore password was asked for before the chain said no.Behavior
reclaim --poolnow reads the pool (getPool) and the head block's timestamp on a wallet-free provider, and runs them through the sameplan_reclaimthat--alluses. The check runs before the buyer store opens and the keystore unlocks. A pool that can't be reclaimed is refused with its own cause, with no password prompt and no transaction:pool 0x… does not exist on this PaymentPool contract — a mistyped --pool, or the wrong payment_pool addressOpenpool 0x… is still Open — run \decdn pool close --pool 0x…` first`Closing, in windowpool 0x… is still in its dispute window; reclaimable after Unix 1790875000 (in 2d 0h 36m)Closing, past deadlinereclaimClosedpool 0x… is already Closed — its residual was already reclaimedThe owner check runs first because a never-opened pool reads as status
0, which isOpen.If the chain still reverts after the check passed, the error names the causes that remain: a concurrent reclaim, or the USDC refund transfer to the owner. One shared message covers the estimation-time and receipt-time reverts.
Chain time, not the local clock
The contract gates on
block.timestamp >= disputeDeadline. The--poolcheck, the--allsweep, and thepool listReclaimable column now compare against the head block's timestamp, notSystemTime::now(). A machine whose clock trails the chain no longer refuses a pool the chain would reclaim. The three privatehead_timestampcopies inunbond,update_multiaddrs, andupdate_regionbecome onechain_ctx::head_timestamp.Other changes
decdn_client::provider::build_read_provider: a new wallet-free builder. It shares a privateparse_rpc_urlwithbuild_provider, so the redacted invalid-URL error lives in one place. The public-API snapshot is updated.reclaim --allrenders its in-window deadline withformat_expiry, the same rendering aspool list.--poolhelp text and thereclaim/plan_reclaim/ReclaimPlandocs describe the check.The deadline is shown as Unix time plus time remaining, not a UTC calendar date. The CLI has no date dependency, and this matches the existing
pool listcolumn.Test plan
single_reclaim_gate_names_the_causecovers each refusal and the at- and past-deadline sendsinvalid_rpc_url_is_redacted_from_both_buildersreclaim_pool_reads_chain_before_store_or_keystore(unreachable RPC →getPool failed, no keystore error, no store file created)cli_pool_reclaim_precheckgoes missing → Open → in-window → reclaim after anevm_increaseTimepast the window (wall clock unchanged) → Closed. Every refusal runs with a wrong keystore password.cargo clippy --workspace --all-targets -D warnings(plusdecdn-e2ewithanvil-e2e),cargo fmt --check,cargo doc -D warnings,check_crate_edges.py,public-api-testcargo nextest run -p decdn-cli -p decdn-client: all pass exceptdriver::tests::an_idle_lane_releases_its_surplus_workers_before_the_drive_ends. It fails in every full parallel run and passes on its own, and this PR does not change the driver code. Tracked in Flaky under load: driver::tests::an_idle_lane_releases_its_surplus_workers_before_the_drive_ends #2240.🤖 Generated with Claude Code