-
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
Revert with reason #3364
Revert with reason #3364
Conversation
4ba678c
to
6826200
Compare
Looking forward to this ;) |
Me toooooooo!!!! :-D |
730de30
to
b90cd1e
Compare
This is ready for review. |
fd4f6b7
to
ac20dfb
Compare
❤️ ❤️ ❤️ ❤️ This is the best! |
Is the string returned regularly, right? In terms of forwarding the return data, would this work https://github.com/aragon/aragon-core/blob/dev/contracts/common/DelegateProxy.sol#L9 |
ac20dfb
to
6201a27
Compare
Rebased. |
Great improvement! |
Looking forward to implementing this in Truffle. Nice job @chriseth! |
6201a27
to
c50a9aa
Compare
bb5bcbe
to
2373264
Compare
Sad to see this bumped to 0.4.22. I was getting ready to change my contracts to take advantage of this new feature with the 0.4.21 release |
a961780
to
b255981
Compare
Failure in appveyor is just bytecode upload and thus can be ignored. |
I think prefixing a specific 4-byte sequence allows us to extend the encoding later, while at the same time it does not reduce usability since it is fixed for now. Also, it is better than just prefixing a certain number of zeros, since it already suggests away how to extend it to encode different types. I would opt to merge it :) |
docs/control-structures.rst
Outdated
in a call to ``revert``. The ``throw`` keyword can also be used as an alternative to ``revert()``. | ||
revert the current call. It is possible to provide a string message containing details about the error | ||
that will be passed back to the caller. | ||
The ``throw`` keyword can also be used as an alternative to ``revert()``, but is deprecated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and it doesn't support an error string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, alternative to rever()
, not to revert("string")
:)
Do you want me to clarify that or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may be cleaner that way. I didn't spot it before you mentioned, of course it is clear after you did.
test/libsolidity/Assembly.cpp
Outdated
@@ -160,11 +160,21 @@ BOOST_AUTO_TEST_CASE(location_test) | |||
shared_ptr<string const> n = make_shared<string>(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still dead code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs test cases for built in revert bubbling:
transfer
- contract creation
- regular foreign contract calls
i.e.
contract C {
function f() {
revert("failed here :(");
}
}
contract D {
D d = new D();
function f() {
return d.f();
}
}
The test case |
That's weird, I have seen revert_with_cause and require_with_message, but not the bubble up ones. Anyway, they look correct. |
Oh wow, this is so great. Thank you! |
How to read require/revert error string from failed transaction log? (ERROR_TEXT in example above) |
I know that maybe is not the right place but I've not found any references or examples so +1 to @vsdigitall. I think that the reason string is in the output as hex in the failed transaction. But I've been not able to fully test this thing. |
Here is a bash script to fetch revert reason: |
Part of issue #1686
Depends on #3373
I went with encoding the reason string as a function call to
Erorr(string)
, including the function selector.Still to do:
require()
require()
The reason we might not want to forward the reason string is that it allows a called attacker to consume more gas in the caller (because the caller needs to copy the return data), but I think this is an acceptable "risk" given the benefit that the error string shows up in the transaction receipt.