-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Feature to apply modifier to all functions #4990
Comments
I'm writing a contract that could benefit from this. I was calling the idea "default modifier" before I found this thread via your thread on modifier areas. |
I no longer need "default modifier" because changed approach. So will likely not have meaningful input to this issue, since not in self-interest for dApp I work on. |
I'm removing the |
I have added some additional background on #13845 as to why this change would not satisfy a blanket reentrancy guard properly, however, if the modifiers can be applied with a proper distinction between mutable and non-mutable functions then this would be a good way to start. A core problem I see with this syntax is its compatibility with inheritance. Libraries (such as OpenZeppelin) will be hesitant to apply a global re-entrancy protection across all their functions, meaning that users would have to specify the On the other hand, due to dependency conflicts certain functions would need to be overridden without any functional changes (i.e. using For the re-entrancy use case in particular I believe this feature would be improperly used and cause more harm than good (i.e. applying Additionally, the feature as it is would cause nuisances when it comes to inheritance as any overridden function would apply the blanket Any solution to the inheritance problem would significantly increase the complexity of how the As a final note, the issue also suffers from how If we extend the syntax to also accept explicit visibilities, it would significantly complicate how it is used (i.e. To conclude, we can alleviate all concerns above by specifying thorough documentation as to how the syntax behaves (i.e. visibility needs to be explicit, both |
If anything I think we'll rather go the route of #623 for solving the underlying request, and would allow to properly distinguish between functions explicitly, which I take it would satisfy the concerns by @alex-ppg. |
Certain use-cases require a check to be applied to all or at least many functions. Most notably, this includes a general smart contract deactivation function (as replacement for dangerous selfdestruct), a "pausable" pattern and so on.
Modifiers already provide basic support, but it is too easy to forget a modifier to be mentioned with a single function, also it requires quite some typing and can get cluttered fast.
Modifier areas ( #623 ) are a similar solution, but they do not work with inheritance.
This proposal tries to start a discussion about how modifier areas could work better with inheritance. The drawback of this proposal is that it provides less choice about which functions to apply.
Syntax proposal:
This applies the given modifier to all functions in this contract, including inherited functions and all functions in potential derived contracts.
It might make sense to restrict this to functions that are non-view functions.
Potential syntax:
using modifier <modifier> for payable, non-payable;
The text was updated successfully, but these errors were encountered: