Skip to content

docs(adr): allow client-initiated zero-voucher close - #424

Merged
alpergundogdu merged 2 commits into
mainfrom
fix/client-zero-voucher-close
May 6, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
fix/client-zero-voucher-close

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Closes #423.

Drops the msg.sender == provider restriction on the zero-voucher close path in ADR 003 so the client can also call closeChannel(amount=0, nonce=0, signature.length==0) when claimedNonce == 0.

The gap (from #423)

A client opens a 10 USDC channel, the node fails (crash, deregistration, network loss) before the first 1 MB voucher boundary, and the client has no way to close the channel. Their only escape is reclaimExpired after expiresAt — default 90 days.

The provider-only restriction was originally an escape hatch for providers tracking abandoned channels; the mirror-image client need was missed. The fix surfaces it.

Why this is safe

The attack surface reduces to exactly the existing stale-close attack surface (ADR 003 §Stale close). The defenses are reused, no new ones are needed:

  • 48h dispute window (ADR 009, governable 12–72h)
  • Permissionless disputeChannel — any address with a higher-nonce voucher can dispute
  • In-process dispute monitor for online nodes — auto-submits the latest voucher when ChannelCloseInitiated fires
  • Forced-inclusion deadline extension for L2 sequencer censorship

A griefing client who signs vouchers off-chain and then tries to repudiate them via zero-voucher close gets disputed by the online node within 48h — same protection as today's stale-close attack with a low-amount voucher.

What changes

Three edit sites in ADR 003:

  1. §Channel close lifecycle §1 closeChannel description — "when either party calls" instead of "when the provider calls"
  2. §Channel griefing §Resolved subsection — retitled "zero-voucher close (either party)"; new Why symmetric paragraph explains the rationale and attack-surface analysis
  3. §Channel close lifecycle closeChannel bullet — same widening, plus framing covering both use cases (provider releasing abandoned channel, client recovering deposit on node failure)

Plus an updated cross-reference in §Voucher Nonce Convention.

Implementation cost

One access-control line in StablePaymentChannel's zero-voucher branch:

```solidity
// before
require(msg.sender == channel.provider, "zero-voucher close is provider-only");
// after
require(
msg.sender == channel.client || msg.sender == channel.provider,
"zero-voucher close requires party authorization"
);
```

PoC contract not yet implemented, so this is a spec-level change before the contract gets written.

Refs

Test plan

  • cargo build clean
  • pre-commit run --files adr/003-payments.md — markdownlint + cargo deny pass
  • All cross-references resolve (no broken anchors)
  • Spec review for symmetry/safety argument

Note: this PR is independent of #422 (the watchtower → fraud-detection refactor). The two touch overlapping prose in ADR 003; whichever lands second will need a small rebase but no structural conflict.

🤖 Generated with Claude Code

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the payment protocol documentation to make the zero-voucher close mechanism symmetric, allowing both clients and providers to initiate a channel close when no vouchers have been submitted. This change addresses potential liquidity locks for clients during node failures and ensures providers can still clear abandoned channels. The review feedback identified technical inconsistencies in the description of the closeChannel parameters and corrected a broken internal anchor link.

Comment thread adr/003-payments.md Resolved
Comment thread adr/003-payments.md Resolved
alpergundogdu added a commit that referenced this pull request May 6, 2026
…nd §Channel close lifecycle

Address PR #424 review:

1. §Fee Routing on Disputed Closes (line 114) was inconsistent with the
   more detailed §Channel close lifecycle bullet (line 381). The Fee
   Routing description omitted bytesDelivered from both the recorded
   fields and the zero-voucher gate, and omitted bytesDelivered != 0
   from the exclusion list of normal-verification calls. Now matches
   the lifecycle bullet exactly.

2. §Voucher Nonce Convention had a broken anchor #contract-stablepaymentchannel.
   The actual section header is `### StablePaymentChannel`, which GFM
   slugifies to #stablepaymentchannel. Fixed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request May 6, 2026
…427)

* docs(adr): add ChannelOpened event so wallets can enumerate channels (#426)

A channel that has been opened but never had any subsequent on-chain
action (no closeChannel, no topUp, no dispute) is invisible to log
scans today — there's no ChannelOpened event in the spec. Wallets,
CLI tools, and indexers cannot list a client's or provider's open
channels without parsing the full transaction history of every
candidate address.

Add ChannelOpened with three indexed fields (channelId, client,
provider — the EVM maximum) so:

- Clients enumerate via eth_getLogs(topics=[ChannelOpened, *, paddedClient])
- Providers enumerate via the third topic
- Indexers key on channelId for full history reconstruction

Non-indexed payload carries `token, deposit, expiresAt`. The token
field is USDC for the PoC and an arbitrary governance-approved ERC-20
in production (per ADR 010), so the same event signature carries
through the multi-token migration without a wire-format break.

Cost: one LOG3 per openChannel (~1,150 gas) — negligible relative
to the SSTORE and safeTransferFrom already in the function (~80k gas).

Three sites updated:
- §Function table: openChannel description now mentions the emit
- §Events table: ChannelOpened added as the chronologically-first row
- New paragraph below the events table explaining the off-chain
  enumeration use case the event enables

This unblocks operationally useful CLI tooling on top of the symmetric
zero-voucher close (#424): `decdn channel list` enumerates open
channels via log scan, `decdn channel close <id>` triggers recovery
when a node has failed before any voucher boundary.

Closes #426

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(adr): drop historical narrative from ChannelOpened paragraph

Replace "Without this event, ... forcing wallets to walk the client's
entire transaction history" with positive framing of current behavior,
per gemini-code-assist review on #427.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request May 6, 2026
…nd §Channel close lifecycle

Address PR #424 review:

1. §Fee Routing on Disputed Closes (line 114) was inconsistent with the
   more detailed §Channel close lifecycle bullet (line 381). The Fee
   Routing description omitted bytesDelivered from both the recorded
   fields and the zero-voucher gate, and omitted bytesDelivered != 0
   from the exclusion list of normal-verification calls. Now matches
   the lifecycle bullet exactly.

2. §Voucher Nonce Convention had a broken anchor #contract-stablepaymentchannel.
   The actual section header is `### StablePaymentChannel`, which GFM
   slugifies to #stablepaymentchannel. Fixed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alpergundogdu
alpergundogdu force-pushed the fix/client-zero-voucher-close branch from 949112f to a3170c9 Compare May 6, 2026 12:48
alpergundogdu and others added 2 commits May 6, 2026 14:27
The provider-only restriction on the zero-voucher close path locks
client deposits for up to 90 days when a node fails before the first
1 MB voucher boundary. Their only escape is reclaimExpired after
maxChannelDuration — a routine ops failure with no malicious actor.

Drop the msg.sender == provider gate so either party can call
closeChannel(amount=0, nonce=0, signature.length==0) when
claimedNonce == 0. The 48h dispute window plus permissionless
disputeChannel handle the symmetric griefing attack surface (client
signing vouchers off-chain and then repudiating via zero-voucher
close) the same way they handle the analogous stale-close attack
today — no new attack surface.

Three sites in ADR 003 updated:
- §"Channel close lifecycle" §1 closeChannel description (line 114)
- §"Channel griefing" "Resolved" subsection (lines 172-174)
- §"Channel close lifecycle" closeChannel bullet (line 381)

Plus a new "Why symmetric" subsection explaining the rationale and
attack-surface analysis. The §"Voucher Nonce Convention" reference
to "provider-initiated zero-voucher close" is also retitled to match.

Closes #423

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…nd §Channel close lifecycle

Address PR #424 review:

1. §Fee Routing on Disputed Closes (line 114) was inconsistent with the
   more detailed §Channel close lifecycle bullet (line 381). The Fee
   Routing description omitted bytesDelivered from both the recorded
   fields and the zero-voucher gate, and omitted bytesDelivered != 0
   from the exclusion list of normal-verification calls. Now matches
   the lifecycle bullet exactly.

2. §Voucher Nonce Convention had a broken anchor #contract-stablepaymentchannel.
   The actual section header is `### StablePaymentChannel`, which GFM
   slugifies to #stablepaymentchannel. Fixed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alpergundogdu
alpergundogdu force-pushed the fix/client-zero-voucher-close branch from a3170c9 to df2cbe0 Compare May 6, 2026 13:28
@alpergundogdu
alpergundogdu merged commit 6abd474 into main May 6, 2026
9 checks passed
@alpergundogdu
alpergundogdu deleted the fix/client-zero-voucher-close branch May 6, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADR 003 gap: client cannot release deposit when node fails before first voucher (90-day liquidity lock)

1 participant