Skip to content

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

@t0rbik

Description

@t0rbik

Bug Description

validateGasFeeParams in @metamask/transaction-controller throws when a transaction includes both gasPrice and maxFeePerGas/maxPriorityFeePerGas, even when the transaction type is explicitly 0x2 (EIP-1559). Instead of stripping the redundant gasPrice and proceeding, MetaMask rejects the transaction entirely.

Steps to Reproduce

Some RPCs return gasPrice alongside EIP-1559 fee fields. For example, Arbitrum's eth_fillTransaction:

curl -s -X POST https://arbitrum-one.publicnode.com \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_fillTransaction",
    "params": [{
      "from": "0x0000000000000000000000000000000000000001",
      "to": "0x0000000000000000000000000000000000000001",
      "value": "0x0",
      "type": "0x2"
    }]
  }'

Response:

{
  "result": {
    "tx": {
      "type": "0x2",
      "gasPrice": "0x0",
      "maxFeePerGas": "0x2e28680",
      "maxPriorityFeePerGas": "0x0",
      "gas": "0x5f12",
      "chainId": "0xa4b1"
    }
  }
}

When a dapp submits a transaction containing these fields to MetaMask, it rejects with:

Invalid transaction envelope type: specified type "0x2" but included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas

Expected Behavior

When a transaction includes both gasPrice and maxFeePerGas/maxPriorityFeePerGas with a fee-market type (0x2 or 0x4), MetaMask should gracefully prefer the EIP-1559 fields and strip the redundant gasPrice, rather than rejecting the transaction.

Additional Context

  • Originally filed as wevm/viem#4323
  • The relevant validation is in packages/transaction-controller/src/utils/validation.ts, in validateGasFeeParams which calls ensureMutuallyExclusiveFieldsNotProvided

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions