Skip to content

#### Sequence diagram for decoding a revert reason #60

@Dargon789

Description

@Dargon789

Reviewer's Guide by Sourcery

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.
crates/forge/tests/it/invariant.rs
crates/forge/tests/cli/test_cmd.rs
testdata/default/cheats/ExpectRevert.t.sol
crates/forge/tests/cli/failure_assertions.rs
crates/cheatcodes/src/test/revert_handlers.rs
crates/forge/tests/cli/script.rs

Tips and commands

Interacting with Sourcery

  • 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.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Originally posted by @sourcery-ai[bot] in #37 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdependenciesPull requests that update a dependency filedocumentationImprovements or additions to documentationduplicateThis issue or pull request already existsgithub_actionsPull requests that update GitHub Actions codegood first issueGood for newcomersinvalidThis doesn't seem rightrustPull requests that update rust code

Projects

Status

Backlog

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions