Skip to content

Route each clear4 signed context to its own order - #2920

Merged
thedavidmeister merged 8 commits into
mainfrom
2026-10-25-clear4-signed-context-routing
Oct 26, 2026
Merged

thedavidmeister merged 8 commits into
mainfrom
2026-10-25-clear4-signed-context-routing

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2850

Stacked on #2929 (V7 adoption: IRaindexV7, SignedContextV2, domains column, signer-domain word, renames, Rust/JS/subgraph/oracle). This PR's diff against it is only the clear4 routing fix and its tests.

Problem

clear4 (like clear3 before it) evaluates alice's order with bobSignedContext and bob's with aliceSignedContext. That contradicts the interface docs and the per-order routing quote3/takeOrders5 use. Per the ruling on #2850, V6 stays as shipped and the fix lands with the V7 interface break.

Fix

clear4 evaluates alice with aliceSignedContext and bob with bobSignedContext.

Why this is correct

Each order's expression asserts the signer, domain and content it sees, so routing is pinned by what the signer signed, not by slot index. Under the old routing alice would see bob's signer and domain.

Evidence

Head 3cdb7c888ee2728520c1027376d513d40908314e, locally at rainix 2aea60e5:

  • Regen (build-meta, Build.sol x2, forge build, script/build.sh, forge fmt). The resulting pins are identical to the previously verified head 5195e565c; the tree differs from it only in tests.
  • forge test: 759 passed, 3 failed, 762 total. The 3 are FLARE_RPC_URL unset.
  • cargo test --workspace: 1927 passed, 0 failed.
  • subgraph-test (matchstick): 46/46.
  • pre-commit run --all-files in sol-shell and rust-shell: pass, no changes.

QA

  • Discriminating tests: RaindexV6.clear.signedContextRouting.t.sol: testClearRoutesEachSignedContextToItsOwnOrder (distinct signers/domains/content per order, clear succeeds), testClearRevertsWhenSignedContextsAreSwapped (reverts alice signer), testClearRevertsWhenDomainsAreSwapped (same signer and content, only the domain differs; reverts alice domain). All three fail on Adopt IRaindexV7 and SignedContextV2 #2929 routing.
  • Mutations applied (targeted RaindexV6.clear.*, each reverted after): clear4 routing swapped back to the base PR's (alice <- bobSignedContext, bob <- aliceSignedContext) -> killed by all three routing tests; M09 (order-eval domains zeroed) and M10 (domains dropped) -> killed by testClearRoutesEachSignedContextToItsOwnOrder, testClearRevertsWhenDomainsAreSwapped and the base PR's testClearEvalSeesSignedContextV2. The base PR's testClearEvalSeesSignedContextV2 passes under both routings, as intended.
  • Oracle: expected routing from the ruling on clear3 cross-wires alice/bob signed context vs its interface docs; next version must fix it with a loud break #2850; signatures built with OZ MessageHashUtils.toTypedDataHash(domainSeparator, LibContext.hashStruct(...)) and vm.sign.
  • Category check: clear3 cross-wires alice/bob signed context vs its interface docs; next version must fix it with a loud break #2850 asks for per-order routing in clear4 behind a loud interface break; the break (removed clear3 selector) is in the base PR, the routing is here.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Corrected signed-context handling during order clearing. Each order now receives its own signed context, preventing valid orders from being evaluated with the other order’s context.
    • Added coverage for context routing, including cases where contexts are swapped or differ by domain.

@thedavidmeister thedavidmeister self-assigned this Oct 25, 2026
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

RaindexV6 now passes each order its corresponding signed context in clear4. New tests check routing by signer, domain, and content. The ABI declarations remain unchanged.

Changes: clear4 signed-context routing

Layer / File(s) Summary
Route contexts to matching orders
src/concrete/raindex/RaindexV6.sol, crates/test_fixtures/abis/RaindexV6.json
clear4 passes Alice’s signed context to Alice’s order evaluation and Bob’s signed context to Bob’s. The RaindexV6 bytecode fixture is updated; ABI declarations are unchanged.
Test signed-context routing
test/concrete/raindex/RaindexV6.clear.signedContextRouting.t.sol
Fuzz tests verify that matching contexts clear successfully and that swapped contexts revert on signer or domain checks.

Priority: Not assessed

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Merge Risk: Minimal · up to c748c

This change fixes clear4 so each order is evaluated with its own signed context, and adds tests that would fail under the old routing. No actionable merge-blocking risk remains.

Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

thedavidmeister and others added 2 commits October 26, 2026 18:56
…ntext-routing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clear4 evaluates alice with aliceSignedContext and bob with bobSignedContext,
matching quote3/takeOrders5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thedavidmeister
thedavidmeister changed the base branch from main to 2026-10-26-raindex-v7 October 26, 2026 18:57
@thedavidmeister thedavidmeister changed the title clear4: route each order's signed context to its own eval (IRaindexV7) Route each clear4 signed context to its own order Oct 26, 2026
thedavidmeister and others added 6 commits October 26, 2026 19:02
…ntext-routing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drops the clear3 selector test duplicated by the base branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ting

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ting

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ting

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thedavidmeister
thedavidmeister changed the base branch from 2026-10-26-raindex-v7 to main October 26, 2026 23:30
@thedavidmeister
thedavidmeister merged commit 9f1d266 into main Oct 26, 2026
17 of 20 checks passed
@linear

linear Bot commented Oct 26, 2026

Copy link
Copy Markdown

RAI-3912

@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

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.

clear3 cross-wires alice/bob signed context vs its interface docs; next version must fix it with a loud break

1 participant