Skip to content

Make L2 exchange response ordering deterministic - #325

Draft
California-a wants to merge 1 commit into
nkaz001:masterfrom
California-a:agent/deterministic-l2-response-order
Draft

Make L2 exchange response ordering deterministic#325
California-a wants to merge 1 commit into
nkaz001:masterfrom
California-a:agent/deterministic-l2-response-order

Conversation

@California-a

Copy link
Copy Markdown

Summary

  • make the L2 PartialFillExchange and NoPartialFillExchange order containers deterministic
  • preserve an explicit ascending OrderId response order when multiple fills share a timestamp
  • add regression tests that exercise the real exchange response bus for both models

Why

The default Rust HashMap and HashSet use randomized seeds and expose arbitrary iteration order. Both L2 exchange models emitted responses while iterating those containers. When several fills had the same timestamp, identical inputs could therefore append responses in different orders across processes.

OrderBus intentionally preserves append order for equal timestamps, so the randomized traversal became externally observable and could change downstream order-lifecycle handling.

Using BTreeMap and BTreeSet gives the response path a stable ascending OrderId order without changing the public API.

Validation

  • cargo test -p hftbacktest --lib --no-default-features --features backtest --offline: 24 passed
  • each new regression test repeats the simultaneous three-order response case 32 times
  • patch-scoped Clippy passed with only the repository's existing unrelated lint categories allowed
  • git diff --check passed

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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