-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from matter-labs/sb-port-1-4-1-fixes
Port 1 4 1 fixes to the short term fee model
- Loading branch information
Showing
22 changed files
with
302 additions
and
201 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
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,20 +2,22 @@ | |
|
||
pragma solidity 0.8.20; | ||
|
||
import "../interfaces/IAdmin.sol"; | ||
import "../libraries/Diamond.sol"; | ||
import {IAdmin} from "../interfaces/IAdmin.sol"; | ||
import {Diamond} from "../libraries/Diamond.sol"; | ||
import {L2_TX_MAX_GAS_LIMIT} from "../Config.sol"; | ||
import "./Base.sol"; | ||
import {Base} from "./Base.sol"; | ||
|
||
// While formally the following import is not used, it is needed to inherit documentation from it | ||
import {IBase} from "../interfaces/IBase.sol"; | ||
|
||
/// @title Admin Contract controls access rights for contract management. | ||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
contract AdminFacet is Base, IAdmin { | ||
/// @inheritdoc IBase | ||
string public constant override getName = "AdminFacet"; | ||
|
||
/// @notice Starts the transfer of governor rights. Only the current governor can propose a new pending one. | ||
/// @notice New governor can accept governor rights by calling `acceptGovernor` function. | ||
/// @param _newPendingGovernor Address of the new governor | ||
/// @inheritdoc IAdmin | ||
function setPendingGovernor(address _newPendingGovernor) external onlyGovernor { | ||
// Save previous value into the stack to put it into the event later | ||
address oldPendingGovernor = s.pendingGovernor; | ||
|
@@ -24,7 +26,7 @@ contract AdminFacet is Base, IAdmin { | |
emit NewPendingGovernor(oldPendingGovernor, _newPendingGovernor); | ||
} | ||
|
||
/// @notice Accepts transfer of governor rights. Only pending governor can accept the role. | ||
/// @inheritdoc IAdmin | ||
function acceptGovernor() external { | ||
address pendingGovernor = s.pendingGovernor; | ||
require(msg.sender == pendingGovernor, "n4"); // Only proposed by current governor address can claim the governor rights | ||
|
@@ -37,9 +39,7 @@ contract AdminFacet is Base, IAdmin { | |
emit NewGovernor(previousGovernor, pendingGovernor); | ||
} | ||
|
||
/// @notice Starts the transfer of admin rights. Only the current governor or admin can propose a new pending one. | ||
/// @notice New admin can accept admin rights by calling `acceptAdmin` function. | ||
/// @param _newPendingAdmin Address of the new admin | ||
/// @inheritdoc IAdmin | ||
function setPendingAdmin(address _newPendingAdmin) external onlyGovernor { | ||
// Save previous value into the stack to put it into the event later | ||
address oldPendingAdmin = s.pendingAdmin; | ||
|
@@ -48,7 +48,7 @@ contract AdminFacet is Base, IAdmin { | |
emit NewPendingAdmin(oldPendingAdmin, _newPendingAdmin); | ||
} | ||
|
||
/// @notice Accepts transfer of admin rights. Only pending admin can accept the role. | ||
/// @inheritdoc IAdmin | ||
function acceptAdmin() external { | ||
address pendingAdmin = s.pendingAdmin; | ||
require(msg.sender == pendingAdmin, "n4"); // Only proposed by current admin address can claim the admin rights | ||
|
@@ -61,24 +61,20 @@ contract AdminFacet is Base, IAdmin { | |
emit NewAdmin(previousAdmin, pendingAdmin); | ||
} | ||
|
||
/// @notice Change validator status (active or not active) | ||
/// @param _validator Validator address | ||
/// @param _active Active flag | ||
/// @inheritdoc IAdmin | ||
function setValidator(address _validator, bool _active) external onlyGovernorOrAdmin { | ||
s.validators[_validator] = _active; | ||
emit ValidatorStatusUpdate(_validator, _active); | ||
} | ||
|
||
/// @notice Change zk porter availability | ||
/// @param _zkPorterIsAvailable The availability of zk porter shard | ||
/// @inheritdoc IAdmin | ||
function setPorterAvailability(bool _zkPorterIsAvailable) external onlyGovernor { | ||
// Change the porter availability | ||
s.zkPorterIsAvailable = _zkPorterIsAvailable; | ||
emit IsPorterAvailableStatusUpdate(_zkPorterIsAvailable); | ||
} | ||
|
||
/// @notice Change the max L2 gas limit for L1 -> L2 transactions | ||
/// @param _newPriorityTxMaxGasLimit The maximum number of L2 gas that a user can request for L1 -> L2 transactions | ||
/// @inheritdoc IAdmin | ||
function setPriorityTxMaxGasLimit(uint256 _newPriorityTxMaxGasLimit) external onlyGovernor { | ||
require(_newPriorityTxMaxGasLimit <= L2_TX_MAX_GAS_LIMIT, "n5"); | ||
|
||
|
@@ -100,9 +96,7 @@ contract AdminFacet is Base, IAdmin { | |
UPGRADE EXECUTION | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/// @notice Executes a proposed governor upgrade | ||
/// @dev Only the current governor can execute the upgrade | ||
/// @param _diamondCut The diamond cut parameters to be executed | ||
/// @inheritdoc IAdmin | ||
function executeUpgrade(Diamond.DiamondCutData calldata _diamondCut) external onlyGovernor { | ||
Diamond.diamondCut(_diamondCut); | ||
emit ExecuteUpgrade(_diamondCut); | ||
|
@@ -112,8 +106,7 @@ contract AdminFacet is Base, IAdmin { | |
CONTRACT FREEZING | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/// @notice Instantly pause the functionality of all freezable facets & their selectors | ||
/// @dev Only the governance mechanism may freeze Diamond Proxy | ||
/// @inheritdoc IAdmin | ||
function freezeDiamond() external onlyGovernor { | ||
Diamond.DiamondStorage storage diamondStorage = Diamond.getDiamondStorage(); | ||
|
||
|
@@ -123,8 +116,7 @@ contract AdminFacet is Base, IAdmin { | |
emit Freeze(); | ||
} | ||
|
||
/// @notice Unpause the functionality of all freezable facets & their selectors | ||
/// @dev Both the governor and its owner can unfreeze Diamond Proxy | ||
/// @inheritdoc IAdmin | ||
function unfreezeDiamond() external onlyGovernorOrAdmin { | ||
Diamond.DiamondStorage storage diamondStorage = Diamond.getDiamondStorage(); | ||
|
||
|
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.