refac(RPC Optimization): Eliminate Client-Side Duplication & Leverage Redis Caching#185
Merged
akiraonstarknet merged 7 commits intoakiraonstarknet:devfrom Oct 21, 2025
Merged
Conversation
- Replace direct instantiation of RpcProvider with a singleton pattern in a new provider module. - Update all API routes to use the new getProvider function for consistent provider access. - Adjust refetch intervals in balance atoms for improved performance.
- Implement a lazy initialization pattern for the Redis client to avoid unnecessary connections. - Update getDataFromRedis and setDataToRedis functions to use the new getRedisClient method. - Enhance error handling in the GET API route to manage Redis operation failures gracefully.
- Upgrade starknetkit to version 3.3.0 - Add support for Keplr mobile app browser with a new connector.
strategy solving methods - Wrap strategy solving logic in try-catch blocks to prevent crashes and set safe defaults on errors. - Improve error logging for better debugging. - Ensure consistent handling of undefined values in strategy actions and calculations.
|
@EjembiEmmanuel is attempting to deploy a commit to the zkdice-xyz's projects Team on Vercel. A member of the Team first needs to authorize it. |
- Remove redundant strategy fetching logic from components and API routes. - Introduce shared strategy resources to minimize RPC overhead and improve performance. - Update API routes and components to utilize shared instances for configuration and pricing.
a1838d9 to
bb62b65
Compare
Reduced the refetch interval for balance queries from 30 seconds to 5 seconds.
akiraonstarknet
approved these changes
Oct 21, 2025
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.
📊 Problem Analysis
Root Cause Discovered
The homepage was making ~600 RPC calls from the browser on every page load because client-side atoms were duplicating server-side calculations.
Before Optimization:
strategy.solve())🎯 Solution: Client-Side RPC Elimination
Key Changes Made
1. Eliminated Client-Side RPC Duplication ✅
strategy.solve()calls fromstrategiesAtomAsync2. Enhanced Redis Caching 🚀
3. Improved API Response 📊
📈 Performance Results
Key Insight: The 85% improvement comes from eliminating client-side duplication. The 100% improvement comes from Redis caching.
Vercel website link
https://troves-client-eight.vercel.app
Checklist before requesting a review