Repository navigation
feat(tron): deduplicate identical requests within 5 seconds - #500
Merged
Merged
Conversation
ulissesferreira
marked this pull request as ready for review
October 22, 2026 14:09
ulissesferreira
temporarily deployed
to
default-branch
October 22, 2026 14:09 — with
GitHub Actions
Inactive
ulissesferreira
force-pushed
the
feat/tron-client-request-cache
branch
2 times, most recently
from
October 22, 2026 15:10
323657b to
ee7fc1d
Compare
stanleyyconsensys
previously approved these changes
Oct 22, 2026
stanleyyconsensys
left a comment
Contributor
There was a problem hiding this comment.
LGTM
thx for the change, using inMemory cache should be enough for our case
ulissesferreira
force-pushed
the
feat/tron-client-request-cache
branch
from
October 22, 2026 15:13
ee7fc1d to
495265d
Compare
|
5 of 7 tasks
LabinatorSolutions
pushed a commit
to LabinatorSolutions/metamask-extension
that referenced
this pull request
Oct 26, 2026
## **Description** Bumps the preinstalled Solana and Tron wallet Snaps to the latest published versions: - `@metamask/solana-wallet-snap`: `^7.1.0` → `^7.2.0` - `@metamask/tron-wallet-snap`: `^4.2.0` → `^4.3.0` ### `@metamask/solana-wallet-snap` 7.2.0 #### Added - Route asset reads (`getAccountAssetByID`, `getAccountAssetsByIDs`, `getAccountAssetsByScope`, `getAccountAssets`) through the Core AssetsController when the Solana assets migration flag is active, falling back to the Snap adapter while it is off ([MetaMask#486](MetaMask/internal-snaps#486)) #### Changed - Retry transient Solana RPC and API read failures with the shared fetch policy while sending transaction submissions only once ([MetaMask#478](MetaMask/internal-snaps#478)) #### Fixed - Fix a race condition in the WebSocket connection recovery so resync no longer skips accounts during re-subscription ([MetaMask#490](MetaMask/internal-snaps#490)) - Accept scan responses that report the `simulation` or `validation` section as explicit `null` instead of failing response validation ### `@metamask/tron-wallet-snap` 4.3.0 #### Changed - Cache identical TronGrid and Tron provider requests for 5 seconds, so rapid keyring calls such as `getAccountAssets` and `getAccountBalances` reuse the previous result ([MetaMask#500](MetaMask/internal-snaps#500)) - Use the shared `executeWithFetchPolicy`, `fetchWithPolicy`, and `parseRetryAfter` helpers from `@metamask/snap-networks-utils`, and apply the shared fetch policy to `TokenApiClient` and the Security Alerts API client ([MetaMask#492](MetaMask/internal-snaps#492)) - Retry transient TronGrid, Tron provider, price API, and signed transaction broadcast failures with bounded backoff and per-attempt timeouts ([MetaMask#472](MetaMask/internal-snaps#472)) - Extend the shared `BaseTransactionScanService` from `@metamask/snap-networks-utils` in the transaction scan service and align the Tron security-scan handling with the Blockaid API documentation ([MetaMask#397](MetaMask/internal-snaps#397)) ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: N/A — dependency version bump only. ## **Manual testing steps** 1. Run the extension. 2. Create or import a wallet, then add a Solana account and select the Solana network. 3. Refresh the asset list and verify balances and token metadata load without errors. 4. Add a Tron account, select the Tron network, and refresh the asset list. 5. Send a small Solana and Tron transaction and confirm the confirmation screen and activity list update correctly. 6. Check the background console for Snap-related errors. <!-- ## **Screenshots/Recordings** ### **Before** N/A ### **After** N/A --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
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.



Explanation
Rapid keyring calls such as
getAccountAssetsandgetAccountBalancesboth resolve throughfetchAccountAssetsFromTrongrid, which issues the same TronGrid/Tron provider requests per scope. When the two calls arrive in quick succession, every request was sent to the network twice.This caches the
#fetchchoke point ofTrongridApiClientandTronHttpClientwith the shareduseCachehelper backed byInMemoryCache. An identical request made within 5 seconds reuses the previous response instead of repeating the network call.Notes:
scope,url, andheadersfor TronGrid, andnetwork,url,method,headers,body, andallowedStatusesfor Tron HTTP. Different arguments never collide, and the 404-allowed transaction-info path stays isolated.context.ts, so the cache spans the whole keyring flow without any keyring changes.References
No ticket.
Checklist