perf: eliminate RPC polling via event streaming, persistent caching, and deduplication (#3238)#3253
perf: eliminate RPC polling via event streaming, persistent caching, and deduplication (#3238)#3253
Conversation
…elay perf(wallet): throttle price polling to 3m; switch to MapEquality to avoid Flutter import (#3238)\n\nchore: update SDK submodule pointer chore: clean-up temp files
|
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 You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ 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 |
|
Visit the preview URL for this PR (updated for commit 1312486): https://walletrc--pull-3253-merge-391130kv.web.app (expires Wed, 05 Nov 2025 11:11:56 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc |
There was a problem hiding this comment.
Pull Request Overview
This PR significantly reduces RPC spam by implementing cache-first pubkey/address fetching, deduplicating network requests, and throttling polling intervals across the application.
Key Changes:
- Introduced cache-first pubkey retrieval using
sdk.pubkeys.lastKnown()before making RPC calls - Throttled polling intervals: price updates from 1m to 3m, trading entities from 1s to 10s
- Refactored validators and form blocs to use cached pubkeys, preventing redundant network requests
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk | Updated submodule with pubkey caching and persistence support |
| taker_order_confirmation.dart | Added 1s delay before fetching entities after swap start |
| mm2_api.dart | Implemented cache-first balance retrieval |
| trading_entities_bloc.dart | Throttled update polling from 1s to 10s |
| withdraw_form_bloc.dart | Uses cached pubkeys for funded address lookup |
| transaction_history_bloc.dart | Cache-first address fetching and code formatting improvements |
| taker_validator.dart | Cache-first pubkey retrieval and formatting improvements |
| nft_receive_bloc.dart | Cache-first pubkey retrieval and formatting improvements |
| fiat_form_bloc.dart | Cache-first pubkey retrieval with retry logic |
| coins_bloc.dart | Changed price polling from 1m to 3m and replaced mapEquals with MapEquality |
| coin_addresses_bloc.dart | Cache-first address retrieval |
| bridge_validator.dart | Cache-first pubkey retrieval and formatting improvements |
| project.pbxproj | Updated iOS bundle identifier |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Wire SDK `ActivatedAssetsCache` into activation/coins flows: updates across `CoinsBloc`, `AssetOverviewBloc`, custom token import, and `sdk_auth_activation_extension` to reuse activation state instead of re-querying. - Debounce/polish polling in `portfolio_growth_bloc` and `profit_loss_bloc` to prevent overlapping requests. - Remove duplicate activation/balance checks in maker/taker validators and forms. - Consolidate repeated calls in `mm2_api`/`mm2_api_nft`/`rpc_native`; prefer cached values. - Reduce startup RPCs in `app_bootstrapper`; stop background timers in `window_close_handler` on app close to avoid trailing calls. - Add shared intervals in `shared/constants`; introduce `lib/shared/utils/activated_assets_cache.dart` for app-specific helpers. - No UI changes; measurable reduction in RPC volume and improved responsiveness. Refs #3238
…into perf/3238-reduce-rpc-spam
Updates SDK to include fix for asset availability verification that was causing transaction history to fail with connection errors.
Updates SDK to fix critical bug where event subscriptions were using display names instead of config IDs, causing balance watchers and transaction history to fail with connection errors.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…into perf/3238-reduce-rpc-spam # Conflicts: # lib/main.dart
…Changes stream in CoinsRepo and broadcast on SDK watchBalance\n- Add CoinsBalanceChanged event\n- Subscribe in CoinsBloc and update state on each change\n- Ensure cleanup in CoinsBloc.close\n\nThis wires SDK streaming into bloc-driven UI for live coin page, coins list, and portfolio totals.
…es\n\nEnsure CoinsBloc merges balance-change updates with existing coin state to avoid flipping active/suspended flags, which could disable Send erroneously.
…set history bleed - Remove global TransactionHistoryBloc provider from AppBlocRoot - Provide per-page bloc in CoinDetails and subscribe to widget.coin - Prevents DOGE history appearing on MATIC page and similar cross-contamination - No SDK changes required

PR description
🎯 App Changes (komodo-wallet)
Core Optimization
Cache-first pubkeys/addresses: All blocs and validators now prefer
sdk.pubkeys.lastKnown()before making RPC callsFiatFormBloc,WithdrawFormBloc,CoinAddressesBloc,NftReceiveBlocBridgeValidator,TakerValidator,TransactionHistoryBlocMm2Api.getBalance()Activated assets cache: Use
activatedAssetsCacheviaCoinsRepoto avoid repeatedgetActivatedAssets()callsgetActivatedAssetIds(),isAssetActivated()methods addedPolling Alignment
kActivationPollingIntervalconstant (default: 2s)Resource Management
Mm2Api.dispose()- cleans up NFT resourcesRPCNative.dispose()- closes HTTP clientKdfCustomTokenImportRepository.dispose()- closes HTTP clientCustomTokenImportBlocnow disposes repositoryMm2Api,SparklineRepository, andmm2on app closeSparklineRepositorywith GetIt for proper lifecycle managementPlatform-Specific
com.komodoplatform.atomicdextocom.komodo.wallet🚀 SDK Submodule Changes
Updated:
0b2312668→6df831553c07270a098bc5874742de12980176e1Event Streaming (Major Performance Win)
Caching & Persistence
Pubkey persistence:
AssetPubkeysnow persisted across sessions using Hive TypeAdaptersActivated assets cache: Coalesced activation checks to reduce repeated RPC calls
Wallet name caching: Reduced repeated wallet name lookups
Balance & Transaction Optimization
Activation Strategy Improvements
Additional Improvements
🎁 Why This Matters
📝 Post-Merge Notes
Update submodules after pulling:
If offline environment:
✅ QA Suggestions
RPC reduction verification:
Functional verification:
Cache behavior:
Performance:
Breaking Changes: None
Dependencies: Requires SDK submodule update
Note
Cuts RPC/polling via cache-first pubkeys and activated-asset caching, adds real-time balance and streamed tx history, lowers polling intervals, improves disposal, and updates iOS bundle ID.
sdk.pubkeys.lastKnown()), and useactivatedAssetsCachevia newCoinsRepohelpers (getActivatedAssetIds,isAssetActivated, cache invalidation on (de)activation).CoinsRepo.balanceChangesstream andCoinsBalanceChangedhandling inCoinsBloc.kActivationPollingIntervaland applied to charts/overview loaders.CoinDetailsprovidesTransactionHistoryBloclocally; improved UI error messages.Mm2Api.dispose,RPCNative.dispose,KdfCustomTokenImportRepository.dispose;WindowCloseHandlerdisposesMm2Api,SparklineRepository, andmm2;AppBootstrapperregistersSparklineRepositoryin GetIt.com.komodo.wallet.Written by Cursor Bugbot for commit 27b7db2. This will update automatically on new commits. Configure here.