MetaMask / MetaMask/core

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

Open
#7,877 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
413
Forks
308
Avg merge
1d 4h
Merged PRs (30d)
253

Description

## 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`:

```bash
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:

```json
{
"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](https://github.com/wevm/viem/issues/4323)
- The relevant validation is in `packages/transaction-controller/src/utils/validation.ts`, in `validateGasFeeParams` which calls `ensureMutuallyExclusiveFieldsNotProvided`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/transaction-controller/src/utils/validation.ts at validateGasFeeParams and its call to ensureMutuallyExclusiveFieldsNotProvided. Reproduce the provided type 0x2 transaction with both fee styles, then verify that fee-market transactions prefer maxFeePerGas and maxPriorityFeePerGas while legacy transactions retain their existing validation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.