Skip to content

Commit 68b0413

Browse files
Fix default upgrade v28 (#1436)
1 parent 92f5de4 commit 68b0413

File tree

5 files changed

+44
-20
lines changed

5 files changed

+44
-20
lines changed

AllContractsHashes.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -873,11 +873,11 @@
873873
},
874874
{
875875
"contractName": "l1-contracts/DefaultUpgrade",
876-
"zkBytecodeHash": "0x010002c1b3042819252c95f9ab5f46e517fe289252fe8b50e56723eba61d4177",
876+
"zkBytecodeHash": "0x010002c78f44229569124cd4f8fd0285a6795b0c33b05f381a949488bcb64003",
877877
"zkBytecodePath": "/l1-contracts/zkout/DefaultUpgrade.sol/DefaultUpgrade.json",
878-
"evmBytecodeHash": "0xff710fc102e0fba52026517db3463f8900a76e217cdb263d9c4eafe2718158ad",
878+
"evmBytecodeHash": "0x324e4c5eadce51161b86cac68145112b4d5d4d1d08ac380b81752f2761d5a244",
879879
"evmBytecodePath": "/l1-contracts/out/DefaultUpgrade.sol/DefaultUpgrade.json",
880-
"evmDeployedBytecodeHash": "0x65a5916935cc49d65810e2e4d584dc4e8d26164972a5a0eb42cb870c48d7ffda"
880+
"evmDeployedBytecodeHash": "0xa21ee18a561100fd760f7c3a0974149bc86638da3358f5eaadecac706729a218"
881881
},
882882
{
883883
"contractName": "l1-contracts/Diamond",
@@ -985,11 +985,11 @@
985985
},
986986
{
987987
"contractName": "l1-contracts/GatewayCTMDeployer",
988-
"zkBytecodeHash": "0x010003c188a3d77697a3eb00d92b04ca871bfb40564a70949eb662b56546dc9b",
988+
"zkBytecodeHash": "0x010003c18fe906515df3edccfffd8c2c93591a8b45aa6ec73a71a3ff194a3959",
989989
"zkBytecodePath": "/l1-contracts/zkout/GatewayCTMDeployer.sol/GatewayCTMDeployer.json",
990-
"evmBytecodeHash": "0xd22197a6f68f4088e6b82ff4b4bf558245a960a426658d83029de6d7ff17006d",
990+
"evmBytecodeHash": "0xdfe9904e51738d8c47a991de1c0121ece7a000220421e89844458db3c8f3aba7",
991991
"evmBytecodePath": "/l1-contracts/out/GatewayCTMDeployer.sol/GatewayCTMDeployer.json",
992-
"evmDeployedBytecodeHash": "0xf26576e2640c73f8ba633df3b2cf56f8187d74920082bc99c86903c4ac4feb64"
992+
"evmDeployedBytecodeHash": "0x67c6917e9b2d58d877d193fb8591d030dd02796c4970536093459fddc9f92cb8"
993993
},
994994
{
995995
"contractName": "l1-contracts/GatewayTransactionFilterer",
@@ -1001,11 +1001,11 @@
10011001
},
10021002
{
10031003
"contractName": "l1-contracts/GatewayUpgrade",
1004-
"zkBytecodeHash": "0x0100057d557e2106afce1091922539b224629ea74561705eb4cdfc5e6dceb0dd",
1004+
"zkBytecodeHash": "0x010005817a46e8cfa63c9938a0eb135443b152714d42a345786ca97dbc0cc1d7",
10051005
"zkBytecodePath": "/l1-contracts/zkout/GatewayUpgrade.sol/GatewayUpgrade.json",
1006-
"evmBytecodeHash": "0x35f4e0b31357cd37d216acb6a5b0c0b5dbcabcae2893ebe4e50ad9f760b0a373",
1006+
"evmBytecodeHash": "0x33e937a9e0251664775649d0136e6fd2c24b98783b8cb689f3a991abfbbe2d9b",
10071007
"evmBytecodePath": "/l1-contracts/out/GatewayUpgrade.sol/GatewayUpgrade.json",
1008-
"evmDeployedBytecodeHash": "0x5ecfc2a8085929fce231c1a878ce58e5f1cac77b37a0f812146e01a790f278cc"
1008+
"evmDeployedBytecodeHash": "0x2e958e2fbc662cb62a6ea2c7668d538057087b051273bd10c3a94b2c29bbf8e8"
10091009
},
10101010
{
10111011
"contractName": "l1-contracts/GettersFacet",
@@ -1049,11 +1049,11 @@
10491049
},
10501050
{
10511051
"contractName": "l1-contracts/L1GenesisUpgrade",
1052-
"zkBytecodeHash": "0x010006c730a40df01dcbd82c1cd60082b97f65d57425eaad9c9b79b8278044b8",
1052+
"zkBytecodeHash": "0x010006c5c012346761c4bf8378a1a31ea0d04db69a37f369781fabcd612d9329",
10531053
"zkBytecodePath": "/l1-contracts/zkout/L1GenesisUpgrade.sol/L1GenesisUpgrade.json",
1054-
"evmBytecodeHash": "0x50f0bc005dc9069984e00d1b908bd43a1502c13877c87c39ea76909e4d597595",
1054+
"evmBytecodeHash": "0x9d4ad5ce116afcb9e7378d64bcd71087b113e34d82df42fb1a52bdb9b077a6ed",
10551055
"evmBytecodePath": "/l1-contracts/out/L1GenesisUpgrade.sol/L1GenesisUpgrade.json",
1056-
"evmDeployedBytecodeHash": "0x071205d074506ef8f14ea32bcc39534ed9bd2fc3fa4eb30a9586a4235a0169e6"
1056+
"evmDeployedBytecodeHash": "0x72230a977e3b0380374a4db9bc7973129d4fab56cbc1042596aac42476966aaf"
10571057
},
10581058
{
10591059
"contractName": "l1-contracts/L1NativeTokenVault",

l1-contracts/contracts/dev-contracts/test/CustomUpgradeTest.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ contract CustomUpgradeTest is BaseZkSyncUpgrade {
2828
/// @notice The main function that will be delegate-called by the chain.
2929
/// @param _proposedUpgrade The upgrade to be executed.
3030
function upgrade(ProposedUpgrade calldata _proposedUpgrade) public override returns (bytes32) {
31-
(uint32 newMinorVersion, bool isPatchOnly) = _setNewProtocolVersion(_proposedUpgrade.newProtocolVersion);
31+
(uint32 newMinorVersion, bool isPatchOnly) = _setNewProtocolVersion(_proposedUpgrade.newProtocolVersion, true);
3232
_upgradeL1Contract(_proposedUpgrade.l1ContractsUpgradeCalldata);
3333
_upgradeVerifier(_proposedUpgrade.verifier, _proposedUpgrade.verifierParams);
3434
_setBaseSystemContracts(

l1-contracts/contracts/upgrades/BaseZkSyncUpgrade.sol

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ abstract contract BaseZkSyncUpgrade is ZKChainBase {
7171
/// @dev This is a virtual function and should be overridden by custom upgrade implementations.
7272
/// @param _proposedUpgrade The upgrade to be executed.
7373
/// @return txHash The hash of the L2 system contract upgrade transaction.
74+
/// @dev Note, that the logic of the upgrade differs depending on whether the upgrade happens on the settlement layer
75+
/// or not. If the upgrade happens on the instance of the diamond proxy that is not on the settlement layer, we
76+
/// do not validate any variants about the upgrade transaction or generally don't do anything related to the upgrade transaction.
77+
/// Updates on diamond proxy located not on settlement layer are needed to ensure that the logic of the contracts remains compatible with
78+
/// the diamond proxy on the settlement layer and so are still needed to update facets, verifiers and so on.
7479
function upgrade(ProposedUpgrade calldata _proposedUpgrade) public virtual returns (bytes32 txHash) {
7580
// Note that due to commitment delay, the timestamp of the L2 upgrade batch may be earlier than the timestamp
7681
// of the L1 block at which the upgrade occurred. This means that using timestamp as a signifier of "upgraded"
@@ -79,8 +84,13 @@ abstract contract BaseZkSyncUpgrade is ZKChainBase {
7984
if (block.timestamp < _proposedUpgrade.upgradeTimestamp) {
8085
revert TimeNotReached(_proposedUpgrade.upgradeTimestamp, block.timestamp);
8186
}
87+
// If settlement layer is 0, it means that this diamond proxy is located on the settlement layer.
88+
bool isOnSettlementLayer = s.settlementLayer == address(0);
8289

83-
(uint32 newMinorVersion, bool isPatchOnly) = _setNewProtocolVersion(_proposedUpgrade.newProtocolVersion);
90+
(uint32 newMinorVersion, bool isPatchOnly) = _setNewProtocolVersion(
91+
_proposedUpgrade.newProtocolVersion,
92+
isOnSettlementLayer
93+
);
8494
_upgradeL1Contract(_proposedUpgrade.l1ContractsUpgradeCalldata);
8595
_upgradeVerifier(_proposedUpgrade.verifier, _proposedUpgrade.verifierParams);
8696
_setBaseSystemContracts(
@@ -90,7 +100,11 @@ abstract contract BaseZkSyncUpgrade is ZKChainBase {
90100
isPatchOnly
91101
);
92102

93-
txHash = _setL2SystemContractUpgrade(_proposedUpgrade.l2ProtocolUpgradeTx, newMinorVersion, isPatchOnly);
103+
// The upgrades that happen not on settlement layers are to update the logic of the facets
104+
// only and do not include the upgrade transaction.
105+
if (isOnSettlementLayer) {
106+
txHash = _setL2SystemContractUpgrade(_proposedUpgrade.l2ProtocolUpgradeTx, newMinorVersion, isPatchOnly);
107+
}
94108

95109
_postUpgrade(_proposedUpgrade.postUpgradeCalldata);
96110

@@ -286,8 +300,10 @@ abstract contract BaseZkSyncUpgrade is ZKChainBase {
286300

287301
/// @notice Changes the protocol version
288302
/// @param _newProtocolVersion The new protocol version
303+
/// @param _isOnSettlementLayer Whether the chain settles on the current settlement layer.
289304
function _setNewProtocolVersion(
290-
uint256 _newProtocolVersion
305+
uint256 _newProtocolVersion,
306+
bool _isOnSettlementLayer
291307
) internal virtual returns (uint32 newMinorVersion, bool patchOnly) {
292308
uint256 previousProtocolVersion = s.protocolVersion;
293309
if (_newProtocolVersion <= previousProtocolVersion) {
@@ -324,7 +340,9 @@ abstract contract BaseZkSyncUpgrade is ZKChainBase {
324340
// If the minor version changes also, we need to ensure that the previous upgrade has been finalized.
325341
// In case the minor version does not change, we permit to keep the old upgrade transaction in the system, but it
326342
// must be ensured in the other parts of the upgrade that the upgrade transaction is not overridden.
327-
if (!patchOnly) {
343+
// Note, that we check for the presence of the protocol upgrade transaction only when the current diamond proxy
344+
// belongs to the settlement layer.
345+
if (!patchOnly && _isOnSettlementLayer) {
328346
// If the previous upgrade had an L2 system upgrade transaction, we require that it is finalized.
329347
// Note it is important to keep this check, as otherwise ZK chains might skip upgrades by overwriting
330348
if (s.l2SystemContractsUpgradeTxHash != bytes32(0)) {

l1-contracts/contracts/upgrades/BaseZkSyncUpgradeGenesis.sol

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pragma solidity 0.8.28;
55
import {SafeCast} from "@openzeppelin/contracts-v4/utils/math/SafeCast.sol";
66

77
import {BaseZkSyncUpgrade} from "./BaseZkSyncUpgrade.sol";
8-
import {ProtocolVersionTooSmall, ProtocolVersionDeltaTooLarge, PreviousUpgradeNotFinalized, PreviousUpgradeBatchNotCleared, ProtocolMajorVersionNotZero} from "./ZkSyncUpgradeErrors.sol";
8+
import {ProtocolVersionTooSmall, ProtocolVersionDeltaTooLarge, PreviousUpgradeNotFinalized, PreviousUpgradeBatchNotCleared, ProtocolMajorVersionNotZero, GenesisUpgradeExpectedOnSettlementLayer} from "./ZkSyncUpgradeErrors.sol";
99
import {MAX_ALLOWED_MINOR_VERSION_DELTA} from "../common/Config.sol";
1010
import {SemVer} from "../common/libraries/SemVer.sol";
1111

@@ -16,7 +16,8 @@ abstract contract BaseZkSyncUpgradeGenesis is BaseZkSyncUpgrade {
1616
/// @notice Changes the protocol version
1717
/// @param _newProtocolVersion The new protocol version
1818
function _setNewProtocolVersion(
19-
uint256 _newProtocolVersion
19+
uint256 _newProtocolVersion,
20+
bool _isOnSettlementLayer
2021
) internal override returns (uint32 newMinorVersion, bool patchOnly) {
2122
uint256 previousProtocolVersion = s.protocolVersion;
2223
if (
@@ -53,6 +54,10 @@ abstract contract BaseZkSyncUpgradeGenesis is BaseZkSyncUpgrade {
5354
revert ProtocolVersionDeltaTooLarge(minorDelta, MAX_ALLOWED_MINOR_VERSION_DELTA);
5455
}
5556

57+
if (!_isOnSettlementLayer) {
58+
revert GenesisUpgradeExpectedOnSettlementLayer();
59+
}
60+
5661
// If the minor version changes also, we need to ensure that the previous upgrade has been finalized.
5762
// In case the minor version does not change, we permit to keep the old upgrade transaction in the system, but it
5863
// must be ensured in the other parts of the upgrade that the upgrade transaction is not overridden.

l1-contracts/contracts/upgrades/ZkSyncUpgradeErrors.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ error PreviousUpgradeNotFinalized(bytes32 txHash);
3232
error PreviousUpgradeNotCleaned();
3333
// 0x5cb29523
3434
error InvalidTxType(uint256 txType);
35-
35+
// 0xb334f781
36+
error GenesisUpgradeExpectedOnSettlementLayer();
3637
// 0x388b6f68
3738
error GatewayUpgradeFailed();

0 commit comments

Comments
 (0)