Skip to content

fix(cli,client): batch fixes for adopted-pool spend, tiny top-ups, stale coverage and dedup slots - #2305

Merged
thiras merged 10 commits into
mainfrom
fix/cli-batch-2281-2283-2292-2296
Oct 5, 2026
Merged

thiras merged 10 commits into
mainfrom
fix/cli-batch-2281-2283-2292-2296

Conversation

@thiras

@thiras thiras commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What

Four cli-area fixes from the testnet SDXL/Whisper bundle-pull batches. There is one commit per issue, plus one for the buyer-table bump and the CHANGELOG.

Closes #2292
Closes #2296
Closes #2281
Closes #2283

Reviewer notes

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • cargo nextest run -p decdn-incentive -p decdn-client -p decdn-cli -p decdn-node: all pass.
  • anvil e2e (--features anvil-e2e): cli_bundle_pull_range_dedup, cli_fetch_topup, node_pull_topup, anvil_pool_redeem, node_pull_pool_adopt, node_pull_pool_redeploy, node_to_node_coalesce, cli_fetch_delegated and smoke, 21/21 pass.
  • New tests:
    • a_reused_adopted_row_keeps_the_pools_redeemed_spend
    • a_confirmed_exhaustion_below_the_low_water_shortfall_refuses
    • an_unaffordable_voucher_tops_up_even_a_small_shortfall
    • an_insufficient_deposit_refusal_at_the_working_deposit_settle_waits
    • a_refill_a_later_lane_build_made_raises_the_running_lanes
    • three_covered_refusals_drop_the_block_from_a_partial_holders_coverage
    • sparse_covered_refusals_never_drop_a_block
    • pool_spend_keeps_an_adopted_pools_redeemed_spend_as_its_lanes_advance
    • seed_progress_moves_a_new_lanes_watermark_out_of_the_redeemed_spend
    • a_partial_holder_refusing_a_covered_block_loses_it_from_its_coverage
    • a_donor_waiter_gives_its_slot_to_a_queued_entry_and_retakes_it_to_drive
  • The scheduler, client: a partial holder that refuses NotFound inside its advertised coverage is asked again every 3 s (follow-up to #2262) #2281 and bundle pull: a range-dedup entry holds its --jobs permit while it waits for a donor, so only 2 of 5 fetches run #2283 regression tests each fail with their fix reverted.
  • CHANGELOG.md entries added.
  • adr/appendix-bundles.md concurrency note updated.

🤖 Generated with Claude Code

thiras and others added 5 commits October 5, 2026 06:01
…ns (#2292)

A row adopted from chain has no lanes, so the pool's `totalRedeemed` is
its only record of what other lanes paid out. Only the adopting run saw
it: every later run reused the row as tracked, passed zero as the spend
elsewhere, and counted just the lanes recorded since. The proactive
refill then read the pool as fuller than it was, and the run's funding
baseline undercounted the same spend.

`BuyerPoolState` now carries `redeemed_elsewhere`, set from
`totalRedeemed` at adoption and persisted at the end of the buyer
record (schema v4). `pool_spend` and the lane's `LaneSpend` read it from
the row, so every run that reuses the row sees what the adopting run saw.

Closes #2292

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on a refill (#2296)

Right after a proactive refill restored a pool, a node whose chain
watcher had not seen it yet refused the next open as InsufficientDeposit.
The driver confirmed an exhaustion, and the pacer topped up the gap to
the working deposit: a few micro-USDC, each costing an approve and a
topUp transaction and one of the run's three reactive top-ups. Lanes
built before the refill also kept the deposit they were built with, so
one classed a gap the refill had paid for as unaffordable.

- The pacer sends a reactive top-up for a confirmed exhaustion the
  deposit can still afford only when it adds at least the low water
  (working / LOW_WATER_DIVISOR), the threshold the proactive refill
  uses. A voucher the deposit cannot pay still tops up any shortfall.
- An InsufficientDeposit refusal while the deposit already sits within
  that low water of the working target settle-waits on the existing
  budget before it confirms an exhaustion.
- A lane build raises the pool's deposit watch and every started lane's
  context to the deposit it read, never lowering one, in place of only
  seeding a zero watch.

Closes #2296

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tFound inside it (#2281)

A probed partial holder that refused a range its own coverage claimed was
never counted: the answer was a delivery fault only, so the holder cooled
for a few seconds and was asked for the same range again, for as long as
the item ran. On the testnet one node refused 108 ranges inside its
advertised coverage in one batch, each followed by a stalled remainder.

Such a refusal now counts against every discovery block the refused range
touches. The node refuses the whole range at its first chunk it does not
hold and does not say which chunk that is. A block refused
ABSENT_AFTER_NOT_FOUND times leaves the holder's coverage for the rest of
the blob, and a rediscovery that repeats the stale claim does not bring it
back. The acquire loop mirrors the narrowed coverage into its per-lane
view, so the block's ranges go to the other sources. Once the block is
outside the coverage, the pull-through bar from #2263 bounds any further
asks.

Closes #2281

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…donor (#2283)

A range-dedup entry held its --jobs permit after its complement landed,
while it only waited for the sibling fetch that registers its donor
chunks. A waiter moves no bytes, yet it kept a queued entry from
fetching. On an SDXL pull with --jobs 5, two or three such waiters held
the run to 2-3 downloading entries for minutes at a time.

Two caps both equalled --jobs: the gate semaphore and run_groups'
buffer_unordered width. Every group is now in flight at once and waits
in start order for a FetchSlot of the gate, the one cap, taken before
its file bar. The dedup reconcile gives the slot back just before it
waits for a donor registration, and every drive (complement, donor
re-fetch, deferred fallback, self-heal) takes one again first. No wait
happens while a permit is held, so the change cannot deadlock.

Closes #2283

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Record schema 4 appends `redeemed_elsewhere` (#2292). The reader matches
`schema_version` exactly, so under the `_v5` tables a row an older binary
wrote fails a point lookup, and `decdn fetch` fails with it. Under `_v6`
the old table reads as absent: the store starts empty, and a node or
client re-adopts its live pool from chain, now with its redeemed spend.

Records the four batch fixes in CHANGELOG.md.

Refs #2292

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

Copilot review overview

🟡 Changes recommended

Adopted-pool accounting still undercounts spend, and node adoption plus covered extra-stream refusal handling remain incomplete.

Review effort: Balanced
Findings: 3 Medium severity · 1 Low severity

Open (4)
What changed in this PR

Fixes buyer-pool accounting, reactive funding, stale holder coverage, and bundle-pull concurrency.

Changes:

  • Persists adopted-pool redeemed spend with schema v4 tables.
  • Avoids tiny top-ups and propagates refilled deposits.
  • Drops stale coverage and releases donor-waiter job slots.
File Description
crates/​incentive/​src/​buyer_pool.rs Adds persisted redeemed spend.
crates/​incentive/​src/​buyer_pool_table.rs Introduces schema v4 and _v6 tables.
crates/​common/​src/​cli/​bundle.rs Updates --jobs documentation.
crates/​client/​src/​source_set.rs Tracks refused covered blocks.
crates/​client/​src/​scheduler.rs Synchronizes coverage and deposits.
crates/​client/​src/​pacer.rs Adds a reactive top-up minimum.
crates/​client/​src/​ledgers.rs Raises deposits across lane contexts.
crates/​client/​src/​driver.rs Waits for stale deposit watchers.
crates/​cli/​src/​commands/​pull_progress.rs Documents donor-waiter bars.
crates/​cli/​src/​commands/​fetch.rs Uses persisted adopted-pool spend.
crates/​cli/​src/​commands/​bundle_pull.rs Releases and reacquires fetch slots.
CHANGELOG.md Records user-visible fixes.
adr/​appendix-bundles.md Updates bundle concurrency semantics.

💡 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/fetch.rs Resolved
Comment thread crates/client/src/source_set.rs Resolved
Comment thread crates/client/src/source_set.rs Resolved
@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit a7b2acd in the fix/cli-batch-2281-2... branch remains at 87%, unchanged from commit 7f938e6 in the main branch.

Show a line coverage summary of the most impacted files.
File main 7f938e6 fix/cli-batch-2281-2... a7b2acd +/-
crates/node/src...hannel_store.rs 93% 92% -1%
crates/client/src/scheduler.rs 95% 95% 0%
crates/node/src/dht/publish.rs 92% 92% 0%
crates/client/src/lib.rs 92% 92% 0%
crates/client/s...c/source_set.rs 97% 97% 0%
crates/node/src...s/client/mod.rs 95% 95% 0%
crates/client/src/streamer.rs 91% 91% 0%
crates/cli/src/.../bundle_pull.rs 80% 81% +1%
crates/cli/src/...mmands/fetch.rs 75% 76% +1%
crates/node/src...uyer_channel.rs 74% 76% +2%

Updated October 05, 2026 04:47 UTC

thiras and others added 5 commits October 5, 2026 07:00
…s lanes advance (#2292)

Keeping `totalRedeemed` as a floor under the tracked lanes' sum lost
spend once a tracked lane advanced. With 100 redeemed, 60 of it on lane
A, A advancing to 80 read as max(80, 100) = 100, while the pool had
spent 120.

`redeemed_elsewhere` is now the redeemed spend no tracked lane accounts
for. Seeding a lane from its on-chain watermark (`seed_lane`, and
`BuyerPoolStore::seed_progress` in one write) records the lane and takes
its amount out of that remainder, so `BuyerPoolState::pool_spend` is the
tracked lanes plus the remainder, and stays right as the lane advances.
`decdn fetch` seeds a lane it resumes from chain before it reads the
spend. The node adopts with `totalRedeemed`, seeds through
`seed_progress`, and its low-water refill reads `pool_spend`. Without
this, the `_v6` move would re-adopt every node's pool with no spend
counted at all.

Refs #2292

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m refusals (#2281)

A covered NotFound is not proof of absence: load shed and a stale
chain view reach the client as the same wire NotFound. A dropped block
now returns after PULL_THROUGH_BAR, with its count restarted, and a
count whose last refusal is that old starts again, so sparse transient
refusals never add up. Rediscovery keeps a block out only until its
drop ends.

A NotFound for a covered range on an extra stream now counts too: the
scheduler passes every extra-stream refusal to `record_extra_refusal`,
which splits covered from uncovered itself.

Refs #2281

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cing out or dropping a source (#2296, #2281)

Review of #2305:

- A source that keeps refusing a deposit near the working target past
  its own settle budget faults as `StaleDepositView`, classified as a
  source fault, with one WARN. It used to fall through to a confirmed
  exhaustion that the pacer floor refuses, which read as PoolExhausted
  and barred the source until a deposit rise no top-up brings. The
  budget is separate from the post-top-up settle budget and re-arms on
  a landed leg; its waits log.
- An extra stream's covered NotFound is not counted again: a node's
  per-signer live cap, which extra streams hit, refuses as plain
  NotFound.
- Covered refusals count from the refused part of a range (after its
  landed bytes), once per cooldown, and a verified byte in a block
  clears its count. A probe that reports a holder as whole ends its
  block drops, so a drop's end cannot make it partial again.
- `raise_to_lane` recovers a poisoned context like its siblings.
- Tests for the stale-view fault, the burst and served-byte rules, a
  whole-holder merge, `Work::set_coverage` restore, a raise that never
  lowers, and `LaneLedgers::raise_all`.

Refs #2296
Refs #2281

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…2283)

Review of #2305: a waiter whose donors arrived without a fallback
drive finished with its slot still released, so its splice, whole-file
hash and materialize ran outside --jobs. The donor wait now gives the
slot back only across the wait (`RangeDriver::retake_slot`).

A slot taken again would otherwise queue behind every group still to
start. `JobGate` adds an admission queue for new groups' first permit,
so a retake waits behind at most the one admitted group.
`FetchSlot::ensure` keeps the first permit if two ever race.

Refs #2283

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd retry a seed on a moved row (#2292)

Review of #2305:

- `BuyerPoolState::adopt` builds an adopted row with its
  `totalRedeemed`, and `hydrate` takes the stored `redeemed_elsewhere`,
  so no caller can drop it. The free setter is gone.
- The CLI lane seed fails the build when the row was forgotten or
  replaced, rather than pricing the lane or escrowing a refill against
  a row the store no longer holds, and resumes from the row when
  another run already moved past the watermark.
- Node tests: an adopted drained pool keeps its redeemed spend and its
  refill fires; a lane seeded on an adopted row counts its watermark
  once.
- Docs: the buyer record's suffix rule, `committed_amount` vs
  `pool_spend`, the lane mutators, LaneSpend, the node reseed and
  refill, and CHANGELOG for the review fixes.

Refs #2292

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants