Skip to content

fix(transaction-controller): broaden gas estimation for type-4 transactions with non-self target#8467

Merged
matthewwalsh0 merged 4 commits intomainfrom
feat/enforced-simulations-gas-estimation
Apr 23, 2026
Merged

fix(transaction-controller): broaden gas estimation for type-4 transactions with non-self target#8467
matthewwalsh0 merged 4 commits intomainfrom
feat/enforced-simulations-gas-estimation

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 commented Apr 15, 2026

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-controller

Changed

  • Gas estimation for EIP-7702 transactions now supports any upgrade-with-data transaction (not only self-targeted). The EIP-7702 gas buffer multiplier applies to this broader set.
  • Upgrade-only estimation step now targets the sender's address, matching the semantics of a 7702 authorization.

Note

Medium Risk
Changes gas estimation and buffer selection for EIP-7702 setCode transactions, 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 setCode transaction that includes non-empty data as an upgrade+execute flow (not just from === to), returning isUpgradeWithData and applying the per-chain eip7702 gas buffer multiplier to this broader set.

The upgrade-only step in the split estimation path is fixed to always call eth_estimateGas with to set to the sender address (and data: 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.

…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.
@matthewwalsh0 matthewwalsh0 force-pushed the feat/enforced-simulations-gas-estimation branch from 53a54cf to 81bca26 Compare April 22, 2026 12:07
@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review April 22, 2026 13:43
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners April 22, 2026 13:43
@matthewwalsh0 matthewwalsh0 added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit 6ecf44f Apr 23, 2026
358 checks passed
@matthewwalsh0 matthewwalsh0 deleted the feat/enforced-simulations-gas-estimation branch April 23, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants