Skip to content

fix: include counterparty (zero address) as 3rd context row in addOrder/removeOrder#2779

Open
thedavidmeister wants to merge 4 commits into
mainfrom
2026-06-17-issue-2619-counterparty-context
Open

fix: include counterparty (zero address) as 3rd context row in addOrder/removeOrder#2779
thedavidmeister wants to merge 4 commits into
mainfrom
2026-06-17-issue-2619-counterparty-context

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • addOrder4 and removeOrder3 populate a post-hook entask context with two rows: orderHash and msg.sender. The spec requires a third row for the counterparty address; for order-management operations the counterparty is always address(0).
  • Fix: add bytes32(uint256(uint160(address(0)))) as the third row in the matrixFrom call for both functions.
  • Test: testAddOrderCounterpartyIsZeroAddress verifies the new third context slot is the zero address.
  • Pre-pins 0.1.7 deploy constants: RaindexV6 address changes (new bytecode), all other contracts (SubParser, RouteProcessor, arb contracts) are unchanged from 0.1.6.

REQUIRES redeploy at land — RaindexV6 bytecode changes, so testProdDeploy* will be red until it is deployed. testIsStartBlock* / testNetworksJson* / testSubgraphYamlAddress will also be red until script/build-start-blocks.sh is run against the new deployment address.

Closes #2619

Co-Authored-By: Claude noreply@anthropic.com

Summary by CodeRabbit

  • Bug Fixes

    • Improved order post-action handling so add/remove order flows now pass the expected context, including a zero-address counterparty where applicable.
    • Updated test coverage for add-order behavior to verify the corrected context handling.
  • Chores

    • Bumped the package release version to 0.1.13.
    • Refreshed deployment references for the latest published release.

…er/removeOrder (#2619)

The entask post-context for addOrder4 and removeOrder3 only had two rows
(orderHash, msg.sender).  The spec requires a third row for the
counterparty address; because these are order-management operations (not
trades) the counterparty is always the zero address.  Add
`bytes32(uint256(uint160(address(0))))` as that third row and test it.
Pre-pins 0.1.7 deploy constants (RaindexV6 address changes, all other
contracts unchanged).

REQUIRES redeploy at land — testProdDeploy* and testIsStartBlock* /
testNetworksJson* will be red until the new RaindexV6 is deployed and
build-start-blocks.sh is run.

Co-Authored-By: Claude <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Jun 17, 2026
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

RaindexV6 add/remove post actions now pass order hash, caller, and zero address in their post-task context. A new test checks order-counterparty() returns address(0). Release metadata is updated for version 0.1.13.

Changes

Raindex V6 context and release metadata

Layer / File(s) Summary
Post-action context and test
src/concrete/raindex/RaindexV6.sol, test/concrete/raindex/RaindexV6.addOrder.entask.t.sol
addOrder4 and removeOrder3 pass orderHash, msg.sender, and address(0) into LibRaindex.doPost, and the add-order enactment test checks order-counterparty() against address(0).
0.1.13 release metadata
src/lib/deploy/LibRaindexDeploy.sol, crates/test_fixtures/abis/RaindexV6.json, foundry.toml
Deployment constants for the 0.1.13 RaindexV6 suite are added, the ABI fixture bytecode object changes, and the package version is set to 0.1.13.

Sequence Diagram(s)

sequenceDiagram
  participant RaindexV6AddOrderEnactTest
  participant RaindexV6
  participant LibRaindex
  RaindexV6AddOrderEnactTest->>RaindexV6: checkAddOrder(...)
  RaindexV6->>LibRaindex: doPost(orderHash, post, [orderHash, msg.sender, address(0)])
  LibRaindex-->>RaindexV6AddOrderEnactTest: order-counterparty() resolves to address(0)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • rainlanguage/raindex#2683: Also updates src/lib/deploy/LibRaindexDeploy.sol with pinned deployment constants for a new Raindex release tag.
  • rainlanguage/raindex#2701: Also changes src/concrete/raindex/RaindexV6.sol addOrder4 post-action handling and control flow.

Poem

🐇 I hopped through contexts, tidy and bright,
Three rows in the post-task, now set just right.
A bytecode nibble, a versioned cheer,
And address(0) came softly near.
Thump thump — the audit moon glows above,
With carrot-crisp changes I nibble with love.

🚥 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 matches the main change: adding the zero-address counterparty context row to addOrder/removeOrder post-actions.
Linked Issues check ✅ Passed The code now passes a third context row with address(0) for addOrder/removeOrder, which addresses issue #2619's runtime revert.
Out of Scope Changes check ✅ Passed The version bump, deploy constants, ABI fixture update, and test all align with the PR's stated redeployment and artifact-pinning work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-06-17-issue-2619-counterparty-context

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 3 commits June 17, 2026 17:30
Regenerate arb-contract pointer files and update 0.1.7 pre-pin constants.
RaindexV6 bytecode change causes arb contracts to deploy at new addresses
since they embed the new RaindexV6 address in their deployment parameters.
…ct-per-file static check

Merge origin/main (0.1.12) into branch. Resolves conflicts in:
- src/concrete/raindex/RaindexV6.sol: keep PR's 3-row context (orderHash,
  msg.sender, address(0)) for addOrder4/removeOrder3 post-hooks
- src/lib/deploy/LibRaindexDeploy.sol: take main's published 0.1.7-0.1.12
  constants, add 0.1.13 pre-pin for this PR's new RaindexV6 bytecode
- src/generated/*.pointers.sol + crates/test_fixtures/abis/: keep HEAD
  (new bytecode from this PR)
- foundry.toml: bump version to 0.1.13

The merge brings in main's one-contract-per-file fix (PR #2731/#2749) which
resolves the rainix-sol/static check failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
test/concrete/raindex/RaindexV6.addOrder.entask.t.sol (1)

205-225: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Mirror this regression on removeOrder3.

This PR fixes both order-management flows, but the new regression only exercises addOrder4. A matching remove-order entask test would keep the second call site from drifting back to the old 2-row context.

src/concrete/raindex/RaindexV6.sol (1)

379-386: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Deduplicate the 3-row post-context builder.

These two entrypoints now hardcode the same matrix while the shared helper still represents the old 2-row shape. Keeping the context contract in two places makes this easy to drift again.

♻️ Proposed refactor
-            LibRaindex.doPost(
-                LibBytes32Matrix.matrixFrom(
-                    LibBytes32Array.arrayFrom(
-                        orderHash, bytes32(uint256(uint160(msg.sender))), bytes32(uint256(uint160(address(0))))
-                    )
-                ),
-                post
-            );
+            _doOrderPost(orderHash, address(0), post);
...
-            LibRaindex.doPost(
-                LibBytes32Matrix.matrixFrom(
-                    LibBytes32Array.arrayFrom(
-                        orderHash, bytes32(uint256(uint160(msg.sender))), bytes32(uint256(uint160(address(0))))
-                    )
-                ),
-                post
-            );
+            _doOrderPost(orderHash, address(0), post);
function _doOrderPost(bytes32 orderHash, address counterparty, TaskV2[] calldata post) internal {
    LibRaindex.doPost(
        LibBytes32Matrix.matrixFrom(
            LibBytes32Array.arrayFrom(
                orderHash,
                bytes32(uint256(uint160(msg.sender))),
                bytes32(uint256(uint160(counterparty)))
            )
        ),
        post
    );
}

Also applies to: 407-414

🤖 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/concrete/raindex/RaindexV6.sol` around lines 379 - 386, The post-context
matrix is duplicated in the RaindexV6 entrypoints, while the shared helper still
reflects the old shape. Update RaindexV6 to centralize this 3-row context
construction in a single internal helper such as _doOrderPost, and have both
entrypoints call it with the appropriate counterparty so LibRaindex.doPost and
the LibBytes32Matrix/LibBytes32Array assembly stay in one place.
🤖 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.

Nitpick comments:
In `@src/concrete/raindex/RaindexV6.sol`:
- Around line 379-386: The post-context matrix is duplicated in the RaindexV6
entrypoints, while the shared helper still reflects the old shape. Update
RaindexV6 to centralize this 3-row context construction in a single internal
helper such as _doOrderPost, and have both entrypoints call it with the
appropriate counterparty so LibRaindex.doPost and the
LibBytes32Matrix/LibBytes32Array assembly stay in one place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c693ebc8-03eb-4b9a-9e16-b4039564bdc2

📥 Commits

Reviewing files that changed from the base of the PR and between 32266db and 38368eb.

⛔ Files ignored due to path filters (4)
  • src/generated/GenericPoolRaindexV6ArbOrderTaker.pointers.sol is excluded by !**/generated/**
  • src/generated/GenericPoolRaindexV6FlashBorrower.pointers.sol is excluded by !**/generated/**
  • src/generated/RaindexV6.pointers.sol is excluded by !**/generated/**
  • src/generated/RouteProcessorRaindexV6ArbOrderTaker.pointers.sol is excluded by !**/generated/**
📒 Files selected for processing (5)
  • crates/test_fixtures/abis/RaindexV6.json
  • foundry.toml
  • src/concrete/raindex/RaindexV6.sol
  • src/lib/deploy/LibRaindexDeploy.sol
  • test/concrete/raindex/RaindexV6.addOrder.entask.t.sol

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.

Audit (Protofire M02): order-counterparty() exposed in add/remove post-actions but its context row is never populated (reverts)

1 participant