The validations report an error if a contract has a constructor, since initializers are expected for upgrades. However, some contracts can indeed have constructors, for example to set immutable variables.
Currently the following annotation at the contract or constructor node is supported to allow the constructor to pass validation:
/// @custom:oz-upgrades-unsafe-allow constructor
However, a contract may be inheriting another contract which itself has a constructor. The author of the most derived contract may want to allow this inheritance if they assess that it is safe, even if the parent contract does not have the above annotation.
This enhancement is to support using the -reachable annotation variant to allow this.
For example, this case should pass after this enhancement is implemented:
abstract contract ParentHasConstructor {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
uint256 immutable x;
constructor(uint256 _x) {
x = _x;
}
}
/// @custom:oz-upgrades-unsafe-allow-reachable constructor
contract ChildHasAllowReachableConstructor_Ok is ParentHasConstructor {
constructor() ParentHasConstructor(1) {}
}
Draft branch with test case added: https://github.com/ericglau/openzeppelin-upgrades/tree/constructorreachable
The validations report an error if a contract has a constructor, since initializers are expected for upgrades. However, some contracts can indeed have constructors, for example to set immutable variables.
Currently the following annotation at the contract or constructor node is supported to allow the constructor to pass validation:
/// @custom:oz-upgrades-unsafe-allow constructorHowever, a contract may be inheriting another contract which itself has a constructor. The author of the most derived contract may want to allow this inheritance if they assess that it is safe, even if the parent contract does not have the above annotation.
This enhancement is to support using the -reachable annotation variant to allow this.
For example, this case should pass after this enhancement is implemented:
Draft branch with test case added: https://github.com/ericglau/openzeppelin-upgrades/tree/constructorreachable