-
Notifications
You must be signed in to change notification settings - Fork 5k
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: Fix SelectedNetworkController state corruption by making NetworkForm update in-place rather than remove and add for rpcUrl changes #26453
Conversation
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. |
Builds ready [fffe69d]
Page Load Metrics (258 ± 245 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Builds ready [7911aef]
Page Load Metrics (540 ± 458 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #26453 +/- ##
===========================================
- Coverage 70.12% 70.12% -0.01%
===========================================
Files 1428 1428
Lines 50103 50089 -14
Branches 13896 13894 -2
===========================================
- Hits 35133 35120 -13
+ Misses 14970 14969 -1 ☔ View full report in Codecov by Sentry. |
@@ -1,24 +1,4263 @@ | |||
diff --git a/dist/NetworkController.js b/dist/NetworkController.js |
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.
Is it possible to just release the fixed network-controller package really quickly and then update to it?
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.
i don't think that'd be realistically possible given the breaking change in 20.0.0 removes providerConfig from state. This is probably why we are still on 19.0.0
I'm going to guess that you're suggesting this since the patch is not human readable
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.
Is it possible to just release the fixed network-controller package really quickly and then update to it?
It is not possible to do this in a timely manner, but we need to get this fix into prod asap
Do we need to include changes to rerun 120.5 in this PR too? |
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.
LGTM
yes, that makes sense |
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.
changing my approval as there will be adding more migration code added here
LGTM ! Tested locally and worked as described. One thing as Nit is we can add an e2e test for editing rpcURL for selected network in the future ticket |
Quality Gate passedIssues Measures |
Builds ready [957f59a]
Page Load Metrics (140 ± 151 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
patch branch for network-controller 19.0.0 https://github.com/MetaMask/core/compare/jl/network-controller%4019.0.0-patch?expand=1 |
Description
Currently it is not possible to change the rpcUrl for an existing network configuration without first removing it then re-adding it. This poses an issue on extension when the rpcUrl for the currently selected network is changed via the
NetworkForm
. The NetworkForm first removes the existing networkClient which causes the SelectedNetworkController to replace any references to the networkClientId being removed with the selectedNetworkClientId, but the problem is that the selectedNetworkClientId is no longer valid at that point and leaves the SelectedNetworkController in a corrupted state.Really what we want in this case is to allow the network configuration to be updated in place by id, but only if the rpcUrl isn't changing to one that already exists on a different network configuration.
This PR achieves that by getting rid of the
removeNetworkConfiguration()
call triggered byNetworkForm
and patching theNetworkController
with changes from MetaMask/core#4614 which allow network configurations to have their rpcUrl updated in place. It also keeps the existing patch that removed alookupNetwork()
call ininitializeProvider()
.Related issues
Related: #26309
Manual testing steps
chrome.storage.local.get(console.log)
for NetworkController.networkConfigurationschrome.storage.local.get(console.log)
, the id for the network configuration that was just edited should not have changed in NetworkController.networkConfigurationschrome.storage.local.get(console.log)
, the dapp should have an entry for the network client we added above SelectedNetworkController.domainschrome.storage.local.get(console.log)
, the dapp should still be pointed at the same network client id in SelectedNetworkController.domains which should still exist in NetworkController.networkConfigurationsScreenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist