Skip to content
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

feat: account syncing various updates #28541

Merged
merged 26 commits into from
Nov 20, 2024

Conversation

mathieuartu
Copy link
Contributor

@mathieuartu mathieuartu commented Nov 19, 2024

Description

This PR adds various account syncing house keeping improvements in order to be ready for re-enablement in a subsequent PR.
The number of files changed by this PR is large, but none affects a user facing feature, since account syncing is disabled in production.

  • Bump @metamask/profile-sync-controller to version 1.0.2
  • Add two new state keys linked to UserStorageController, isAccountSyncingReadyToBeDispatched and hasAccountSyncingSyncedAtLeastOnce
  • Wait for _addAccountsWithBalance to finish adding accounts after onboarding, then set isAccountSyncingReadyToBeDispatched to true
  • Use USER_STORAGE_FEATURE_NAMES exported constant from @metamask/profile-sync-controller to define user storage paths everywhere (no more magic strings)
  • Add batch delete delete support for E2E util UserStorageMockttpController
  • Update all account sync E2E tests in order to wait for account sync to have successfully been completed once before going on with the rest of the instructions.

⚠️ Please note that this PR does NOT re-enable account syncing in production. This will be done in a subsequent PR.

Related issues

Manual testing steps

  1. Import your SRP
  2. Add accounts, rename accounts
  3. Uninstall & reinstall
  4. Import the same SRP
  5. Verify that previous updates made in step 2 are there

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link

socket-security bot commented Nov 19, 2024

Copy link

socket-security bot commented Nov 19, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Network access npm/@metamask/[email protected] 🚫
New author npm/@metamask/[email protected] 🚫
Unstable ownership npm/@metamask/[email protected] 🚫
Network access npm/@metamask/[email protected] 🚫

View full report↗︎

Next steps

What is network access?

This module accesses the network.

Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

What is new author?

A new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.

Scrutinize new collaborator additions to packages because they now have the ability to publish code into your dependency tree. Packages should avoid frequent or unnecessary additions or changes to publishing rights.

What is unstable ownership?

A new collaborator has begun publishing package versions. Package stability and security risk may be elevated.

Try to reduce the amount of authors you depend on to reduce the risk to malicious actors gaining access to your supply chain. Packages should remove inactive collaborators with publishing rights from packages on npm.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

@mathieuartu mathieuartu changed the title Improv: account syncing various updates feat: account syncing various updates Nov 19, 2024
if (count !== 1) {
await this.removeAccount(address);
}
break;
Copy link
Contributor Author

@mathieuartu mathieuartu Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole function appears to be fully modified but it has just been wrapped in a try - catch - finally block

} catch (e) {
log.warn(`Failed to add accounts with balance. Error: ${e}`);
} finally {
this.preferencesController.setHasFinishedAddingAccountsWithBalance(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to prevent conflicts with different actors adding accounts at the end of onboarding, we're only dispatching account syncing when _addAccountsWithBalance is done.

@mathieuartu
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@metamaskbot
Copy link
Collaborator

Builds ready [32286e0]
Page Load Metrics (2341 ± 112 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint32927011955800384
domContentLoaded182826892302236113
load184127022341233112
domInteractive326748115
backgroundConnect990322210
firstReactRender6837715810450
getState822141284421
initialActions01000
loadScripts13322061172519996
setupStore781202411
uiStartup214932442830310149
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 171 Bytes (0.00%)
  • ui: 225 Bytes (0.00%)
  • common: -55.86 KiB (-0.67%)

@metamaskbot
Copy link
Collaborator

Builds ready [0ed48a0]
Page Load Metrics (1897 ± 66 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint16442243190513565
domContentLoaded16342203185712459
load16442248189713766
domInteractive289542189
backgroundConnect1386402512
firstReactRender683871429244
getState452501145526
initialActions01000
loadScripts12121694140010450
setupStore685222914
uiStartup193929512327311149
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 171 Bytes (0.00%)
  • ui: 225 Bytes (0.00%)
  • common: -55.86 KiB (-0.66%)

@metamaskbot
Copy link
Collaborator

Builds ready [c2f24fd]
Page Load Metrics (2110 ± 64 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint52323412031370178
domContentLoaded17932243204812359
load18712355211013464
domInteractive15172473316
backgroundConnect10198614321
firstReactRender663661277737
getState482041104622
initialActions00000
loadScripts12831713154811756
setupStore6391073
uiStartup21653021251719996
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 412 Bytes (0.01%)
  • ui: 225 Bytes (0.00%)
  • common: -55.79 KiB (-0.66%)

Copy link
Contributor

@cmd-ob cmd-ob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good! Thanks for sorting.

@mathieuartu mathieuartu marked this pull request as ready for review November 20, 2024 15:14
@mathieuartu mathieuartu requested review from a team as code owners November 20, 2024 15:14
@mathieuartu mathieuartu added this pull request to the merge queue Nov 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 20, 2024
@mathieuartu mathieuartu added this pull request to the merge queue Nov 20, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 20, 2024
@mathieuartu mathieuartu added this pull request to the merge queue Nov 20, 2024
Merged via the queue into develop with commit fac35b8 Nov 20, 2024
74 of 75 checks passed
@mathieuartu mathieuartu deleted the improv/account_syncing_various_updates branch November 20, 2024 16:42
@github-actions github-actions bot locked and limited conversation to collaborators Nov 20, 2024
@metamaskbot metamaskbot added the release-12.9.0 Issue or pull request that will be included in release 12.9.0 label Nov 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.9.0 Issue or pull request that will be included in release 12.9.0 team-identity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants