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

fix: Prevent rpc request before onboarding is completed #23622

Merged
merged 12 commits into from
Mar 26, 2024

Conversation

pedronfigueiredo
Copy link
Contributor

Description

The temporary solution is to:

  • Prevent two network controller requests by:
    • Patch the network controller so that the lookup on initializeProvidercan be avoided.
    • Call that initializeProvider with the lookup: false argument right after the network controller is constructed
    • Call await this.networkController.lookupNetwork(); at the end of the metamask controller if the onboarding has been completed
    • Call await this.networkController.lookupNetwork(); once the onboarding complete state changes
  • Prevent one accounts tracker request by:
    • Moving the blockTracker event listener from the constructor of the controller to the start function

The long term solution will be #23005 (currently blocked by #4004 on core.

Related issues

Fixes: https://github.com/MetaMask/metamask-planning/issues/881

Manual testing steps

  1. Add await new Promise((resolve) => setTimeout(resolve, 10000)); to the top of initialize on the background.js file
  2. Build the app
  3. Load extension and immediately open the network tab on the background console before the app initializes
  4. No requests should happen

Screenshots/Recordings

Before

Peek.2023-12-05.06-44.mp4

After

Peek.2023-12-05.06-31.mp4

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

@pedronfigueiredo pedronfigueiredo force-pushed the prevent-rpc-request-before-onboard branch from d16dad8 to 91acfcc Compare March 21, 2024 09:38
@pedronfigueiredo pedronfigueiredo changed the title fix: Prevent rpc request before onboarding is complete fix: Prevent rpc request before onboarding is completed Mar 21, 2024
Copy link

socket-security bot commented Mar 21, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@pedronfigueiredo
Copy link
Contributor Author

@SocketSecurity ignore npm/@metamask/safe-event-emitter@3.0.0

@metamaskbot
Copy link
Collaborator

Builds ready [91acfcc]
Page Load Metrics (1381 ± 563 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint784131577637
domContentLoaded137729157
load58263913811172563
domInteractive137729157
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 113 Bytes (0.00%)
  • ui: 9 Bytes (0.00%)
  • common: 23 Bytes (0.00%)

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

I left two comments

@metamaskbot
Copy link
Collaborator

Builds ready [7e532de]
Page Load Metrics (1019 ± 588 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint722721535828
domContentLoaded11116402814
load57314410191225588
domInteractive11116402814
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 171 Bytes (0.00%)
  • ui: 9 Bytes (0.00%)
  • common: 23 Bytes (0.00%)

@pedronfigueiredo pedronfigueiredo force-pushed the prevent-rpc-request-before-onboard branch 2 times, most recently from 63af236 to 536ab0a Compare March 25, 2024 10:39
brad-decker
brad-decker previously approved these changes Mar 25, 2024
@pedronfigueiredo pedronfigueiredo force-pushed the prevent-rpc-request-before-onboard branch from 430c5cd to 3988377 Compare March 26, 2024 12:41
@metamaskbot
Copy link
Collaborator

Builds ready [3988377]
Page Load Metrics (1232 ± 496 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint812751484923
domContentLoaded166230147
load67260612321032496
domInteractive166230147
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 169 Bytes (0.00%)
  • ui: 9 Bytes (0.00%)
  • common: -27 Bytes (-0.00%)

@pedronfigueiredo pedronfigueiredo merged commit c947630 into develop Mar 26, 2024
65 of 66 checks passed
@pedronfigueiredo pedronfigueiredo deleted the prevent-rpc-request-before-onboard branch March 26, 2024 14:50
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2024
@metamaskbot metamaskbot added the release-11.15.0 Issue or pull request that will be included in release 11.15.0 label Mar 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-11.15.0 Issue or pull request that will be included in release 11.15.0 team-extension-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants