Skip to content

fix: Prevent invalid selectedNetworkClientId on startup#33480

Merged
DDDDDanica merged 2 commits intochore/master-sync-12.20.0from
fix-incident-1051
Jun 4, 2025
Merged

fix: Prevent invalid selectedNetworkClientId on startup#33480
DDDDDanica merged 2 commits intochore/master-sync-12.20.0from
fix-incident-1051

Conversation

@mcmire
Copy link
Copy Markdown
Contributor

@mcmire mcmire commented Jun 4, 2025

Description

If selectedNetworkClientId in NetworkController state does not point to an RPC endpoint and therefore does not also point to a network client, then we automatically correct it to point to the default RPC endpoint of the first network (sorted by chain ID). This allows the wallet to start normally.

This change is being added as a patch because we do not want to upgrade to 23.5.1, as doing so would fix another unrelated bug, and we want to limit the scope of the change.

Open in GitHub Codespaces

Related issues

See MetaMask/core#5851 for the equivalent changes to network-controller that were copied here.

Also see MetaMask/metamask-mobile#15941 for a similar fix on the mobile side.

Manual testing steps

  1. Check out this branch.
  2. Run yarn start.
  3. Open the extension, and go through onboarding.
  4. Close the UI.
  5. Find the extension and open the service worker.
  6. Navigate to the Application tab.
  7. Click on "Extension storage", then "Local".
  8. Click on the value for "data".
  9. Look in the preview pane below (rendered JSON), right-click and choose "Copy value".
  10. Paste the value in another screen such as TextEdit.
  11. Look for selectedNetworkClientId and change it to something invalid.
  12. Reload the extension.
  13. The extension should still load successfully.
  14. Go back to the service worker. You should still be on the Application tab, and the preview should have been updated so that selectedNetworkClientId should no longer be invalid.
  15. Repeat the same steps, except run yarn webpack --watch instead of yarn start (to test MV2).

Screenshots/Recordings

(N/A)

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 4, 2025

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.

@mcmire mcmire changed the title Prevent invalid selectedNetworkClientId on startup fix: Prevent invalid selectedNetworkClientId on startup Jun 4, 2025
If `selectedNetworkClientId` in NetworkController state does not point
to an RPC endpoint and therefore does not also point to a network
client, then we automatically correct it to point to the default RPC
endpoint of the first network (sorted by chain ID). This allows the
wallet to start normally.

This change is being added as a patch because we do not want to upgrade
to 23.5.1, as doing so would fix another unrelated bug, and we want to
limit the scope of the change.
@mcmire mcmire force-pushed the fix-incident-1051 branch from 47fc2a2 to 678bbd7 Compare June 4, 2025 19:49
@mcmire
Copy link
Copy Markdown
Contributor Author

mcmire commented Jun 4, 2025

@metamaskbot update-policies

@metamaskbot
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

✨ Files requiring CODEOWNER review ✨

🧩 @MetaMask/extension-devs

  • lavamoat/browserify/beta/policy.json
  • lavamoat/browserify/flask/policy.json
  • lavamoat/browserify/main/policy.json

📜 @MetaMask/policy-reviewers

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.

  • lavamoat/browserify/beta/policy.json
  • lavamoat/browserify/flask/policy.json
  • lavamoat/browserify/main/policy.json

🔗 @MetaMask/supply-chain

  • lavamoat/browserify/beta/policy.json
  • lavamoat/browserify/flask/policy.json
  • lavamoat/browserify/main/policy.json

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [eb9ee9a]
UI Startup Metrics (1184 ± 71 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1184107115307112171309
load101391711745710511122
domContentLoaded100690811655710451116
domInteractive16133851628
firstPaint667129115040110221106
backgroundConnect74294713
firstReactRender21164962132
getState165129152032
initialActions001001
loadScripts79969694955836903
setupStore85273914
WebpackHomeuiStartup21181706252119922642440
load16411323194315017501864
domContentLoaded16341320193414817451852
domInteractive15115691242
firstPaint1556637556177267
backgroundConnect2294572736
firstReactRender15643361116301348
getState194321481233
initialActions317135
loadScripts16311318193114717431841
setupStore236309431843
FirefoxBrowserifyHomeuiStartup12881121180712213231546
load1138999165811211781383
domContentLoaded1138998165711211771383
domInteractive963524232103171
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2012140152039
firstReactRender23194842330
getState74242810
initialActions001001
loadScripts1120982162110711641364
setupStore10420827621
WebpackHomeuiStartup16061360230018416812042
load13951177189716914901825
domContentLoaded13951177189716914891825
domInteractive83361612291139
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect21156662332
firstReactRender42275344550
getState84293914
initialActions102111
loadScripts13761159187616814691806
setupStore85808812
Benchmark value 16 exceeds gate value 15 for chrome browserify home mean getState
Benchmark value 11 exceeds gate value 9 for firefox browserify home mean setupStore
Benchmark value 1395 exceeds gate value 1380 for firefox webpack home mean load
Benchmark value 1395 exceeds gate value 1380 for firefox webpack home mean domContentLoaded
Benchmark value 42 exceeds gate value 38 for firefox webpack home mean firstReactRender
Benchmark value 1377 exceeds gate value 1360 for firefox webpack home mean loadScripts
Benchmark value 2042 exceeds gate value 1935 for firefox webpack home p95 uiStartup
Benchmark value 1825 exceeds gate value 1660 for firefox webpack home p95 load
Benchmark value 1825 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded
Benchmark value 1806 exceeds gate value 1630 for firefox webpack home p95 loadScripts
Sum of mean exceeds: 54ms | Sum of p95 exceeds: 613ms
Sum of all benchmark exceeds: 667ms

@DDDDDanica DDDDDanica marked this pull request as ready for review June 4, 2025 22:23
@DDDDDanica DDDDDanica requested review from a team as code owners June 4, 2025 22:23
@DDDDDanica DDDDDanica merged commit 329624c into chore/master-sync-12.20.0 Jun 4, 2025
148 of 152 checks passed
@DDDDDanica DDDDDanica deleted the fix-incident-1051 branch June 4, 2025 22:23
@github-actions github-actions bot locked and limited conversation to collaborators Jun 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants