Skip to content

test(incentive,contracts): pin cooperative-close EIP-712 waiver parity vector (#1009) - #1010

Merged
thiras merged 2 commits into
mainfrom
fix/1009-coop-close-waiver-vector
Jun 27, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/1009-coop-close-waiver-vector

Conversation

@thiras

@thiras thiras commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

What

Closes #1009. Test-only change pinning a committed EIP-712 parity vector for the cooperative-close waiver across the off-chain Rust signer (crates/incentive) and the on-chain Solidity verifier (PaymentChannel).

Why

The cooperative-close path (#948/#949/#957/#973) signs the waiver off-chain in Rust and verifies it on-chain, with the EIP-712 type and domain hand-duplicated on each side and no shared source. Nothing pinned the full typed-data digest across both languages, so a drift in the domain (name/version) or struct encoding would produce unsettleable waivers with no test failure — the prior coverage only pinned the typehash string (Rust) and round-tripped sign/recover within each language.

Change

One canonical vector, asserted from both sides:

  • Rust — EXPECTED_COOP_CLOSE_DIGEST + cooperative_close_digest_matches_committed_vector: sample_close().signing_hash(sample_domain()) must equal the pinned digest (full real sol! impl).
  • Solidity — test_cooperativeClose_digestMatchesVector recomputes the digest with the contract's live COOPERATIVE_CLOSE_TYPEHASH() and the vector's fixed domain; test_cooperativeClose_domainMatchesVector ties the deployed contract's ERC-5267 eip712Domain() name/version to the vector.

The single committed digest 0x680080f3…d8d627 is byte-identical in both files; either side drifting breaks its test.

Verification

Reviewed via pr-review-toolkit (code / tests / comments); no critical issues. Comment-precision feedback folded in.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added committed cooperative-close EIP-712 parity fixtures and cross-language checks.
    • Added digest verification that recomputes the full signing hash and matches a committed expected value.
    • Added domain metadata verification for the expected name and version.
    • Updated gas snapshots for multiple PaymentChannel test scenarios.
  • Bug Fixes
    • Strengthened typed-data signing consistency checks to keep on-chain and off-chain results aligned.

…y vector (#1009)

The cooperative-close waiver (PRs #948/#949/#957/#973) is signed off-chain in
Rust and verified on-chain by PaymentChannel, with the EIP-712 type and domain
hand-duplicated on each side. Nothing pinned the full typed-data digest across
both, so a drift in the domain (name/version) or struct encoding would produce
unsettleable waivers with no test failure — the existing coverage only pinned
the typehash string (Rust) and round-tripped sign/recover within each language.

Commit one canonical parity vector and assert it from both sides:

- Rust: EXPECTED_COOP_CLOSE_DIGEST + cooperative_close_digest_matches_committed_vector
  asserting sample_close().signing_hash(sample_domain()) equals it.
- Solidity: test_cooperativeClose_digestMatchesVector recomputes the digest with
  the contract's public COOPERATIVE_CLOSE_TYPEHASH and the fixed domain, and
  test_cooperativeClose_domainMatchesVector ties the deployed contract's
  ERC-5267 eip712Domain() name/version to the vector.

Verified the vector catches the drift class: bumping the domain version on
either side fails the corresponding test. Test-only; no production code changed.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 27, 2026 04:46
@coderabbitai

coderabbitai Bot commented Jun 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fdabe834-c4e1-4091-954e-40bdce9b8cfb

📥 Commits

Reviewing files that changed from the base of the PR and between d53ccaf and c14c5f3.

📒 Files selected for processing (1)
  • contracts/.gas-snapshot
✅ Files skipped from review due to trivial changes (1)
  • contracts/.gas-snapshot

Walkthrough

Adds committed cooperative-close EIP-712 digest vectors and verification tests in Rust and Solidity, and refreshes the gas snapshot values for affected test cases.

Changes

Cross-language cooperative-close parity

Layer / File(s) Summary
Rust digest vector
crates/incentive/src/cooperative_close.rs
Adds a committed cooperative-close typed-data digest and a test that recomputes signing_hash from sample_close() and sample_domain().
Solidity parity tests
contracts/test/PaymentChannel.t.sol
Adds cooperative-close fixture constants and tests that recompute the EIP-712 digest and verify eip712Domain() name/version.

Gas snapshot refresh

Layer / File(s) Summary
Snapshot updates
contracts/.gas-snapshot
Updates recorded gas values for PaymentChannelTest cases and adjusts one TokenTest snapshot entry.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: pinning a cooperative-close EIP-712 parity vector across incentive and contracts tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1009-coop-close-waiver-vector

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jun 27, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.96% (2160/2401 lines)
▲ +0.00pp vs base (89.96% → 89.96%)
Run: 28293686618

@github-actions

github-actions Bot commented Jun 27, 2026 •

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@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 introduces cross-language EIP-712 parity tests between the Solidity smart contracts and the off-chain Rust signer. It adds a canonical test vector and corresponding tests in both Solidity (PaymentChannel.t.sol) and Rust (cooperative_close.rs) to ensure that the computed cooperative-close digests match, preventing silent encoding or domain drift. I have no feedback to provide.

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.

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

Pins a single canonical EIP-712 typed-data digest test vector for the cooperative-close waiver and asserts it from both the off-chain Rust signer (crates/incentive) and the on-chain Solidity verifier (PaymentChannel tests), preventing silent cross-language drift in domain/type/encoding.

Changes:

  • Add a committed Rust-side EXPECTED_COOP_CLOSE_DIGEST and a test asserting sample_close().signing_hash(sample_domain()) matches it.
  • Add Solidity-side parity vector fixtures and tests that (a) recompute the digest using the contract’s live COOPERATIVE_CLOSE_TYPEHASH() and (b) assert the deployed contract’s eip712Domain() name/version match the vector.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/incentive/src/cooperative_close.rs Adds a pinned digest constant and a Rust test asserting the signer’s EIP-712 digest matches the committed vector.
contracts/test/PaymentChannel.t.sol Adds matching vector fixtures plus Solidity tests that recompute the digest and pin the contract’s EIP-712 domain name/version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jun 27, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 83.09% (was 83.09%, ● 0.00%) — 41838/50351 lines

File Coverage Lines Δ
crates/incentive/src/cooperative_close.rs 99.14% 115/116 ▲ +0.05%
History
Commit Total Δ vs base
d53ccaf 83.09% ● 0.00%
c14c5f3 (HEAD) 83.09% ● 0.00%

…ests

The #1010 vector tests add two functions plus fixtures to
PaymentChannel.t.sol, enlarging that suite's test-contract bytecode and
shifting per-test deployment gas across PaymentChannelTest, plus the two
new entries (test_cooperativeClose_digestMatchesVector,
test_cooperativeClose_domainMatchesVector). Regenerated via
`FOUNDRY_PROFILE=ci forge snapshot --snap .gas-snapshot`; non-reproducible
fuzz `runs:` lines left at committed values (the CI gate strips them).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras merged commit d2c33aa into main Jun 27, 2026
22 checks passed
@thiras
thiras deleted the fix/1009-coop-close-waiver-vector branch June 27, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants