Skip to content

feat: PreCallExecutionModule for non-atomic batch execution - #358

Closed
dancoombs wants to merge 1 commit into
v2.0.xfrom
danc/pre-call-execution-module
Closed

dancoombs wants to merge 1 commit into
v2.0.xfrom
danc/pre-call-execution-module

Conversation

@dancoombs

Copy link
Copy Markdown

Summary

  • Adds PreCallExecutionModule, an execution module that provides a non-atomic batch execution pattern with precondition checks
  • executeWithPreCalls(preCalls, calls) splits execution into two phases:
    • Pre-calls: run atomically — if any revert, the UO fails (useful for on-chain state assertions, price bounds, etc.)
    • Calls: run atomically after pre-calls pass — if they revert, the revert reason is captured in a CallsExecuted event but the UO still succeeds
  • Requires installation as both an execution module and a global direct-call validator (so it can call executeBatch back on the account)

Design notes

  • The module calls back into the account via executeBatch, which requires direct-call validation (installValidation with DIRECT_CALL_VALIDATION_ENTITY_ID and isGlobal = true). This is the standard ERC-6900 pattern for modules that need to issue calls from the account (see DirectCallModule, ResultConsumerModule).
  • Both installs can be batched into a single deferred action (demonstrated in tests).
  • Ideally this would be a native account function to avoid the callback/validation overhead, but this approach works without modifying the account implementation.

Test plan

  • Both pre-calls and calls succeed
  • Pre-calls revert → UO inner call fails, no state changes persist
  • Pre-calls pass, calls revert → UO succeeds, only pre-call state persists, failure event emitted
  • Pre-calls as precondition guard (view call assertions)
  • Precondition check fails → UO fails
  • Empty pre-calls with calls
  • Empty pre-calls and empty calls
  • Multiple pre-calls with partial revert (atomicity of pre-call batch)
  • Deferred action: install module + use executeWithPreCalls in the same user operation

🤖 Generated with Claude Code

Adds an execution module that splits batch execution into two phases:
pre-calls (hard revert) and calls (soft revert with event capture).
This guarantees the UO succeeds once preconditions pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dancoombs dancoombs closed this Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant