Skip to content

fix(transaction-controller): strip gasPrice for fee-market transactions instead of rejecting#8396

Open
skyc1e wants to merge 1 commit intoMetaMask:mainfrom
skyc1e:fix/strip-gasPrice-for-fee-market-txs
Open

fix(transaction-controller): strip gasPrice for fee-market transactions instead of rejecting#8396
skyc1e wants to merge 1 commit intoMetaMask:mainfrom
skyc1e:fix/strip-gasPrice-for-fee-market-txs

Conversation

@skyc1e
Copy link
Copy Markdown

@skyc1e skyc1e commented Apr 8, 2026

Explanation

Some RPCs (notably Arbitrum's eth_fillTransaction) return both gasPrice and EIP-1559 fields (maxFeePerGas/maxPriorityFeePerGas). The current validation rejects these with:

"Invalid transaction params: specified gasPrice but also included maxFeePerGas, these cannot be mixed"

When the envelope type is explicitly fee-market (0x2 or 0x4), the gasPrice field is redundant. The codebase already strips it in several downstream locations (GasFeePoller, updateGasFees, retry utils), but validateGasFeeParams runs first and throws before normalization can happen.

Changes

In validateGasFeeParams, strip gasPrice when:

  1. the transaction type is explicitly 0x2 or 0x4, and
  2. EIP-1559 fee fields are also present.

Without an explicit fee-market type, the existing mutual exclusivity check still throws — this only relaxes validation when the intent is unambiguous.

Tests

Three new test cases:

  • fee-market type (0x2) with both fields → strips gasPrice, does not throw
  • setCode type (0x4) with both fields → strips gasPrice, does not throw
  • no explicit type with both fields → still throws (existing behavior preserved)

All 52 validation tests pass.

Closes #7877


Note

Medium Risk
Changes transaction parameter validation by mutating txParams to drop gasPrice for explicit fee-market envelopes, which could affect how some callers’ transactions are accepted and normalized. Risk is limited by gating the behavior on explicit type and keeping existing mutual-exclusion errors for untyped params.

Overview
Improves fee-field validation to accept RPC-returned fee-market transactions that include both gasPrice and EIP-1559 fields: when txParams.type is explicitly fee-market (0x2/0x4), validateGasFeeParams now strips the redundant gasPrice instead of throwing.

Adds targeted tests covering the new strip behavior for feeMarket and setCode envelopes, while preserving the existing error when both fee styles are provided without an explicit fee-market type. Updates the transaction-controller changelog to note the compatibility fix (e.g. Arbitrum).

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

…d of rejecting

Some RPCs (e.g. Arbitrum's eth_fillTransaction) return both gasPrice
and EIP-1559 fields. When the envelope type is explicitly fee-market
(0x2/0x4), strip the redundant gasPrice before validating mutual
exclusivity instead of throwing.

This matches the normalization already done in GasFeePoller,
updateGasFees, and retry utils.

Closes MetaMask#7877
@skyc1e skyc1e requested review from a team as code owners April 8, 2026 00:06
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.

transaction-controller: reject transactions with both gasPrice and EIP-1559 fee fields instead of gracefully preferring maxFeePerGas

1 participant