Repository navigation
Description
Problem
A client's unused deposit (`deposit − claimedAmount`) is only returned via `closeChannel` → 48h dispute window → `settleChannel`. The window exists to let an offline party counter a stale-low close with a higher voucher. When both parties are online and agree on the final state, that 48h is pure latency on the client's refund.
The provider already has a window-free path to its own earnings (`withdraw`); the client has no equivalent. Asymmetry, not a deep design constraint.
Proposal
Add `cooperativeClose(channelId, amount, nonce, bytesDelivered, clientVoucherSig, providerCloseSig)` — settles in one tx, no dispute window, callable by either party. Requires two signatures over the same final tuple:
- client voucher sig — caps the amount the provider may claim.
- provider `CooperativeClose` waiver (new EIP-712 typehash) — provider attests it holds no higher voucher and waives the window.
With both sigs over one tuple there is nothing to dispute → settle immediately (route provider's `amount − withdrawnAmount`, refund client `deposit − amount`).
Safety
- No locked funds. Purely additive; if the node is offline/declines, client falls back to the existing `closeChannel` path. No enforcement/timeout/escrow.
- Finality. Terminal `Closed` set atomically; the on-chain `claimed*` watermark (not the off-chain sig) is the anchor — a stale waiver below it reverts (`AmountRegression`/`NonMonotonicNonce`) and can never under-settle. `Open`-only.
- Paused router. Mirrors `settleChannel`'s defer branch so a paused `FeeRouter` never freezes the client refund.
Off-chain exchange
Two new `cdn/client/v1` `ClientMessage` variants: `CooperativeCloseRequest { channel_id }` → `CooperativeCloseAuth { amount, nonce, bytes_delivered, signature }`. Standalone request/response. Node-side discipline: don't sign while a delivery is in flight, and stop accepting payment on the channel after signing.
Scope
- ADR 003 § Cooperative close
- `PaymentChannel.cooperativeClose` + `COOPERATIVE_CLOSE_TYPEHASH` + tests (Solidity)
- Rust wire variants + `crates/incentive` waiver signing + node handler/guard (follow-up)
ADR + Solidity land together; the Rust off-chain implementation follows the ADR.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
github-actions commentedon Jun 18, 2026
🎯 Triage report
A well-specified feature that eliminates the 48h dispute window when both parties are online and cooperating. The proposal uses dual EIP-712 signatures (client voucher sig + provider
CooperativeClosewaiver) over the same final tuple, which is the standard safe pattern for off-chain payment channel optimistic settlement. The Solidity scope (ADR 003 update + contract + tests) is self-contained; the Rust off-chain implementation is correctly deferred as a follow-up.📊 Assessment
enhancement,technical,ADR,economics,medium🔗 Similar issues
PaymentChannel.💡 Notes and suggestions
Implementation checklist (Solidity)
COOPERATIVE_CLOSE_TYPEHASH— includechannelId,amount,nonce,bytesDeliveredin the type hash to prevent cross-channel and cross-field replay.amount— theamount − withdrawnAmountrouting requiresamount >= withdrawnAmount, otherwise revert (similar toAmountRegression).Open-only (per spec). Must not be callable inClosingstate (would bypass the dispute window the uncooperative-close path relies on).claimedAmountwatermark is updated atomically when writing the terminalClosedstate, not just on theFeeRoutercall, so a replay attempt always reverts.settleChannel's paused-router defer branch exactly — test with a mock paused router to confirm the client refund is never frozen.withdrawnAmount) reverts withAmountRegression.NonMonotonicNonce.settleChannelso indexers don't need a separate code path.Closing-state channel reverts.EIP-712 note: The provider waiver is a new typehash distinct from the client voucher typehash — ensure the domain separator binds to the contract address and chain ID so testnet waivers can't be replayed on mainnet.
Node-side (Rust, follow-up): The guard "don't sign while a delivery is in flight" should be a mutex/state flag in
crates/incentive, not just a convention. The node must also stop accepting new vouchers on a channel after emittingCooperativeCloseAuth— otherwise a race between the off-chain ack and an in-flight voucher could leave a higher voucher unclaimed.Add this agentic workflows to your repo
To install this agentic workflow, run
feat(protocol,incentive): cooperative-close wire + EIP-712 foundation (…
docs(incentive): note cooperativeClose binding precedes the contract (#…
refactor(contracts): cooperativeClose reverts (not defers) on paused …
feat(contracts): cooperative close on PaymentChannel (fast settle, no…
feat(protocol,incentive): cooperative-close wire + EIP-712 foundation (…
feat(node): cooperative-close provider side — sign waiver + stop serv…
feat(node): cooperative-close provider side — sign waiver + stop serv…
feat(node): cooperative-close provider side — sign waiver + stop serv…