-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1982d82
commit 02d6fbb
Showing
7 changed files
with
44 additions
and
26 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
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
pragma solidity 0.8.24; | ||
|
||
import {CallNotAllowed, RemovingPermanentRestriction, ZeroAddress, UnallowedImplementation, AlreadyWhitelisted, NotAllowed} from "../common/L1ContractErrors.sol"; | ||
import {TooHighDeploymentNonce, CallNotAllowed, RemovingPermanentRestriction, ZeroAddress, UnallowedImplementation, AlreadyWhitelisted, NotAllowed} from "../common/L1ContractErrors.sol"; | ||
|
||
import {L2TransactionRequestTwoBridgesOuter, BridgehubBurnCTMAssetData} from "../bridgehub/IBridgehub.sol"; | ||
import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable-v4/access/Ownable2StepUpgradeable.sol"; | ||
|
@@ -24,6 +24,11 @@ import {IPermanentRestriction} from "./IPermanentRestriction.sol"; | |
/// has at least this amount. | ||
uint256 constant MIN_GAS_FOR_FALLABLE_CALL = 5_000_000; | ||
|
||
/// @dev The value up to which the nonces of the L2AdminDeployer could be used. This is needed | ||
/// to limit the impact of the birthday paradox attack, where an attack could craft a malicious | ||
/// address on L1. | ||
uint256 constant MAX_ALLOWED_NONCE = (1 << 48); | ||
|
||
/// @title PermanentRestriction contract | ||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
|
@@ -98,18 +103,15 @@ contract PermanentRestriction is Restriction, IPermanentRestriction, Ownable2Ste | |
} | ||
|
||
/// @notice Whitelists a certain L2 admin. | ||
/// @param deploymentSalt The salt for the deployment. | ||
/// @param l2BytecodeHash The hash of the L2 bytecode. | ||
/// @param constructorInputHash The hash of the constructor data for the deployment. | ||
function allowL2Admin(bytes32 deploymentSalt, bytes32 l2BytecodeHash, bytes32 constructorInputHash) external { | ||
/// @param deploymentNonce The deployment nonce of the `L2_ADMIN_FACTORY` used for the deployment. | ||
function allowL2Admin(uint256 deploymentNonce) external { | ||
if (deploymentNonce > MAX_ALLOWED_NONCE) { | ||
revert TooHighDeploymentNonce(); | ||
} | ||
|
||
// We do not do any additional validations for constructor data or the bytecode, | ||
// we expect that only admins of the allowed format are to be deployed. | ||
address expectedAddress = L2ContractHelper.computeCreate2Address( | ||
L2_ADMIN_FACTORY, | ||
deploymentSalt, | ||
l2BytecodeHash, | ||
constructorInputHash | ||
); | ||
address expectedAddress = L2ContractHelper.computeCreateAddress(L2_ADMIN_FACTORY, deploymentNonce); | ||
|
||
if (allowedL2Admins[expectedAddress]) { | ||
revert AlreadyWhitelisted(expectedAddress); | ||
|
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