perf: Move request inspection outside of the executor#3356
Merged
FrederikBolding merged 7 commits intomainfrom Oct 1, 2025
Merged
perf: Move request inspection outside of the executor#3356FrederikBolding merged 7 commits intomainfrom
FrederikBolding merged 7 commits intomainfrom
Conversation
653abb1 to
9005464
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3356 +/- ##
==========================================
- Coverage 98.30% 98.27% -0.03%
==========================================
Files 417 417
Lines 11927 11903 -24
Branches 1844 1845 +1
==========================================
- Hits 11725 11698 -27
- Misses 202 205 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0db0eba to
797d795
Compare
FrederikBolding
commented
Apr 28, 2025
github-merge-queue bot
pushed a commit
that referenced
this pull request
May 6, 2025
Moved some of the ideas from #3356 to this PR which will be a simple to merge right away. The other referenced PR needs some more work, but is eventually what we should do. This PR let's Snaps start their outbound request before waiting for the notification to land, this should be a small perf improvement to all requests made from the Snap.
a4a33fb to
17263e8
Compare
FrederikBolding
commented
Oct 1, 2025
| rpcStream.write = (chunk, encoding, callback) => { | ||
| // Ignore chain switching notifications as it doesn't matter for the SnapProvider. | ||
| if (chunk?.data?.method === 'metamask_chainChanged') { | ||
| return true; |
Member
Author
There was a problem hiding this comment.
This is uncovered, but we don't have an easy way to test this right now
Mrtenz
approved these changes
Oct 1, 2025
1b1adf9 to
8b9e40f
Compare
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.
In the current implementation, every RPC request requires a least 3 messages to be sent to manage outbound request/response tracking. This PR proposes to move that tracking to the client side where we can simply monitor the RPC stream for requests and responses. This should alleviate some pressure on the communication layer for Snaps.
Note
Shift outbound request/response tracking to AbstractExecutionService by inspecting the JSON-RPC stream, removing executor-side notifications and updating tests accordingly.
packages/snaps-controllers):AbstractExecutionServiceto detect outbound activity by inspectingrpcstream:ExecutionService:outboundRequeston inbound RPC chunks with anid.rpcStream.writeto publishExecutionService:outboundResponsewhen writing responses; ignoremetamask_chainChanged.packages/snaps-execution-environments):OutboundRequest/OutboundResponsenotifications fromBaseSnapExecutorprovider wrappers (snap.request,ethereum.request) and simplify teardown handling.BaseSnapExecutor.test.browser.tsto drop expectations for command-stream outbound notifications where applicable, keeping RPC flow assertions intact.Written by Cursor Bugbot for commit 8b9e40f. This will update automatically on new commits. Configure here.