Skip to content

Commit

Permalink
[OZ][N-10] _disableInitializers() Not Being Called From Initializable…
Browse files Browse the repository at this point in the history
… Contract Constructors (#106)
  • Loading branch information
Mike-CZ authored Dec 17, 2024
1 parent 3d3be8e commit c87e6eb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contracts/sfc/NodeDriver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ contract NodeDriver is OwnableUpgradeable, UUPSUpgradeable, INodeDriver {
event UpdateNetworkVersion(uint256 version);
event AdvanceEpochs(uint256 num);

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

/// Initialization is called only once, after the contract deployment.
/// Because the contract code is written directly into genesis, constructor cannot be used.
function initialize(address _backend, address _evmWriterAddress, address _owner) external initializer {
Expand Down
5 changes: 5 additions & 0 deletions contracts/sfc/NodeDriverAuth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ contract NodeDriverAuth is OwnableUpgradeable, UUPSUpgradeable {
error DriverCodeHashMismatch();
error RecipientNotSFC();

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

// Initialize NodeDriverAuth, NodeDriver and SFC in one call to allow fewer genesis transactions
function initialize(address payable _sfc, address _driver, address _owner) external initializer {
__Ownable_init(_owner);
Expand Down
5 changes: 5 additions & 0 deletions contracts/sfc/SFC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ contract SFC is OwnableUpgradeable, UUPSUpgradeable, Version {
_;
}

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}

/// Initialization is called only once, after the contract deployment.
/// Because the contract code is written directly into genesis, constructor cannot be used.
function initialize(
Expand Down

0 comments on commit c87e6eb

Please sign in to comment.