Skip to content

Cooperative close: unilateral pre-expiry settle for unreachable providers #988

Description

@alpergundogdu

Follow-up to #972 (idle buyer-channel cooperative-close reconcile). That sweep cooperatively closes idle channels whose provider answers; when the provider is unreachable / declined / reverted it leaves the channel for the existing expiry-reclaim sweep (reclaimExpired), which only fires after on-chain expiry (default 90 days).

Gap

If a provider vanishes (deregistered / offline), its idle channel's deposit stays locked until expiry even though cooperative close is impossible. Reclaiming sooner needs a buyer-side unilateral path: closeChannel(channelId, amount, nonce, bytes, clientSig) → 48h dispute window → settleChannel.

Scope

  • Buyer-side closeChannel submit (the node already signs the client voucher; the contract call is callable by either party).
  • Pending-window tracking + a settleChannel follow-up sweep for buyer channels (mirrors the seller-side close→settle in crates/node/src/payment_settlement.rs, which today is seller-only).
  • Trigger from the Cooperative close: node-as-buyer periodic reconcile of node→node channels #972 reconcile sweep when an idle channel's provider is unreachable (node_id_for returns None) or repeatedly declines, rather than waiting for expiry.

Why deferred

Roughly doubles the buyer-side surface (new dispute-window state machine) and the expiry-reclaim sweep already recovers these deposits — just later. Capital-efficiency optimization, not correctness.

Refs: #972, #947 (parent), ADR 003 §Cooperative close / §node→node.

Activity

  1. added
    status:blocked
    design:economics
    kind:feature
    prio:low
    on Jun 24, 2026
  2. github-actions commented on Jun 24, 2026

    @github-actions

    🎯 Triage report

    A well-scoped, explicitly deferred capital-efficiency improvement to the payment-channel close lifecycle. When the #972 cooperative-close sweep finds a provider unreachable or repeatedly declining, it currently falls through to the 90-day reclaimExpired path, leaving the buyer's deposit locked far longer than necessary. This issue proposes adding the buyer-side unilateral closeChannel → 48h dispute window → settleChannel path — mirroring the existing seller-side logic in payment_settlement.rs — and having #972 trigger it instead of silently deferring. The author explicitly marks it deferred because correctness is preserved by the existing expiry path; this is an optimization.

    📊 Assessment

    Dimension Value Reasoning
    Type Feature New buyer-side unilateral close state machine; additive to existing settlement paths
    Labels enhancement, economics, technical, blocked, low Capital-efficiency improvement; involves Rust payment infra; explicitly blocked on #972; author-designated deferred/non-critical
    Coding agent Needs more info Scope is clear and well-defined, but blocked on #972 landing first; implementation requires the #972 reconcile sweep to exist as the trigger point

    🔗 Similar issues

    💡 Notes and suggestions

    Implementation sketch (once #972 lands):

    1. closeChannel submit — buyer_channel.rs already holds the signed client voucher needed as clientSig. The call itself is contract-callable by either party, so no new signing surface is needed. Add a submit_unilateral_close(channel_id) helper in crates/incentive/src/buyer_channel.rs (or crates/node/src/buyer_channel.rs) that wraps the closeChannel contract call.

    2. Pending-window state — The seller-side payment_settlement.rs already has a close→settle state machine. Buyer-side needs an analogous structure: a persisted map of channel_id → close_submitted_at (block timestamp or wall clock) to know when the 48h window has elapsed. Consider whether this lives in BuyerChannelState or a separate table in the node's store.

    3. settleChannel follow-up sweep — A periodic task (can be the same periodic cadence as the seller-side sweep) that queries pending-window entries and calls settleChannel once block.timestamp >= close_submitted_at + 48h. Watch for the alloy cached-nonce issue documented in Buyer/seller PaymentChannel: reverting reclaimExpired leaks alloy cached nonce, can wedge subsequent txs #904 — pre-check on-chain state before submitting.

    4. Trigger integration in Cooperative close: node-as-buyer periodic reconcile of node→node channels #972 — In the Cooperative close: node-as-buyer periodic reconcile of node→node channels #972 reconcile sweep's provider_unreachable / declined_repeatedly branches, call submit_unilateral_close instead of logging and continuing. The existing reclaimExpired path remains as the ultimate fallback if the dispute-window settle also fails.

    Key risk: The dispute window means a provider who comes back online within 48h can counter with a higher voucher. This is the intended contract behavior — but the sweep should check that the voucher held locally is the highest nonce before initiating unilateral close, to avoid a legitimate counter that results in less reclaim than expected.

    Sub-tasks:

    Generated by Agentic Triage for issue #988 · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

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

Metadata

Metadata

Assignees

Labels

design:economicskind:featureprio:lowstatus:blocked

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions