fix(rs-sdk): withdrawals orderBy bug (#2409)#3536
Conversation
Adds network-testing-only integration tests in `packages/rs-sdk/tests/fetch/` that hit live mainnet DAPI and exercise the withdrawals system contract with paired asc/desc queries: - `withdrawals_orderby_owner_id_asc_vs_desc`: simple `orderBy: $ownerId` with no `where`, mirroring the UI screenshot from the bug report. - `withdrawals_orderby_issue_2409_range_plus_in`: the exact query from the issue — `transactionIndex in [0..5]` + `status > 0`, orderBy on `[status, transactionIndex]`. The tests are currently failing on mainnet: - The simple query returns 100 docs in both directions with identical sets (no asymmetry visible; likely because total withdrawal count on mainnet is ≤100). - The range+in query returns 0 docs in both directions — reproducing the "empty array" half of #2409, though not the asc/desc asymmetry. Pushing as a draft so the assertion shape / dataset choice can be iterated on before this is suitable as a regression gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 56 minutes and 37 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ 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 |
…document queries (#2409) Replaces the mainnet-dependent rs-sdk reproducer with two deterministic rs-drive integration tests and fixes the two underlying bugs in `DriveDocumentQuery::get_non_primary_key_path_query`: 1. `recursive_create_query` was called with `order_by = None` in the `last_clause == None` branch, so queries with no `where` clauses that used an index purely for ordering silently coerced `desc` back to the index's intrinsic direction. Forward `Some(&self.order_by)` to match the sibling branch that already did so. 2. When both `in` and `range` clauses were present, `last_clause` was unconditionally set to the `in` clause regardless of each field's position in the chosen index. Queries whose `in` was on a leaf-side property (e.g. `status > 0 AND transactionIndex in [..]` on the `[status, transactionIndex]` index) built a path query whose primary query operated on one field while the path terminated at another, returning `[]`. Pick `last_clause` vs `subquery_clause` based on each field's index position instead. New tests (`packages/rs-drive/tests/query_tests.rs`): - `test_withdrawals_query_orderby_asc_vs_desc_owner_id_limit_10_of_15` - `test_withdrawals_query_range_plus_in_issue_2409` All 33 tests in `query_tests.rs` pass, including existing withdrawal tests with hardcoded root-hash and expected-ID assertions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
✅ Review complete (commit ced8573) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3536 +/- ##
=========================================
Coverage 88.18% 88.19%
=========================================
Files 2474 2474
Lines 298763 298738 -25
=========================================
- Hits 263477 263461 -16
+ Misses 35286 35277 -9
🚀 New features to boost your workflow:
|
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Both Claude and Codex reviewed the rs-drive diff (orderBy direction + in/range index position fix and its regression test) and surfaced no actionable findings. The change is a localized correctness fix in document query construction with a targeted reproducer test, and no blocking issues, suggestions, or nitpicks remain after validation.
Reviewed commit: ced8573
|
@QuantumExplorer please update PR title |
Issue being fixed or feature implemented
Integration-test reproducer for #2409 — documents fetched from the withdrawals system contract with range/
inwhereclauses return an empty array, and the reporter also noted asymmetric behavior between asc and descorderBydirections.Draft because the tests are currently failing on mainnet and the exact assertion shape still needs tuning against a dataset that actually exhibits the bug.
What was done?
Added
packages/rs-sdk/tests/fetch/withdrawals_orderby.rswith two tests:withdrawals_orderby_owner_id_asc_vs_desc— simpleorderBy: [["$ownerId", asc|desc]], nowhere. Mirrors the UI screenshot from the bug report.withdrawals_orderby_issue_2409_range_plus_in— exact query from the issue:where: [['transactionIndex', 'in', [0..5]], ['status', '>', 0]]with matching multi-fieldorderBy.The module is gated on
--features network-testingintests/fetch/mod.rsso it only compiles/runs when explicitly invoked, and the SDK is built directly viaSdkBuilder+TrustedHttpContextProviderwith a hardcoded mainnet DAPI address list (the same listrs-sdk-ffiuses for its trusted-mode default) — no.envrequired.How Has This Been Tested?
Run locally against mainnet:
cargo test -p dash-sdk --no-default-features --features network-testing \ --test main withdrawals_orderby -- --nocaptureCurrent findings on mainnet (v3.1-dev):
limit=100saturates both directions).transactionIndexvalues fall inside[0..5]).Open questions for reviewers / follow-up:
assert_ne!(asc_set, desc_set)toassert!(!result.is_empty()), which is a more direct bug signal?157.66.81.162,178.215.237.134) currently serve expired TLS certs; requests retried through other nodes so tests still run, but the list probably deserves a refresh (separate issue).Breaking Changes
None — test-only addition, gated on a non-default feature.
Checklist:
For repository code-owners and collaborators only