fix(transaction-controller): broaden gas estimation for type-4 transactions with non-self target#8467
Merged
matthewwalsh0 merged 4 commits intomainfrom Apr 23, 2026
Conversation
…ctions with non-self target Broaden isUpgradeWithData condition to support type-4 transactions where to != from (e.g. enforced simulations targeting the delegation manager). Override to=from in the upgrade-only estimation since a bare 7702 authorization upgrade is always a self-transaction.
Apply EIP-7702 gas buffer to all type-4 upgrade-with-data transactions instead of only self-targeted ones.
…sUpgradeWithData Reflect that the field is now set for any upgrade-with-data transaction, not only self-targeted ones.
53a54cf to
81bca26
Compare
vinistevam
approved these changes
Apr 23, 2026
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
Gas estimation for EIP-7702 transactions was previously limited to self-targeted upgrades (where
from === to). This blocked reliable gas estimation for transactions that combine a 7702 authorization upgrade with a call to a different contract — notably enforced simulations, which target the delegation manager.Broadening this path enables accurate gas estimation for the general case of "upgrade + execute in one transaction", correctly applies the EIP-7702 gas buffer to all such transactions, and fixes the upgrade-only step to always send to the account itself (since a bare 7702 authorization is always a self-transaction regardless of the full transaction's target).
References
Companion to MetaMask/metamask-extension#41775
Changelog
@metamask/transaction-controllerChanged
Note
Medium Risk
Changes gas estimation and buffer selection for EIP-7702
setCodetransactions, which can affect gas limits (and thus transaction success/cost) across supported networks. Scope is contained to estimation paths and is covered by updated unit tests, but incorrect detection could impact type-4 transactions.Overview
Gas estimation now treats any EIP-7702
setCodetransaction that includes non-emptydataas an upgrade+execute flow (not justfrom === to), returningisUpgradeWithDataand applying the per-chaineip7702gas buffer multiplier to this broader set.The upgrade-only step in the split estimation path is fixed to always call
eth_estimateGaswithtoset to the sender address (anddata: 0x), aligning with 7702 authorization semantics. Tests and the changelog are updated to reflect the renamed flag and expanded behavior.Reviewed by Cursor Bugbot for commit 81bca26. Bugbot is set up for automated code reviews on this repo. Configure here.