Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
design doc for 'Always using _disableInitializers() in constructors' #144
design doc for 'Always using _disableInitializers() in constructors' #144
Changes from all commits
773ebbf
4bc8f59
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
It's not clear to my why the current approach of calling
initialize()
(as long as it has theinitializer
modifier on it) is different from calling_disableInitializers()
?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.
The major benefit is that
_disableInitializers()
is less verbose and does not need modification if initialize parameters change.But then also, there's a scenario where if
reinitializer
modifier is used in the future for some reason, the call toinitialize
in the constructor does not stop the implementation contract from being reinitialized after deployment. This is becauseinitialize
sets the initialized storage value to 1 which makes it reinitializable if the public function to do so exists but_disableInitializers()
sets this value totype(uint8).max
, preventing this entirely.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.
Ahh, I see, thanks for clarifying.
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.
What do you mean by this, I don't get it.
Does this means that
reinitializer()
should check that the slot value is1
only and should revert if the slot is set totype(uint8).max
?I don't see it here: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/448efeea6640bbbc09373f03fbc9c88e280147ba/contracts/proxy/utils/Initializable.sol#L152
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.
It works if the slot is 1 but it can't be nested. For the max, it reverts if the version is >
type(uint64*).max
(which can be set manually viareinitialize
or via_disableInitializers()