-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix): merge conflicts from all commits
- Loading branch information
Raid Ateir
committed
Oct 29, 2024
1 parent
9bcd15b
commit bcc12d4
Showing
8 changed files
with
54 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,8 @@ import {ReentrancyGuard} from "../common/ReentrancyGuard.sol"; | |
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
/// @notice The contract is designed to hold the `admin` role in ZKSync Chain (State Transition) contracts. | ||
/// @dev Note, that it does not implement any form of access control by default, but instead utilizes | ||
/// so called "restrictions": contracts that implement the `IRestriction` interface and ensure that | ||
/// @dev Note, that it does not implement any form of access control by default, but instead utilizes | ||
/// so called "restrictions": contracts that implement the `IRestriction` interface and ensure that | ||
/// particular restrictions are ensured for the contract, including access control, security invariants, etc. | ||
contract ChainAdmin is IChainAdmin, ReentrancyGuard { | ||
using EnumerableSet for EnumerableSet.AddressSet; | ||
|
@@ -107,15 +107,9 @@ contract ChainAdmin is IChainAdmin, ReentrancyGuard { | |
/// @dev Contract might receive/hold ETH as part of the maintenance process. | ||
receive() external payable {} | ||
|
||
<<<<<<< HEAD | ||
/// @notice Function that ensures that the current admin can perform the call. | ||
/// @dev Reverts in case the call can not be performed. Successfully executes otherwise. | ||
function _validateCall(Call calldata _call) internal view { | ||
======= | ||
/// @notice Function that returns the current admin can perform the call. | ||
/// @dev By default it always returns true, but can be overridden in derived contracts. | ||
function _validateCall(Call calldata _call) private view { | ||
>>>>>>> origin/vb-governance-n03 | ||
address[] memory restrictions = getRestrictions(); | ||
|
||
unchecked { | ||
|
@@ -127,19 +121,12 @@ contract ChainAdmin is IChainAdmin, ReentrancyGuard { | |
|
||
/// @notice Adds a new restriction to the active restrictions set. | ||
/// @param _restriction The address of the restriction contract to be added. | ||
<<<<<<< HEAD | ||
function _addRestriction(address _restriction) internal { | ||
<<<<<<< HEAD | ||
RestrictionValidator.validateRestriction(_restriction); | ||
|
||
======= | ||
function _addRestriction(address _restriction) private { | ||
if (_restriction == address(0)) { | ||
revert ZeroAddress(); | ||
} | ||
>>>>>>> origin/sb-governance-l02 | ||
======= | ||
function _addRestriction(address _restriction) private { | ||
>>>>>>> origin/vb-governance-n03 | ||
RestrictionValidator.validateRestriction(_restriction); | ||
|
||
if (!activeRestrictions.add(_restriction)) { | ||
revert RestrictionWasAlreadyPresent(_restriction); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,8 @@ | |
pragma solidity 0.8.24; | ||
|
||
import {ChainAdmin} from "./ChainAdmin.sol"; | ||
<<<<<<< HEAD | ||
import {RestrictionValidator} from "./restriction/RestrictionValidator.sol"; | ||
======= | ||
import {ZeroAddress} from "../common/L1ContractErrors.sol"; | ||
>>>>>>> origin/sb-governance-l02 | ||
|
||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
|
@@ -28,72 +25,62 @@ contract L2AdminFactory { | |
address[] public requiredRestrictions; | ||
|
||
constructor(address[] memory _requiredRestrictions) { | ||
<<<<<<< HEAD | ||
_validateRestrctions(_requiredRestrictions); | ||
======= | ||
_validateZeroAddress(_requiredRestrictions); | ||
>>>>>>> origin/sb-governance-l02 | ||
_validateRestrctions(_requiredRestrictions); | ||
requiredRestrictions = _requiredRestrictions; | ||
} | ||
|
||
/// @notice Deploys a new L2 admin contract. | ||
/// @return admin The address of the deployed admin contract. | ||
<<<<<<< HEAD | ||
// solhint-disable-next-line gas-calldata-parameters | ||
function deployAdmin(address[] memory _additionalRestrictions, bytes32 _salt) external returns (address admin) { | ||
// Even though the chain admin will likely perform similar checks, | ||
// Even though the chain admin will likely perform similar checks, | ||
// we keep those here just in case, since it is not expensive, while allowing to fail fast. | ||
<<<<<<< HEAD | ||
_validateRestrctions(_additionalRestrictions); | ||
======= | ||
_validateZeroAddress(_additionalRestrictions); | ||
_validateRestrctions(_additionalRestrictions); | ||
|
||
>>>>>>> origin/sb-governance-l02 | ||
address[] memory restrictions = new address[](requiredRestrictions.length + _additionalRestrictions.length); | ||
======= | ||
function deployAdmin(address[] calldata _additionalRestrictions, bytes32 _salt) external returns (address admin) { | ||
>>>>>>> origin/sb-governance-n01 | ||
uint256 cachedRequired = requiredRestrictions.length; | ||
uint256 cachedAdditional = _additionalRestrictions.length; | ||
address[] memory restrictions = new address[](cachedRequired + cachedRequired); | ||
|
||
address[] memory restrictions = new address[](cachedRequired + cachedAdditional); | ||
|
||
unchecked { | ||
for (uint256 i = 0; i < cachedRequired; ++i) { | ||
restrictions[i] = requiredRestrictions[i]; | ||
} | ||
for (uint256 i = 0; i < cachedAdditional; ++i) { | ||
restrictions[cachedRequired + i] = _additionalRestrictions[i]; | ||
} | ||
} | ||
} | ||
|
||
admin = address(new ChainAdmin{salt: _salt}(restrictions)); | ||
|
||
emit AdminDeployed(admin); | ||
} | ||
|
||
<<<<<<< HEAD | ||
/// @notice Checks that the provided list of restrictions is correct. | ||
/// @param _restrictions List of the restrictions to check. | ||
/// @dev In case either of the restrictions is not correct, the function reverts. | ||
function _validateRestrctions(address[] memory _restrictions) internal view { | ||
unchecked { | ||
uint256 length = _restrictions.length; | ||
for(uint256 i = 0; i < length; ++i) { | ||
RestrictionValidator.validateRestriction(_restrictions[i]); | ||
======= | ||
/// @notice Checks that the provided list of restrictions does not contain | ||
/// any zero addresses. | ||
/// @param _restrictions List of the restrictions to check. | ||
/// @dev In case either of the restrictions is zero address, the function reverts. | ||
function _validateZeroAddress(address[] memory _restrictions) internal view { | ||
function _validateZeroAddress(address[] memory _restrictions) private pure { | ||
unchecked { | ||
uint256 length = _restrictions.length; | ||
for(uint256 i = 0; i < length; ++i) { | ||
for (uint256 i = 0; i < length; ++i) { | ||
if (_restrictions[i] == address(0)) { | ||
revert ZeroAddress(); | ||
} | ||
>>>>>>> origin/sb-governance-l02 | ||
} | ||
} | ||
} | ||
|
||
/// @notice Checks that the provided list of restrictions is correct. | ||
/// @param _restrictions List of the restrictions to check. | ||
/// @dev In case either of the restrictions is not correct, the function reverts. | ||
function _validateRestrctions(address[] memory _restrictions) private view { | ||
unchecked { | ||
uint256 length = _restrictions.length; | ||
for (uint256 i = 0; i < length; ++i) { | ||
RestrictionValidator.validateRestriction(_restrictions[i]); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.