Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ethclient: add RevertErrorData function and example #30669

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Oct 24, 2024

Here I'm adding a new helper function that extracts the revert reason of a contract call.
Unfortunately, this aspect of the API is underspecified. See these spec issues for more detail:

The function added here only works with Geth-like servers that return error code 3. We will not be able to support all possible servers. However, if there is a specific server implementation that makes it possible to extract the same info, we could add it in the same function as well.

@fjl fjl mentioned this pull request Oct 24, 2024
@fjl fjl linked an issue Oct 24, 2024 that may be closed by this pull request
Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

@rjl493456442 rjl493456442 added this to the 1.14.12 milestone Oct 25, 2024
}
fmt.Println("message:", message)

// Output:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should test for the message here, otherwise the test only tests that the revert unpacking doesn't error

Copy link
Contributor Author

@fjl fjl Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go checks the output of example functions. The comment here declares the expected output. If there is a mismatch, the example fails during go test.

https://go.dev/blog/examples#output-comments

fjl and others added 2 commits October 30, 2024 08:28
Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
This is done to make the RevertErrorData example code look better.
@fjl fjl merged commit e92e22a into ethereum:master Nov 7, 2024
3 checks passed
holiman pushed a commit that referenced this pull request Nov 19, 2024
Here I'm adding a new helper function that extracts the revert reason of
a contract call. Unfortunately, this aspect of the API is underspecified.
See these spec issues for more detail:

- ethereum/execution-apis#232
- ethereum/execution-apis#463
- ethereum/execution-apis#523

The function added here only works with Geth-like servers that return
error code `3`. We will not be able to support all possible servers.
However, if there is a specific server implementation that makes it
possible to extract the same info, we could add it in the same function
as well.

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
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.

solidity custom error support
3 participants