Cross-assign signed context for intra clear3#457
Conversation
Raindex evaluates each order with the counterparty's signed context slot, so oracle context fetched onto an order struct must be swapped when building clear3 args. Co-authored-by: Cursor <cursoragent@cursor.com>
WalkthroughAdds a ChangesSigned context centralization
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/core/modes/intra/simulation.test.ts (1)
637-694: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAdd V6 calldata coverage for the swapped signed contexts. This file only covers
getCalldataForV4Order; add the sameclear3signed-context expectation forgetCalldataForV4OrderV6()(or a dedicated V6 case) so the Orderbook V6 path is covered too.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/core/modes/intra/simulation.test.ts` around lines 637 - 694, The current test only validates the V4 calldata path in getCalldataForV4Order, so add coverage for the V6 variant as well. Extend the simulation.test.ts suite with a getCalldataForV4OrderV6 case (or equivalent) that asserts the clear3 call includes the swapped signed contexts via getClearSignedContexts, using the same style of encodeFunctionData expectations already present for the V4 test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/core/modes/intra/simulation.test.ts`:
- Around line 637-694: The current test only validates the V4 calldata path in
getCalldataForV4Order, so add coverage for the V6 variant as well. Extend the
simulation.test.ts suite with a getCalldataForV4OrderV6 case (or equivalent)
that asserts the clear3 call includes the swapped signed contexts via
getClearSignedContexts, using the same style of encodeFunctionData expectations
already present for the V4 test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 46b1c527-0c5b-41b2-b0f0-35d96dd1a922
📒 Files selected for processing (2)
src/core/modes/intra/simulation.test.tssrc/core/modes/intra/simulation.ts
|
moved to #458 |
Summary
clear3reverts (panic 0x32) on RaindexV6 by cross-assigning signed context when building intra-orderbook calldata.signedContexttoclear3/4#456 stopped passing empty[], []but still wired each order's context into the same-named calldata slot; Raindex actually evaluates alice withbobSignedContextand bob withaliceSignedContext.getClearSignedContexts()and uses it for both V5 and V6clear3calldata builders.Context
For a clear where the oracle order is bob (
0x571b97e3…), oracle context must land inaliceSignedContext. With #456's direct assignment it ended up inbobSignedContext, so bob's eval saw an empty array and reverted onsigned-context<0 0>().Test plan
getClearSignedContexts()cross-assignmentgetCalldataForV4Ordertest to expect swapped context argstestjobSummary by CodeRabbit