@@ -21,6 +21,11 @@ contract NodeDriverAuth is OwnableUpgradeable, UUPSUpgradeable {
2121 error DriverCodeHashMismatch ();
2222 error RecipientNotSFC ();
2323
24+ /// @custom:oz-upgrades-unsafe-allow constructor
25+ constructor () {
26+ _disableInitializers ();
27+ }
28+
2429 // Initialize NodeDriverAuth, NodeDriver and SFC in one call to allow fewer genesis transactions
2530 function initialize (address payable _sfc , address _driver , address _owner ) external initializer {
2631 __Ownable_init (_owner);
@@ -53,7 +58,6 @@ contract NodeDriverAuth is OwnableUpgradeable, UUPSUpgradeable {
5358 _transferOwnership (executable);
5459 INodeDriverExecutable (executable).execute ();
5560 _transferOwnership (newOwner);
56- //require(driver.backend() == address(this), "ownership of driver is lost");
5761 if (_getCodeHash (address (this )) != selfCodeHash) {
5862 revert SelfCodeHashMismatch ();
5963 }
@@ -63,7 +67,7 @@ contract NodeDriverAuth is OwnableUpgradeable, UUPSUpgradeable {
6367 }
6468
6569 /// Execute a batch update of network configuration.
66- /// Run given contract with a permission of the NodeDriverAuth owner.
70+ /// The executable will run with the privileges of the NodeDriverAuth owner.
6771 /// Does not allow changing NodeDriver and NodeDriverAuth code.
6872 function execute (address executable ) external onlyOwner {
6973 _execute (executable, owner (), _getCodeHash (address (this )), _getCodeHash (address (driver)));
@@ -83,13 +87,10 @@ contract NodeDriverAuth is OwnableUpgradeable, UUPSUpgradeable {
8387
8488 /// Mint native token. To be used by SFC for minting validators rewards.
8589 function incBalance (address acc , uint256 diff ) external onlySFC {
86- if (acc != address (sfc)) {
87- revert RecipientNotSFC ();
88- }
8990 driver.setBalance (acc, address (acc).balance + diff);
9091 }
9192
92- /// Upgrade code of given contract by coping it from other deployed contract.
93+ /// Upgrade code of given contract by copying it from other deployed contract.
9394 /// Avoids setting code to an external address.
9495 function upgradeCode (address acc , address from ) external onlyOwner {
9596 if (! isContract (acc) || ! isContract (from)) {
@@ -98,7 +99,7 @@ contract NodeDriverAuth is OwnableUpgradeable, UUPSUpgradeable {
9899 driver.copyCode (acc, from);
99100 }
100101
101- /// Upgrade code of given contract by coping it from other deployed contract.
102+ /// Upgrade code of given contract by copying it from other deployed contract.
102103 /// Does not avoid setting code to an external address. (DANGEROUS!)
103104 function copyCode (address acc , address from ) external onlyOwner {
104105 driver.copyCode (acc, from);
@@ -171,19 +172,12 @@ contract NodeDriverAuth is OwnableUpgradeable, UUPSUpgradeable {
171172 }
172173
173174 function isContract (address account ) internal view returns (bool ) {
174- uint256 size;
175- // solhint-disable-next-line no-inline-assembly
176- assembly {
177- size := extcodesize (account)
178- }
179- return size > 0 ;
175+ return account.code.length > 0 ;
180176 }
181177
182178 function _getCodeHash (address addr ) internal view returns (bytes32 ) {
183- bytes32 codeHash;
184- assembly {
185- codeHash := extcodehash (addr)
186- }
187- return codeHash;
179+ return addr.codehash;
188180 }
181+
182+ uint256 [50 ] private __gap;
189183}
0 commit comments