Skip to content

Commit b55ab5a

Browse files
authored
Merge pull request #1996 from matter-labs/ib-new-contracts-config
new contracts config
2 parents 6f510db + d944d29 commit b55ab5a

File tree

5 files changed

+47
-40
lines changed

5 files changed

+47
-40
lines changed

contracts/contracts/AdditionalZkSync.sol

+37-22
Original file line numberDiff line numberDiff line change
@@ -112,36 +112,20 @@ contract AdditionalZkSync is Storage, Config, Events, ReentrancyGuard {
112112
totalOpenPriorityRequests -= toProcess;
113113
}
114114

115-
uint256 internal constant SECURITY_COUNCIL_2_WEEKS_THRESHOLD = $$(SECURITY_COUNCIL_2_WEEKS_THRESHOLD);
116-
uint256 internal constant SECURITY_COUNCIL_1_WEEK_THRESHOLD = $$(SECURITY_COUNCIL_1_WEEK_THRESHOLD);
117-
uint256 internal constant SECURITY_COUNCIL_3_DAYS_THRESHOLD = $$(SECURITY_COUNCIL_3_DAYS_THRESHOLD);
118-
119-
function cutUpgradeNoticePeriod() external {
120-
requireActive();
115+
uint256 internal constant SECURITY_COUNCIL_THRESHOLD = $$(SECURITY_COUNCIL_THRESHOLD);
121116

117+
function approvedCutUpgradeNoticePeriod(address addr) internal {
122118
address payable[SECURITY_COUNCIL_MEMBERS_NUMBER] memory SECURITY_COUNCIL_MEMBERS = [
123119
$(SECURITY_COUNCIL_MEMBERS)
124120
];
125121
for (uint256 id = 0; id < SECURITY_COUNCIL_MEMBERS_NUMBER; ++id) {
126-
if (SECURITY_COUNCIL_MEMBERS[id] == msg.sender) {
127-
require(upgradeStartTimestamp != 0);
128-
require(securityCouncilApproves[id] == false);
122+
if (SECURITY_COUNCIL_MEMBERS[id] == addr && !securityCouncilApproves[id]) {
129123
securityCouncilApproves[id] = true;
130124
numberOfApprovalsFromSecurityCouncil++;
131125

132-
if (numberOfApprovalsFromSecurityCouncil == SECURITY_COUNCIL_2_WEEKS_THRESHOLD) {
133-
if (approvedUpgradeNoticePeriod > 2 weeks) {
134-
approvedUpgradeNoticePeriod = 2 weeks;
135-
emit NoticePeriodChange(approvedUpgradeNoticePeriod);
136-
}
137-
} else if (numberOfApprovalsFromSecurityCouncil == SECURITY_COUNCIL_1_WEEK_THRESHOLD) {
138-
if (approvedUpgradeNoticePeriod > 1 weeks) {
139-
approvedUpgradeNoticePeriod = 1 weeks;
140-
emit NoticePeriodChange(approvedUpgradeNoticePeriod);
141-
}
142-
} else if (numberOfApprovalsFromSecurityCouncil == SECURITY_COUNCIL_3_DAYS_THRESHOLD) {
143-
if (approvedUpgradeNoticePeriod > 3 days) {
144-
approvedUpgradeNoticePeriod = 3 days;
126+
if (numberOfApprovalsFromSecurityCouncil == SECURITY_COUNCIL_THRESHOLD) {
127+
if (approvedUpgradeNoticePeriod > 0) {
128+
approvedUpgradeNoticePeriod = 0;
145129
emit NoticePeriodChange(approvedUpgradeNoticePeriod);
146130
}
147131
}
@@ -151,6 +135,37 @@ contract AdditionalZkSync is Storage, Config, Events, ReentrancyGuard {
151135
}
152136
}
153137

138+
function cutUpgradeNoticePeriod() external {
139+
requireActive();
140+
require(upgradeStartTimestamp != 0);
141+
142+
approvedCutUpgradeNoticePeriod(msg.sender);
143+
}
144+
145+
function cutUpgradeNoticePeriodBySignature(bytes[] calldata signatures) external {
146+
requireActive();
147+
require(upgradeStartTimestamp != 0);
148+
149+
address gatekeeper = 0x38A43F4330f24fe920F943409709fc9A6084C939;
150+
(, bytes memory newTarget0) = gatekeeper.call(abi.encodeWithSignature("nextTargets(uint256)", 0));
151+
(, bytes memory newTarget1) = gatekeeper.call(abi.encodeWithSignature("nextTargets(uint256)", 1));
152+
(, bytes memory newTarget2) = gatekeeper.call(abi.encodeWithSignature("nextTargets(uint256)", 2));
153+
154+
bytes32 targetsHash = keccak256(abi.encodePacked(newTarget0, newTarget1, newTarget2));
155+
bytes32 messageHash = keccak256(
156+
abi.encodePacked(
157+
"\x19Ethereum Signed Message:\n110",
158+
"Approved new ZkSync's target contracts hash\n0x",
159+
Bytes.bytesToHexASCIIBytes(abi.encodePacked(targetsHash))
160+
)
161+
);
162+
163+
for (uint256 i = 0; i < signatures.length; ++i) {
164+
address recoveredAddress = Utils.recoverAddressFromEthSignature(signatures[i], messageHash);
165+
approvedCutUpgradeNoticePeriod(recoveredAddress);
166+
}
167+
}
168+
154169
/// @notice Set data for changing pubkey hash using onchain authorization.
155170
/// Transaction author (msg.sender) should be L2 account address
156171
/// @notice New pubkey hash can be reset, to do that user should send two transactions:

contracts/contracts/Config.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ contract Config {
6060
/// @dev Expiration delta for priority request to be satisfied (in seconds)
6161
/// @dev NOTE: Priority expiration should be > (EXPECT_VERIFICATION_IN * BLOCK_PERIOD)
6262
/// @dev otherwise incorrect block with priority op could not be reverted.
63-
uint256 internal constant PRIORITY_EXPIRATION_PERIOD = 7 days;
63+
uint256 internal constant PRIORITY_EXPIRATION_PERIOD = 14 days;
6464

6565
/// @dev Expiration delta for priority request to be satisfied (in ETH blocks)
6666
uint256 internal constant PRIORITY_EXPIRATION =
@@ -72,7 +72,7 @@ contract Config {
7272
uint64 internal constant MAX_PRIORITY_REQUESTS_TO_DELETE_IN_VERIFY = 6;
7373

7474
/// @dev Reserved time for users to send full exit priority operation in case of an upgrade (in seconds)
75-
uint256 internal constant MASS_FULL_EXIT_PERIOD = 9 days;
75+
uint256 internal constant MASS_FULL_EXIT_PERIOD = 5 days;
7676

7777
/// @dev Reserved time for users to withdraw funds from full exit priority operation in case of an upgrade (in seconds)
7878
uint256 internal constant TIME_TO_WITHDRAW_FUNDS_FROM_FULL_EXIT = 2 days;

contracts/contracts/ZkSync.sol

+3-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ contract ZkSync is UpgradeableMaster, Storage, Config, Events, ReentrancyGuard {
157157
/// @notice zkSync contract upgrade. Can be external because Proxy contract intercepts illegal calls of this function.
158158
/// @param upgradeParameters Encoded representation of upgrade parameters
159159
// solhint-disable-next-line no-empty-blocks
160-
function upgrade(bytes calldata upgradeParameters) external nonReentrant {}
160+
function upgrade(bytes calldata upgradeParameters) external nonReentrant {
161+
approvedUpgradeNoticePeriod = UPGRADE_NOTICE_PERIOD;
162+
}
161163

162164
function cutUpgradeNoticePeriod() external {
163165
/// All functions delegated to additional contract should NOT be nonReentrant

contracts/hardhat.config.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ const prodConfig = {
1414

1515
SECURITY_COUNCIL_MEMBERS_NUMBER: process.env.MISC_SECURITY_COUNCIL_MEMBERS_NUMBER,
1616
SECURITY_COUNCIL_MEMBERS: process.env.MISC_SECURITY_COUNCIL_MEMBERS,
17-
SECURITY_COUNCIL_2_WEEKS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_2_WEEKS_THRESHOLD,
18-
SECURITY_COUNCIL_1_WEEK_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_1_WEEK_THRESHOLD,
19-
SECURITY_COUNCIL_3_DAYS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_3_DAYS_THRESHOLD
17+
SECURITY_COUNCIL_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_THRESHOLD
2018
};
2119
const testnetConfig = {
2220
UPGRADE_NOTICE_PERIOD: 0,
@@ -28,9 +26,7 @@ const testnetConfig = {
2826

2927
SECURITY_COUNCIL_MEMBERS_NUMBER: process.env.MISC_SECURITY_COUNCIL_MEMBERS_NUMBER,
3028
SECURITY_COUNCIL_MEMBERS: process.env.MISC_SECURITY_COUNCIL_MEMBERS,
31-
SECURITY_COUNCIL_2_WEEKS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_2_WEEKS_THRESHOLD,
32-
SECURITY_COUNCIL_1_WEEK_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_1_WEEK_THRESHOLD,
33-
SECURITY_COUNCIL_3_DAYS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_3_DAYS_THRESHOLD
29+
SECURITY_COUNCIL_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_THRESHOLD
3430
};
3531

3632
const testConfig = {
@@ -43,9 +39,7 @@ const testConfig = {
4339

4440
SECURITY_COUNCIL_MEMBERS_NUMBER: process.env.MISC_SECURITY_COUNCIL_MEMBERS_NUMBER,
4541
SECURITY_COUNCIL_MEMBERS: process.env.MISC_SECURITY_COUNCIL_MEMBERS,
46-
SECURITY_COUNCIL_2_WEEKS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_2_WEEKS_THRESHOLD,
47-
SECURITY_COUNCIL_1_WEEK_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_1_WEEK_THRESHOLD,
48-
SECURITY_COUNCIL_3_DAYS_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_3_DAYS_THRESHOLD
42+
SECURITY_COUNCIL_THRESHOLD: process.env.MISC_SECURITY_COUNCIL_THRESHOLD
4943
};
5044

5145
const localConfig = Object.assign({}, prodConfig);
@@ -59,9 +53,7 @@ localConfig.NEW_ADDITIONAL_ZKSYNC_ADDRESS = process.env.MISC_NEW_ADDITIONAL_ZKSY
5953

6054
localConfig.SECURITY_COUNCIL_MEMBERS_NUMBER = process.env.MISC_SECURITY_COUNCIL_MEMBERS_NUMBER;
6155
localConfig.SECURITY_COUNCIL_MEMBERS = process.env.MISC_SECURITY_COUNCIL_MEMBERS;
62-
localConfig.SECURITY_COUNCIL_2_WEEKS_THRESHOLD = process.env.MISC_SECURITY_COUNCIL_2_WEEKS_THRESHOLD;
63-
localConfig.SECURITY_COUNCIL_1_WEEK_THRESHOLD = process.env.MISC_SECURITY_COUNCIL_1_WEEK_THRESHOLD;
64-
localConfig.SECURITY_COUNCIL_3_DAYS_THRESHOLD = process.env.MISC_SECURITY_COUNCIL_3_DAYS_THRESHOLD;
56+
localConfig.SECURITY_COUNCIL_THRESHOLD = process.env.MISC_SECURITY_COUNCIL_THRESHOLD;
6557

6658
// @ts-ignore
6759
localConfig.EASY_EXODUS = process.env.CONTRACTS_TEST_EASY_EXODUS === 'true';

etc/env/base/misc.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,4 @@ listing_treasury="0xaFe6A91979021206ad79F58562Eef4204720E2A3"
5151
security_council_members_number=3
5252
security_council_members=["0x22C3F9177F485bF9a058cE4C7253Da81a59495Db","0x56dF84566a67e87808A73dA0Be61a40bda3e2AFA","0xCE004d039cD86b08274FC453bd5536E6e9F6Fac7"]
5353

54-
security_council_2_weeks_threshold=1
55-
security_council_1_week_threshold=2
56-
security_council_3_days_threshold=3
54+
security_council_threshold=2

0 commit comments

Comments
 (0)