batch transactions for delegated accounts to avoid in-flight tx limit#8125
Open
cloudonshore wants to merge 11 commits intomainfrom
Open
batch transactions for delegated accounts to avoid in-flight tx limit#8125cloudonshore wants to merge 11 commits intomainfrom
cloudonshore wants to merge 11 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.
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.
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 transaction submission and batching behavior for EVM swap/bridge flows, which can affect how approvals/trades are sent and recorded. Risk is moderated by a try/catch fallback when
isAtomicBatchSupportedfails and by expanded unit test coverage.Overview
Delegated (EIP-7702) accounts are now detected and forced through the atomic batch path so approval + trade are submitted as a single batch when needed, avoiding node “in-flight tx limit” failures.
This adds a new messenger-exposed action
TransactionController:isAtomicBatchSupported(and exportedTransactionControllerIsAtomicBatchSupportedActiontype), wires Bridge Status Controller permissions for it, and updates batch parameter construction to decouple 7702 batching from gas sponsorship (skip gas fields only whengasIncluded7702is true, otherwise estimate/include gas for delegated batches).Also fixes 7702 batch post-signing reconciliation by matching and re-typing
bridge/bridgeApprovalentries (not just swap), skipping undefined type entries, and ensures delegated-account batch submissions are recorded in bridge history; tests/snapshots are updated and include a failure-case fallback forisAtomicBatchSupportederrors.Written by Cursor Bugbot for commit cc67872. This will update automatically on new commits. Configure here.