@@ -71,6 +71,11 @@ abstract contract BaseZkSyncUpgrade is ZKChainBase {
71
71
/// @dev This is a virtual function and should be overridden by custom upgrade implementations.
72
72
/// @param _proposedUpgrade The upgrade to be executed.
73
73
/// @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.
74
79
function upgrade (ProposedUpgrade calldata _proposedUpgrade ) public virtual returns (bytes32 txHash ) {
75
80
// Note that due to commitment delay, the timestamp of the L2 upgrade batch may be earlier than the timestamp
76
81
// 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 {
79
84
if (block .timestamp < _proposedUpgrade.upgradeTimestamp) {
80
85
revert TimeNotReached (_proposedUpgrade.upgradeTimestamp, block .timestamp );
81
86
}
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 );
82
89
83
- (uint32 newMinorVersion , bool isPatchOnly ) = _setNewProtocolVersion (_proposedUpgrade.newProtocolVersion);
90
+ (uint32 newMinorVersion , bool isPatchOnly ) = _setNewProtocolVersion (
91
+ _proposedUpgrade.newProtocolVersion,
92
+ isOnSettlementLayer
93
+ );
84
94
_upgradeL1Contract (_proposedUpgrade.l1ContractsUpgradeCalldata);
85
95
_upgradeVerifier (_proposedUpgrade.verifier, _proposedUpgrade.verifierParams);
86
96
_setBaseSystemContracts (
@@ -90,7 +100,11 @@ abstract contract BaseZkSyncUpgrade is ZKChainBase {
90
100
isPatchOnly
91
101
);
92
102
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
+ }
94
108
95
109
_postUpgrade (_proposedUpgrade.postUpgradeCalldata);
96
110
@@ -286,8 +300,10 @@ abstract contract BaseZkSyncUpgrade is ZKChainBase {
286
300
287
301
/// @notice Changes the protocol version
288
302
/// @param _newProtocolVersion The new protocol version
303
+ /// @param _isOnSettlementLayer Whether the chain settles on the current settlement layer.
289
304
function _setNewProtocolVersion (
290
- uint256 _newProtocolVersion
305
+ uint256 _newProtocolVersion ,
306
+ bool _isOnSettlementLayer
291
307
) internal virtual returns (uint32 newMinorVersion , bool patchOnly ) {
292
308
uint256 previousProtocolVersion = s.protocolVersion;
293
309
if (_newProtocolVersion <= previousProtocolVersion) {
@@ -324,7 +340,9 @@ abstract contract BaseZkSyncUpgrade is ZKChainBase {
324
340
// If the minor version changes also, we need to ensure that the previous upgrade has been finalized.
325
341
// In case the minor version does not change, we permit to keep the old upgrade transaction in the system, but it
326
342
// 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) {
328
346
// If the previous upgrade had an L2 system upgrade transaction, we require that it is finalized.
329
347
// Note it is important to keep this check, as otherwise ZK chains might skip upgrades by overwriting
330
348
if (s.l2SystemContractsUpgradeTxHash != bytes32 (0 )) {
0 commit comments