Skip to content

Document clear3 signed-context cross-assignment (alice/bob slots) #2800

Closed

Description

@Siddharth2207

Question

Is the signed-context cross-assignment in clear3 intentional?

clear3 takes aliceSignedContext and bobSignedContext in that order, but each order's IO calculation appears to receive the other side's array:

  • Alice's calculateOrderIO is called with bobSignedContext
  • Bob's calculateOrderIO is called with aliceSignedContext

Relevant code in RaindexV6.sol:

OrderIOCalculationV4 memory aliceOrderIOCalculation = calculateOrderIO(
    aliceOrder,
    ...,
    bobOrder.owner,
    bobSignedContext,
    ...
);
OrderIOCalculationV4 memory bobOrderIOCalculation = calculateOrderIO(
    bobOrder,
    ...,
    aliceOrder.owner,
    aliceSignedContext,
    ...
);

This mirrors the counterparty-owner swap (bobOrder.owner for alice, aliceOrder.owner for bob), but the parameter names (aliceSignedContext / bobSignedContext) are easy to read as "context for alice's order" / "context for bob's order", which led to integrator bugs (e.g. oracle context placed in the wrong slot → signed-context<0 0>() panic on clear).

Context

  • Single-order paths (quote2, takeOrders4) pass signedContext directly to the order being evaluated — no swap.
  • Subparser authoring meta says signed context is "provided by the order clearer/taker" (LibRaindexSubParser.sol), but there is no clear clear3-specific doc explaining which calldata slot each order reads.
  • RaindexV6.clear.context.t.sol documents/test counterparty wiring for order-counterparty(), but not signed-context slot assignment.

Request

Could we confirm whether this cross-assignment is by design? If so, could we add clearer documentation, for example:

  1. NatSpec on clear3 / IRaindexV6.clear3 explaining that each order reads the counterparty-named signed-context slot (or equivalently: oracle/context for order X must be passed in the slot named after X's counterparty).
  2. A short test that passes non-empty signed context into one slot and asserts the expected order's eval receives it (similar to RaindexV6.clear.context.t.sol but for signed context).

Happy to open a PR once the intended semantics are confirmed.

Activity

  1. linear commented on Jul 8, 2026

    @linear
  2. thedavidmeister commented on Oct 27, 2026

    @thedavidmeister
    Contributor

    Fixed by #2920: clear3 is removed and clear4 routes each order its own signed context (RaindexV6.sol: alice's calculateOrderIO gets aliceSignedContext, bob's gets bobSignedContext), matching quote3/takeOrders5. Pinned by test/concrete/raindex/RaindexV6.clear.signedContextRouting.t.sol.

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions