-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display more deployed addresses #1203
Changes from 15 commits
8965047
56dc377
572cd0c
3cd7159
e7f9163
eed6e01
e1b50e8
67e4828
6612664
f749f8a
30b471f
91c6752
4338f5d
c461207
741d10d
1cd5d6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.21; | ||
|
||
import {Utils} from "./Utils.sol"; | ||
import {IGovernance} from "contracts/governance/IGovernance.sol"; | ||
import {stdToml} from "forge-std/StdToml.sol"; | ||
import {IProtocolUpgradeHandler} from "./interfaces/IProtocolUpgradeHandler.sol"; | ||
import {Script} from "forge-std/Script.sol"; | ||
import {Vm} from "forge-std/Vm.sol"; | ||
|
||
contract SecurityCouncilApproveStageUpgrade is Script { | ||
using stdToml for string; | ||
|
||
function run() external { | ||
// Insert the address of the protocol upgrade handler here. | ||
IProtocolUpgradeHandler protocolUpgradeHandler = IProtocolUpgradeHandler(address(0)); | ||
// Insert the private key of the stage governance | ||
Vm.Wallet memory wallet = vm.createWallet(uint256(0)); | ||
|
||
bytes32 upgradeId = bytes32(0); | ||
|
||
Utils.securityCouncilApproveUpgrade(protocolUpgradeHandler, wallet, upgradeId); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import {IChainAdmin} from "contracts/governance/IChainAdmin.sol"; | |
import {EIP712Utils} from "./EIP712Utils.sol"; | ||
import {IProtocolUpgradeHandler} from "./interfaces/IProtocolUpgradeHandler.sol"; | ||
import {IEmergencyUpgrageBoard} from "./interfaces/IEmergencyUpgrageBoard.sol"; | ||
import {ISecurityCouncil} from "./interfaces/ISecurityCouncil.sol"; | ||
import {IMultisig} from "./interfaces/IMultisig.sol"; | ||
import {ISafe} from "./interfaces/ISafe.sol"; | ||
import {AccessControlRestriction} from "contracts/governance/AccessControlRestriction.sol"; | ||
|
@@ -38,6 +39,9 @@ bytes32 constant EXECUTE_EMERGENCY_UPGRADE_ZK_FOUNDATION_TYPEHASH = keccak256( | |
"ExecuteEmergencyUpgradeZKFoundation(bytes32 id)" | ||
); | ||
|
||
/// @dev EIP-712 TypeHash for protocol upgrades approval by the Security Council. | ||
bytes32 constant APPROVE_UPGRADE_SECURITY_COUNCIL_TYPEHASH = keccak256("ApproveUpgradeSecurityCouncil(bytes32 id)"); | ||
|
||
/// @dev The offset from which the built-in, but user space contracts are located. | ||
uint160 constant USER_CONTRACTS_OFFSET = 0x10000; // 2^16 | ||
|
||
|
@@ -1002,6 +1006,53 @@ library Utils { | |
} | ||
} | ||
|
||
function securityCouncilApproveUpgrade( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a comment on what this method does |
||
IProtocolUpgradeHandler _protocolUpgradeHandler, | ||
Vm.Wallet memory _governorWallet, | ||
bytes32 upgradeId | ||
) internal returns (bytes memory) { | ||
address securityCouncilAddr = _protocolUpgradeHandler.securityCouncil(); | ||
bytes32 securityCouncilDigest; | ||
{ | ||
securityCouncilDigest = EIP712Utils.buildDomainHash(securityCouncilAddr, "SecurityCouncil", "1"); | ||
} | ||
|
||
bytes[] memory securityCouncilRawSignatures = new bytes[](12); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment why 12 - and maybe do a constant? |
||
address[] memory securityCouncilMembers = new address[](12); | ||
{ | ||
{ | ||
IMultisig securityCouncil = IMultisig(_protocolUpgradeHandler.securityCouncil()); | ||
for (uint256 i = 0; i < 12; i++) { | ||
securityCouncilMembers[i] = securityCouncil.members(i); | ||
} | ||
} | ||
for (uint256 i = 0; i < securityCouncilMembers.length; i++) { | ||
bytes32 safeDigest; | ||
{ | ||
bytes32 digest = EIP712Utils.buildDigest( | ||
securityCouncilDigest, | ||
keccak256(abi.encode(APPROVE_UPGRADE_SECURITY_COUNCIL_TYPEHASH, upgradeId)) | ||
); | ||
safeDigest = ISafe(securityCouncilMembers[i]).getMessageHash(abi.encode(digest)); | ||
} | ||
{ | ||
(uint8 v, bytes32 r, bytes32 s) = vm.sign(_governorWallet, safeDigest); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so we're using governor's wallet 12 times ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this is the case for the staging env |
||
securityCouncilRawSignatures[i] = abi.encodePacked(r, s, v); | ||
} | ||
} | ||
} | ||
|
||
{ | ||
vm.startBroadcast(msg.sender); | ||
ISecurityCouncil(securityCouncilAddr).approveUpgradeSecurityCouncil( | ||
upgradeId, | ||
securityCouncilMembers, | ||
securityCouncilRawSignatures | ||
); | ||
vm.stopBroadcast(); | ||
} | ||
} | ||
|
||
function adminExecute( | ||
address _admin, | ||
address _accessControlRestriction, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
interface ISecurityCouncil { | ||
function approveUpgradeSecurityCouncil( | ||
bytes32 _id, | ||
address[] calldata _signers, | ||
bytes[] calldata _signatures | ||
) external; | ||
|
||
function softFreeze(uint256 _validUntil, address[] calldata _signers, bytes[] calldata _signatures) external; | ||
|
||
function hardFreeze(uint256 _validUntil, address[] calldata _signers, bytes[] calldata _signatures) external; | ||
|
||
function unfreeze(uint256 _validUntil, address[] calldata _signers, bytes[] calldata _signatures) external; | ||
|
||
function setSoftFreezeThreshold( | ||
uint256 _threshold, | ||
uint256 _validUntil, | ||
address[] calldata _signers, | ||
bytes[] calldata _signatures | ||
) external; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one changed because previously for the
l1-contracts/Utils
we used/l1-contracts/out/Utils.sol/Utils.json
, while now we are using/l1-contracts/out/SystemContractsCaller.sol/Utils.json
. The former was from a test, while the latter is actually a library in code