You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cooperative close: unilateral pre-expiry settle for unreachable providers #988
design:economicsToken economics, pricing, fee split, bond sizingkind:featureNew capability or a change to current behaviorprio:lowWhen convenientstatus:blockedWaits on another PR, an upstream fix or a decision
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).
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.
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
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.
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.
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:
Add submit_unilateral_close to buyer channel incentive logic
design:economicsToken economics, pricing, fee split, bond sizingkind:featureNew capability or a change to current behaviorprio:lowWhen convenientstatus:blockedWaits on another PR, an upstream fix or a decision
Activity
github-actions commentedon Jun 24, 2026
🎯 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
reclaimExpiredpath, leaving the buyer's deposit locked far longer than necessary. This issue proposes adding the buyer-side unilateralcloseChannel→ 48h dispute window →settleChannelpath — mirroring the existing seller-side logic inpayment_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
enhancement,economics,technical,blocked,low🔗 Similar issues
cooperativeCloseon-chain contract and ADR 003 cooperative-close section that defines the primitives used herereclaimExpirednonce-leak bug, now closed, highlights the care needed around buyer-channel tx management💡 Notes and suggestions
Implementation sketch (once #972 lands):
closeChannelsubmit —buyer_channel.rsalready holds the signed client voucher needed asclientSig. The call itself is contract-callable by either party, so no new signing surface is needed. Add asubmit_unilateral_close(channel_id)helper incrates/incentive/src/buyer_channel.rs(orcrates/node/src/buyer_channel.rs) that wraps thecloseChannelcontract call.Pending-window state — The seller-side
payment_settlement.rsalready has aclose→settlestate machine. Buyer-side needs an analogous structure: a persisted map ofchannel_id → close_submitted_at(block timestamp or wall clock) to know when the 48h window has elapsed. Consider whether this lives inBuyerChannelStateor a separate table in the node's store.settleChannelfollow-up sweep — A periodic task (can be the same periodic cadence as the seller-side sweep) that queries pending-window entries and callssettleChannelonceblock.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.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_repeatedlybranches, callsubmit_unilateral_closeinstead of logging and continuing. The existingreclaimExpiredpath 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:
submit_unilateral_closeto buyer channel incentive logicsettle_pending_buyer_closessweep taskevm_increaseTime)Add this agentic workflows to your repo
To install this agentic workflow, run
fix(node): address PR review on buyer unilateral close (#988)
fix(node): keep buyer record when the post-close settle handoff fails (…
feat(node): buyer-side unilateral close→settle for unreachable provid…
refactor(node): remove dead pairwise-channel dispute/close/settle met…
refactor(node): drop PaymentPool close monitor; lean on the redeem sw…