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

solidity custom error support #26823

Open
ARR552 opened this issue Mar 7, 2023 · 12 comments
Open

solidity custom error support #26823

ARR552 opened this issue Mar 7, 2023 · 12 comments

Comments

@ARR552
Copy link

ARR552 commented Mar 7, 2023

Rationale

Formerly, the only way to return a revert reason was using require(condition, ‘Something bad happened’);. The code generated by the abigen tool for a smartcontract, returned the revert reason if something was wrong. This error was triggered during the gas estimation.
Now, the new way of adding custom errors (revert messages) is revert NotAllowed();. Using the code generated by the abigen, the error received is just execution reverted.
I could decode the error by my own if i had access to the output data returned in the tx but this is inside the autogenerated code and not exported.
I want to keep receiving the same revert reason even using the new solidity custom errors.

If this feature is already implemented, if so how can i use it??

Implementation

It should be something like this:
https://blog.soliditylang.org/2021/04/21/custom-errors/

@MariusVanDerWijden
Copy link
Member

I added custom error handling a while ago: #23161
However I think it only added the types and not the error unmarshaling part

@smartcontracts
Copy link

@MariusVanDerWijden is it correct that Geth currently doesn't surface custom revert messages in call/gas estimation?

@MariusVanDerWijden
Copy link
Member

yes

@smartcontracts
Copy link

Got it, thank you!

@n00b21337
Copy link

n00b21337 commented Sep 29, 2023

@MariusVanDerWijden is it correct that Geth currently doesn't surface custom revert messages in call/gas estimation?

Could you please elaborate a bit on that want to be sure.
Does this mean there isn't any trace of a custom error data in hex value when we use call or gasEstimate in the response we get?

edited:

I did make a test calls over Alchemy to see what is happening and I see that in Data there is info that is signature of error
so maybe you are saying that there isn't "translation" of error to human readable string? But this isnt only for call/estimates but all
custom errors outputs in trx, right?

image

@n00b21337
Copy link

But just plain eth_call will output nothing

image

@samlaf
Copy link
Contributor

samlaf commented Mar 7, 2024

Are there plans to support this anytime soon? Took me a while to figure out what was happening, and seems like our only option is to revert to more gas-expensive string errors. Probably not that hard to take the 4byte error code from the data and show it as part of the error string, unless I'm missing something?

@RonTuretzky
Copy link

bumping this for attention

@n00b21337
Copy link

Are there plans to support this anytime soon? Took me a while to figure out what was happening, and seems like our only option is to revert to more gas-expensive string errors. Probably not that hard to take the 4byte error code from the data and show it as part of the error string, unless I'm missing something?

I suppose its intended to be solved on app level, like Tenderly solves that perfectly most of the time, etherscan sadly still doesn't for some reason.

@samlaf
Copy link
Contributor

samlaf commented Mar 11, 2024

Are there plans to support this anytime soon? Took me a while to figure out what was happening, and seems like our only option is to revert to more gas-expensive string errors. Probably not that hard to take the 4byte error code from the data and show it as part of the error string, unless I'm missing something?

I suppose its intended to be solved on app level, like Tenderly solves that perfectly most of the time, etherscan sadly still doesn't for some reason.

Are those projects even using geth abigen? We're using abigen directly and this is making us unable to use custom errors in our contracts. Unless I'm missing something when simulating transactions to estimate gas limit, there's no way right now to retrieve the error string, as its not exposed by geth.

@samlaf
Copy link
Contributor

samlaf commented Apr 26, 2024

ethereum/solidity#14442 just got merged. The Solidity change is specifically enabling custom errors to use with the common require(bool, err) syntax. It's a widely used syntax because it's quite concise, but until now you couldn't use error types with it so basically no one used error types. More and more teams will probably start migrating to use it, so would be really nice to have abigen support for it.

@RonTuretzky
Copy link

ethereum/solidity#14442 just got merged. The Solidity change is specifically enabling custom errors to use with the common require(bool, err) syntax. It's a widely used syntax because it's quite concise, but until now you couldn't use error types with it so basically no one used error types. More and more teams will probably start migrating to use it, so would be really nice to have abigen support for it.

Bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants