-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Distinguishing explicit and implicit throws #1589
Comments
We are planning, especially for formal verification, to use different revert mechanisms for "wanted" and "unwanted" situations. What would your exact use-case be here? |
@chriseth Great! This is precisely the use case I'm interested in. I'm working on a formal analysis for smart contracts and without this it is difficult to tell which errors should be reported to a developer that's using the analyzer. I assume that you agree that all the "implicit throws" would constitute "unwanted" situations, comparable to runtime errors. On the other hand, for "explicit throws" it's more difficult to tell if they are wanted or unwanted. I would argue that ones that essentially express preconditions of a procedure should only be reported as errors in clients that call the procedure, comparable to a precondition violation. Now, a user might also want to express assertions explicitly and I would consider violations of those to be "unwanted". I don't think Solidity supports assert-statements at the moment, but if they would be added they should be treated much like other runtime errors. Do you agree? I haven't looked at enough Solidity code out there, but I haven't seen explicit throws that didn't essentially express preconditions or assume-statements. Can you confirm this? |
@pirapira we already talked about this, do you remember what our conclusions were? Did we create an issue somewhere? |
@chriseth our conclusion was to use an invalid opcode for this purpose. |
#1130, that is. |
@wuestholz that makes sense. |
@wuestholz if you want to do it, then please go ahead. We need a new |
From what I can tell Solidity currently translates explicit, user-provided throw statements just like implicit ones (e.g., for division-by-zero or other runtime exceptions).
It would be nice if one were able to distinguish these to cases by looking at the resulting EVM byte code. For instance, a failing implicit throw usually constitutes an error in the contract. On the other hand, an implicit one is often used for parameter validation (i.e., a precondition) and usually the client contact (i.e., caller) is to blame (at least if the exception it is not properly dealt with).
Would it be possible to use different error tags for these two cases? Or is there some other way to tell them apart?
The text was updated successfully, but these errors were encountered: