diff --git a/contracts/contracts/AdditionalZkSync.sol b/contracts/contracts/AdditionalZkSync.sol index f5784eb66f..c89bf94461 100644 --- a/contracts/contracts/AdditionalZkSync.sol +++ b/contracts/contracts/AdditionalZkSync.sol @@ -112,36 +112,20 @@ contract AdditionalZkSync is Storage, Config, Events, ReentrancyGuard { totalOpenPriorityRequests -= toProcess; } - uint256 internal constant SECURITY_COUNCIL_2_WEEKS_THRESHOLD = $$(SECURITY_COUNCIL_2_WEEKS_THRESHOLD); - uint256 internal constant SECURITY_COUNCIL_1_WEEK_THRESHOLD = $$(SECURITY_COUNCIL_1_WEEK_THRESHOLD); - uint256 internal constant SECURITY_COUNCIL_3_DAYS_THRESHOLD = $$(SECURITY_COUNCIL_3_DAYS_THRESHOLD); - - function cutUpgradeNoticePeriod() external { - requireActive(); + uint256 internal constant SECURITY_COUNCIL_THRESHOLD = $$(SECURITY_COUNCIL_THRESHOLD); + function approvedCutUpgradeNoticePeriod(address addr) internal { address payable[SECURITY_COUNCIL_MEMBERS_NUMBER] memory SECURITY_COUNCIL_MEMBERS = [ $(SECURITY_COUNCIL_MEMBERS) ]; for (uint256 id = 0; id < SECURITY_COUNCIL_MEMBERS_NUMBER; ++id) { - if (SECURITY_COUNCIL_MEMBERS[id] == msg.sender) { - require(upgradeStartTimestamp != 0); - require(securityCouncilApproves[id] == false); + if (SECURITY_COUNCIL_MEMBERS[id] == addr && !securityCouncilApproves[id]) { securityCouncilApproves[id] = true; numberOfApprovalsFromSecurityCouncil++; - if (numberOfApprovalsFromSecurityCouncil == SECURITY_COUNCIL_2_WEEKS_THRESHOLD) { - if (approvedUpgradeNoticePeriod > 2 weeks) { - approvedUpgradeNoticePeriod = 2 weeks; - emit NoticePeriodChange(approvedUpgradeNoticePeriod); - } - } else if (numberOfApprovalsFromSecurityCouncil == SECURITY_COUNCIL_1_WEEK_THRESHOLD) { - if (approvedUpgradeNoticePeriod > 1 weeks) { - approvedUpgradeNoticePeriod = 1 weeks; - emit NoticePeriodChange(approvedUpgradeNoticePeriod); - } - } else if (numberOfApprovalsFromSecurityCouncil == SECURITY_COUNCIL_3_DAYS_THRESHOLD) { - if (approvedUpgradeNoticePeriod > 3 days) { - approvedUpgradeNoticePeriod = 3 days; + if (numberOfApprovalsFromSecurityCouncil == SECURITY_COUNCIL_THRESHOLD) { + if (approvedUpgradeNoticePeriod > 0) { + approvedUpgradeNoticePeriod = 0; emit NoticePeriodChange(approvedUpgradeNoticePeriod); } } @@ -151,6 +135,37 @@ contract AdditionalZkSync is Storage, Config, Events, ReentrancyGuard { } } + function cutUpgradeNoticePeriod() external { + requireActive(); + require(upgradeStartTimestamp != 0); + + approvedCutUpgradeNoticePeriod(msg.sender); + } + + function cutUpgradeNoticePeriodBySignature(bytes[] calldata signatures) external { + requireActive(); + require(upgradeStartTimestamp != 0); + + address gatekeeper = 0x38A43F4330f24fe920F943409709fc9A6084C939; + (, bytes memory newTarget0) = gatekeeper.call(abi.encodeWithSignature("nextTargets(uint256)", 0)); + (, bytes memory newTarget1) = gatekeeper.call(abi.encodeWithSignature("nextTargets(uint256)", 1)); + (, bytes memory newTarget2) = gatekeeper.call(abi.encodeWithSignature("nextTargets(uint256)", 2)); + + bytes32 targetsHash = keccak256(abi.encodePacked(newTarget0, newTarget1, newTarget2)); + bytes32 messageHash = keccak256( + abi.encodePacked( + "\x19Ethereum Signed Message:\n110", + "Approved new ZkSync's target contracts hash\n0x", + Bytes.bytesToHexASCIIBytes(abi.encodePacked(targetsHash)) + ) + ); + + for (uint256 i = 0; i < signatures.length; ++i) { + address recoveredAddress = Utils.recoverAddressFromEthSignature(signatures[i], messageHash); + approvedCutUpgradeNoticePeriod(recoveredAddress); + } + } + /// @notice Set data for changing pubkey hash using onchain authorization. /// Transaction author (msg.sender) should be L2 account address /// @notice New pubkey hash can be reset, to do that user should send two transactions: diff --git a/contracts/contracts/Config.sol b/contracts/contracts/Config.sol index cb8a7148f9..db4e4bd59a 100644 --- a/contracts/contracts/Config.sol +++ b/contracts/contracts/Config.sol @@ -60,7 +60,7 @@ contract Config { /// @dev Expiration delta for priority request to be satisfied (in seconds) /// @dev NOTE: Priority expiration should be > (EXPECT_VERIFICATION_IN * BLOCK_PERIOD) /// @dev otherwise incorrect block with priority op could not be reverted. - uint256 internal constant PRIORITY_EXPIRATION_PERIOD = 7 days; + uint256 internal constant PRIORITY_EXPIRATION_PERIOD = 14 days; /// @dev Expiration delta for priority request to be satisfied (in ETH blocks) uint256 internal constant PRIORITY_EXPIRATION = @@ -72,7 +72,7 @@ contract Config { uint64 internal constant MAX_PRIORITY_REQUESTS_TO_DELETE_IN_VERIFY = 6; /// @dev Reserved time for users to send full exit priority operation in case of an upgrade (in seconds) - uint256 internal constant MASS_FULL_EXIT_PERIOD = 9 days; + uint256 internal constant MASS_FULL_EXIT_PERIOD = 5 days; /// @dev Reserved time for users to withdraw funds from full exit priority operation in case of an upgrade (in seconds) uint256 internal constant TIME_TO_WITHDRAW_FUNDS_FROM_FULL_EXIT = 2 days; diff --git a/contracts/contracts/ZkSync.sol b/contracts/contracts/ZkSync.sol index d4a4c1bca6..e06bacade6 100644 --- a/contracts/contracts/ZkSync.sol +++ b/contracts/contracts/ZkSync.sol @@ -157,7 +157,9 @@ contract ZkSync is UpgradeableMaster, Storage, Config, Events, ReentrancyGuard { /// @notice zkSync contract upgrade. Can be external because Proxy contract intercepts illegal calls of this function. /// @param upgradeParameters Encoded representation of upgrade parameters // solhint-disable-next-line no-empty-blocks - function upgrade(bytes calldata upgradeParameters) external nonReentrant {} + function upgrade(bytes calldata upgradeParameters) external nonReentrant { + approvedUpgradeNoticePeriod = UPGRADE_NOTICE_PERIOD; + } function cutUpgradeNoticePeriod() external { /// All functions delegated to additional contract should NOT be nonReentrant diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 164f9f28a8..0bd23f9c7f 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -14,9 +14,7 @@ const prodConfig = { SECURITY_COUNCIL_MEMBERS_NUMBER: process.env.MISC_SECURITY_COUNCIL_MEMBERS_NUMBER, SECURITY_COUNCIL_MEMBERS: process.env.MISC_SECURITY_COUNCIL_MEMBERS, - SECURITY_COUNCIL_2_WEEKS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_2_WEEKS_THRESHOLD, - SECURITY_COUNCIL_1_WEEK_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_1_WEEK_THRESHOLD, - SECURITY_COUNCIL_3_DAYS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_3_DAYS_THRESHOLD + SECURITY_COUNCIL_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_THRESHOLD }; const testnetConfig = { UPGRADE_NOTICE_PERIOD: 0, @@ -28,9 +26,7 @@ const testnetConfig = { SECURITY_COUNCIL_MEMBERS_NUMBER: process.env.MISC_SECURITY_COUNCIL_MEMBERS_NUMBER, SECURITY_COUNCIL_MEMBERS: process.env.MISC_SECURITY_COUNCIL_MEMBERS, - SECURITY_COUNCIL_2_WEEKS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_2_WEEKS_THRESHOLD, - SECURITY_COUNCIL_1_WEEK_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_1_WEEK_THRESHOLD, - SECURITY_COUNCIL_3_DAYS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_3_DAYS_THRESHOLD + SECURITY_COUNCIL_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_THRESHOLD }; const testConfig = { @@ -43,9 +39,7 @@ const testConfig = { SECURITY_COUNCIL_MEMBERS_NUMBER: process.env.MISC_SECURITY_COUNCIL_MEMBERS_NUMBER, SECURITY_COUNCIL_MEMBERS: process.env.MISC_SECURITY_COUNCIL_MEMBERS, - SECURITY_COUNCIL_2_WEEKS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_2_WEEKS_THRESHOLD, - SECURITY_COUNCIL_1_WEEK_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_1_WEEK_THRESHOLD, - SECURITY_COUNCIL_3_DAYS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_3_DAYS_THRESHOLD + SECURITY_COUNCIL_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_THRESHOLD }; const localConfig = Object.assign({}, prodConfig); @@ -59,9 +53,7 @@ localConfig.NEW_ADDITIONAL_ZKSYNC_ADDRESS = process.env.MISC_NEW_ADDITIONAL_ZKSY localConfig.SECURITY_COUNCIL_MEMBERS_NUMBER = process.env.MISC_SECURITY_COUNCIL_MEMBERS_NUMBER; localConfig.SECURITY_COUNCIL_MEMBERS = process.env.MISC_SECURITY_COUNCIL_MEMBERS; -localConfig.SECURITY_COUNCIL_2_WEEKS_THRESHOLD = process.env.MISC_SECURITY_COUNCIL_2_WEEKS_THRESHOLD; -localConfig.SECURITY_COUNCIL_1_WEEK_THRESHOLD = process.env.MISC_SECURITY_COUNCIL_1_WEEK_THRESHOLD; -localConfig.SECURITY_COUNCIL_3_DAYS_THRESHOLD = process.env.MISC_SECURITY_COUNCIL_3_DAYS_THRESHOLD; +localConfig.SECURITY_COUNCIL_THRESHOLD = process.env.MISC_SECURITY_COUNCIL_THRESHOLD; // @ts-ignore localConfig.EASY_EXODUS = process.env.CONTRACTS_TEST_EASY_EXODUS === 'true'; diff --git a/etc/env/base/misc.toml b/etc/env/base/misc.toml index 8998422e68..ea017ae256 100644 --- a/etc/env/base/misc.toml +++ b/etc/env/base/misc.toml @@ -51,6 +51,4 @@ listing_treasury="0xaFe6A91979021206ad79F58562Eef4204720E2A3" security_council_members_number=3 security_council_members=["0x22C3F9177F485bF9a058cE4C7253Da81a59495Db","0x56dF84566a67e87808A73dA0Be61a40bda3e2AFA","0xCE004d039cD86b08274FC453bd5536E6e9F6Fac7"] -security_council_2_weeks_threshold=1 -security_council_1_week_threshold=2 -security_council_3_days_threshold=3 +security_council_threshold=2