feat(simulation): update how we select revert reason - #975
Open
crystalt wants to merge 1 commit into
Open
Conversation
crystalt
requested review from
0xForerunner,
0xOsiris,
Dzejkop,
Kemperino,
alessandromazza98,
cichaczem,
karankurbur,
kilianglas,
murph and
piohei
as code owners
August 4, 2026 21:10
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.
What
The response-level
revertReasonnow follows the terminally failing frame path instead of "first revert seen bottom-up":ExecutionFailed()on anexecuteUserOpframe is replaced by the revert its Safe call caught (gated on the exact selector and exact payload). This RPC calls the smart account directly, so EntryPoint wrappers likeFailedOpnever appear and get no special case.Every frame still carries its own local
revertReasonin the trace; this only changes which one the response surfaces.How
Selection is a pure recursive function (
terminal_revert_payload) over the completed trace — the inspector records raw revert payloads and does no candidate bookkeeping during execution.take_trace_entriesbecame the borrowingtrace_entries, so reason selection and trace extraction are order-independent (no drain-ordering footgun).Testing
cast sig.Note
Medium Risk
Changes only how simulation RPC explains failures (revert selection semantics), but wrong heuristics could mislead wallets on Safe/UserOp errors; scope is localized to the simulate inspector and response assembly.
Overview
Simulation responses now pick
revertReasonfrom a post-execution walk of the completed call trace instead of recording the first revert payload seen incall_end/create_endhooks.The inspector stores raw
revert_outputper frame and exposesterminal_revert_reason()viaterminal_revert_payload/frame_revert_payload: a reverted frame’s own payload wins; empty reverts inherit from the last direct child only if that child also failed (later successful siblings discard earlier caught reverts). Safe4337Module bareExecutionFailed()onexecuteUserOpis replaced by the revert hidden under a successful “catching” subtree when selector and payload match exactly (EXECUTE_USER_OP_SELECTOR,EXECUTION_FAILED_SELECTORinsimulate_consts.rs). Handler order is halt reason → terminal trace selection → outer execution revert decode.take_trace_entries→trace_entries(borrow, no drain) so trace export and terminal reason selection are order-independent. Per-frame tracerevertReasonis still decoded from each frame’s payload at read time.Tests cover hand-built trace trees, CREATE empty-revert inheritance, caught-child vs terminal parent, and Safe-style bytecode integration.
Reviewed by Cursor Bugbot for commit 3dad3b2. Bugbot is set up for automated code reviews on this repo. Configure here.