Repository navigation
Description
Gap
The CLI decdn fetch buyer opens a payment channel with a fixed deposit and has no way to add funds to a reused channel whose deposit runs low mid-use. The only options a client has today are to let the channel expire (then a fresh one is opened) or to close and reopen manually.
Where
crates/cli/src/commands/fetch.rs:499—open_or_reuse(...): if a live (non-expired) channel is tracked for the provider, it is reused verbatim with its existing on-chain deposit (fetch.rs:514-521); otherwise a new channel is opened with a fixeddeposit(fetch.rs:547-556). A tracked-but-expired channel is the only trigger for opening a replacement (fetch.rs:493-527). There is no branch that tops up a live channel whose remaining deposit is insufficient for the next fetch.crates/cli/src/commands/fetch.rs:50—DEFAULT_DEPOSIT_MICRO_USDC = 10_000_000(10 USDC), used atfetch.rs:185-187as the fallback deposit.crates/cli/src/commands/channel.rs— the onlydecdn channelsubcommand iscoop-close(cooperative close). There is no top-up / refill subcommand. A repo-wide grep of the CLI crate findstop_up/top-uponly in the operator bond top-up path (bond.rs,setup.rs— a TOKEN swap), never for a payment-channel deposit.
Net: the contract and the Rust binding both expose topUp, but no CLI buyer code path ever calls it.
Existing precedent to mirror
The node cache-miss buyer already implements this against the same contract method:
contracts/src/PaymentChannel.sol:379—topUp(bytes32 channelId, uint256 additionalDeposit)(client-only; adds funds, does not extendexpiresAt).crates/incentive/src/payment_channel.rs:179— thetopUpABI binding.crates/node/src/buyer_channel.rs:622—BuyerChannelService::top_up(provider, additional)calls.topUp(channel_id, additional)(buyer_channel.rs:633) and reconciles the local deposit record, handling the escrowed-but-untracked race.crates/node/tests/anvil_settlement_e2e.rs:937— e2e test assertingtop_upraises the on-chain deposit and persists the new deposit in the buyer record.
All of this landed under the node buyer-side service (#744). The CLI fetch buyer never got the equivalent.
Why it matters
The default buyer deposit is a candidate to drop from 10 USDC (~1 TB at current per-MB pricing) to ~2 USDC (~200 GB) to shrink buyer escrow — but that reduction is deferred until this refill path exists (see comment below), because a small channel with no top-up would strand a client doing sustained fetches against one provider. This issue is the prerequisite for lowering the default.
Scope (decided)
Implement auto-topUp only — no manual subcommand. Inside open_or_reuse (or at fetch time), when a reused channel's remaining deposit is insufficient for the next fetch, top up on-chain before proceeding, mirroring BuyerChannelService::top_up (crates/node/src/buyer_channel.rs:622) — including its deposit-record reconciliation and escrowed-but-untracked handling.
A manual decdn channel top-up / decdn fetch --top-up subcommand was considered and dropped: the automatic path covers the need and an explicit command is redundant surface. Reconsider only if a concrete manual-refill use case appears.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
alpergundogdu commentedon Jul 11, 2026
Motivation / linked follow-up: the default buyer deposit is currently 10 USDC (~1 TB at the $0.01/GB market rate). We considered lowering it to ~2 USDC (~200 GB) to shrink buyer escrow, but it's held until this refill path exists — a 2 USDC channel with no client top-up would strand a sustained fetcher mid-session. When this lands, revisit the default together:
DEFAULT_DEPOSIT_MICRO_USDC(crates/cli/src/commands/fetch.rs:50), the node buyer default, and ADR 003 § Deposit Economics (the 10 USDC recommendation + its 2.3% gas-overhead math).🤖 via Claude Code
feat(cli): auto-topUp a reused fetch payment channel when its deposit…