Repository navigation
refactor(contracts): drop PaymentChannel forced-inclusion detection, raise dispute floor to 48h - #1204
Conversation
…raise dispute floor to 48h Forced-inclusion detection is un-implementable on Arbitrum One: a user's signed delayed-inbox tx is indistinguishable on-chain from a sequencer tx, so `_arrivedViaForcedInclusion()` can never return true and the deadline- extension branch is permanently dead. Remove the seam, the guarantee constant, the `extended` struct field, and the test scaffolding. Censorship resistance now rests solely on the baseline dispute window sitting above the L2 force-inclusion delay; raise the governance floor from 12h to 48h (floor = default) per the monotonic-tightening posture. Closes #1196 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Warning Review limit reached
Next review available in: 14 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (1)
WalkthroughThe payment channel dispute-window minimum changes from 12 hours to 48 hours. Forced-inclusion deadline extension support is removed, Channel layouts and Rust bindings are synchronized, tests and gas snapshots are updated, and ADRs reflect the revised protocol bounds. ChangesPayment channel dispute behavior
Estimated code review effort: 2 (Simple) | ~15 minutes Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 88.92% (2488/2798 lines) |
There was a problem hiding this comment.
Code Review
This pull request simplifies the censorship resistance mechanism by removing the on-chain forced-inclusion deadline extension and raising the minimum dispute window floor from 12 hours to 48 hours. Feedback suggests optimizing the Channel struct layout in PaymentChannel.sol to reduce its storage footprint from 10 to 9 slots, which would save gas during channel creation.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| // Packed into one slot (8+8+8+1 = 25 bytes): timestamps fit `uint64` | ||
| // for ~584 billion years, matching the `SlashRecord`/`Appeal` convention. | ||
| uint64 openedAt; | ||
| uint64 expiresAt; | ||
| uint64 disputeDeadline; | ||
| Status status; |
There was a problem hiding this comment.
By reordering the fields in the Channel struct, we can pack the address fields with the uint64 timestamps and the Status enum, reducing the storage footprint of each Channel from 10 slots to 9 slots. This saves 1 storage slot write (20,000 gas) on channel creation (openChannel).\n\nCurrently, the struct is laid out as:\n- Slot 0: client (20 bytes)\n- Slot 1: provider (20 bytes)\n- Slot 2: token (20 bytes)\n- Slots 3-8: deposit, claimedAmount, claimedNonce, claimedBytes, withdrawnAmount, withdrawnBytes (32 bytes each)\n- Slot 9: openedAt (8 bytes) + expiresAt (8 bytes) + disputeDeadline (8 bytes) + status (1 byte)\n\nIf we reorder the fields to interleave the address fields with the uint64 and Status fields, Solidity will pack them as follows:\n- Slot 0: client (20 bytes) + openedAt (8 bytes) + status (1 byte) = 29 bytes\n- Slot 1: provider (20 bytes) + expiresAt (8 bytes) = 28 bytes\n- Slot 2: token (20 bytes) + disputeDeadline (8 bytes) = 28 bytes\n- Slots 3-8: the remaining uint256 fields\n\nThis reduces the total storage slots used by the Channel struct from 10 to 9.\n\nHere is the suggested optimized struct layout:\n\nsolidity\n struct Channel {\n address client;\n uint64 openedAt;\n Status status;\n address provider;\n uint64 expiresAt;\n address token;\n uint64 disputeDeadline;\n uint256 deposit;\n uint256 claimedAmount;\n uint256 claimedNonce;\n uint256 claimedBytes;\n uint256 withdrawnAmount;\n uint256 withdrawnBytes;\n }\n
There was a problem hiding this comment.
Applied in 4c0dddf. Reordered the Channel struct to interleave each address with a uint64 timestamp (and status on client's slot), packing the header from 4 slots into 3. Gas snapshot regenerated; openChannel drops ~20k gas as expected. The alloy sol! binding and the ADR 003 snippet were updated to match the new ABI field order.
There was a problem hiding this comment.
Pull request overview
This PR removes the (Arbitrum-unimplementable) forced-inclusion detection / deadline-extension path from PaymentChannel, and hardens censorship resistance by raising the governance dispute-window floor to 48h (equal to the default), with corresponding test and ADR documentation updates.
Changes:
- Drop
PaymentChannel’s forced-inclusion detection seam and the one-time dispute-deadline extension logic (including theextendedchannel field). - Raise the dispute-window safety floor from 12h to 48h (bounds now 48h–72h), updating enforcement and tests.
- Update ADRs/appendices to reflect that censorship resistance relies solely on keeping the baseline dispute window above the L2 force-inclusion delay.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| contracts/src/PaymentChannel.sol | Removes forced-inclusion extension machinery and raises DISPUTE_WINDOW_FLOOR to 48h; updates NatSpec accordingly. |
| contracts/test/PaymentChannel.t.sol | Deletes forced-inclusion harness/tests; updates dispute-window bound expectations and adds/keeps a “deadline does not move” dispute test. |
| adr/003-payments.md | Updates dispute-window bounds and rewrites L2 censorship mitigation text to baseline-window-only. |
| adr/009-governance.md | Updates governance parameter table and rationale for dispute-window bounds to 48h–72h. |
| adr/016-contract-interactions.md | Updates dispute-window min/max in the contract parameter table. |
| adr/architecture.md | Updates the Arbitrum sequencer liveness assumption mitigation bounds to 48h–72h. |
| adr/appendix-fraud-detection.md | Updates dispute-window bounds and removes references to the forced-inclusion deadline extension. |
| adr/appendix-operator-key-rotation.md | Updates operational guidance to reflect new production dispute-window governance bounds. |
| adr/appendix-l2-deployment.md | Updates the dispute-window governance bounds and narrative for the new 48h floor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| uint256 openedAt; | ||
| uint256 expiresAt; | ||
| uint8 status; // 0 = Open, 1 = Closing (dispute window active), 2 = Closed (settled) | ||
| uint256 disputeDeadline; // set when close is initiated; may be extended once via the forced-inclusion path (see § L2 sequencer censorship) | ||
| bool extended; // true if disputeDeadline has been extended once via the forced-inclusion path; reset to false on closeChannel | ||
| uint256 disputeDeadline; // set when close is initiated; fixed for the dispute window |
There was a problem hiding this comment.
Fixed in 4c0dddf. The ADR 003 Channel snippet now mirrors the on-chain declaration order exactly — uint64 for openedAt/expiresAt/disputeDeadline, and the packed order (client, openedAt, status, provider, expiresAt, token, disputeDeadline, then the uint256 fields) — so a getChannel tuple decodes correctly against the doc.
| (12 h–72 h) apply identically; the 12-hour floor is unsafe wherever forced-inclusion | ||
| exceeds 12 hours — a governance guardrail issue independent of the chain chosen here. | ||
| (48 h–72 h) apply identically; the 48-hour floor equals the default, so the baseline | ||
| window can only be tightened upward and never dropped below a ≤ 24 h forced-inclusion delay. |
There was a problem hiding this comment.
Reworded in 4c0dddf: "...never dropped below the forced-inclusion delay (≤ 24 h)." The inequality now clearly qualifies the delay, not the comparison.
…nnel struct - Regenerate .gas-snapshot after the struct/const removal (stale baseline failed `solidity build+test`). - Sync the `decdn_incentive` PaymentChannel `sol!` binding to the new `Channel` ABI (drop `extended`, new field order); the 14→13 field drift broke `getChannel` decoding and stalled the anvil settlement e2e. - Pack the `Channel` struct: interleave each address with a uint64 timestamp (and status), 4 header slots → 3, saving ~20k gas on openChannel (Gemini). - Match the ADR 003 Channel snippet to the on-chain layout (Copilot) and reword the appendix force-inclusion-delay sentence. - Drop stale forced-inclusion-extension references in settlement comments. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-forced-inclusion
Coverage reportTotal: 80.45% (was 80.44%, ▲ +0.01%) — 47557/59117 lines
History
|
…-forced-inclusion # Conflicts: # contracts/.gas-snapshot
Forced-inclusion detection is un-implementable on Arbitrum One — a signed delayed-inbox tx is on-chain indistinguishable from a sequencer tx, so the extension branch was permanently dead. Censorship resistance now rests solely on the baseline dispute window being above the L2 force-inclusion delay; the governance floor rises from 12h to 48h (floor = default).
Closes #1196
🤖 Generated with Claude Code
Summary by CodeRabbit
Updates
Bug Fixes