batch transactions for delegated accounts to avoid in-flight tx limit#8125
batch transactions for delegated accounts to avoid in-flight tx limit#8125cloudonshore wants to merge 15 commits intomainfrom
Conversation
…limit Ethereum nodes only allow 1 pending transaction for EIP-7702 delegated accounts. When a swap requires token approval, the approve and swap transactions are submitted separately, causing the second to be rejected. This fix detects delegated accounts via isAtomicBatchSupported and routes them through the batched transaction path, combining approve + swap into a single transaction. Changes: - Expose isAtomicBatchSupported as a TransactionController messenger action - Add delegation check in BridgeStatusController before tx submission - Allow 7702 batching for delegated accounts without requiring gas sponsorship
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
The new TransactionController:isAtomicBatchSupported messenger call in submitTx shifts mock queues for all EVM bridge and swap tests. Add the mock to setupEventTrackingMocks helpers and manual setups, update call count assertions, refresh snapshots, and add a test covering the catch fallback path.
Keep both unreleased entries from #8125 and main.
This file was incorrectly added in 9bef1f4 — it's a Cursor IDE config that doesn't belong in the repo.
|
|
||
| ### Fixed | ||
|
|
||
| - Delegated accounts (EIP-7702) now use batched transactions to avoid in-flight transaction limit ([#8125](https://github.com/MetaMask/core/pull/8125)) |
There was a problem hiding this comment.
Can you mark this as a breaking change since the clients will need to add the new action handler permissions?
There was a problem hiding this comment.
Done. Just to double check, do you think this is the ideal pattern? I could also detect whether the account is delegated directly in bridge-status-controller (via eth_getCode) to avoid the breaking change, but didn't want the code duplication.
There was a problem hiding this comment.
I prefer reusing TransactionController's handler too so this looks good to me
Motivation
Ethereum nodes (reth, geth) enforce a limit of 1 pending transaction for EIP-7702 delegated accounts. When a swap or bridge requires token approval, the bridge-status-controller submits approve and trade as two separate transactions. The second transaction gets rejected by the node with
"in-flight transaction limit reached for delegated accounts", causing the swap/bridge to fail.Related: MetaMask/metamask-mobile#25595
Description
This PR detects EIP-7702 delegated accounts and routes them through the existing batched transaction path (previously only used for smart transactions and gasless 7702 quotes), combining approve + trade into a single atomic transaction.
Changes
@metamask/transaction-controllerisAtomicBatchSupportedas a messenger action so other controllers can check whether an account is delegated to a supported smart contract@metamask/bridge-status-controllerTransactionControllerIsAtomicBatchSupportedActiontoAllowedActionsisAtomicBatchSupportedto detect delegated accountsisDelegatedAccountas a third condition (alongsideisStxEnabledOnClientandgasIncluded7702) for entering the batch transaction pathisDelegatedAccountthrough togetAddTransactionBatchParamsso thatdisable7702is set tofalsefor delegated accounts — enabling 7702 batching with user-paid gas (not just gas-sponsored)isDelegatedAccountoutside the#tracecallback so it's accessible in theisNonBatchEvmcheck, ensuring batch transactions from delegated accounts are properly recorded in bridge status historyfindAndUpdateTransactionsInBatchto handleTransactionType.bridgeandTransactionType.bridgeApprovalin the 7702 matching logic (previously only handledswap/swapApproval), fixing transaction lookup for bridge operations from delegated accountstxDataByTypeiteration to prevent bridge transactions from being incorrectly retyped as swapsKey design decisions
disable7702flag is nowfalsewhen eithergasIncluded7702is true OR the account is delegated.false, so ifisAtomicBatchSupportedfails for any reason, the transaction falls back to the standard (non-batch) path.References
Changelog
@metamask/transaction-controllerTransactionControllerIsAtomicBatchSupportedActiontype exportisAtomicBatchSupported@metamask/bridge-status-controllerfindAndUpdateTransactionsInBatch)Checklist
Note
Medium Risk
Changes the EVM swap/bridge submission path to conditionally batch transactions for EIP-7702 delegated accounts and adds a new required messenger permission/action, which could affect transaction creation, gas handling, and history recording if miswired.
Overview
Delegated (EIP-7702) accounts are now routed through the existing atomic batch path so approval + trade are submitted as a single batch to avoid delegated-account in-flight limits.
BridgeStatusControllernow callsTransactionController:isAtomicBatchSupported(new messenger action) to detect delegated accounts, records batched delegated txs in history, and updates 7702 batch post-processing to correctly match/retagbridge+bridgeApprovaltypes (and skip undefined type entries).Gas handling for batched 7702 flows is refined: gas fields are omitted only when gas is sponsored (
gasIncluded7702), while delegated-account batching keeps 7702 enabled but still includes user-paid gas fields when not sponsored; tests/snapshots and changelogs are updated accordingly.Written by Cursor Bugbot for commit 1197f32. This will update automatically on new commits. Configure here.