fix(transaction-controller): strip gasPrice for fee-market transactions instead of rejecting#8396
Open
skyc1e wants to merge 1 commit intoMetaMask:mainfrom
Open
fix(transaction-controller): strip gasPrice for fee-market transactions instead of rejecting#8396skyc1e wants to merge 1 commit intoMetaMask:mainfrom
skyc1e wants to merge 1 commit intoMetaMask:mainfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Some RPCs (notably Arbitrum's
eth_fillTransaction) return bothgasPriceand EIP-1559 fields (maxFeePerGas/maxPriorityFeePerGas). The current validation rejects these with:When the envelope type is explicitly fee-market (
0x2or0x4), thegasPricefield is redundant. The codebase already strips it in several downstream locations (GasFeePoller,updateGasFees, retry utils), butvalidateGasFeeParamsruns first and throws before normalization can happen.Changes
In
validateGasFeeParams, stripgasPricewhen:0x2or0x4, andWithout 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:
0x2) with both fields → strips gasPrice, does not throw0x4) with both fields → strips gasPrice, does not throwAll 52 validation tests pass.
Closes #7877
Note
Medium Risk
Changes transaction parameter validation by mutating
txParamsto dropgasPricefor explicit fee-market envelopes, which could affect how some callers’ transactions are accepted and normalized. Risk is limited by gating the behavior on explicittypeand keeping existing mutual-exclusion errors for untyped params.Overview
Improves fee-field validation to accept RPC-returned fee-market transactions that include both
gasPriceand EIP-1559 fields: whentxParams.typeis explicitly fee-market (0x2/0x4),validateGasFeeParamsnow strips the redundantgasPriceinstead of throwing.Adds targeted tests covering the new strip behavior for
feeMarketandsetCodeenvelopes, while preserving the existing error when both fee styles are provided without an explicit fee-markettype. Updates thetransaction-controllerchangelog 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.