Skip to content

cherry-pick: Prevent rpc request before onboarding is completed (#23622)#23730

Merged
pedronfigueiredo merged 1 commit intoVersion-v11.14.0from
pnf/private-onboarding-cherry-pick
Mar 26, 2024
Merged

cherry-pick: Prevent rpc request before onboarding is completed (#23622)#23730
pedronfigueiredo merged 1 commit intoVersion-v11.14.0from
pnf/private-onboarding-cherry-pick

Conversation

@pedronfigueiredo
Copy link
Copy Markdown
Contributor

@pedronfigueiredo pedronfigueiredo commented Mar 26, 2024

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.

Description

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability
  • 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.

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.

## **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](#23005)
(currently blocked by [#4004 on
core](MetaMask/core#4004).


## **Related issues**

Fixes: MetaMask/MetaMask-planning#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**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**




https://github.com/MetaMask/metamask-extension/assets/7499938/73513327-90fb-4e9f-8af2-aa41c731b647





### **After**



https://github.com/MetaMask/metamask-extension/assets/7499938/d6dee1c6-fa13-48c8-9fe2-520e3d43d0b3



## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] 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](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
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.

---------

Co-authored-by: Dan J Miller <danjm.com@gmail.com>
@pedronfigueiredo pedronfigueiredo added team-extension-platform Extension Platform team release-11.14.0 Issue or pull request that will be included in release 11.14.0 labels Mar 26, 2024
@pedronfigueiredo pedronfigueiredo self-assigned this Mar 26, 2024
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner March 26, 2024 15:00
@github-actions
Copy link
Copy Markdown
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 changed the title fix: Prevent rpc request before onboarding is completed (#23622) cherry-pick: Prevent rpc request before onboarding is completed (#23622) Mar 26, 2024
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [f315975]
Page Load Metrics (1066 ± 527 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint693281285627
domContentLoaded115225105
load61279510661098527
domInteractive115225105
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 f9be841 into Version-v11.14.0 Mar 26, 2024
@pedronfigueiredo pedronfigueiredo deleted the pnf/private-onboarding-cherry-pick branch March 26, 2024 15:36
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-11.14.0 Issue or pull request that will be included in release 11.14.0 team-extension-platform Extension Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants