Skip to content

feat: Add defaults for policy and block tracker options#9002

Merged
FrederikBolding merged 7 commits into
mainfrom
fb/network-controller-default-policy-options
Jun 4, 2026
Merged

feat: Add defaults for policy and block tracker options#9002
FrederikBolding merged 7 commits into
mainfrom
fb/network-controller-default-policy-options

Conversation

@FrederikBolding
Copy link
Copy Markdown
Member

@FrederikBolding FrederikBolding commented Jun 4, 2026

Explanation

Port defaults for maxRetries, maxConsecutiveFailures and circuitBreakDuration from the clients into core. This also enables us to make getRpcServiceOptions optional. Also brings in defaults for pollingInterval and retryTimeout.

References

https://consensyssoftware.atlassian.net/browse/WPC-1054

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes default RPC retry/circuit-break and block polling behavior for all network clients; consumers who omitted getRpcServiceOptions or depended on prior client-only defaults may see different failover and unavailable timing.

Overview
Network clients now ship built-in RPC and block-tracker tuning so callers no longer have to supply getRpcServiceOptions for standard retry/circuit behavior.

getRpcServiceOptions is optional on NetworkController and network client creation paths. When omitted, create-network-client merges @metamask/controller-utils defaults into each RPC endpoint: maxRetries 3, circuitBreakDuration 30s, and maxConsecutiveFailures 12 on the primary URL vs 40 on failover URLs (higher threshold so QuickNode-style activation does not trip the circuit too early). Custom overrides from getRpcServiceOptions still win via spread after those defaults.

Block tracker defaults are set in the same layer: 20s pollingInterval and retryTimeout (still 1s for custom networks under IN_TEST). Tests were updated for the new retry counts and circuit timing (e.g. 12 vs 40 mocked failures, 30s timer advance).

Reviewed by Cursor Bugbot for commit 6ae0d77. Bugbot is set up for automated code reviews on this repo. Configure here.

Base automatically changed from fb/network-controller-option-defaults to main June 4, 2026 10:23
@FrederikBolding FrederikBolding changed the title feat: Add defaults for policyOptions feat: Add defaults for policyOptions Jun 4, 2026
@FrederikBolding FrederikBolding force-pushed the fb/network-controller-default-policy-options branch from a292e7d to 86fa366 Compare June 4, 2026 10:57
@FrederikBolding FrederikBolding changed the title feat: Add defaults for policyOptions feat: Add defaults for policy and block tracker options Jun 4, 2026

### Added

- Add defaults for policy and block tracker options ([#9002](https://github.com/MetaMask/core/pull/9002))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we consider this breaking?

Each client already uses these values FWIW.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. It doesn't require any changes in consumers.

@FrederikBolding FrederikBolding marked this pull request as ready for review June 4, 2026 11:07
@FrederikBolding FrederikBolding requested review from a team as code owners June 4, 2026 11:07
Comment thread packages/network-controller/src/create-network-client.ts
Mrtenz
Mrtenz previously approved these changes Jun 4, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 e8d81a4. Configure here.

Comment thread packages/network-controller/src/create-network-client.ts Outdated
Mrtenz
Mrtenz previously approved these changes Jun 4, 2026
@FrederikBolding FrederikBolding added this pull request to the merge queue Jun 4, 2026
Merged via the queue into main with commit bd3da61 Jun 4, 2026
370 checks passed
@FrederikBolding FrederikBolding deleted the fb/network-controller-default-policy-options branch June 4, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants