Skip to content

Node-to-node buyer-side openChannel for cache-miss settlement #744

Closed

Description

@thiras

Context

Split out from #327 (PR #743), which implemented the seller/provider on-chain PaymentChannel path. The buyer-side path is deferred.

Per ADR 003 §node→node, when a node pulls content from another node (typically an origin-backed node) on a cache miss, it pays via the same channel mechanism — i.e. it acts as the client: opens a channel against the upstream provider, signs cumulative vouchers as bytes arrive, and tops up / lets the upstream close & settle.

Scope

  • PaymentChannel.openChannel(provider, deposit) from the node when it first pulls from an upstream node (driven by the cache-miss requester, Implement cdn/client/v1 paid delivery protocol (StreamRequest, StreamResponse, ChunkData, vouchers) #317 client_requester).
  • USDC approve handling for the channel deposit (first-channel one-time approval per ADR 003 § Deposit Economics).
  • Voucher signing on the buyer side (the decdn_incentive::voucher signing primitives already exist).
  • Channel lifecycle/bookkeeping for buyer-held channels (distinct from the seller-held channels the current PaymentChannelService tracks): deposit accounting, top-up, and reclaimExpired fallback if an upstream abandons a channel.
  • Decide the open-channel trigger policy (lazy on first miss to a given provider; channel reuse across misses).

Notes

Out of scope

Dispute monitor (#324).

Activity

  1. self-assigned this
    on May 31, 2026
  2. added
    design:economics
    kind:feature
    rust
    on May 31, 2026
  3. github-actions commented on May 31, 2026

    @github-actions

    🎯 Triage report

    This is a well-scoped follow-on task split from #327/PR #743, implementing the buyer side of node-to-node payment channels in crates/incentive. It covers openChannel, USDC approve, voucher signing, channel lifecycle (top-up, reclaimExpired), and the open-channel trigger policy — complementing the already-merged seller/provider path. All referenced ADRs and prior code are in place.

    📊 Assessment

    Dimension Value Reasoning
    Type Feature/Task New implementation of a defined subsystem; no bug, no design ambiguity
    Labels enhancement, technical, rust, economics Rust incentive crate, payment-channel economics per ADR 003
    Coding agent Suitable Requirements and scope are clearly enumerated; existing bindings and voucher primitives are already in-tree; success criteria are explicit (openChannel + lifecycle calls wired into cache-miss path)

    🔗 Similar issues

    No duplicates found. Directly related: #327 (parent), #317 (cache-miss client_requester), #324 (dispute monitor, explicitly out of scope).

    💡 Notes and suggestions

    Implementation entry points:

    • crates/incentive/src/payment_channel.rs — add openChannel, topUp, reclaimExpired to the sol! binding surface.
    • New BuyerChannelService (or extend existing service with a buyer role) to hold HashMap<Address, ChannelState> keyed by upstream provider address.
    • Hook into the cache-miss requester (#317 client_requester) to lazily open/reuse a channel on first pull to each provider.

    Key decision to land: Lazy-open trigger policy. The issue suggests lazy on first miss + channel reuse — that's the natural default given USDC approve gas overhead is amortized over many pulls.

    USDC approve: One-time approval per ADR 003 § Deposit Economics. Recommend a large but bounded approval (e.g. type(uint256).max) issued once at node startup if a USDC balance is present, or per-channel if the node prefers tighter allowances.

    Suggested sub-tasks:

    Anti-panic reminder: all new incentive crate code must use Result/Option — no unwrap/expect (clippy denies workspace-wide).

    Generated by Agentic Triage for issue #744 · sonnet46 373.2K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

design:economicskind:featurerust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions