perf: RPC race mode — portfolio 1.2s (was 21–26s)#2
Merged
Conversation
…or change) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extracts single_attempt (one URL, 3 retries w/ backoff) and adds rpc_call_race that fans out to all URLs via JoinSet. First Ok wins, losers aborted. 8s per-URL timeout in race mode. Aggregated error when all nodes fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract single_batch_attempt (shared by sequential + race paths), add rpc_batch_race with JoinSet fan-out and OwnedRequest for task ownership. Batch race uses same 8s per-URL timeout as single-call race. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 429 on one peer + 200 on other → 200 wins - both 5xx → aggregated error lists both URLs - single URL list → race degenerates to single call - non-retryable RPC error on peer + ok on other → ok wins Also derive Debug on RpcResponse for test unwrap_err. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- balance.rs: getBalance, getTokenAccountsByOwner (USDC/Token-2022/specific), batch portfolio getMultipleAccounts → Race - fee.rs: getRecentPrioritizationFees, getMinimumBalanceForRentExemption → Race - transfer.rs: getAccountInfo, getTokenAccountsByOwner (both programs), chunked getMultipleAccounts → Race - transaction.rs: getSignatureStatuses, simulateTransaction → Race; getLatestBlockhash + sendTransaction stay Sequential (ordering-sensitive / write) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds test-util Cargo feature exposing get_portfolio_balances_with_urls (takes explicit URL slice instead of single --rpc-url). Refactors get_portfolio_balances to delegate to a shared core function. portfolio_race_beats_slow_url simulates the real failure: one mock stalls response body 30s, the other responds fast. Run with: cargo test -p rwa-ondo --features test-util portfolio_race_beats_slow_url Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JoinSet::abort_all. Writes (sendTransaction) and ordering-sensitive reads (getLatestBlockhash) stay sequential.RpcMode::{Sequential, Race}enum — every call-site explicitly picks a mode (compile-time safety against accidentally racing a write).rwa gm portfoliowall time: ~1.2–1.7s typical (previously 21–26s).rwa gm balanceand other read-heavy commands benefit too.Changes
crates/ondo/src/solana/rpc.rs—RpcModeenum,single_attempt,rpc_call_race,single_batch_attempt,rpc_batch_race,OwnedRequeststruct (+714 / -129 lines)crates/ondo/src/solana/balance.rs— all read call-sites →RpcMode::Race; portfolio entry-point refactored for multi-URL supportcrates/ondo/src/solana/{fee,transfer,transaction}.rs— read call-sites → Race; writes stay Sequentialcrates/ondo/tests/rpc_portfolio.rs— new acceptance test: 2 mock servers (one 30s-stalled), asserts < 2sTest plan
cargo test -p rwa-ondo --lib)cargo test -p rwa-ondo --features test-util --test rpc_portfolio)cargo clippy --workspace --all-targets -- -D warningscleanrwa gm portfolioreturns in 1.04–1.54s across multiple runs🤖 Generated with Claude Code