-
-
Notifications
You must be signed in to change notification settings - Fork 239
feat(backup & sync): use entropySourceId to sync accounts for Multi-SRP #5753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…art 1 This is a first pass at syncing account data for each SRP. This commit adds an entropySourceId param to all methods that might use it.
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
duplicate getIdentifier call
…in e2e environments
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
…t` (#5841) ## Explanation `AccountsController:accountAdded` events were missing the `.options.entropySource` property, causing account syncing to misbehave, registering new accounts to the primary SRP instead of the actual SRP used to add the account. We now add the `entropySource` to these new `InternalAccount`s based on the `keyring` that was used to create them. ## References Relates to #5618 Relates to #5725 Relates to #5753
@metamaskbot publish-preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mathieuartu I added a bunch of notes and questions. Please take a look 🙏
packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts
Show resolved
Hide resolved
packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts
Show resolved
Hide resolved
packages/profile-sync-controller/src/controllers/user-storage/UserStorageController.ts
Show resolved
Hide resolved
...ofile-sync-controller/src/controllers/user-storage/account-syncing/controller-integration.ts
Outdated
Show resolved
Hide resolved
packages/profile-sync-controller/src/controllers/user-storage/UserStorageController.ts
Outdated
Show resolved
Hide resolved
...ofile-sync-controller/src/controllers/user-storage/account-syncing/controller-integration.ts
Outdated
Show resolved
Hide resolved
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving @mirceanis changes, while also approving my changes on behalf of @mirceanis
## **Description** This PR implements the core changes seen in [this PR](MetaMask/core#5753). In short, this changes the implementation of `AuthenticationController` so that it can manage parallel sessions based on `entropySource`. In turn, this addition permits `UserStorageController` to scope user storage requests to a specific `entropySource`. Using all those changes, account syncing now iterates over each `entropySource` present in the client and syncs accounts in consequence. This will ensure that each SRP has its own data, that can be synced independently of the context (e.g Device 1 (SRP 1 + SRP 2), Device 2 (SRP 2 only) will bi-directionally sync). [](https://codespaces.new/MetaMask/metamask-extension/pull/32951?quickstart=1) ## **Related issues** Fixes: - https://consensyssoftware.atlassian.net/browse/IDENTITY-43 - https://consensyssoftware.atlassian.net/browse/IDENTITY-102 ## **Manual testing steps** 1. Import or create an SRP, complete onboarding, add and rename an EVM account 2. Import a second SRP, add and rename an EVM account 3. Uninstall and reinstall extension, onboard with one or both previous SRPs 4. Verify that EVM accounts are restored ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **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** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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. --------- Co-authored-by: MetaMask Bot <[email protected]>
## **Description** This PR implements the core changes seen in [this PR](MetaMask/core#5753). In short, this changes the implementation of `AuthenticationController` so that it can manage parallel sessions based on `entropySource`. In turn, this addition permits `UserStorageController` to scope user storage requests to a specific `entropySource`. Using all those changes, account syncing now iterates over each `entropySource` present in the client and syncs accounts in consequence. This will ensure that each SRP has its own data, that can be synced independently of the context (e.g Device 1 (SRP 1 + SRP 2), Device 2 (SRP 2 only) will bi-directionally sync). ## **Related issues** Fixes: - https://consensyssoftware.atlassian.net/browse/IDENTITY-43 - https://consensyssoftware.atlassian.net/browse/IDENTITY-102 ## **Manual testing steps** 1. Import or create an SRP, complete onboarding, add and rename an EVM account 2. Import a second SRP, add and rename an EVM account 3. Uninstall and reinstall extension, onboard with one or both previous SRPs 4. Verify that EVM accounts are restored ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/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-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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.
Explanation
This is a first pass at syncing account data for each SRP.
This PR adds an optional
entropySourceId
param to all methods that might use it, and then uses it for account-syncing.Following #5618 we have extra
options
available onInternalAccount
objects;entropySource
andderivationPath
.We can use these to properly segregate account data for multi-SRP.
This PR does not introduce breaking changes to the API, but to be able to get the benefits we still need the clients to cooperate, so some changes are needed there too.
entropySourceId
params in the user-storage sdk/controller with multiplethis.config.auth
instances, or something along those lines.entropySourceId
instead of needing an update to all method paramsentropySourceId
parametersSubtasks
performSignIn
, list entropy sources, login for eachgetIdentifier
callsessionData
and usesrpSessionData
insteadupdateAccounts
before each sync to refreshentropySource
when missinglistAccounts
to get accounts by entropySourceIdReferences
Fixes:
Related to:
Changelog
Checklist