You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request modifies the RevertDecoder to strip the "revert: " prefix from the revert reason when decoding Solidity's Error(string). It also updates tests to reflect the change in revert reason formatting.
Sequence diagram for decoding a revert reason
sequenceDiagram
participant RevertDecoder
participant ContractError
participant String
RevertDecoder->>ContractError: decode(err)
alt ContractError is Error(string)
ContractError-->>RevertDecoder: Revert(reason)
RevertDecoder->>String: extract reason
RevertDecoder-->>RevertDecoder: strip "revert: " prefix
RevertDecoder-->>RevertDecoder: return reason
else ContractError is other error
ContractError-->>RevertDecoder: OtherError
RevertDecoder-->>RevertDecoder: handle other error
end
Loading
File-Level Changes
Change
Details
Files
The pull request modifies the RevertDecoder to strip the "revert: " prefix from the revert reason when decoding Solidity's Error(string).
Modified maybe_decode function in RevertDecoder to handle ContractError::Revert and extract the revert reason.
Added a helper function decode_as_non_empty_string to decode ABI-encoded or ASCII strings.
Updated logic to prioritize decoding as ContractError::Revert to strip the prefix.
Adjusted the order of decoding attempts to handle different error types correctly.
crates/evm/core/src/decode.rs
The pull request updates tests to reflect the change in revert reason formatting.
Updated expected revert messages in invariant tests to remove the "revert: " prefix.
Modified test assertions in test_cmd.rs to match the new revert message format.
Updated test cases in ExpectRevert.t.sol to include tests with encoded error prefixes.
Adjusted expected failure messages in failure_assertions.rs to align with the updated revert reason format.
Modified test output assertions in script.rs to remove the "revert: " prefix from error messages.
Updated test assertions in revert_handlers.rs to ensure that the expected and actual revert reasons match after stripping the prefix.
Trigger a new review: Comment @sourcery-ai review on the pull request.
Continue discussions: Reply directly to Sourcery's review comments.
Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with @sourcery-ai issue to create an issue from it.
Generate a pull request title: Write @sourcery-ai anywhere in the pull
request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
Generate a pull request summary: Write @sourcery-ai summary anywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment @sourcery-ai summary on the pull request to
(re-)generate the summary at any time.
Generate reviewer's guide: Comment @sourcery-ai guide on the pull
request to (re-)generate the reviewer's guide at any time.
Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!
Generate a plan of action for an issue: Comment @sourcery-ai plan on
an issue to generate a plan of action for it.
Reviewer's Guide by Sourcery
This pull request modifies the
RevertDecoderto strip the "revert: " prefix from the revert reason when decoding Solidity'sError(string). It also updates tests to reflect the change in revert reason formatting.Sequence diagram for decoding a revert reason
sequenceDiagram participant RevertDecoder participant ContractError participant String RevertDecoder->>ContractError: decode(err) alt ContractError is Error(string) ContractError-->>RevertDecoder: Revert(reason) RevertDecoder->>String: extract reason RevertDecoder-->>RevertDecoder: strip "revert: " prefix RevertDecoder-->>RevertDecoder: return reason else ContractError is other error ContractError-->>RevertDecoder: OtherError RevertDecoder-->>RevertDecoder: handle other error endFile-Level Changes
RevertDecoderto strip the "revert: " prefix from the revert reason when decoding Solidity'sError(string).maybe_decodefunction inRevertDecoderto handleContractError::Revertand extract the revert reason.decode_as_non_empty_stringto decode ABI-encoded or ASCII strings.ContractError::Revertto strip the prefix.crates/evm/core/src/decode.rstest_cmd.rsto match the new revert message format.ExpectRevert.t.solto include tests with encoded error prefixes.failure_assertions.rsto align with the updated revert reason format.script.rsto remove the "revert: " prefix from error messages.revert_handlers.rsto ensure that the expected and actual revert reasons match after stripping the prefix.crates/forge/tests/it/invariant.rscrates/forge/tests/cli/test_cmd.rstestdata/default/cheats/ExpectRevert.t.solcrates/forge/tests/cli/failure_assertions.rscrates/cheatcodes/src/test/revert_handlers.rscrates/forge/tests/cli/script.rsTips and commands
Interacting with Sourcery
@sourcery-ai reviewon the pull request.issue from a review comment by replying to it. You can also reply to a
review comment with
@sourcery-ai issueto create an issue from it.@sourcery-aianywhere in the pullrequest title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time.@sourcery-ai summaryanywhere inthe pull request body to generate a PR summary at any time exactly where you
want it. You can also comment
@sourcery-ai summaryon the pull request to(re-)generate the summary at any time.
@sourcery-ai guideon the pullrequest to (re-)generate the reviewer's guide at any time.
@sourcery-ai resolveon thepull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
@sourcery-ai dismisson the pullrequest to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!@sourcery-ai planonan issue to generate a plan of action for it.
Customizing Your Experience
Access your dashboard to:
summary, the reviewer's guide, and others.
Getting Help
Originally posted by @sourcery-ai[bot] in #37 (comment)