Skip to content

[indexer]: index the gateway's OrderCancelled event - #1185

Draft
Wizdave97 wants to merge 1 commit into
mainfrom
feat/indexer-order-cancelled
Draft

[indexer]: index the gateway's OrderCancelled event#1185
Wizdave97 wants to merge 1 commit into
mainfrom
feat/indexer-order-cancelled

Conversation

@Wizdave97

Copy link
Copy Markdown
Member

09888bd1 added OrderCancelled(bytes32 indexed commitment, address canceller) to IntentGatewayV2. It was the only contract event with no counterpart here — the ABI already carried the other reshaped events from this cycle (OrderFilled/PartialFill/ EscrowReleased/EscrowRefunded with their token arrays, DeploymentAdded, DestinationProtocolFeeUpdated), so cancellation was the whole gap.

Adds a CANCELLED status, an IOrderV3Cancellation entity, a handler, and the datasource wiring. canceller is stored separately from the order's user because the destination-side cancel route is permissionless once the order has expired, so the two are not the same account in general.

recordOrderCancellation advances the status only from PLACED. OrderCancelled marks the initiation of a cancellation, not its completion — EscrowRefunded stays terminal and still owns REFUNDED. Since updateOrderStatus assigns without comparing against the current value, and a cross-chain cancel is initiated on the destination chain while its refund lands on the source chain via a separate datasource with no ordering guarantee between them, an unguarded write would let a late-indexed cancellation move a settled order back to CANCELLED. Guarding on PLACED makes it idempotent and order-independent.

The guard is local to the new method rather than a general never-regress rule in updateOrderStatus: the broader change would alter every existing transition on a path with no ordering test coverage, and deserves its own justification.

An order resting at CANCELLED is an expected steady state, not an indexing gap — the source-side route re-emits on every call and only refunds when the GET response returns.

`09888bd1` added `OrderCancelled(bytes32 indexed commitment, address canceller)` to
IntentGatewayV2. It was the only contract event with no counterpart here — the ABI already
carried the other reshaped events from this cycle (`OrderFilled`/`PartialFill`/
`EscrowReleased`/`EscrowRefunded` with their token arrays, `DeploymentAdded`,
`DestinationProtocolFeeUpdated`), so cancellation was the whole gap.

Adds a `CANCELLED` status, an `IOrderV3Cancellation` entity, a handler, and the datasource
wiring. `canceller` is stored separately from the order's `user` because the
destination-side cancel route is permissionless once the order has expired, so the two are
not the same account in general.

`recordOrderCancellation` advances the status only from `PLACED`. `OrderCancelled` marks
the initiation of a cancellation, not its completion — `EscrowRefunded` stays terminal and
still owns `REFUNDED`. Since `updateOrderStatus` assigns without comparing against the
current value, and a cross-chain cancel is initiated on the destination chain while its
refund lands on the source chain via a separate datasource with no ordering guarantee
between them, an unguarded write would let a late-indexed cancellation move a settled order
back to `CANCELLED`. Guarding on `PLACED` makes it idempotent and order-independent.

The guard is local to the new method rather than a general never-regress rule in
`updateOrderStatus`: the broader change would alter every existing transition on a path
with no ordering test coverage, and deserves its own justification.

An order resting at `CANCELLED` is an expected steady state, not an indexing gap — the
source-side route re-emits on every call and only refunds when the GET response returns.
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.

1 participant