Skip to content

fix: return 410 ChannelClosed for zero-deposit settled channels#243

Open
grandizzy wants to merge 1 commit intowevm:mainfrom
grandizzy:fix/zero-deposit-channel-closed
Open

fix: return 410 ChannelClosed for zero-deposit settled channels#243
grandizzy wants to merge 1 commit intowevm:mainfrom
grandizzy:fix/zero-deposit-channel-closed

Conversation

@grandizzy
Copy link

During settlement the escrow contract may zero the deposit before setting the finalized flag. This creates a brief window where finalized=false but deposit=0.

Without this guard, vouchers against such channels return 402 (AmountExceedsDepositError) instead of the correct 410 (ChannelClosedError).

The 402 causes clients (e.g. Foundry's MPP transport) to misinterpret the error — they think the voucher amount is wrong and retry with the same stale channel state. With 410, clients correctly clear their local channel state and open a fresh channel on the next request.

Fix

Add a guard in verifyAndAcceptVoucher (after the finalized and closeRequestedAt checks): if deposit === 0 on a channel with a real payer, throw ChannelClosedError (410).

How to reproduce

  1. Open a channel and send vouchers until settlement is triggered
  2. Settlement zeroes the deposit on-chain
  3. Client sends another voucher before finalized is set
  4. Server returns 402 instead of 410

During settlement the escrow contract may zero the deposit before
setting the finalized flag. This creates a window where finalized=false
but deposit=0. Without this guard, vouchers against such channels
return 402 AmountExceedsDepositError instead of 410 ChannelClosedError.

The 410 response tells clients to clear their local channel state and
open a fresh channel on the next request, which is the correct recovery
path.
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.

1 participant