Repository navigation
refactor: drop legacy RPC endpoint failoverUrls - #38801
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. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
Smart E2E Test SelectionSelected E2E tags: ALL AI Confidence: 100 E2E reasoningExpand to readThe hard-rule seed (controller-version-update) selects ALL, and the diffs support keeping it. |
MetaMask#11266) ## Explanation `NetworkController` has two places to define RPC failover URLs: the `failoverUrls` constructor option (keyed by chain ID) and a legacy `failoverUrls` property on each RPC endpoint in state. The state property was only a fallback for chains missing from the constructor option, and both clients now pass that option. This PR removes the legacy property: - `failoverUrls` is gone from `InfuraRpcEndpoint` and `CustomRpcEndpoint`, so `addNetwork` and `updateNetwork` no longer accept it. - Network clients use `failoverUrls?.[chainId] ?? []`, so `configuration.failoverRpcUrls` keeps its shape. ## References - Extension Work: MetaMask/metamask-extension#47594 - Mobile Work: MetaMask/metamask-mobile#38801 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **High Risk** > Breaking API and behavior change to RPC failover sourcing in core network infrastructure; clients relying on per-endpoint persisted failover URLs will lose failover unless they migrate to the constructor option. > > **Overview** > **Breaking change:** `failoverUrls` is removed from `InfuraRpcEndpoint` and `CustomRpcEndpoint`, so persisted RPC endpoints and `addNetwork` / `updateNetwork` payloads must no longer include it. Default and custom network templates in `NetworkController` stop emitting empty `failoverUrls` arrays on each endpoint. > > RPC failover is now **only** supplied via the `NetworkController` constructor option `failoverUrls` (keyed by chain ID). When building network clients, `failoverRpcUrls` is set to `failoverUrls?.[chainId] ?? []` with no fallback to values that used to live on individual endpoints—chains without a constructor entry get no failover URLs. > > Tests and fixtures across `network-controller`, `assets-controller`, `assets-controllers`, `multichain-network-controller`, and `selected-network-controller` are updated accordingly (provider failover tests now pass chain-level `failoverUrls`). The changelog documents client migration (stop writing endpoint `failoverUrls`, optionally strip them from persisted state). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 76a9a4b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…rpc-failover-urls # Conflicts: # app/store/migrations/161.test.ts # app/store/migrations/161.ts # package.json # yarn.lock
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 61e196b. Configure here.
…rpc-failover-urls # Conflicts: # package.json # yarn.lock
| /** | ||
| * Failover URLs for each chain that has them configured, keyed by chain ID. | ||
| * This is the single source of truth for RPC failover: it is passed to | ||
| * `NetworkController` as the `failoverUrls` constructor option (which applies | ||
| * it to every RPC endpoint of the chain) and read by the network details UI. | ||
| * | ||
| * @returns Failover URLs keyed by chain ID. | ||
| */ |
There was a problem hiding this comment.
nitpick (non-blocking): This JSDoc says the failoverUrls constructor option "applies it to every RPC endpoint of the chain", which is broader than what v38 does. Core only attaches failover when the endpoint hostname ends with .infura.io, as the JSDoc on getFailoverUrlsForEndpoint already says. Tightening this would keep a later change from assuming failover on custom RPCs.
Suggested wording for the parenthetical:
* `NetworkController` as the `failoverUrls` constructor option (core applies
* those URLs only to endpoints whose hostname ends with `.infura.io`) and read
* by the network details UI.
vinnyhoward
left a comment
There was a problem hiding this comment.
UX owned files look good
|
javiergarciavera
left a comment
There was a problem hiding this comment.
QA review against the MetaMask mobile-testing skill (unit and test-layer placement). Please consider using that skill during development so layer choice and coverage are checked as the change is written.
The failover helpers, migration 162, and the feature-flag selector are covered at the unit layer, which is the right place for this work. The inline comment is a gap in the new RpcEndpointSection cases.
| ).toBeOnTheScreen(); | ||
| }); | ||
|
|
||
| it('shows the failover tag for an endpoint with a failover', () => { | ||
| const formHook = createRpcModalFormHook({ | ||
| form: { rpcUrl: 'https://mainnet.infura.io/v3/key', chainId: '0x1' }, | ||
| showMultiRpcAddModal: false, | ||
| rpcModalShowForm: false, | ||
| }); | ||
|
|
||
| const { queryByText } = render( | ||
| <RpcEndpointSection | ||
| formHook={formHook} | ||
| validation={createRpcValidation()} | ||
| onValidationSuccess={jest.fn()} | ||
| isRpcFailoverEnabled | ||
| styles={styles} | ||
| themeAppearance="light" | ||
| placeholderTextColor={placeholderTextColor} | ||
| />, | ||
| ); | ||
|
|
||
| expect(queryByText(strings('app_settings.failover'))).toBeOnTheScreen(); | ||
| }); | ||
|
|
||
| it('hides the failover tag for an endpoint without a failover', () => { | ||
| const formHook = createRpcModalFormHook({ | ||
| form: { rpcUrl: 'https://rpc1.example.com', chainId: '0x1' }, | ||
| showMultiRpcAddModal: false, | ||
| rpcModalShowForm: false, | ||
| }); | ||
|
|
||
| const { queryByText } = render( | ||
| <RpcEndpointSection | ||
| formHook={formHook} | ||
| validation={createRpcValidation()} | ||
| onValidationSuccess={jest.fn()} | ||
| isRpcFailoverEnabled | ||
| styles={styles} | ||
| themeAppearance="light" | ||
| placeholderTextColor={placeholderTextColor} | ||
| />, | ||
| ); | ||
|
|
||
| expect(queryByText(strings('app_settings.failover'))).not.toBeOnTheScreen(); | ||
| }); | ||
|
|
||
| it('renders RPC selector in edit mode', () => { |
There was a problem hiding this comment.
These cases check the Failover tag, but the section also renders a read-only failover URL (strings('app_settings.network_failover_rpc_url_label') and failoverRpcUrls[0]). That is the behavior called out in the PR's manual steps: the tag and URL appear for an Infura endpoint, and neither appears for a custom RPC.
Please also assert the URL field in these two tests (for mainnet Infura, the value should be https://mainnet.quicknode.example from the beforeEach env setup). And add a case with isRpcFailoverEnabled={false} on an Infura endpoint that has failover configured, so the tag and URL stay hidden when the flag is off.
There was a problem hiding this comment.
@javiergarciavera to not loose the current approvals, I have done this as a follow up on this stacked PR #39394




Description
MetaMask/core#11266 removes the per endpoint
failoverUrlsproperty from@metamask/network-controller(v38). Failover URLs now come only from the controller'sfailoverUrlsconstructor option (chain ID to URLs), and core applies them only to*.infura.ioendpoints.This PR adapts mobile to that:
customNetworks.tsx, and stops writingfailoverUrlson endpoints (popular networks, config registry, swap deeplink, card and bridge hooks).failoverUrlsfrom persistedNetworkControllerstate. Migrations 72 and 83 no longer write the field (needed to type check).0x1237) to the map. Its only failover source used to be the endpoint state value.The v38 bump also changes failover behavior beyond the
failoverUrlsremoval:enabled. Before, a missing or malformedcorePlatformRpcFailoverModeflag was read asdisabled. Now it is skipped, so the default applies. A valid value (disabled,enabled,forced) is still honored.corePlatformRpcFailoverMode(on unlessdisabled), matching the controller. The retiredwalletFrameworkRpcFailoverEnabledflag is no longer referenced, and the feature flag registry is updated.Changelog
CHANGELOG entry: null
Related issues
Refs: MetaMask/core#11266
Manual testing steps
Before testing, set a failover URL for Ethereum Mainnet in
.js.env. Without it the chain has no failover configured and the tag never shows:Then restart Metro with
yarn watch:clean(the value is baked into the bundle, so a plain reload is not enough) and reload the app. Any URL works for checking the display.Screenshots/Recordings
Screen.Recording.iPhone.18.Pro.10-11-2026.at.15.47.54.mp4
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches core RPC configuration, a persistence migration, and a major
network-controllerbump; failover gating and defaults change when remote flags are missing, but scope is largely aligned with upstream core behavior.Overview
Upgrades
@metamask/network-controllerto v38 and removes the legacyfailoverUrlsfield on RPC endpoints everywhere the app adds or edits networks (PopularList, bridge/card hooks, swap deeplinks, config registry, network form state).Failover is now chain-level only:
customNetworks.tsxexposesgetFailoverUrlsByChainId()(including Robinhood chain0x1237), passed intoNetworkControllervia wallet init options. The network details UI and RPC list usegetFailoverUrlsForEndpoint(chainId, rpcUrl)so the Failover tag and read-only URL appear only for*.infura.ioendpoints when failover is enabled—matching core behavior.Migration 162 strips persisted per-endpoint
failoverUrlsfromnetworkConfigurationsByChainId. Older migrations and fixtures stop writing the field.Feature flags:
selectIsRpcFailoverEnablednow keys offcorePlatformRpcFailoverMode(off only whendisabled; absent flag defaults to on), replacingwalletFrameworkRpcFailoverEnabled.Reviewed by Cursor Bugbot for commit 25c1ebe. Bugbot is set up for automated code reviews on this repo. Configure here.