Skip to content

Publisher-pays channels: open-on-behalf + adopt-by-id + reject-bundle resume #1481

Closed

Description

@alpergundogdu

Builds on #1476 (delegated voucherSigner). Lets a client fetch with no wallet, no on-chain tx, and no USDC: the publisher opens channels on the client's behalf pinning the client's key as voucherSigner, and the client signs vouchers locally. The wire needs no channel handshake — nodes already learn channels from ChannelOpened, and the delivery binding gate already checks voucher_signer (#1478).

1 - decdn channel open --provider-address --deposit-micro-usdc [--voucher-signer] (publisher-side)

  • New subcommand. Plumb a signer arg through open_channel (crates/client-pull/src/buyer_channel.rs:218), replacing the hardcoded Address::ZERO. Prints channelId.

2 - decdn node lookup --node-id | --region (client-side, unpaid)

  • CapacityBond.getActiveNodes() read → operator address (= openChannel's provider), optionally probe-ranked by RTT/rate. This is the "discover a node so I can tell the publisher who to open with" step. No sentinel hash needed — a probe for any absent hash returns a full signed response and is cheaper for the node than a hit.

3 - Buyer store schema v2 (crates/incentive/src/buyer_channel.rs)

  • Re-key BuyerChannelState by channel_id (currently keyed by provider → one channel per node); keep a provider index for the auto-open path. Enables a future multi-process/parallel-pull client; cheap now, expensive once channels exist on disk.
  • Add voucher_signer. Also fixes the channel close branch bug recorded in feat(payments): delegated voucherSigner + voucher-less close #1478 (has_claim_watermark used as a proxy for "I hold a key this channel accepts").
  • Bump BUYER_SUPPORTED_SCHEMA_VERSION 1→2 (independent of the seller table; unsupported buyer versions are skipped, not fatal).

4 - decdn fetch --channel-id <id> (client-side)

  • First use: getChannel(id), verify provider + voucherSigner-in-keystore + Open/unexpired, resolve watermark, write a buyer row, fetch. Reuse the row after. No separate adopt or channel show — validation folds into fetch.
  • Lift the hydration from the node's reconcile_one_opened (crates/node/src/buyer_channel.rs:2641); the CLI has none.
  • Skip the fetch-time open_or_reuse top-up when funder ≠ local key — topUp is funder-only (PaymentChannel.sol:407) and reverts on a delegated channel. Surface exhaustion instead.

5 - Voucher-reject watermark bundle (resume)

  • A client can't reconstruct its watermark from chain (the claim watermark is 0 until settlement). On a regression reject (StaleNonce/AmountRegression/BytesRegression), attach the node's true watermark + the client's own last signature to StreamError::VoucherRejected, so the client self-heals and re-signs.
  • Gate the bundle on a signature that recovers to voucher_signer — else it leaks the watermark to anyone who guessed the chain-derivable channel_id. Security property, not a compat concern.
  • Pre-launch: add the field inline, no ALPN/extension ceremony.

Resume / exhaustion — reactive. Both StaleNonce and InsufficientDeposit resume from the last byte (StreamRequest.byte_offset, BLAKE3 range-addressable). StaleNonce self-heals on the same channel; InsufficientDeposit → the app asks the publisher to top up (the delegate can't), then resumes. No proactive low-deposit warning; the node signals exhaustion reactively at the last coverable voucher (cache-hit path) or via a coarse pre-flight guard (pull-through path).

Depends on #1478 (voucher_signer pin, closeChannelWithoutVoucher). Do not start until it merges — items 3/4/5 touch files it changes. The separately-tracked coop-close auth hardening shares the same binding→voucher_signer gate.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions