Skip to content

Commit

Permalink
Merge pull request #1996 from matter-labs/ib-new-contracts-config
Browse files Browse the repository at this point in the history
new contracts config
  • Loading branch information
Deniallugo authored Nov 11, 2021
2 parents 6f510db + d944d29 commit b55ab5a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 40 deletions.
59 changes: 37 additions & 22 deletions contracts/contracts/AdditionalZkSync.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/Config.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion contracts/contracts/ZkSync.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 4 additions & 12 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = {
Expand All @@ -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);
Expand All @@ -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';
Expand Down
4 changes: 1 addition & 3 deletions etc/env/base/misc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b55ab5a

Please sign in to comment.