-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Modifiers add to stack, discourages modifier usage #3060
Comments
Yes, that is expected behavior. Since modifier wraps the function like a decorator, the variable x which is pushed into the stack at the beginning of the call to You showcase an interesting case though, and I think there is a simple optimization to be made here, which is to pop modifier local variables when the |
There is a more general case to be made for incorporating liveness analysis into the compiler, as long as it can intelligently balance stack/gas tradeoffs. |
We are not planning any such optimizations at the high level language layer, since the benefit / danger - ratio is just too low. |
I think it is good to keep this open as a reminder. With the new IR it should be possible to move some of the arguments into memory to accommodate this (or evm1.5/ewasm would actually allow way more arguments). |
@leonardoalt @chriseth @ekpyron I think with the new scoping rules this could be improved in certain cases. |
Not really, because modifiers generate a block that surrounds the function. |
My code is now a lot uglier because of this |
I know this is low priority but feel like it should be re-considered. At least in the case where |
This issue has been marked as stale due to inactivity for the last 90 days. |
Hi everyone! This issue has been automatically closed due to inactivity. |
I assume there's nothing that can be done about this, but I was surprised to see that the following contract doesn't compile because each modifier is added to the stack:
Error:
For methods with many modifiers and a lot of variables, it means that people will need to write functions to do their checking instead of modifiers in order to work around stack depth issues. Like this:
Is this expected behavior?
The text was updated successfully, but these errors were encountered: