Skip to content

Use SDK positive output vault filter before quoting#84

Merged
graphite-app[bot] merged 1 commit into
mainfrom
review/alastair-zero-balance-stage-timing
May 6, 2026
Merged

Use SDK positive output vault filter before quoting#84
graphite-app[bot] merged 1 commit into
mainfrom
review/alastair-zero-balance-stage-timing

Conversation

@findolor
Copy link
Copy Markdown
Collaborator

@findolor findolor commented Apr 20, 2026

Motivation

This PR preserves direct-pushed commit b1ebea3 for review after removing it from the intended main history. It is stacked on #83 and contains the third original direct-pushed commit.

The zero-balance quote skip now belongs in Raindex so order pagination and totals are filtered before the REST API fetches quotes. This REST PR now delegates that predicate to the SDK instead of parsing/filtering balances locally.

Depends On

Solution

  • Pass has_positive_output_vault_balance: Some(true) when listing orders by owner or token.
  • Remove REST-side output balance parsing/filtering and quote the SDK-filtered orders directly.
  • Keep stage timing instrumentation from the original commit.
  • Update REST compatibility for the newer SDK bindings, take-order candidate signature, signed context field, and spec version 5 test fixtures.

Checks

  • nix develop -c cargo fmt
  • nix develop -c cargo check
  • nix develop -c cargo test routes::orders
  • nix develop -c cargo test
  • nix develop -c rainix-rs-static fails on existing clippy too_many_arguments errors in src/routes/trades.rs route handlers.

Stack note: merge/review after #82 and #83. This PR is based on review/alastair-metaboard-direct-trades.

Summary by CodeRabbit

  • New Features

    • Orders now filtered to include only those with a positive output vault balance
    • Added support for version-5 Raindex registry configuration
  • Tests

    • Expanded token listing tests and remote-token scenario coverage
    • Added/updated tests for version-5 Raindex registry compatibility
  • Chores

    • Updated submodule reference and adjusted build/prep configuration paths

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Warning

Rate limit exceeded

@graphite-app[bot] has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 43 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ca574263-089e-41f3-b35a-fda618f85591

📥 Commits

Reviewing files that changed from the base of the PR and between 068864e and 6fb902f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • flake.nix
  • lib/rain.orderbook
  • src/routes/orders/get_by_owner.rs
  • src/routes/orders/get_by_token.rs
  • src/routes/swap/mod.rs
  • src/routes/tokens.rs
  • src/test_helpers.rs
📝 Walkthrough

Walkthrough

Updates include a rain.orderbook submodule bump, added positive-output-vault filters to order listing endpoints, swap route call updated to pass Address::ZERO and NoopInjector, and test/test-helper migrations to Raindex v5 plus token test adjustments.

Changes

Raindex Integration & Order Filtering Upgrade

Layer / File(s) Summary
Dependency Update
lib/rain.orderbook
Submodule pointer bumped from commit 57253129e47b... to 014016c699a2....
Data / Schema
src/test_helpers.rs
Raindex test schema bumped from version 4 → version 5; import path changed from IOrderBookV6 to IRaindexV6; OrderV4 mock now includes signed_context; new helper mock_raindex_registry_url_with_settings(settings: &str) -> String.
Behavior / Filters
src/routes/orders/get_by_owner.rs, src/routes/orders/get_by_token.rs
GetOrdersFilters construction now includes has_positive_output_vault_balance: Some(true).
Core Wiring
src/routes/swap/mod.rs
Import adds NoopInjector; build_take_order_candidates_for_pair call extended to include Address::ZERO and &NoopInjector.
Tests / Coverage
src/routes/tokens.rs, src/test_helpers.rs
Token endpoint tests updated to use Raindex v5 settings, added test asserting two tokens returned, and remote-token test adjusted to validate name/isin from remote payload.
Build Config
flake.nix
Forge target path in prepSolArtifacts adjusted to use rain.raindex.interface path for build target.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • hardyjosh
  • 0xgleb

Poem

🐰 Small hops and big bumps in the tree,
Submodules updated — raindex v5 we see,
Filters snug for vaults that hold true,
NoopInjector joins the build too,
Tests and tokens sing, a release rendezvous.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Use SDK positive output vault filter before quoting' directly matches the main objective of the PR: delegating the positive output vault balance predicate to the SDK instead of REST-side filtering.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch review/alastair-zero-balance-stage-timing

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

findolor added a commit that referenced this pull request Apr 20, 2026
Reverts the three direct commits pushed by Alastair so main returns to the reviewed d924310 tree state while preserving the changes for review in PRs #82, #83, and #84.
graphite-app Bot pushed a commit that referenced this pull request Apr 27, 2026
## Motivation

Three commits were pushed directly to `main` without the normal PR review flow:

- `543a103` - Add order caching and fix trades-by-address timeout
- `50e7fd9` - Add metaboard neutralization, order caching, direct trades, quote chunking, and nginx hardening
- `b1ebea3` - Skip RPC quotes for zero-balance orders and add stage timing

Branch protection currently prevents rewriting `main`, so this PR restores the reviewed tree state with a normal revert commit instead. The original changes are preserved for review in #82, #83, and #84.

## Solution

- Revert the three direct-pushed commits in newest-to-oldest order.
- Fold the revert into a single commit for review clarity.
- Leave the original changes available in the stacked review PRs.

## Checks

- `nix develop -c cargo fmt`
- `nix develop -c rainix-rs-static`

Note: `rainix-rs-static` passed, with existing warnings reported in the nested `rain.orderbook` crate.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

## Release Notes

* **Removed Features**
  * Disabled trade-related API endpoints (`GET /trades/by-tx`, `GET /trades/by-address`, batch trade queries).
  * Removed in-memory caching layer for order listings.

* **Improvements**
  * Simplified application architecture by removing unnecessary caching mechanisms and dependencies.
  * Streamlined order retrieval logic.

* **Infrastructure**
  * Updated server configuration and system settings.
  * Removed local database storage layer integration.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@findolor findolor changed the title Skip RPC quotes for zero-balance orders and add stage timing Use SDK positive output vault filter before quoting Apr 30, 2026
@findolor findolor self-assigned this Apr 30, 2026
@findolor findolor requested review from JuaniRios and hardyjosh April 30, 2026 11:02
@findolor findolor requested a review from 0xgleb May 6, 2026 07:48
@findolor findolor changed the base branch from review/alastair-metaboard-direct-trades to graphite-base/84 May 6, 2026 11:33
@findolor findolor force-pushed the review/alastair-zero-balance-stage-timing branch from 77697aa to 65f9508 Compare May 6, 2026 11:33
@findolor findolor changed the base branch from graphite-base/84 to main May 6, 2026 11:33
Copy link
Copy Markdown
Collaborator Author

findolor commented May 6, 2026


How to use the Graphite Merge Queue

Add 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.

@findolor findolor force-pushed the review/alastair-zero-balance-stage-timing branch 4 times, most recently from ce96866 to 068864e Compare May 6, 2026 17:05
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/routes/swap/mod.rs (1)

87-94: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Missing has_positive_output_vault_balance filter on the swap quoting path.

The list endpoints (get_by_owner.rs, get_by_token.rs) both include has_positive_output_vault_balance: Some(true) in their GetOrdersFilters, but get_orders_for_pair in swap/mod.rs (lines 87-94) does not. This inconsistency means the swap quote path will still consider zero-output-balance orders, defeating the purpose of delegating this filtering to the SDK.

🔧 Proposed fix
         let filters = GetOrdersFilters {
             active: Some(true),
             tokens: Some(GetOrdersTokenFilter {
                 inputs: Some(vec![input_token]),
                 outputs: Some(vec![output_token]),
             }),
+            has_positive_output_vault_balance: Some(true),
             ..Default::default()
         };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/routes/swap/mod.rs` around lines 87 - 94, The GetOrdersFilters used in
get_orders_for_pair is missing the has_positive_output_vault_balance flag so
zero-output-balance orders are still considered; update the filters construction
in swap::get_orders_for_pair to include has_positive_output_vault_balance:
Some(true) (alongside the existing active and tokens fields) so the SDK performs
the positive-output-balance filtering; modify the GetOrdersFilters literal where
filters is created to add the has_positive_output_vault_balance field.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/routes/swap/mod.rs`:
- Around line 87-94: The GetOrdersFilters used in get_orders_for_pair is missing
the has_positive_output_vault_balance flag so zero-output-balance orders are
still considered; update the filters construction in swap::get_orders_for_pair
to include has_positive_output_vault_balance: Some(true) (alongside the existing
active and tokens fields) so the SDK performs the positive-output-balance
filtering; modify the GetOrdersFilters literal where filters is created to add
the has_positive_output_vault_balance field.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 422a18f3-435b-4ead-90ff-68a7d215935d

📥 Commits

Reviewing files that changed from the base of the PR and between 750a433 and 068864e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • flake.nix
  • lib/rain.orderbook
  • src/routes/orders/get_by_owner.rs
  • src/routes/orders/get_by_token.rs
  • src/routes/swap/mod.rs
  • src/routes/tokens.rs
  • src/test_helpers.rs

@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented May 6, 2026

Merge activity

## Motivation

This PR preserves direct-pushed commit `b1ebea3` for review after removing it from the intended `main` history. It is stacked on #83 and contains the third original direct-pushed commit.

The zero-balance quote skip now belongs in Raindex so order pagination and totals are filtered before the REST API fetches quotes. This REST PR now delegates that predicate to the SDK instead of parsing/filtering balances locally.

## Depends On

- rainlanguage/raindex#2562 (`feat: add positive output vault balance order filter`)
- This PR bumps `lib/rain.orderbook` to `014016c699a2da4aa27d335bbf565e7347c2f762`, which is from that Raindex work and exposes `has_positive_output_vault_balance`.

## Solution

- Pass `has_positive_output_vault_balance: Some(true)` when listing orders by owner or token.
- Remove REST-side output balance parsing/filtering and quote the SDK-filtered orders directly.
- Keep stage timing instrumentation from the original commit.
- Update REST compatibility for the newer SDK bindings, take-order candidate signature, signed context field, and spec version 5 test fixtures.

## Checks

- `nix develop -c cargo fmt`
- `nix develop -c cargo check`
- `nix develop -c cargo test routes::orders`
- `nix develop -c cargo test`
- `nix develop -c rainix-rs-static` fails on existing clippy `too_many_arguments` errors in `src/routes/trades.rs` route handlers.

Stack note: merge/review after #82 and #83. This PR is based on `review/alastair-metaboard-direct-trades`.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Orders now filtered to include only those with a positive output vault balance
  * Added support for version-5 Raindex registry configuration

* **Tests**
  * Expanded token listing tests and remote-token scenario coverage
  * Added/updated tests for version-5 Raindex registry compatibility

* **Chores**
  * Updated submodule reference and adjusted build/prep configuration paths
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@graphite-app graphite-app Bot force-pushed the review/alastair-zero-balance-stage-timing branch from 068864e to 6fb902f Compare May 6, 2026 17:30
@graphite-app graphite-app Bot merged commit 6fb902f into main May 6, 2026
10 checks passed
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.

3 participants