Skip to content

fix(account-abstraction): preserve cause in user op contract errors#4535

Closed
mk0walsk wants to merge 7 commits into
wevm:mainfrom
mk0walsk:fix-aa-preserve-cause-userop-errors
Closed

fix(account-abstraction): preserve cause in user op contract errors#4535
mk0walsk wants to merge 7 commits into
wevm:mainfrom
mk0walsk:fix-aa-preserve-cause-userop-errors

Conversation

@mk0walsk
Copy link
Copy Markdown
Contributor

What is this PR solving?

In getUserOperationError (Account Abstraction), the revert-data branch wrapped contract errors without forwarding the original cause.
This breaks the error chain for ContractFunctionZeroDataError / ContractFunctionRevertedError, which makes debugging and root-cause analysis harder.

This PR preserves the original ExecutionRevertedError cause when wrapping these errors, aligning AA behavior with the cause-preservation direction in getContractError (related:
#4388).

What changed?

  • src/account-abstraction/utils/errors/getUserOperationError.ts
    • Passes bundler cause into the internal contract-error wrapping path.
    • Forwards cause to:
      • ContractFunctionZeroDataError
      • ContractFunctionRevertedError
  • src/account-abstraction/utils/errors/getUserOperationError.test.ts
    • Adds targeted tests for:
      • revert-data branch (0x08c379a0...)
      • zero-data branch (0x)
    • Asserts the nested cause chain is preserved.

What alternatives were explored?

  • Keep current wrapping behavior and rely on top-level error text only.
    • Rejected because it loses causal context and weakens debugging signals.
  • Refactor AA code to reuse shared getContractError directly.
    • Rejected for now to keep this fix minimal and reduce regression risk.

What needs reviewer attention?

  • Verify cause is preserved in both revert-data and zero-data paths.
  • Verify non-revert AA error behavior is unchanged.
  • Verify added tests clearly capture the intended cause-chain behavior.

Documentation / tests

  • Docs: no updates needed (internal error-wrapping behavior change only).
  • Tests: added focused tests that fail without this change and pass with it.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

@mk0walsk is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

⚠️ No Changeset found

Latest commit: c2a532c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 21, 2026

Open in StackBlitz

npm i https://pkg.pr.new/viem@4535

commit: c2a532c

@mk0walsk mk0walsk closed this Apr 27, 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