fix(snap-account-service): faster :getLegacySnapKeyring#8865
Open
ccharly wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
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
Now check if the keyring is already there without locking the
KeyringControllermutex (like we used to do in the clients).References
N/A
Checklist
Note
Medium Risk
Changes how the legacy Snap keyring is retrieved/created by adding a pre-check that bypasses the
KeyringControllermutex in the common case, which could affect keyring lifecycle and error handling if assumptions are wrong. Test coverage was expanded, but behavior still depends onwithKeyringUnsafe/withControllersemantics.Overview
Speeds up
SnapAccountService.getLegacySnapKeyring()by first attempting to fetch the existing legacy Snap keyring viaKeyringController:withKeyringUnsafeand returning immediately when present, avoiding theKeyringController:withControllermutex.If the fast-path reports the keyring missing, the method falls back to
withControllerto safely find-or-create the Snap keyring. Tests were updated to cover the fast-path, fallback creation, and error propagation, and the package changelog documents the change.Reviewed by Cursor Bugbot for commit 9c8d42a. Bugbot is set up for automated code reviews on this repo. Configure here.