feat: add executeWithPreCalls native function#359
Closed
dancoombs wants to merge 3 commits into
Closed
Conversation
Two-phase batch execution: preCalls must all succeed (hard revert), then calls execute atomically with failures caught and reported via event. Enables setup-then-attempt patterns (approvals, unwraps) without wasting the entire UO on a legitimate call failure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dancoombs
marked this pull request as draft
April 6, 2026 21:57
|
Contract sizes: | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
|------------------------------|------------------|-------------------|--------------------|---------------------|
| AccountFactory | 6,604 | 7,161 | 17,972 | 41,991 |
| Address | 16 | 44 | 24,560 | 49,108 |
-| AllowlistModule | 10,148 | 10,174 | 14,428 | 38,978 |
+| AllowlistModule | 10,635 | 10,661 | 13,941 | 38,491 |
| Base64 | 16 | 44 | 24,560 | 49,108 |
| Create2 | 16 | 44 | 24,560 | 49,108 |
| ECDSA | 16 | 44 | 24,560 | 49,108 |
| ERC165Checker | 16 | 44 | 24,560 | 49,108 |
| ERC1967Utils | 16 | 44 | 24,560 | 49,108 |
| ExecutionInstallDelegate | 5,835 | 5,880 | 18,741 | 43,272 |
| FCL_Elliptic_ZZ | 16 | 44 | 24,560 | 49,108 |
| FCL_ecdsa | 16 | 44 | 24,560 | 49,108 |
| Math | 16 | 44 | 24,560 | 49,108 |
| MessageHashUtils | 16 | 44 | 24,560 | 49,108 |
-| ModularAccount | 22,935 | 23,323 | 1,641 | 25,829 |
-| NativeTokenLimitModule | 4,917 | 4,943 | 19,659 | 44,209 |
+| ModularAccount | 25,083 | 25,471 | -507 | 23,681 |
+| NativeTokenLimitModule | 5,199 | 5,225 | 19,377 | 43,927 |
| PaymasterGuardModule | 2,028 | 2,054 | 22,548 | 47,098 |
| SafeERC20 | 16 | 44 | 24,560 | 49,108 |
-| SemiModularAccount7702 | 23,336 | 23,717 | 1,240 | 25,435 |
-| SemiModularAccountBytecode | 23,812 | 24,200 | 764 | 24,952 |
+| SemiModularAccount7702 | 25,385 | 25,766 | -809 | 23,386 |
+| SemiModularAccountBytecode | 25,836 | 26,224 | -1,260 | 22,928 |
| SignatureChecker | 16 | 44 | 24,560 | 49,108 |
| SignedMath | 16 | 44 | 24,560 | 49,108 |
| SingleSignerValidationModule | 3,853 | 3,879 | 20,723 | 45,273 |
| StorageSlot | 16 | 44 | 24,560 | 49,108 |
| Strings | 16 | 44 | 24,560 | 49,108 |
| TimeRangeModule | 2,435 | 2,461 | 22,141 | 46,691 |
| WebAuthn | 16 | 44 | 24,560 | 49,108 |
| WebAuthnValidationModule | 9,277 | 9,303 | 15,299 | 39,849 |Code coverage:
|
Replaces the self-call to executeBatch with a hookless, self-call-only performBatchCall helper. Saves gas by skipping wrapNativeFunction overhead (hook storage reads, pre/post hook dispatch) on the inner call, and avoids double-execution of executeBatch selector hooks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
NativeTokenLimitModule and AllowlistModule both do selector-based calldata decoding in their hooks and didn't know about executeWithPreCalls. The token limit silently skipped ETH accounting (value fell through to 0), and the allowlist reverted on the unknown selector, completely blocking executeWithPreCalls. Both modules now decode both Call[] arrays (preCalls and calls) and apply their checks to each. Also updates checkAllowlistCalldata for the validation-phase hook path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
executeWithPreCalls(Call[] preCalls, Call[] calls)as a new native function onModularAccountBaseexecuteBatch)executeBatch— if any call fails, the batch reverts but the overall function succeedsExecuteWithPreCallsResult(bool success, bytes[] results)event with outcomeChanges
src/interfaces/IModularAccountBase.sol— Interface + event definitionsrc/account/ModularAccountBase.sol— Implementation withwrapNativeFunction, self-call re-entrancy protections in_checkIfValidationAppliesCallData,_checkExecuteBatchValidationApplicability, and new_checkExecuteWithPreCallsValidationApplicability/_checkCallArrayValidationhelperssrc/account/ModularAccountView.sol— Registered in_isWrappedNativeFunctiontest/account/ExecuteWithPreCalls.t.sol— 18 tests covering happy path, call failures, atomic rollback, preCall failures, empty arrays, ETH forwarding, event emission, and self-call recursion protectionTest plan
executeBatchfor the try/catch boundary🤖 Generated with Claude Code