Improve order endpoint trade lookup#109
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe PR refactors the order trades endpoint to fetch trades by order hashes through the ChangesOrder Trades Query Refactoring
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
How to use the Graphite Merge QueueAdd the label add-to-gt-merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
db8d0c8 to
0875f73
Compare
6ef2cb1 to
b4fac6d
Compare
b4fac6d to
f4de41e
Compare
f4de41e to
73a5ca6
Compare
6580777 to
dcd8d19
Compare
1c569cb to
e8e2ed7
Compare
16ce1e8 to
2f3ac5b
Compare
0648e86 to
2df41e9
Compare
388fcf9 to
0f3f104
Compare
bafb7ff to
8288d45
Compare
0f3f104 to
6d5a8da
Compare
6d5a8da to
19a27bf
Compare
9d05162 to
8ca2f09
Compare
0c641a1 to
a2d3f74
Compare
511bbd2 to
9003bad
Compare
42a41f4 to
b48bc36
Compare
9003bad to
c6e1a8a
Compare
c6e1a8a to
eeb2321
Compare
b48bc36 to
c2fa4be
Compare
eeb2321 to
3bd8ca1
Compare
c2fa4be to
256b854
Compare
d03ce25 to
9b39e94
Compare
b0b84fb to
d41526b
Compare
9b39e94 to
7a5bdbf
Compare
Merge activity
|
## Dependent PR Stacked on #108, `feature/rai-581-preview-api-infrastructure`. ## Linear Part of RAI-580. ## Motivation `GET /v1/order/{order_hash}` was the biggest confirmed endpoint latency issue in the benchmark pass. The production path was observed around 30-40s for a real order hash, which made the endpoint unsuitable for normal interactive use. ## Solution - Replace the order endpoint's trade lookup from `order.get_trades_list(...)` to `client.get_trades_by_order_hashes(...)`. - Keep the response shape unchanged by selecting the requested order hash's grouped trades from the batch result. - Leave broader SDK and SQL changes out of this PR; this is the safe checkpoint for the confirmed endpoint win. ## Benchmark Notes Order hash used: `0x55c8f34ab380147ee98450e145f32c5dda080a4c6c9ad45206267048a3b475bf` Observed before this change: - Production API: roughly 30-40s for the order endpoint. - Old `order.get_trades_list(...)` path against a ready local DB: roughly 10-11s. Observed with this change against the current production registry bootstrap DB: - Warm local runs mostly landed around 1.5-2.0s. - Earlier local runs were around 1.6-1.8s after the DB was ready. - The same response returned 72 trades. Follow-up investigation showed direct SQLite trade SQL itself is fast, so remaining latency is likely SDK enrichment work rather than missing indexes: - `order.get_quotes(...)` - dotrain/metaboard source hydration during order lookup - object hydration, formatting, and response serialization ## Checks - `nix develop -c cargo fmt` - `nix develop -c rainix-rs-static` <!-- codesmith:footer --> --- <a href="https://app.blacksmith.sh/ST0x-Technology/codesmith/st0x.rest.api/pr/109"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-in-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-in-codesmith-light.svg"><img alt="View in Codesmith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-in-codesmith-dark.svg"></picture></a> <sup>Need help on this PR? Tag <code>@codesmith</code> with what you need.</sup> - [ ] Let Codesmith autofix CI failures and bot reviews <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Improved backend trade data retrieval mechanism for orders, enhancing system reliability and query performance. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/ST0x-Technology/st0x.rest.api/pull/109?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
d41526b to
249f3f6
Compare
7a5bdbf to
0924bce
Compare

Dependent PR
Stacked on #108,
feature/rai-581-preview-api-infrastructure.Linear
Part of RAI-580.
Motivation
GET /v1/order/{order_hash}was the biggest confirmed endpoint latency issue in the benchmark pass. The production path was observed around 30-40s for a real order hash, which made the endpoint unsuitable for normal interactive use.Solution
order.get_trades_list(...)toclient.get_trades_by_order_hashes(...).Benchmark Notes
Order hash used:
0x55c8f34ab380147ee98450e145f32c5dda080a4c6c9ad45206267048a3b475bfObserved before this change:
order.get_trades_list(...)path against a ready local DB: roughly 10-11s.Observed with this change against the current production registry bootstrap DB:
Follow-up investigation showed direct SQLite trade SQL itself is fast, so remaining latency is likely SDK enrichment work rather than missing indexes:
order.get_quotes(...)Checks
nix develop -c cargo fmtnix develop -c rainix-rs-staticNeed help on this PR? Tag
@codesmithwith what you need.Summary by CodeRabbit