Commit Graph
1 Commits
Author SHA1 Message Date
moondev 94cd09b0e5 fix events being dropped in streaming ordered mode for multi event transactions
in StreamingOrdered mode the slot buffer is fed one event at a time, but every
event parsed from the same transaction carries that transaction's tx_index.
push_streaming bumps the streaming watermark to tx_index + 1 as soon as it
releases the first event, so the rest of that transaction's events have
tx_index < watermark, fall into the "already delivered" branch and get dropped
without any trace.

so any transaction that parses into more than one dex event (a swap route that
touches several pools, a create + buy, and so on) only ever delivered its first
event when order_mode was StreamingOrdered. Unordered, Ordered and MicroBatch
were not affected.

fix:
- push_streaming now takes all events of one (slot, tx_index) as a group so the
  watermark advances once per transaction instead of once per event
- the buffered drain advances the watermark per distinct tx_index, since a slot
  can now hold several events under the same index
- the ordered buffers use a stable sort so events inside one transaction keep
  the order the parser produced them in, sort_unstable could shuffle equal keys

added tests for the multi event transaction case and for releasing buffered out
of order multi event transactions.
2026-06-16 00:28:15 +09:00