-
Notifications
You must be signed in to change notification settings - Fork 11.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
Improve Initializable docstrings #3704
Improve Initializable docstrings #3704
Conversation
Thanks! These are great additions. I'm not sure I agree with the removal of the "equivalent to..." notes. While you're right that they are not exactly equivalent, and we should definitely document the differences, I think the comparisons are valuable to give an intuition about what the modifiers do and how they relate. Perhaps we should simply replace "equivalent" with "similar", and explain how the differ (as you've done). Do you agree, and can you make this change? Regarding the last point about the difference between |
I see your point. Agreed! I changed it so that it better states that the modifiers are indeed similar, except for the mentioned behavior. I also removed the WARNING label for these, because I think they were too strong.
Yes, that's my point. Though I might be overthinking it, and probably the discussion is out of scope of the PR. If I can come up with an example scenario to be clearer, I'll open an issue. |
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.
Approved with minor changes. Thanks!
Woohoo, your important contribution to this open-source project has earned you a GitPOAP! GitPOAP: 2022 OpenZeppelin Contracts Contributor: Head on over to GitPOAP.io and connect your GitHub account to mint! |
Co-authored-by: tincho <[email protected]> Co-authored-by: Francisco Giordano <[email protected]> (cherry picked from commit a549ec6)
Co-authored-by: tincho <[email protected]> Co-authored-by: Francisco Giordano <[email protected]>
Updating the docstrings of the
Initializable
contract so they better reflect the actual behavior of the code.Changes include:
reinitializer(1)
is not equivalent toinitializer
. Because one allows nesting while the other doesn't. I noticed this was even mentioned in Simplify Initializable #3450, so I guess you're already aware of the difference, and the docs were just outdated.reinitializer(255)
will prevent further reinitializations.There's one additional thing I wanted to raise, that I noticed while writing (2) but I did not mention in the docs. At first sight, it may seem that a function that executes
reinitializer(255)
would behave the same as calling_disableInitializers
, in terms of disabling further reinitialization. However,_disableInitializers
explicitly requires that the contract is not initializing. Whilereinitializer(255)
first checks the same, then it would continue execution into initializing mode. So it feels like a subtle inconsistency, but I'm not sure to what extent it could actually be problematic, or even worth highlighting in the docs.