feat(network-controller): force RPC failover via remote flag#9175
Open
cryptodev-2s wants to merge 15 commits into
Open
feat(network-controller): force RPC failover via remote flag#9175cryptodev-2s wants to merge 15 commits into
cryptodev-2s wants to merge 15 commits into
Conversation
Thread isRpcFailoverForced through createNetworkClient, createRpcServiceChain, and createAutoManagedNetworkClient. When the force flag is on for an Infura endpoint that has failover URLs, the endpoint chain is built from failovers only, bypassing Infura entirely.
… param Add a disableRpcFailoverForced reconstruction test mirroring the sibling, and add the missing isRpcFailoverForced JSDoc tags.
…e-enabled flag Subscribe to RemoteFeatureFlagController state changes and read the forced failover flag on init, reconstructing affected network clients. Add public enableRpcFailoverForced/disableRpcFailoverForced methods and their messenger action types. Update existing tests for the new createAutoManagedNetworkClient argument and the new auto-managed client methods.
Export NetworkControllerEnableRpcFailoverForcedAction and NetworkControllerDisableRpcFailoverForcedAction, and update the init JSDoc to mention both failover flags.
…form prefix Rename the remote flag key from wallet-framework-rpc-failover-force-enabled to core-platform-rpc-failover-force-enabled to match the team's new name.
a049dda to
0bd5566
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
54126df to
0bd5566
Compare
Resolve create-network-client.ts by keeping main's URL-based isInfura (#9125) plus the forced-failover branch. Resolve NetworkController.test.ts by dropping the stale megaeth-testnet expectation that main replaced with megaeth-testnet-v2.
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Failover is automatic today: Infura is tried first and traffic only diverts to
failoverRpcUrlsafter the circuit breaker trips, gated bywalletFrameworkRpcFailoverEnabled. If that failover logic itself ever misbehaves, there is no way to deterministically take Infura out of the path.This adds an emergency kill switch: a new remote flag
core-platform-rpc-failover-force-enabled. When on, any Infura endpoint that has failover URLs sends all traffic (including block tracker polling) to those failovers and never hits Infura.It works independently of
walletFrameworkRpcFailoverEnabled(force implies failover) and mirrors the existingisRpcFailoverEnabledmachinery across every layer. AddsNetworkController.enableRpcFailoverForced()/disableRpcFailoverForced()and their messenger actions.References
Checklist
Note
High Risk
Changes which RPC host serves all wallet traffic for Infura networks when the flag is on; misconfiguration or bad failovers could break connectivity broadly, though scope is limited to Infura endpoints with configured failovers.
Overview
Adds an emergency forced RPC failover path controlled by remote flag
core-platform-rpc-failover-force-enabled, separate fromwalletFrameworkRpcFailoverEnabled.When forced failover is on, Infura clients that have
failoverRpcUrlsrebuild their RPC chain so all traffic (including block polling) goes only to failover URLs—Infura is not in the endpoint list. Infura without failovers and custom RPC endpoints behave as before.NetworkControllergainsenableRpcFailoverForced/disableRpcFailoverForced, matching messenger actions,init()andRemoteFeatureFlagController:stateChangewiring (same pattern as automatic failover). Auto-managed network clients passisRpcFailoverForcedthrough tocreateNetworkClient, which prioritizes the forced Infura+failover branch increateRpcServiceChain. Changelog and tests cover routing behavior and controller updates.Reviewed by Cursor Bugbot for commit eca6f20. Bugbot is set up for automated code reviews on this repo. Configure here.