Skip to content

Commit 8eb2748

Browse files
koloz193Raid5594
andauthored
feat: update upgrade script for v28 (#1423)
Co-authored-by: Raid Ateir <[email protected]> Co-authored-by: Raid5594 <[email protected]>
1 parent 68b0413 commit 8eb2748

28 files changed

+1329
-293
lines changed

AllContractsHashes.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,11 +985,11 @@
985985
},
986986
{
987987
"contractName": "l1-contracts/GatewayCTMDeployer",
988-
"zkBytecodeHash": "0x010003c18fe906515df3edccfffd8c2c93591a8b45aa6ec73a71a3ff194a3959",
988+
"zkBytecodeHash": "0x010003c16917108b4c68b889f841af139429fd2f226a89a33d1f68667fd11653",
989989
"zkBytecodePath": "/l1-contracts/zkout/GatewayCTMDeployer.sol/GatewayCTMDeployer.json",
990-
"evmBytecodeHash": "0xdfe9904e51738d8c47a991de1c0121ece7a000220421e89844458db3c8f3aba7",
990+
"evmBytecodeHash": "0x7e25f86cb3b2538b7a34158bc855a15293a334545d41cc8dd9e633a1d6941a92",
991991
"evmBytecodePath": "/l1-contracts/out/GatewayCTMDeployer.sol/GatewayCTMDeployer.json",
992-
"evmDeployedBytecodeHash": "0x67c6917e9b2d58d877d193fb8591d030dd02796c4970536093459fddc9f92cb8"
992+
"evmDeployedBytecodeHash": "0x1d44717c44de5bcb6e84380922619c9169c3983b3182c21f3f67da8d80bff05f"
993993
},
994994
{
995995
"contractName": "l1-contracts/GatewayTransactionFilterer",
@@ -1431,6 +1431,14 @@
14311431
"evmBytecodePath": "/l1-contracts/out/UnsafeBytes.sol/UnsafeBytes.json",
14321432
"evmDeployedBytecodeHash": "0x97b15b9cf3a912e69c3f08a5c2dbe0ec352ba2283f230b17e39c2eaa0a8244ca"
14331433
},
1434+
{
1435+
"contractName": "l1-contracts/UpgradeStageValidator",
1436+
"zkBytecodeHash": "0x010000a3e8b9be8fcea224da8557ac4f61717f0b68e01f4b1ad1f7844ac57e8f",
1437+
"zkBytecodePath": "/l1-contracts/zkout/UpgradeStageValidator.sol/UpgradeStageValidator.json",
1438+
"evmBytecodeHash": "0x0ddd2d6d39b37506a20617e093464c3c4ac3b9cabde47defe9e0e987cc4cc33c",
1439+
"evmBytecodePath": "/l1-contracts/out/UpgradeStageValidator.sol/UpgradeStageValidator.json",
1440+
"evmDeployedBytecodeHash": "0x06e43ee2956a2a8425fe9512a7440bba4fd5b2341ffd2b632f6f254f4c082743"
1441+
},
14341442
{
14351443
"contractName": "l1-contracts/UpgradeableBeacon",
14361444
"zkBytecodeHash": "0x010000674dd9c2b44a5c02408bda04df734b258d1c6ee9e07f5a6904a13d27fc",

l1-contracts/contracts/state-transition/chain-deps/GatewayCTMDeployer.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {RelayedSLDAValidator} from "../data-availability/RelayedSLDAValidator.so
1313
import {ValidiumL1DAValidator} from "../data-availability/ValidiumL1DAValidator.sol";
1414

1515
import {DualVerifier} from "../verifiers/DualVerifier.sol";
16-
import {L2VerifierFflonk} from "../verifiers/L2VerifierFflonk.sol";
17-
import {L2VerifierPlonk} from "../verifiers/L2VerifierPlonk.sol";
16+
import {L1VerifierFflonk} from "../verifiers/L1VerifierFflonk.sol";
17+
import {L1VerifierPlonk} from "../verifiers/L1VerifierPlonk.sol";
1818

1919
import {VerifierParams, IVerifier} from "../chain-interfaces/IVerifier.sol";
2020
import {TestnetVerifier} from "../verifiers/TestnetVerifier.sol";
@@ -286,9 +286,9 @@ contract GatewayCTMDeployer {
286286
bool _testnetVerifier,
287287
DeployedContracts memory _deployedContracts
288288
) internal {
289-
L2VerifierFflonk fflonkVerifier = new L2VerifierFflonk{salt: _salt}();
289+
L1VerifierFflonk fflonkVerifier = new L1VerifierFflonk{salt: _salt}();
290290
_deployedContracts.stateTransition.verifierFflonk = address(fflonkVerifier);
291-
L2VerifierPlonk verifierPlonk = new L2VerifierPlonk{salt: _salt}();
291+
L1VerifierPlonk verifierPlonk = new L1VerifierPlonk{salt: _salt}();
292292
_deployedContracts.stateTransition.verifierPlonk = address(verifierPlonk);
293293
if (_testnetVerifier) {
294294
_deployedContracts.stateTransition.verifier = address(
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.18;
3+
4+
import {IBridgehub} from "../bridgehub/IBridgehub.sol";
5+
import {IChainTypeManager} from "../state-transition/IChainTypeManager.sol";
6+
import {ZeroAddress, MigrationPaused, MigrationsNotPaused, ProtocolIdMismatch} from "../common/L1ContractErrors.sol";
7+
8+
/// @title Rules to validate that different upgrade stages have passed.
9+
/// @author Matter Labs
10+
/// @custom:security-contact [email protected]
11+
/// @notice This contract will be used by the governance to ensure that certain criteria are met before proceeding to the
12+
/// next upgrade stage.
13+
contract UpgradeStageValidator {
14+
/// @notice Address of bridgehub.
15+
IBridgehub public immutable BRIDGEHUB;
16+
17+
/// @notice Address of chain type manager.
18+
IChainTypeManager public immutable CHAIN_TYPE_MANAGER;
19+
20+
/// @notice Protocol Version of chain after the upgrade
21+
uint256 public immutable NEW_PROTOCOL_VERSION;
22+
23+
/// @dev Initializes the contract with immutable values for `BRIDGEHUB`, `CHAIN_TYPE_MANAGER`,
24+
/// and `NEW_PROTOCOL_VERSION`.
25+
/// @param chainTypeManager The address of the ChainTypeManager for the chain.
26+
/// @param newProtocolVersion The protocol version of the chain post upgrade.
27+
constructor(address chainTypeManager, uint256 newProtocolVersion) {
28+
if (chainTypeManager == address(0)) {
29+
revert ZeroAddress();
30+
}
31+
32+
CHAIN_TYPE_MANAGER = IChainTypeManager(chainTypeManager);
33+
BRIDGEHUB = IBridgehub(CHAIN_TYPE_MANAGER.BRIDGE_HUB());
34+
NEW_PROTOCOL_VERSION = newProtocolVersion;
35+
}
36+
37+
/// @notice Check if migrations are paused
38+
function checkMigrationsPaused() external {
39+
if (!BRIDGEHUB.migrationPaused()) {
40+
revert MigrationsNotPaused();
41+
}
42+
}
43+
44+
/// @notice Check if migrations are unpaused
45+
function checkMigrationsUnpaused() external {
46+
if (BRIDGEHUB.migrationPaused()) {
47+
revert MigrationPaused();
48+
}
49+
}
50+
51+
/// @notice Check if the upgrade data was sent to the CTM.
52+
function checkProtocolUpgradePresence() external {
53+
uint256 protocolVersion = CHAIN_TYPE_MANAGER.protocolVersion();
54+
55+
if (protocolVersion != NEW_PROTOCOL_VERSION) {
56+
revert ProtocolIdMismatch(NEW_PROTOCOL_VERSION, protocolVersion);
57+
}
58+
}
59+
}

l1-contracts/deploy-script-config-template/config-deploy-l1.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ owner_address = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
33
testnet_verifier = true
44
support_l2_legacy_shared_bridge_test = false
55

6+
[gateway]
7+
chain_id = 123
8+
69
[contracts]
710
governance_security_council_address = "0x0000000000000000000000000000000000000000"
811
governance_min_delay = 0

l1-contracts/deploy-scripts/AdminFunctions.s.sol

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,67 @@ contract AdminFunctions is Script {
305305
saveAndSendAdminTx(chainInfo.admin, calls, _shouldSend);
306306
}
307307

308+
struct UpgradeZKChainOnGatewayParams {
309+
uint256 l1GasPrice;
310+
uint256 oldProtocolVersion;
311+
bytes upgradeCutData;
312+
address chainDiamondProxyOnGateway;
313+
uint256 gatewayChainId;
314+
uint256 chainId;
315+
address bridgehub;
316+
address l1AssetRouterProxy;
317+
address refundRecipient;
318+
bool shouldSend;
319+
}
320+
321+
function _prepareUpgradeZKChainOnGatewayInner(UpgradeZKChainOnGatewayParams memory data) private {
322+
ChainInfoFromBridgehub memory chainInfo = Utils.chainInfoFromBridgehubAndChainId(data.bridgehub, data.chainId);
323+
Diamond.DiamondCutData memory upgradeCutData = abi.decode(data.upgradeCutData, (Diamond.DiamondCutData));
324+
325+
Call[] memory calls = Utils.prepareAdminL1L2DirectTransaction(
326+
data.l1GasPrice,
327+
abi.encodeCall(IAdmin.upgradeChainFromVersion, (data.oldProtocolVersion, upgradeCutData)),
328+
Utils.MAX_PRIORITY_TX_GAS,
329+
new bytes[](0),
330+
data.chainDiamondProxyOnGateway,
331+
0,
332+
data.gatewayChainId,
333+
data.bridgehub,
334+
data.l1AssetRouterProxy,
335+
data.refundRecipient
336+
);
337+
338+
saveAndSendAdminTx(chainInfo.admin, calls, data.shouldSend);
339+
}
340+
341+
function prepareUpgradeZKChainOnGateway(
342+
uint256 l1GasPrice,
343+
uint256 oldProtocolVersion,
344+
bytes memory upgradeCutData,
345+
address chainDiamondProxyOnGateway,
346+
uint256 gatewayChainId,
347+
uint256 chainId,
348+
address bridgehub,
349+
address l1AssetRouterProxy,
350+
address refundRecipient,
351+
bool shouldSend
352+
) public {
353+
_prepareUpgradeZKChainOnGatewayInner(
354+
UpgradeZKChainOnGatewayParams({
355+
l1GasPrice: l1GasPrice,
356+
oldProtocolVersion: oldProtocolVersion,
357+
upgradeCutData: upgradeCutData,
358+
chainDiamondProxyOnGateway: chainDiamondProxyOnGateway,
359+
gatewayChainId: gatewayChainId,
360+
chainId: chainId,
361+
bridgehub: bridgehub,
362+
l1AssetRouterProxy: l1AssetRouterProxy,
363+
refundRecipient: refundRecipient,
364+
shouldSend: shouldSend
365+
})
366+
);
367+
}
368+
308369
function grantGatewayWhitelist(
309370
address _bridgehub,
310371
uint256 _chainId,

l1-contracts/deploy-scripts/Create2FactoryUtils.s.sol

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,16 @@ abstract contract Create2FactoryUtils is Script {
103103
function deployViaCreate2AndNotify(
104104
bytes memory creationCode,
105105
bytes memory constructorParams,
106-
string memory contractName
106+
string memory contractName,
107+
bool isZKBytecode
107108
) internal returns (address deployedAddress) {
108-
deployedAddress = deployViaCreate2AndNotify(creationCode, constructorParams, contractName, contractName);
109+
deployedAddress = deployViaCreate2AndNotify(
110+
creationCode,
111+
constructorParams,
112+
contractName,
113+
contractName,
114+
isZKBytecode
115+
);
109116
}
110117

111118
/// @notice Deploys a contract via Create2 and notifies via console logs.
@@ -118,11 +125,12 @@ abstract contract Create2FactoryUtils is Script {
118125
bytes memory creationCode,
119126
bytes memory constructorParams,
120127
string memory contractName,
121-
string memory displayName
128+
string memory displayName,
129+
bool isZKBytecode
122130
) internal returns (address deployedAddress) {
123131
bytes memory bytecode = abi.encodePacked(creationCode, constructorParams);
124132
deployedAddress = deployViaCreate2(bytecode);
125-
notifyAboutDeployment(deployedAddress, contractName, constructorParams, displayName);
133+
notifyAboutDeployment(deployedAddress, contractName, constructorParams, displayName, isZKBytecode);
126134
}
127135

128136
/// @notice Deploys a contract via Create2 with a deterministic owner.
@@ -150,10 +158,11 @@ abstract contract Create2FactoryUtils is Script {
150158
bytes memory constructorParams,
151159
address owner,
152160
string memory contractName,
153-
string memory displayName
161+
string memory displayName,
162+
bool isZKBytecode
154163
) internal returns (address contractAddress) {
155164
contractAddress = create2WithDeterministicOwner(abi.encodePacked(initCode, constructorParams), owner);
156-
notifyAboutDeployment(contractAddress, contractName, constructorParams, displayName);
165+
notifyAboutDeployment(contractAddress, contractName, constructorParams, displayName, isZKBytecode);
157166
}
158167

159168
/// @notice Overload for notifyAboutDeployment that takes three arguments.
@@ -163,9 +172,10 @@ abstract contract Create2FactoryUtils is Script {
163172
function notifyAboutDeployment(
164173
address contractAddr,
165174
string memory contractName,
166-
bytes memory constructorParams
175+
bytes memory constructorParams,
176+
bool isZKBytecode
167177
) internal {
168-
notifyAboutDeployment(contractAddr, contractName, constructorParams, contractName);
178+
notifyAboutDeployment(contractAddr, contractName, constructorParams, contractName, isZKBytecode);
169179
}
170180

171181
/// @notice Notifies about a deployment by printing messages to the console.
@@ -178,7 +188,8 @@ abstract contract Create2FactoryUtils is Script {
178188
address contractAddr,
179189
string memory contractName,
180190
bytes memory constructorParams,
181-
string memory displayName
191+
string memory displayName,
192+
bool isZKBytecode
182193
) internal {
183194
string memory basicMessage = string.concat(displayName, " has been deployed at ", vm.toString(contractAddr));
184195
console.log(basicMessage);
@@ -202,6 +213,10 @@ abstract contract Create2FactoryUtils is Script {
202213
vm.toString(constructorParams)
203214
);
204215
}
216+
217+
if (isZKBytecode) {
218+
forgeMessage = string.concat(forgeMessage, " --verifier zksync");
219+
}
205220
console.log(forgeMessage);
206221
}
207222

l1-contracts/deploy-scripts/DeployGatewayTransactionFilterer.s.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ contract DeployGatewayTransactionFilterer is Script, Create2FactoryUtils {
3939
type(GatewayTransactionFilterer).creationCode,
4040
abi.encode(bridgehub, l1AssetRouter),
4141
"GatewayTransactionFilterer",
42-
"GatewayTransactionFilterer"
42+
"GatewayTransactionFilterer",
43+
false
4344
);
4445

4546
// Prepare the initialization calldata.
@@ -56,7 +57,8 @@ contract DeployGatewayTransactionFilterer is Script, Create2FactoryUtils {
5657
initData // initialization calldata to set chainAdmin as owner
5758
),
5859
"TransparentUpgradeableProxy",
59-
"GatewayTxFiltererProxy"
60+
"GatewayTxFiltererProxy",
61+
false
6062
);
6163
}
6264

0 commit comments

Comments
 (0)