Skip to content

fix(script): preserve exit reason in failed revert decode#13985

Open
ArshLabs wants to merge 3 commits intofoundry-rs:masterfrom
ArshLabs:fix/script-exit-reason-revert-decoding
Open

fix(script): preserve exit reason in failed revert decode#13985
ArshLabs wants to merge 3 commits intofoundry-rs:masterfrom
ArshLabs:fix/script-exit-reason-revert-decoding

Conversation

@ArshLabs
Copy link
Copy Markdown
Contributor

Motivation

failed script output in PreSimulationState::show_json and PreSimulationState::show_traces decodes revert bytes with status = None.
when revert bytes are empty or opaque, this can hide the real halt reason and show generic output.

Solution

thread exit_reason through ScriptResult from RawCallResult, then pass it into RevertDecoder::decode in both script failure rendering paths.

this keeps current behavior for decoded revert payloads and improves fallback output for cases like OutOfGas.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@ArshLabs
Copy link
Copy Markdown
Contributor Author

ArshLabs commented Apr 5, 2026

@DaniPopes @mattsse @grandizzy @zerosnacks @onbjerg @0xrusowsky quick bump when you have a moment.
this is a small scoped script fix that preserves exit reason in failed revert decoding, so cases like OutOfGas show a clear halt reason instead of generic or empty revert output
happy to adjust anything if you want changes...

@zerosnacks
Copy link
Copy Markdown
Member

Hi @ArshLabs, would you mind adding / updating the snapshot tests to assert the new output change?

@ArshLabs
Copy link
Copy Markdown
Contributor Author

ArshLabs commented Apr 7, 2026

Thanks for the review, pushed updates.

Removed the unnecessary clone in execute.rs.
Also fixed exit_reason propagation in execute_with_runner so the failure renderer gets the status context.
Added snapshot coverage for the output change in both forge script and forge script --json out-of-gas failure paths.

Re-ran the related CLI tests:

  • script::assert_exit_code_error_on_out_of_gas_script
  • script::assert_exit_code_error_on_out_of_gas_script_with_json
  • script::assert_exit_code_error_on_failure_script
  • script::assert_exit_code_error_on_failure_script_with_json

@ArshLabs ArshLabs requested a review from zerosnacks April 7, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants