openzeppelin-contracts
openzeppelin-contracts copied to clipboard
Consider simpler initializer modifier
The current version of the initializer
modifier includes some logic for backwards compatibility that was added in #3450, which was in fact a simplification of the backwards compatibility code introduced in #3344.
We should consider further simplifications that break backwards compatibility for 5.0.
Haven't thought about this yet but it would probably come down to making initializer
exactly equivalent to reinitializer(1)
. This means that instead of:
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/d59306bd06a241083841c2e4a39db08e1f3722cc/contracts/proxy/utils/Initializable.sol#L85-L88
the code should look more like:
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/d59306bd06a241083841c2e4a39db08e1f3722cc/contracts/proxy/utils/Initializable.sol#L119
Note: In https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3344 it is explained that the isConstructor
exception was added back (after removal in 4.0) in order to use the initializer
modifier to disable the initialization of implementation contracts with the following pattern:
contract A is Initializable {
constructor() initializer { /* ... */ }
}
contract B is A {
constructor() initializer { /* ... */ }
}
This is no longer a requirement since the introduction of _disableInitializers
.
@frangio is this open for a PR or just a suggestion citing Consider
?
Consider means undecided.
Okay 👍