Skip to content

cli: proactive pool refill checks one lane's spend, not the pool's, so it never fires on a multi-provider pool #2288

Closed

Description

@thiras

Component

cli (decdn binary)

Version

9f243c9f (main), client and fleet on the same build.

Summary

The proactive low-water refill in open_or_reuse_pool (crates/cli/src/commands/fetch.rs ~3034–3047) compares the pool deposit with the spend of one lane. The spend of the whole pool is the sum over every provider lane. A pool that is spent across several providers never reaches the low-water mark, so the proactive refill does not fire. The pull then runs until the reactive mid-fetch top-up (driver.rs ~1070) catches a real exhaustion.

let (prior_bytes, prior_amount) = match state.lane_progress(lane) { ... };   // one provider's lane
let spent = prior_amount.max(spent_elsewhere);                              // spent_elsewhere is 0 for a tracked pool
let additional = refill_amount(state.deposit, spent, working_deposit, low_water);

The refill_amount doc says the opposite: "prior_amount the cumulative amount already vouchered across its lanes". Only the adoption path (pool_to_reuse → adopt_owned_pool) passes a pool-wide figure (spent_elsewhere = on-chain totalRedeemed).

Steps to reproduce

  1. Use one buyer pool (10 USDC working deposit) for many bundle pull runs that spread over several providers.
  2. decdn pool list --json: the per-lane last_amount_usdc values.

Expected behavior

When the pool-wide unspent balance (deposit − Σ lane last_amount) is below working_deposit / LOW_WATER_DIVISOR, the next lane build tops the pool back up to working_deposit.

Actual behavior

Live pool 0xcb5986… on 2026-10-02 had 6 lanes. Their cumulative spends were 2.374 + 2.360 + 2.147 + 1.043 + 0.483 + 0.248 = 8.655 of 10 USDC, so 1.345 USDC was unspent. That is below the 2 USDC low water. The largest single lane is 2.374, so every lane build computes 10 − 2.374 = 7.6 USDC "remaining" and does not refill. The proactive refill fired in this run only because the local pool row was missing and the pool was adopted from chain (the adoption path uses totalRedeemed).

Fix direction

Pass the pool-wide spend: max(Σ state.lanes().last_amount, spent_elsewhere), not one lane's last_amount. Keep refill_amount pure. Add a unit test with N lanes, each below the low water, whose sum is above it.

Activity

  1. added
    kind:bug
    area:cli
    area:payments
    on Oct 2, 2026
  2. self-assigned this
    on Oct 2, 2026
  3. altanoruc commented on Oct 2, 2026

    @altanoruc
    Contributor

    Field repro on the pre-fix binary (2026-10-02, CLI 2e1a93c5)

    An overnight batch of 34 bundle pulls drained pool 0xdb5db181… (deposit 19.42 USDC). The proactive refill never fired: no low on deposit line appears in any of the 34 run logs. Meanwhile the wallet 0x96bF…d03d kept 20.58 USDC untouched. The last two runs then failed:

    • Run 29 (gpt-oss, 07:02:24 UTC, after 485 s): bcl refused with voucher rejected: PoolExhausted. The client classified it as Fatal(Command), which ended the whole bundle with 1 file failed.
    • Run 30 (SDXL, 7 s): NoAffordableSource, no provider's next voucher fits the pool's deposit of 0 (micro-USDC).

    On-chain afterwards: deposit=19.42, totalRedeemed=18.77.

    One point for verification after #2291: a provider-side VoucherRejected { PoolExhausted } is still fatal to the command, not Unaffordable. With pool-wide spend in the gate, the client should not send such a voucher. If it does, for example because of a stale view of totalRedeemed (#2292), the whole bundle aborts and does not top up. I will rerun this batch on origin/main to confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:cliarea:paymentskind:bug

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions