Skip to content

refactor(contracts): drop PaymentChannel forced-inclusion detection, raise dispute floor to 48h - #1204

Merged
thiras merged 4 commits into
mainfrom
refactor/paychan-drop-forced-inclusion
Jul 15, 2026
Merged

thiras merged 4 commits into
mainfrom
refactor/paychan-drop-forced-inclusion

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

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

    • Increased the configurable payment-channel dispute window from 12–72 hours to 48–72 hours, with a 48-hour default.
    • Removed forced-inclusion-based deadline extensions; dispute deadlines now remain fixed.
    • Updated payment-channel data returned by the system to reflect the revised channel information layout.
    • Updated settlement handling, governance guidance, deployment documentation, and operational runbooks to reflect the new safety bounds.
  • Bug Fixes

    • Added coverage ensuring disputes cannot move an existing deadline.

…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]>
Copilot AI review requested due to automatic review settings July 15, 2026 15:38
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@thiras, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 14 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 5713606a-bbb6-4565-9de8-00bef0eb1aa8

📥 Commits

Reviewing files that changed from the base of the PR and between 4c0dddf and ed650a5.

📒 Files selected for processing (1)
  • contracts/.gas-snapshot

Walkthrough

The 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.

Changes

Payment channel dispute behavior

Layer / File(s) Summary
Contract bounds and fixed dispute deadlines
contracts/src/PaymentChannel.sol, contracts/test/PaymentChannel.t.sol, contracts/.gas-snapshot
The dispute window is constrained to 48h–72h, forced-inclusion deadline extension paths are removed, the Channel tuple changes, and tests verify deadlines remain fixed.
ABI and settlement interface alignment
crates/incentive/src/payment_channel.rs, crates/node/src/payment_settlement.rs
The Rust Channel binding matches the reordered contract tuple without extended, and settlement comments describe live-deadline restamping.
ADR and operational parameter updates
adr/003-payments.md, adr/009-governance.md, adr/016-contract-interactions.md, adr/appendix-*.md, adr/architecture.md
Protocol and operational documentation changes the governable dispute-window range to 48h–72h and removes the deadline-extension mitigation description.

Estimated code review effort: 2 (Simple) | ~15 minutes


Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 88.92% (2488/2798 lines)
▼ -0.05pp vs base (88.97% → 88.92%)
Run: 29457201438

@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 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.

Comment thread contracts/src/PaymentChannel.sol Outdated
Comment on lines 160 to 165
// 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copilot AI 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.

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 the extended channel 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.

Comment thread adr/003-payments.md Outdated
Comment on lines +380 to +383
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread adr/appendix-l2-deployment.md Outdated
(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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reworded in 4c0dddf: "...never dropped below the forced-inclusion delay (≤ 24 h)." The inequality now clearly qualifies the delay, not the comparison.

alpergundogdu and others added 2 commits July 15, 2026 17:33
…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]>
@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.45% (was 80.44%, ▲ +0.01%) — 47557/59117 lines

File Coverage Lines Δ
crates/node/src/payment_settlement.rs 54.61% 906/1659 ● 0.00%
History
Commit Total Δ vs base
4c627f0 80.42% ▲ +0.13%
ed650a5 (HEAD) 80.45% ▲ +0.01%

…-forced-inclusion

# Conflicts:
#	contracts/.gas-snapshot
@thiras
thiras merged commit 2b42f8d into main Jul 15, 2026
23 checks passed
@thiras
thiras deleted the refactor/paychan-drop-forced-inclusion branch July 15, 2026 23:10
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.

PaymentChannel: cut forced-inclusion detection; raise dispute-window floor to 48h

3 participants