Skip to content

feat(twap-monitor): index ConditionalOrderCreated → local-store (BLEU-826)#3

Open
brunota20 wants to merge 2 commits into
feat/twap-monitor-skeleton-bleu-825from
feat/twap-monitor-indexing-bleu-826
Open

feat(twap-monitor): index ConditionalOrderCreated → local-store (BLEU-826)#3
brunota20 wants to merge 2 commits into
feat/twap-monitor-skeleton-bleu-825from
feat/twap-monitor-indexing-bleu-826

Conversation

@brunota20

Copy link
Copy Markdown
Collaborator

Summary

  • on_event(Event::Logs) decodes each log against ComposableCoW.ConditionalOrderCreated via alloy_sol_types and writes watch:{owner}:{params_hash}abi_encode(params) to local-store.
  • Idempotent: `local_store::set` overwrites in place, so re-org replay / overlapping subscription windows produce no observable side effect.
  • Resilient: `decode_conditional_order_created` returns `None` on wrong topic0 or malformed payload — adjacent events on the same subscription (MerkleRootSet, SwapGuardSet) are skipped instead of short-circuiting the batch.
  • Stored value (abi-encoded params) is exactly the `(handler, salt, staticInput)` tuple BLEU-827 will pass back to `getTradeableOrderWithSignature`.

Decode fn is on plain slices so unit tests cover well-formed / wrong-topic / empty-topics without wit-bindgen scaffolding. Block / Tick / Message dispatch is left for BLEU-827 / future PRs.

Stacks on #2 (BLEU-825 skeleton). Base will switch to `dev/m2-base` once #2 merges.

Linear: BLEU-826. Ref ADR-0006.

Test plan

  • `cargo test -p twap-monitor` — 3 host tests (decodes_well_formed_log, rejects_wrong_topic, rejects_empty_topics).
  • `cargo check --target wasm32-wasip2 -p twap-monitor`.
  • `cargo clippy --target wasm32-wasip2 -p twap-monitor -- -Dwarnings`.
  • `cargo clippy -p twap-monitor --tests -- -Dwarnings`.
  • `cargo build --target wasm32-wasip2 --release -p twap-monitor` — 96 KB .wasm.

…-826)

`on_event(Event::Logs)` decodes each log against
`ComposableCoW.ConditionalOrderCreated` via `alloy_sol_types`,
extracts `(owner, params)`, and writes `watch:{owner}:{params_hash}`
to local-store with the abi-encoded `ConditionalOrderParams` as
the value. BLEU-827 reads this back via `list-keys("watch:")` and
the value is exactly the `(handler, salt, staticInput)` tuple the
poll path passes to `getTradeableOrderWithSignature`.

Idempotency: `local_store::set` overwrites in place, so re-org
replay or overlapping subscription windows produce no observable
side effect.

Resilience: `decode_conditional_order_created` returns `None`
when topic0 does not match the event signature or the payload
fails ABI decoding. Adjacent events on the same subscription
(MerkleRootSet, SwapGuardSet) are silently skipped instead of
short-circuiting the batch. The fn is on plain slices so the
host-free unit tests cover well-formed / wrong-topic / empty-
topics without wit-bindgen scaffolding.

Block, Tick, and Message variants of `Event` are left unhandled
in this PR — `Event::Block` dispatch lands in BLEU-827 (poll
path); the other two are not used by this module.

Adds `alloy-primitives` as a direct dep so the topic/data plumbing
does not rely on alloy types leaking through `cowprotocol`'s
re-exports.

`cargo build --target wasm32-wasip2 --release -p twap-monitor`
emits a 96 KB .wasm (up from the 65 KB skeleton because of the
alloy + cowprotocol composable types now linked in).
@linear-code

linear-code Bot commented Jun 15, 2026

Copy link
Copy Markdown

BLEU-826

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