-
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
"require" helper in assembly #7317
Comments
Same argument I always give: Hidden library functions are hard to debug or verify. It would be much better to support importing assembly functions by source. Then it is easier to check what actually happens. |
I actually think |
So for these particular two it might actually make verifying easier, if we add them... |
I don't see the difference to checking whether |
As verification target maybe, yes, but for assumptions? |
The (one?) purpose of require/assert is that you can do bytecode-level verification. |
@MicahZoltu brought this up in the chat again and there is actually another good argument for having this for requires with message. The argument so far was that one can always just define a function, but for reverts with reason this becomes a problem. Say we define
And then use it several times, the optimizer likely won't inline this. This results in the message being pushed on the stack needlessly when the condition is true. Since we need builtins with mixed "required literal" and arbitrary arguments anyways for the immutables, this might be quite a good reason to introduce a |
I don't think we should introduce a builtin function only to save 3 gas. |
Hm, true - for some reason I was thinking about the data gas being expensive, but that's paid either way... |
Hi everyone! This issue has been closed due to inactivity. |
It would be nice to start introducing helper functions in assembly. This was previously discussed in #474 and #1319.
A lot of contracts/libraries deal with calling precompiles directly to avoid cost overheads. They do this with
if iszero(staticcall(..)) { revert(0, 0) }
. It would be nice to supportrequire
and/orassert
:require(expr)
->if iszero(expr) { revert(0, 0) }
assert(expr)
->if iszero(expr) { invalid }
The text was updated successfully, but these errors were encountered: