Skip to content

Commit 76aa2c4

Browse files
authored
Merge pull request #1620 from matter-labs/di/zksync-os-stable
2 parents c029b98 + 339c9c2 commit 76aa2c4

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

l1-contracts/contracts/common/Config.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ bytes32 constant L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH = 0x72abee45b59e344af8a6e5202
2020

2121
bytes32 constant DEFAULT_L2_LOGS_TREE_ROOT_HASH = bytes32(0);
2222

23-
/// @dev Denotes the type of the ZKsync transaction that came from L1.
23+
/// @dev Denotes the type of the ZKsync Era transaction that came from L1.
2424
uint256 constant PRIORITY_OPERATION_L2_TX_TYPE = 255;
2525

26-
/// @dev Denotes the type of the ZKsync transaction that is used for system upgrades.
26+
/// @dev Denotes the type of the ZKsync Era transaction that is used for system upgrades.
2727
uint256 constant SYSTEM_UPGRADE_L2_TX_TYPE = 254;
2828

29+
/// @dev Denotes the type of the ZKsync OS transaction that came from L1.
30+
uint256 constant ZKSYNC_OS_PRIORITY_OPERATION_L2_TX_TYPE = 127;
31+
32+
/// @dev Denotes the type of the ZKsync OS transaction that is used for system upgrades.
33+
uint256 constant ZKSYNC_OS_SYSTEM_UPGRADE_L2_TX_TYPE = 126;
34+
2935
/// @dev The maximal allowed difference between protocol minor versions in an upgrade. The 100 gap is needed
3036
/// in case a protocol version has been tested on testnet, but then not launched on mainnet, e.g.
3137
/// due to a bug found.

l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {UncheckedMath} from "../../../common/libraries/UncheckedMath.sol";
1818
import {L2ContractHelper} from "../../../common/l2-helpers/L2ContractHelper.sol";
1919
import {AddressAliasHelper} from "../../../vendor/AddressAliasHelper.sol";
2020
import {ZKChainBase} from "./ZKChainBase.sol";
21-
import {L1_GAS_PER_PUBDATA_BYTE, MAX_NEW_FACTORY_DEPS, PRIORITY_EXPIRATION, PRIORITY_OPERATION_L2_TX_TYPE, REQUIRED_L2_GAS_PRICE_PER_PUBDATA, SERVICE_TRANSACTION_SENDER, SETTLEMENT_LAYER_RELAY_SENDER} from "../../../common/Config.sol";
21+
import {L1_GAS_PER_PUBDATA_BYTE, MAX_NEW_FACTORY_DEPS, PRIORITY_EXPIRATION, REQUIRED_L2_GAS_PRICE_PER_PUBDATA, SERVICE_TRANSACTION_SENDER, SETTLEMENT_LAYER_RELAY_SENDER} from "../../../common/Config.sol";
2222
import {L2_BOOTLOADER_ADDRESS, L2_BRIDGEHUB_ADDR} from "../../../common/l2-helpers/L2ContractAddresses.sol";
2323

2424
import {IL1AssetRouter} from "../../../bridge/asset-router/IL1AssetRouter.sol";
@@ -492,10 +492,10 @@ contract MailboxFacet is ZKChainBase, IMailboxImpl, MessageVerification {
492492

493493
function _serializeL2Transaction(
494494
WritePriorityOpParams memory _priorityOpParams
495-
) internal pure returns (L2CanonicalTransaction memory transaction) {
495+
) internal view returns (L2CanonicalTransaction memory transaction) {
496496
BridgehubL2TransactionRequest memory request = _priorityOpParams.request;
497497
transaction = L2CanonicalTransaction({
498-
txType: PRIORITY_OPERATION_L2_TX_TYPE,
498+
txType: _getPriorityTxType(),
499499
from: uint256(uint160(request.sender)),
500500
to: uint256(uint160(request.contractL2)),
501501
gasLimit: request.l2GasLimit,

l1-contracts/contracts/state-transition/chain-deps/facets/ZKChainBase.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {PriorityTree} from "../../libraries/PriorityTree.sol";
99
import {NotSettlementLayer} from "../../L1StateTransitionErrors.sol";
1010
import {Unauthorized} from "../../../common/L1ContractErrors.sol";
1111
import {IBridgehub} from "../../../bridgehub/IBridgehub.sol";
12+
import {PRIORITY_OPERATION_L2_TX_TYPE, SYSTEM_UPGRADE_L2_TX_TYPE, ZKSYNC_OS_PRIORITY_OPERATION_L2_TX_TYPE, ZKSYNC_OS_SYSTEM_UPGRADE_L2_TX_TYPE} from "../../../common/Config.sol";
1213

1314
/// @title Base contract containing functions accessible to the other facets.
1415
/// @author Matter Labs
@@ -106,4 +107,12 @@ contract ZKChainBase is ReentrancyGuard {
106107
function _getTotalPriorityTxs() internal view returns (uint256) {
107108
return s.priorityTree.getTotalPriorityTxs();
108109
}
110+
111+
function _getPriorityTxType() internal view returns (uint256) {
112+
return s.boojumOS ? ZKSYNC_OS_PRIORITY_OPERATION_L2_TX_TYPE : PRIORITY_OPERATION_L2_TX_TYPE;
113+
}
114+
115+
function _getUpgradeTxType() internal view returns (uint256) {
116+
return s.boojumOS ? ZKSYNC_OS_SYSTEM_UPGRADE_L2_TX_TYPE : SYSTEM_UPGRADE_L2_TX_TYPE;
117+
}
109118
}

l1-contracts/contracts/upgrades/BaseZkSyncUpgrade.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {ZKChainBase} from "../state-transition/chain-deps/facets/ZKChainBase.sol
88
import {IVerifier, VerifierParams} from "../state-transition/chain-interfaces/IVerifier.sol";
99
import {L2ContractHelper} from "../common/l2-helpers/L2ContractHelper.sol";
1010
import {TransactionValidator} from "../state-transition/libraries/TransactionValidator.sol";
11-
import {MAX_ALLOWED_MINOR_VERSION_DELTA, MAX_NEW_FACTORY_DEPS, SYSTEM_UPGRADE_L2_TX_TYPE} from "../common/Config.sol";
11+
import {MAX_ALLOWED_MINOR_VERSION_DELTA, MAX_NEW_FACTORY_DEPS} from "../common/Config.sol";
1212
import {L2CanonicalTransaction} from "../common/Messaging.sol";
1313
import {InvalidTxType, L2UpgradeNonceNotEqualToNewProtocolVersion, NewProtocolMajorVersionNotZero, PatchCantSetUpgradeTxn, PatchUpgradeCantSetBootloader, PatchUpgradeCantSetDefaultAccount, PatchUpgradeCantSetEvmEmulator, PreviousProtocolMajorVersionNotZero, PreviousUpgradeNotCleaned, PreviousUpgradeNotFinalized, ProtocolVersionMinorDeltaTooBig, ProtocolVersionTooSmall} from "./ZkSyncUpgradeErrors.sol";
1414
import {TimeNotReached, TooManyFactoryDeps} from "../common/L1ContractErrors.sol";
@@ -253,7 +253,7 @@ abstract contract BaseZkSyncUpgrade is ZKChainBase {
253253
return bytes32(0);
254254
}
255255

256-
if (_l2ProtocolUpgradeTx.txType != SYSTEM_UPGRADE_L2_TX_TYPE) {
256+
if (_l2ProtocolUpgradeTx.txType != _getUpgradeTxType()) {
257257
revert InvalidTxType(_l2ProtocolUpgradeTx.txType);
258258
}
259259
if (_patchOnly) {

l1-contracts/contracts/upgrades/L1GenesisUpgrade.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {IL2GenesisUpgrade} from "../state-transition/l2-deps/IL2GenesisUpgrade.s
1212
import {IL1GenesisUpgrade} from "./IL1GenesisUpgrade.sol";
1313
import {IComplexUpgrader} from "../state-transition/l2-deps/IComplexUpgrader.sol";
1414
import {L2_COMPLEX_UPGRADER_ADDR, L2_FORCE_DEPLOYER_ADDR, L2_GENESIS_UPGRADE_ADDR} from "../common/l2-helpers/L2ContractAddresses.sol";
15-
import {PRIORITY_TX_MAX_GAS_LIMIT, REQUIRED_L2_GAS_PRICE_PER_PUBDATA, SYSTEM_UPGRADE_L2_TX_TYPE} from "../common/Config.sol";
15+
import {PRIORITY_TX_MAX_GAS_LIMIT, REQUIRED_L2_GAS_PRICE_PER_PUBDATA} from "../common/Config.sol";
1616
import {SemVer} from "../common/libraries/SemVer.sol";
1717

1818
import {IBridgehub} from "../bridgehub/IBridgehub.sol";
@@ -69,7 +69,7 @@ contract L1GenesisUpgrade is IL1GenesisUpgrade, BaseZkSyncUpgradeGenesis, L1Fixe
6969
// slither-disable-next-line unused-return
7070
(, uint32 minorVersion, ) = SemVer.unpackSemVer(SafeCast.toUint96(_protocolVersion));
7171
l2ProtocolUpgradeTx = L2CanonicalTransaction({
72-
txType: SYSTEM_UPGRADE_L2_TX_TYPE,
72+
txType: _getUpgradeTxType(),
7373
from: uint256(uint160(L2_FORCE_DEPLOYER_ADDR)),
7474
to: uint256(uint160(L2_COMPLEX_UPGRADER_ADDR)),
7575
gasLimit: PRIORITY_TX_MAX_GAS_LIMIT,

l1-contracts/deploy-scripts/upgrade/DefaultEcosystemUpgrade.s.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {BridgedStandardERC20} from "contracts/bridge/BridgedStandardERC20.sol";
5151
import {AddressHasNoCode} from "../ZkSyncScriptErrors.sol";
5252
import {ICTMDeploymentTracker} from "contracts/bridgehub/ICTMDeploymentTracker.sol";
5353
import {IMessageRoot} from "contracts/bridgehub/IMessageRoot.sol";
54-
import {SYSTEM_UPGRADE_L2_TX_TYPE} from "contracts/common/Config.sol";
54+
import {SYSTEM_UPGRADE_L2_TX_TYPE, ZKSYNC_OS_SYSTEM_UPGRADE_L2_TX_TYPE} from "contracts/common/Config.sol";
5555
import {IL2ContractDeployer} from "contracts/common/interfaces/IL2ContractDeployer.sol";
5656
import {L2ContractHelper} from "contracts/common/l2-helpers/L2ContractHelper.sol";
5757
import {AddressAliasHelper} from "contracts/vendor/AddressAliasHelper.sol";
@@ -389,8 +389,9 @@ contract DefaultEcosystemUpgrade is Script, DeployL1Additional {
389389

390390
(address target, bytes memory data) = _getL2UpgradeTargetAndData(forceDeployments);
391391

392+
uint256 txType = config.isZKsyncOS ? ZKSYNC_OS_SYSTEM_UPGRADE_L2_TX_TYPE : SYSTEM_UPGRADE_L2_TX_TYPE;
392393
transaction = L2CanonicalTransaction({
393-
txType: SYSTEM_UPGRADE_L2_TX_TYPE,
394+
txType: txType,
394395
from: uint256(uint160(L2_FORCE_DEPLOYER_ADDR)),
395396
to: uint256(uint160(target)),
396397
// TODO: dont use hardcoded values

l1-contracts/deploy-scripts/upgrade/EcosystemUpgrade_v28.s.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {INativeTokenVault} from "contracts/bridge/ntv/INativeTokenVault.sol";
4646
import {BridgedStandardERC20} from "contracts/bridge/BridgedStandardERC20.sol";
4747
import {AddressHasNoCode} from "../ZkSyncScriptErrors.sol";
4848
import {ICTMDeploymentTracker} from "contracts/bridgehub/ICTMDeploymentTracker.sol";
49-
import {SYSTEM_UPGRADE_L2_TX_TYPE} from "contracts/common/Config.sol";
49+
import {SYSTEM_UPGRADE_L2_TX_TYPE, ZKSYNC_OS_SYSTEM_UPGRADE_L2_TX_TYPE} from "contracts/common/Config.sol";
5050
import {IL2ContractDeployer} from "contracts/common/interfaces/IL2ContractDeployer.sol";
5151
import {L2ContractHelper} from "contracts/common/l2-helpers/L2ContractHelper.sol";
5252
import {AddressAliasHelper} from "contracts/vendor/AddressAliasHelper.sol";
@@ -286,8 +286,9 @@ contract EcosystemUpgrade_v28 is Script, DeployL1Script {
286286

287287
bytes memory data = abi.encodeCall(IL2ContractDeployer.forceDeployOnAddresses, (forceDeployments));
288288

289+
uint256 txType = config.isZKsyncOS ? ZKSYNC_OS_SYSTEM_UPGRADE_L2_TX_TYPE : SYSTEM_UPGRADE_L2_TX_TYPE;
289290
transaction = L2CanonicalTransaction({
290-
txType: SYSTEM_UPGRADE_L2_TX_TYPE,
291+
txType: txType,
291292
from: uint256(uint160(L2_FORCE_DEPLOYER_ADDR)),
292293
to: uint256(uint160(address(L2_DEPLOYER_SYSTEM_CONTRACT_ADDR))),
293294
// TODO: dont use hardcoded values

0 commit comments

Comments
 (0)