Skip to content

Conversation

@dan437
Copy link
Contributor

@dan437 dan437 commented Nov 11, 2025

Explanation

The fix ensures that when a network switch happens and a transaction immediately follows, the EIP-1559 compatibility is correctly determined rather than returning undefined, which would cause transaction validation to fail.

Disclaimer: I'm not familiar with the network controller, this PR is just a draft for the team that owns the network controller.

References

Fixes MetaMask/metamask-extension#37570

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, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

When EIP-1559 compatibility is not cached in metadata, compute it on demand, cache the result, and add tests covering both compatible and incompatible cases.

  • Network Controller
    • get1559CompatibilityWithNetworkClientId: If EIPS[1559] is undefined, determine compatibility via #determineEIP1559Compatibility, cache it in networksMetadata[networkClientId].EIPS[1559], and return the value; otherwise return the cached value.
  • Tests
    • Add tests verifying on-demand determination and caching of EIP-1559 compatibility when EIPS[1559] is initially undefined for both compatible (true) and incompatible (false) scenarios.

Written by Cursor Bugbot for commit 453379f. This will update automatically on new commits. Configure here.

Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
@dan437 dan437 requested review from a team as code owners November 11, 2025 10:19
@dan437 dan437 marked this pull request as draft November 11, 2025 10:20
@Gudahtt
Copy link
Member

Gudahtt commented Nov 12, 2025

The NetworkController is intended to initialize the network metadata to:

{
  status: NetworkStatus.Unknown,
  EIPS: {},
};

It refreshes metadata on-demand when lookupNetwork or lookupNetworkByClientId are called. It also refreshes this data for the "globally selected network", but since that is now used less often in our new designs, that is increasingly less relevant.

Based on your description of the problem, it sounds like we are failing to call lookupNetwork somewhere. As currently designed the NetworkController doesn't know when each network client is being used, so it doesn't know when to spend the time updating this metadata.

Updating it when we attempt to read this data could work, but there are a few problems still:

  • The network status remains potentially outdated
  • It doesn't help cases where the EIP status is read via state (which is probably most cases?)
  • It would be slower than fixing the root issue (i.e. slower than calling lookupNetwork as soon as a network is first used for something).

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.

[Bug]: Invalid transaction params Error after switching account and network (EIP-1559 mismatch)

3 participants