Skip to content

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

Open
thedavidmeister wants to merge 6 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 6 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

Warning

Review limit reached

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

Next review available in: 58 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: Pro

Run ID: a75bedf1-9b94-46f9-8917-2816d0a15f70

📥 Commits

Reviewing files that changed from the base of the PR and between 38368eb and 4b78f01.

⛔ Files ignored due to path filters (1)
  • src/generated/RaindexV6.pointers.sol is excluded by !**/generated/**
📒 Files selected for processing (3)
  • crates/test_fixtures/abis/RaindexV6.json
  • src/concrete/raindex/RaindexV6.sol
  • src/lib/deploy/LibRaindexDeploy.sol
📝 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

…rom merged source

The merge-update (step 3d) pulled main's source back into the PR but did
not regenerate src/generated/RaindexV6.pointers.sol.  The generated file
still carried bytecode compiled from the PR's original source (which had
the OrderNoSources / OrderNoHandleIO source-count check removed to match
an older rainlang version).  After the merge the source has those checks
again, so the etched-bytecode mock tests now expect them to fire — but the
stale RUNTIME_CODE etched at RAINDEX_DEPLOYED_ADDRESS lacked them, causing
testAddOrderWithoutCalculationsReverts (and friends) to fail with "next
call did not revert as expected".

Fix: re-run script/build-meta.sh → forge script BuildPointers.sol →
forge build → script/build.sh → forge fmt to regenerate the pointers,
update the 0_1_13 pinned constants in LibRaindexDeploy to the new address
and codehash, and refresh crates/test_fixtures/abis/RaindexV6.json.
testProdDeploy* / testIsStartBlock* / testNetworksJson* remain red
(WAITING-DEPLOY): the new RaindexV6 must be deployed before they pass.

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

Copy link
Copy Markdown
Contributor Author

Producer note: HAND-OFF (three prior 3b attempts, latest 2026-07-04, checks still red). Three distinct causes: (1) copy-artifacts + 9 codehash/runtime-code test fails: the 2026-07-04 regen covered RaindexV6 pointers only — the arb-contract pointers (GenericPool*/RouteProcessor*) are still stale; fix is a FULL ./build.sh run with ALL regenerated artifacts staged. (2) 5 testProdDeploy* + 3 isStartBlock + networks.json/subgraph.yaml: WAITING-DEPLOY (bytecode-changing PR, routine pre-merge deploy). (3) rainix-sol static + rs-static: rainix's new no-ignored-tests gate bans vm.skip, and the flagged vm.skip lines exist on raindex MAIN too (test/lib/deploy/*.t.sol) — an org-level collision that will red main's own next static run; needs an org decision (allow-list or rework those skips), not a branch fix. Per one-attempt-per-check back-off I am not pushing again.

@thedavidmeister

Copy link
Copy Markdown
Contributor Author

🤖 ai:producer
Producer note: 3b HAND-OFF. [3b-attempt] commits already targeted rainix-sol-static and rainix-sol-test here; still red, so per back-off no further pushes. Current state (run 28707744726/57): static + rs-static + part of test are MAIN-STATE reds (rainix no-vm.skip gate vs five test/lib/deploy files with vm.skip on main; missing 0.1.13 soldeer-tag deploy constants) — not fixable from this branch. copy-artifacts remains this PR's own red (artifact regen vs committed, after the RaindexV6 pointer regen attempt) — parked for a human in the CI-identical env.

@thedavidmeister thedavidmeister added the ai:ready AI vetter: passes review, ready for human decision label Jul 6, 2026
@thedavidmeister

thedavidmeister commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

🤖 ai:vetter
Reviewed bb9fa95: ready — both addOrder4 and removeOrder3 now pass 3-element context row including address(0) counterparty; te
cost 200 — addOrder+removeOrder context-row fix with end-to-end test

@thedavidmeister thedavidmeister added ai:reject AI vetter: needs rework (code issue) and removed ai:ready AI vetter: passes review, ready for human decision labels Jul 9, 2026
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

🤖 ai:vetter
Reviewed 4b78f01: reject — closes #2619 — right fix wrong shape: (1) inlines 3-row context at both call sites instead of editing main's _doOrderPost helper, duplicating construction; (2) leaves _doOrderPost DEAD at head with stale 2-row body and now-false doc comment (regression trap); (3) removeOrder3 third row unpinned — testRemoveOrderContext asserts order-hash/order-owner only, no order-counterparty() test in remove context, so reverting the remove hunk survives the suite; rework: 1-line edit to _doOrderPost + remove-side counterparty test
cost 618 — settlement context change, deploy pins, merge fallout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:reject AI vetter: needs rework (code issue)

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