diff --git a/l1-contracts/contracts/common/Config.sol b/l1-contracts/contracts/common/Config.sol index c0e05f1fc..e6e3118bb 100644 --- a/l1-contracts/contracts/common/Config.sol +++ b/l1-contracts/contracts/common/Config.sol @@ -108,3 +108,6 @@ bytes32 constant TWO_BRIDGES_MAGIC_VALUE = bytes32(uint256(keccak256("TWO_BRIDGE /// @dev https://eips.ethereum.org/EIPS/eip-1352 address constant BRIDGEHUB_MIN_SECOND_BRIDGE_ADDRESS = address(uint160(type(uint16).max)); + +/// @dev Used as the `msg.sender` for system service transactions. +address constant SERVICE_TRANSACTION_SENDER = address(uint160(0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF)); diff --git a/l1-contracts/contracts/common/interfaces/IL2ContractDeployer.sol b/l1-contracts/contracts/common/interfaces/IL2ContractDeployer.sol index 3d5b597df..7aa5c1cc0 100644 --- a/l1-contracts/contracts/common/interfaces/IL2ContractDeployer.sol +++ b/l1-contracts/contracts/common/interfaces/IL2ContractDeployer.sol @@ -2,6 +2,14 @@ // We use a floating point pragma here so it can be used within other projects that interact with the ZKsync ecosystem without using our exact pragma version. pragma solidity ^0.8.21; +/// @notice Defines what types of bytecode are allowed to be deployed on this chain +/// - `EraVm` means that only native contracts can be deployed +/// - `EraVmAndEVM` means that native contracts and EVM contracts can be deployed +enum AllowedBytecodeTypes { + EraVm, + EraVmAndEVM +} + /** * @author Matter Labs * @notice System smart contract that is responsible for deploying other smart contracts on a ZKsync hyperchain. @@ -29,4 +37,8 @@ interface IL2ContractDeployer { /// @param _bytecodeHash The correctly formatted hash of the bytecode. /// @param _input The constructor calldata. function create2(bytes32 _salt, bytes32 _bytecodeHash, bytes calldata _input) external; + + /// @notice Changes what types of bytecodes are allowed to be deployed on the chain. + /// @param newAllowedBytecodeTypes The new allowed bytecode types mode. + function setAllowedBytecodeTypesToDeploy(AllowedBytecodeTypes newAllowedBytecodeTypes) external; } diff --git a/l1-contracts/contracts/governance/ChainAdmin.sol b/l1-contracts/contracts/governance/ChainAdmin.sol index 4d9ff858f..c322477a7 100644 --- a/l1-contracts/contracts/governance/ChainAdmin.sol +++ b/l1-contracts/contracts/governance/ChainAdmin.sol @@ -48,6 +48,13 @@ contract ChainAdmin is IChainAdmin, Ownable2Step { emit UpdateUpgradeTimestamp(_protocolVersion, _upgradeTimestamp); } + /// @notice Enable EVM emulation on chain. + /// @param _chainContract The chain contract address where the EVM emulator will be enabled. + function enableEvmEmulator(IAdmin _chainContract) external onlyOwner returns (bytes32 canonicalTxHash) { + canonicalTxHash = _chainContract.allowEvmEmulation(); + emit EnableEvmEmulator(); + } + /// @notice Execute multiple calls as part of contract administration. /// @param _calls Array of Call structures defining target, value, and data for each call. /// @param _requireSuccess If true, reverts transaction on any call failure. diff --git a/l1-contracts/contracts/governance/IChainAdmin.sol b/l1-contracts/contracts/governance/IChainAdmin.sol index d5d8f117c..5bdd15ac9 100644 --- a/l1-contracts/contracts/governance/IChainAdmin.sol +++ b/l1-contracts/contracts/governance/IChainAdmin.sol @@ -27,6 +27,9 @@ interface IChainAdmin { /// @notice Emitted when the new token multiplier address is set. event NewTokenMultiplierSetter(address _oldTokenMultiplierSetter, address _newTokenMultiplierSetter); + /// @notice The EVM emulator has been enabled + event EnableEvmEmulator(); + function setTokenMultiplierSetter(address _tokenMultiplierSetter) external; function setUpgradeTimestamp(uint256 _protocolVersion, uint256 _upgradeTimestamp) external; @@ -34,4 +37,6 @@ interface IChainAdmin { function multicall(Call[] calldata _calls, bool _requireSuccess) external payable; function setTokenMultiplier(IAdmin _chainContract, uint128 _nominator, uint128 _denominator) external; + + function enableEvmEmulator(IAdmin _chainContract) external returns (bytes32 canonicalTxHash); } diff --git a/l1-contracts/contracts/state-transition/StateTransitionManager.sol b/l1-contracts/contracts/state-transition/StateTransitionManager.sol index f610bad78..a14298f2a 100644 --- a/l1-contracts/contracts/state-transition/StateTransitionManager.sol +++ b/l1-contracts/contracts/state-transition/StateTransitionManager.sol @@ -13,7 +13,6 @@ import {IDiamondInit} from "./chain-interfaces/IDiamondInit.sol"; import {IExecutor} from "./chain-interfaces/IExecutor.sol"; import {IStateTransitionManager, StateTransitionManagerInitializeData, ChainCreationParams} from "./IStateTransitionManager.sol"; import {ISystemContext} from "./l2-deps/ISystemContext.sol"; -import {AllowedBytecodeTypes} from "./l2-deps/AllowedBytecodeTypes.sol"; import {IZkSyncHyperchain} from "./chain-interfaces/IZkSyncHyperchain.sol"; import {FeeParams} from "./chain-deps/ZkSyncHyperchainStorage.sol"; import {L2_SYSTEM_CONTEXT_SYSTEM_CONTRACT_ADDR, L2_FORCE_DEPLOYER_ADDR} from "../common/L2ContractAddresses.sol"; @@ -323,15 +322,8 @@ contract StateTransitionManager is IStateTransitionManager, ReentrancyGuard, Own /// registration /// @dev we have to set the chainId at genesis, as blockhashzero is the same for all chains with the same chainId - function _setChainConfigurationUpgrade( - uint256 _chainId, - AllowedBytecodeTypes _allowedBytecodeTypesMode, - address _chainContract - ) internal { - bytes memory systemContextCalldata = abi.encodeCall( - ISystemContext.setChainConfiguration, - (_chainId, uint256(_allowedBytecodeTypesMode)) - ); + function _setChainIdUpgrade(uint256 _chainId, address _chainContract) internal { + bytes memory systemContextCalldata = abi.encodeCall(ISystemContext.setChainId, (_chainId)); uint256[] memory uintEmptyArray; bytes[] memory bytesEmptyArray; @@ -404,13 +396,13 @@ contract StateTransitionManager is IStateTransitionManager, ReentrancyGuard, Own /// @param _baseToken the base token address used to pay for gas fees /// @param _sharedBridge the shared bridge address, used as base token bridge /// @param _admin the chain's admin address - /// @param _inputData the input data for chain creation + /// @param _diamondCut the diamond cut data that initializes the chains Diamond Proxy function createNewChain( uint256 _chainId, address _baseToken, address _sharedBridge, address _admin, - bytes calldata _inputData + bytes calldata _diamondCut ) external onlyBridgehub { if (getHyperchain(_chainId) != address(0)) { // Hyperchain already registered @@ -418,18 +410,12 @@ contract StateTransitionManager is IStateTransitionManager, ReentrancyGuard, Own } // check not registered - (bytes memory _diamondCut, AllowedBytecodeTypes allowedBytecodeTypesMode) = abi.decode( - _inputData, - (bytes, AllowedBytecodeTypes) - ); Diamond.DiamondCutData memory diamondCut = abi.decode(_diamondCut, (Diamond.DiamondCutData)); - { - // check input - bytes32 cutHashInput = keccak256(_diamondCut); - if (cutHashInput != initialCutHash) { - revert HashMismatch(initialCutHash, cutHashInput); - } + // check input + bytes32 cutHashInput = keccak256(_diamondCut); + if (cutHashInput != initialCutHash) { + revert HashMismatch(initialCutHash, cutHashInput); } // construct init data @@ -459,8 +445,8 @@ contract StateTransitionManager is IStateTransitionManager, ReentrancyGuard, Own _registerNewHyperchain(_chainId, hyperchainAddress); - // set chain configuration: chainId in VM and allowed bytecode types - _setChainConfigurationUpgrade(_chainId, allowedBytecodeTypesMode, hyperchainAddress); + // set chainId in VM + _setChainIdUpgrade(_chainId, hyperchainAddress); } /// @dev This internal function is used to register a new hyperchain in the system. diff --git a/l1-contracts/contracts/state-transition/chain-deps/facets/Admin.sol b/l1-contracts/contracts/state-transition/chain-deps/facets/Admin.sol index 9f98c00ec..479f4bbdb 100644 --- a/l1-contracts/contracts/state-transition/chain-deps/facets/Admin.sol +++ b/l1-contracts/contracts/state-transition/chain-deps/facets/Admin.sol @@ -3,12 +3,15 @@ pragma solidity 0.8.24; import {IAdmin} from "../../chain-interfaces/IAdmin.sol"; +import {IMailbox} from "../../chain-interfaces/IMailbox.sol"; import {Diamond} from "../../libraries/Diamond.sol"; import {MAX_GAS_PER_TRANSACTION} from "../../../common/Config.sol"; import {FeeParams, PubdataPricingMode} from "../ZkSyncHyperchainStorage.sol"; import {ZkSyncHyperchainBase} from "./ZkSyncHyperchainBase.sol"; import {IStateTransitionManager} from "../../IStateTransitionManager.sol"; import {Unauthorized, TooMuchGas, PriorityTxPubdataExceedsMaxPubDataPerBatch, InvalidPubdataPricingMode, ProtocolIdMismatch, ChainAlreadyLive, HashMismatch, ProtocolIdNotGreater, DenominatorIsZero, DiamondAlreadyFrozen, DiamondNotFrozen} from "../../../common/L1ContractErrors.sol"; +import {L2_DEPLOYER_SYSTEM_CONTRACT_ADDR} from "../../../common/L2ContractAddresses.sol"; +import {IL2ContractDeployer, AllowedBytecodeTypes} from "../../../common/interfaces/IL2ContractDeployer.sol"; // While formally the following import is not used, it is needed to inherit documentation from it import {IZkSyncHyperchainBase} from "../../chain-interfaces/IZkSyncHyperchainBase.sol"; @@ -119,6 +122,15 @@ contract AdminFacet is ZkSyncHyperchainBase, IAdmin { emit NewTransactionFilterer(oldTransactionFilterer, _transactionFilterer); } + /// @inheritdoc IAdmin + function allowEvmEmulation() external onlyAdmin returns (bytes32 canonicalTxHash) { + canonicalTxHash = IMailbox(address(this)).requestL2ServiceTransaction( + L2_DEPLOYER_SYSTEM_CONTRACT_ADDR, + abi.encodeCall(IL2ContractDeployer.setAllowedBytecodeTypesToDeploy, AllowedBytecodeTypes.EraVmAndEVM) + ); + emit EnableEvmEmulator(); + } + /*////////////////////////////////////////////////////////////// UPGRADE EXECUTION //////////////////////////////////////////////////////////////*/ diff --git a/l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol b/l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol index 43f6b04e7..771c66176 100644 --- a/l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol +++ b/l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol @@ -15,7 +15,7 @@ import {UncheckedMath} from "../../../common/libraries/UncheckedMath.sol"; import {L2ContractHelper} from "../../../common/libraries/L2ContractHelper.sol"; import {AddressAliasHelper} from "../../../vendor/AddressAliasHelper.sol"; import {ZkSyncHyperchainBase} from "./ZkSyncHyperchainBase.sol"; -import {REQUIRED_L2_GAS_PRICE_PER_PUBDATA, ETH_TOKEN_ADDRESS, L1_GAS_PER_PUBDATA_BYTE, L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH, PRIORITY_OPERATION_L2_TX_TYPE, PRIORITY_EXPIRATION, MAX_NEW_FACTORY_DEPS} from "../../../common/Config.sol"; +import {REQUIRED_L2_GAS_PRICE_PER_PUBDATA, ETH_TOKEN_ADDRESS, L1_GAS_PER_PUBDATA_BYTE, L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH, PRIORITY_OPERATION_L2_TX_TYPE, PRIORITY_EXPIRATION, MAX_NEW_FACTORY_DEPS, SERVICE_TRANSACTION_SENDER} from "../../../common/Config.sol"; import {L2_BOOTLOADER_ADDRESS, L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR} from "../../../common/L2ContractAddresses.sol"; import {IL1SharedBridge} from "../../../bridge/interfaces/IL1SharedBridge.sol"; @@ -248,6 +248,28 @@ contract MailboxFacet is ZkSyncHyperchainBase, IMailbox { ); } + /// @inheritdoc IMailbox + function requestL2ServiceTransaction( + address _contractL2, + bytes calldata _l2Calldata + ) external onlySelf returns (bytes32 canonicalTxHash) { + canonicalTxHash = _requestL2TransactionFree( + BridgehubL2TransactionRequest({ + sender: SERVICE_TRANSACTION_SENDER, + contractL2: _contractL2, + mintValue: 0, + l2Value: 0, + // Very large amount + l2GasLimit: 72_000_000, + l2Calldata: _l2Calldata, + l2GasPerPubdataByteLimit: REQUIRED_L2_GAS_PRICE_PER_PUBDATA, + factoryDeps: new bytes[](0), + // Tx is free, so no refund recipient needed + refundRecipient: address(0) + }) + ); + } + function _requestL2TransactionSender( BridgehubL2TransactionRequest memory _request ) internal nonReentrant returns (bytes32 canonicalTxHash) { @@ -313,6 +335,19 @@ contract MailboxFacet is ZkSyncHyperchainBase, IMailbox { canonicalTxHash = _writePriorityOp(_params); } + function _requestL2TransactionFree( + BridgehubL2TransactionRequest memory _request + ) internal nonReentrant returns (bytes32 canonicalTxHash) { + WritePriorityOpParams memory params = WritePriorityOpParams({ + request: _request, + txId: s.priorityQueue.getTotalPriorityTxs(), + l2GasPrice: 0, + expirationTimestamp: uint64(block.timestamp + PRIORITY_EXPIRATION) + }); + + canonicalTxHash = _writePriorityOp(params); + } + function _serializeL2Transaction( WritePriorityOpParams memory _priorityOpParams ) internal pure returns (L2CanonicalTransaction memory transaction) { diff --git a/l1-contracts/contracts/state-transition/chain-deps/facets/ZkSyncHyperchainBase.sol b/l1-contracts/contracts/state-transition/chain-deps/facets/ZkSyncHyperchainBase.sol index 0910fcab3..8d6bbb4ce 100644 --- a/l1-contracts/contracts/state-transition/chain-deps/facets/ZkSyncHyperchainBase.sol +++ b/l1-contracts/contracts/state-transition/chain-deps/facets/ZkSyncHyperchainBase.sol @@ -64,4 +64,11 @@ contract ZkSyncHyperchainBase is ReentrancyGuard { } _; } + + modifier onlySelf() { + if (msg.sender != address(this)) { + revert Unauthorized(msg.sender); + } + _; + } } diff --git a/l1-contracts/contracts/state-transition/chain-interfaces/IAdmin.sol b/l1-contracts/contracts/state-transition/chain-interfaces/IAdmin.sol index 643c6114d..6771c349f 100644 --- a/l1-contracts/contracts/state-transition/chain-interfaces/IAdmin.sol +++ b/l1-contracts/contracts/state-transition/chain-interfaces/IAdmin.sol @@ -46,6 +46,9 @@ interface IAdmin is IZkSyncHyperchainBase { /// @notice Set the transaction filterer function setTransactionFilterer(address _transactionFilterer) external; + /// @notice Allow EVM emulation on chain + function allowEvmEmulation() external returns (bytes32 canonicalTxHash); + /// @notice Perform the upgrade from the current protocol version with the corresponding upgrade data /// @param _protocolVersion The current protocol version from which upgrade is executed /// @param _cutData The diamond cut parameters that is executed in the upgrade @@ -105,4 +108,7 @@ interface IAdmin is IZkSyncHyperchainBase { /// @notice Emitted when the contract is unfrozen. event Unfreeze(); + + /// @notice The EVM emulator has been enabled + event EnableEvmEmulator(); } diff --git a/l1-contracts/contracts/state-transition/chain-interfaces/IMailbox.sol b/l1-contracts/contracts/state-transition/chain-interfaces/IMailbox.sol index 9daffebcf..563fcb12e 100644 --- a/l1-contracts/contracts/state-transition/chain-interfaces/IMailbox.sol +++ b/l1-contracts/contracts/state-transition/chain-interfaces/IMailbox.sol @@ -95,6 +95,15 @@ interface IMailbox is IZkSyncHyperchainBase { address _refundRecipient ) external payable returns (bytes32 canonicalTxHash); + /// @notice Request execution of service L2 transaction from L1. + /// @dev Used for chain configuration. Can be called only by DiamondProxy itself. + /// @param _contractL2 The L2 receiver address + /// @param _l2Calldata The input of the L2 transaction + function requestL2ServiceTransaction( + address _contractL2, + bytes calldata _l2Calldata + ) external returns (bytes32 canonicalTxHash); + function bridgehubRequestL2Transaction( BridgehubL2TransactionRequest calldata _request ) external returns (bytes32 canonicalTxHash); diff --git a/l1-contracts/contracts/state-transition/l2-deps/AllowedBytecodeTypes.sol b/l1-contracts/contracts/state-transition/l2-deps/AllowedBytecodeTypes.sol deleted file mode 100644 index 2d6a3a136..000000000 --- a/l1-contracts/contracts/state-transition/l2-deps/AllowedBytecodeTypes.sol +++ /dev/null @@ -1,11 +0,0 @@ -// SPDX-License-Identifier: MIT -// We use a floating point pragma here so it can be used within other projects that interact with the zkSync ecosystem without using our exact pragma version. -pragma solidity ^0.8.21; - -/// @notice Defines what types of bytecode are allowed to be deployed on this chain -/// - `EraVm` means that only native contracts can be deployed -/// - `EraVmAndEVM` means that native contracts and EVM contracts can be deployed -enum AllowedBytecodeTypes { - EraVm, - EraVmAndEVM -} diff --git a/l1-contracts/contracts/state-transition/l2-deps/ISystemContext.sol b/l1-contracts/contracts/state-transition/l2-deps/ISystemContext.sol index cdc1140e7..d3244b74b 100644 --- a/l1-contracts/contracts/state-transition/l2-deps/ISystemContext.sol +++ b/l1-contracts/contracts/state-transition/l2-deps/ISystemContext.sol @@ -3,8 +3,5 @@ pragma solidity ^0.8.21; interface ISystemContext { - /// @notice Set the chain configuration. - /// @param _newChainId The chainId - /// @param _newAllowedBytecodeTypes The new allowed bytecode types mode. - function setChainConfiguration(uint256 _newChainId, uint256 _newAllowedBytecodeTypes) external; + function setChainId(uint256 _newChainId) external; } diff --git a/l1-contracts/deploy-scripts/EnableEvmEmulator.s.sol b/l1-contracts/deploy-scripts/EnableEvmEmulator.s.sol new file mode 100644 index 000000000..5e9d466ce --- /dev/null +++ b/l1-contracts/deploy-scripts/EnableEvmEmulator.s.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.21; + +import {Script} from "forge-std/Script.sol"; + +import {IZkSyncHyperchain} from "contracts/state-transition/chain-interfaces/IZkSyncHyperchain.sol"; +import {IChainAdmin} from "contracts/governance/IChainAdmin.sol"; + +contract EnableEvmEmulator is Script { + // This function should be called by the owner to update token multiplier setter role + function chainAllowEvmEmulation(address chainAdmin, address target) public { + IChainAdmin admin = IChainAdmin(chainAdmin); + + vm.startBroadcast(); + admin.enableEvmEmulator(IZkSyncHyperchain(target)); + vm.stopBroadcast(); + } +} diff --git a/l1-contracts/deploy-scripts/PrepareZKChainRegistrationCalldata.s.sol b/l1-contracts/deploy-scripts/PrepareZKChainRegistrationCalldata.s.sol index a965704b6..c2d48f322 100644 --- a/l1-contracts/deploy-scripts/PrepareZKChainRegistrationCalldata.s.sol +++ b/l1-contracts/deploy-scripts/PrepareZKChainRegistrationCalldata.s.sol @@ -12,9 +12,7 @@ import {L2ContractHelper} from "contracts/common/libraries/L2ContractHelper.sol" import {AddressAliasHelper} from "contracts/vendor/AddressAliasHelper.sol"; import {L1SharedBridge} from "contracts/bridge/L1SharedBridge.sol"; import {IStateTransitionManager} from "contracts/state-transition/IStateTransitionManager.sol"; -import {AllowedBytecodeTypes} from "contracts/state-transition/l2-deps/AllowedBytecodeTypes.sol"; import {IGovernance} from "contracts/governance/IGovernance.sol"; -import {IChainAdmin} from "contracts/governance/IChainAdmin.sol"; import {Call} from "contracts/governance/Common.sol"; import {Utils} from "./Utils.sol"; @@ -276,12 +274,6 @@ contract PrepareZKChainRegistrationCalldataScript is Script { function prepareRegisterHyperchainCall() internal view returns (Call memory) { Bridgehub bridgehub = Bridgehub(ecosystem.bridgehub); - AllowedBytecodeTypes allowedBytecodeTypesMode = config.allowEvmEmulator - ? AllowedBytecodeTypes.EraVmAndEVM - : AllowedBytecodeTypes.EraVm; - - bytes memory diamondCutEncoded = abi.encode(config.diamondCutData); - bytes memory data = abi.encodeCall( bridgehub.createNewChain, ( @@ -290,7 +282,7 @@ contract PrepareZKChainRegistrationCalldataScript is Script { config.baseToken, config.bridgehubCreateNewChainSalt, config.chainAdmin, - abi.encode(diamondCutEncoded, allowedBytecodeTypesMode) + config.diamondCutData ) ); diff --git a/l1-contracts/deploy-scripts/RegisterHyperchain.s.sol b/l1-contracts/deploy-scripts/RegisterHyperchain.s.sol index 7dfa127d2..9a8c5f781 100644 --- a/l1-contracts/deploy-scripts/RegisterHyperchain.s.sol +++ b/l1-contracts/deploy-scripts/RegisterHyperchain.s.sol @@ -9,7 +9,6 @@ import {stdToml} from "forge-std/StdToml.sol"; import {Bridgehub} from "contracts/bridgehub/Bridgehub.sol"; import {IZkSyncHyperchain} from "contracts/state-transition/chain-interfaces/IZkSyncHyperchain.sol"; -import {AllowedBytecodeTypes} from "contracts/state-transition/l2-deps/AllowedBytecodeTypes.sol"; import {ValidatorTimelock} from "contracts/state-transition/ValidatorTimelock.sol"; import {Governance} from "contracts/governance/Governance.sol"; import {ChainAdmin} from "contracts/governance/ChainAdmin.sol"; @@ -157,14 +156,7 @@ contract RegisterHyperchainScript is Script { function registerHyperchain() internal { Bridgehub bridgehub = Bridgehub(config.bridgehub); - AllowedBytecodeTypes allowedBytecodeTypesMode = config.allowEvmEmulator - ? AllowedBytecodeTypes.EraVmAndEVM - : AllowedBytecodeTypes.EraVm; - - bytes memory initData = abi.encode(config.diamondCutData, allowedBytecodeTypesMode); - vm.recordLogs(); - bytes memory data = abi.encodeCall( bridgehub.createNewChain, ( @@ -173,7 +165,7 @@ contract RegisterHyperchainScript is Script { config.baseToken, config.bridgehubCreateNewChainSalt, msg.sender, - initData + config.diamondCutData ) ); diff --git a/l1-contracts/scripts/register-hyperchain.ts b/l1-contracts/scripts/register-hyperchain.ts index 587edec2e..485eb3579 100644 --- a/l1-contracts/scripts/register-hyperchain.ts +++ b/l1-contracts/scripts/register-hyperchain.ts @@ -107,10 +107,6 @@ async function main() { const tokenMultiplierSetterAddress = cmd.tokenMultiplierSetterAddress || ""; - const isEvmEmulatorSupported = !!cmd.allowEvmEmulation; - - console.log(`EVM emulator: ${isEvmEmulatorSupported ? "SUPPORTED" : " NOT SUPPORTED"}`); - await deployer.registerHyperchain( baseTokenAddress, cmd.validiumMode, @@ -119,13 +115,18 @@ async function main() { null, null, null, - useGovernance, - isEvmEmulatorSupported + useGovernance ); if (tokenMultiplierSetterAddress != "") { console.log(`Using token multiplier setter address: ${tokenMultiplierSetterAddress}`); await deployer.setTokenMultiplierSetterAddress(tokenMultiplierSetterAddress); } + + if (cmd.allowEvmEmulation) { + console.log("Allowing EVM emulation"); + await deployer.enableEvmEmulation(); + } + await deployer.transferAdminFromDeployerToChainAdmin(); }); diff --git a/l1-contracts/src.ts/deploy-process.ts b/l1-contracts/src.ts/deploy-process.ts index 1e1a00be2..e9622bfbe 100644 --- a/l1-contracts/src.ts/deploy-process.ts +++ b/l1-contracts/src.ts/deploy-process.ts @@ -80,8 +80,7 @@ export async function registerHyperchain( gasPrice: BigNumberish, baseTokenName?: string, chainId?: string, - useGovernance: boolean = false, - isEvmEmulatorSupported: boolean = false + useGovernance: boolean = false ) { const testnetTokens = getTokens(); @@ -100,7 +99,6 @@ export async function registerHyperchain( false, null, chainId, - useGovernance, - isEvmEmulatorSupported + useGovernance ); } diff --git a/l1-contracts/src.ts/deploy.ts b/l1-contracts/src.ts/deploy.ts index 7b96f6358..dfc16a810 100644 --- a/l1-contracts/src.ts/deploy.ts +++ b/l1-contracts/src.ts/deploy.ts @@ -734,8 +734,7 @@ export class Deployer { compareDiamondCutHash: boolean = false, nonce?, predefinedChainId?: string, - useGovernance: boolean = false, - isEvmEmulatorSupported: boolean = false + useGovernance: boolean = false ) { const gasLimit = 10_000_000; @@ -749,12 +748,6 @@ export class Deployer { const diamondCutData = await this.initialZkSyncHyperchainDiamondCut(extraFacets, compareDiamondCutHash); const diamondCutDataEncoded = new ethers.utils.AbiCoder().encode([DIAMOND_CUT_DATA_ABI_STRING], [diamondCutData]); - const allowedBytecodeTypesMode = isEvmEmulatorSupported ? 1 : 0; - const initData = new ethers.utils.AbiCoder().encode( - ["bytes", "uint256"], - [diamondCutDataEncoded, allowedBytecodeTypesMode] - ); - const receipt = await this.executeDirectOrGovernance( useGovernance, bridgehub, @@ -765,7 +758,7 @@ export class Deployer { baseTokenAddress, Date.now(), admin, - initData, + diamondCutDataEncoded, ], 0, { @@ -871,6 +864,17 @@ export class Deployer { } } + public async enableEvmEmulation() { + const stm = this.stateTransitionManagerContract(this.deployWallet); + const diamondProxyAddress = await stm.getHyperchain(this.chainId); + const hyperchain = IZkSyncHyperchainFactory.connect(diamondProxyAddress, this.deployWallet); + + const receipt = await (await hyperchain.allowEvmEmulation()).wait(); + if (this.verbose) { + console.log(`EVM emulation allowed, gas used: ${receipt.gasUsed.toString()}`); + } + } + public async transferAdminFromDeployerToChainAdmin() { const stm = this.stateTransitionManagerContract(this.deployWallet); const diamondProxyAddress = await stm.getHyperchain(this.chainId); diff --git a/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol index 32fd846db..43826e6ac 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol @@ -8,7 +8,6 @@ import {Diamond} from "contracts/state-transition/libraries/Diamond.sol"; import {TestnetERC20Token} from "contracts/dev-contracts/TestnetERC20Token.sol"; import {Bridgehub} from "contracts/bridgehub/Bridgehub.sol"; import {ChainCreationParams} from "contracts/state-transition/IStateTransitionManager.sol"; -import {AllowedBytecodeTypes} from "contracts/state-transition/l2-deps/AllowedBytecodeTypes.sol"; import {L2TransactionRequestDirect, L2TransactionRequestTwoBridgesOuter} from "contracts/bridgehub/IBridgehub.sol"; import {DummyStateTransitionManagerWBH} from "contracts/dev-contracts/test/DummyStateTransitionManagerWithBridgeHubAddress.sol"; import {DummyHyperchain} from "contracts/dev-contracts/test/DummyHyperchain.sol"; @@ -662,8 +661,7 @@ contract ExperimentalBridgeTest is Test { isFreezable, mockSelectors, mockInitAddress, - mockInitCalldata, - false + mockInitCalldata ); // bridgeHub.createNewChain => stateTransitionManager.createNewChain => this function sets the stateTransition mapping @@ -1433,8 +1431,7 @@ contract ExperimentalBridgeTest is Test { bool isFreezable, bytes4[] memory mockSelectors, address, //mockInitAddress, - bytes memory, //mockInitCalldata - bool allowEvmEmulation + bytes memory //mockInitCalldata ) internal returns (bytes memory) { bytes4[] memory singleSelector = new bytes4[](1); singleSelector[0] = bytes4(0xabcdef12); @@ -1468,13 +1465,7 @@ contract ExperimentalBridgeTest is Test { mockSTM.setChainCreationParams(params); - bytes memory diamondCutEncoded = abi.encode(diamondCutData); - - AllowedBytecodeTypes allowedBytecodeTypesMode = allowEvmEmulation - ? AllowedBytecodeTypes.EraVmAndEVM - : AllowedBytecodeTypes.EraVm; - - return abi.encode(diamondCutEncoded, allowedBytecodeTypesMode); + return abi.encode(diamondCutData); } function _setUpHyperchainForChainId(uint256 mockChainId) internal returns (uint256 mockChainIdInRange) { diff --git a/l1-contracts/test/foundry/unit/concrete/state-transition/StateTransitionManager/CreateNewChain.t.sol b/l1-contracts/test/foundry/unit/concrete/state-transition/StateTransitionManager/CreateNewChain.t.sol index 48cbb95b2..bce302a9b 100644 --- a/l1-contracts/test/foundry/unit/concrete/state-transition/StateTransitionManager/CreateNewChain.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/state-transition/StateTransitionManager/CreateNewChain.t.sol @@ -3,7 +3,6 @@ pragma solidity 0.8.24; import {StateTransitionManagerTest} from "./_StateTransitionManager_Shared.t.sol"; import {Diamond} from "contracts/state-transition/libraries/Diamond.sol"; -import {AllowedBytecodeTypes} from "contracts/state-transition/l2-deps/AllowedBytecodeTypes.sol"; import {Unauthorized, HashMismatch} from "contracts/common/L1ContractErrors.sol"; contract createNewChainTest is StateTransitionManagerTest { @@ -34,7 +33,7 @@ contract createNewChainTest is StateTransitionManagerTest { _baseToken: baseToken, _sharedBridge: sharedBridge, _admin: admin, - _inputData: getCreateInputData(initialDiamondCutData, false) + _diamondCut: abi.encode(initialDiamondCutData) }); } diff --git a/l1-contracts/test/foundry/unit/concrete/state-transition/StateTransitionManager/_StateTransitionManager_Shared.t.sol b/l1-contracts/test/foundry/unit/concrete/state-transition/StateTransitionManager/_StateTransitionManager_Shared.t.sol index b13b1f920..80195e850 100644 --- a/l1-contracts/test/foundry/unit/concrete/state-transition/StateTransitionManager/_StateTransitionManager_Shared.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/state-transition/StateTransitionManager/_StateTransitionManager_Shared.t.sol @@ -17,7 +17,6 @@ import {DiamondInit} from "contracts/state-transition/chain-deps/DiamondInit.sol import {GenesisUpgrade} from "contracts/upgrades/GenesisUpgrade.sol"; import {InitializeDataNewChain} from "contracts/state-transition/chain-interfaces/IDiamondInit.sol"; import {StateTransitionManager} from "contracts/state-transition/StateTransitionManager.sol"; -import {AllowedBytecodeTypes} from "contracts/state-transition/l2-deps/AllowedBytecodeTypes.sol"; import {StateTransitionManagerInitializeData, ChainCreationParams} from "contracts/state-transition/IStateTransitionManager.sol"; import {TestnetVerifier} from "contracts/state-transition/TestnetVerifier.sol"; import {ZeroAddress} from "contracts/common/L1ContractErrors.sol"; @@ -129,18 +128,6 @@ contract StateTransitionManagerTest is Test { return Diamond.DiamondCutData({facetCuts: facetCuts, initAddress: _diamondInit, initCalldata: initCalldata}); } - function getCreateInputData( - Diamond.DiamondCutData memory _diamondCut, - bool allowEvmEmulator - ) internal view returns (bytes memory) { - bytes memory diamondCutEncoded = abi.encode(_diamondCut); - AllowedBytecodeTypes allowedBytecodeTypesMode = allowEvmEmulator - ? AllowedBytecodeTypes.EraVmAndEVM - : AllowedBytecodeTypes.EraVm; - - return abi.encode(diamondCutEncoded, allowedBytecodeTypesMode); - } - function createNewChain(Diamond.DiamondCutData memory _diamondCut) internal { _createNewChain(_diamondCut, false); } @@ -158,7 +145,7 @@ contract StateTransitionManagerTest is Test { _baseToken: baseToken, _sharedBridge: sharedBridge, _admin: newChainAdmin, - _inputData: getCreateInputData(_diamondCut, allowEvmEmulator) + _diamondCut: abi.encode(_diamondCut) }); } diff --git a/system-contracts/SystemContractsHashes.json b/system-contracts/SystemContractsHashes.json index f8c17571a..1bc5f5115 100644 --- a/system-contracts/SystemContractsHashes.json +++ b/system-contracts/SystemContractsHashes.json @@ -3,49 +3,49 @@ "contractName": "AccountCodeStorage", "bytecodePath": "zkout/AccountCodeStorage.sol/AccountCodeStorage.json", "sourceCodePath": "contracts-preprocessed/AccountCodeStorage.sol", - "bytecodeHash": "0x0100007317994a1fc65998cd916c99f52951e58cefedce3c330aacf7fd20dd94", + "bytecodeHash": "0x0100007360eb189d11c57c8b45bdd29ae2a996786b55e21847fbbe8e7b285ce2", "sourceCodeHash": "0xfdac12f45b5cfd4abd12923206f2d6f253d11a6624783e079b55e975d573ceb6" }, { "contractName": "BootloaderUtilities", "bytecodePath": "zkout/BootloaderUtilities.sol/BootloaderUtilities.json", "sourceCodePath": "contracts-preprocessed/BootloaderUtilities.sol", - "bytecodeHash": "0x010006f3eaa43c2aeece380d750965b772ae2d8874f942fe598445977118fd23", + "bytecodeHash": "0x010006f3bacfc75db6a91f2f2c05485c8f6d7ed0dd259b5d1a7de5bb5f0170a2", "sourceCodeHash": "0x10f30ac1a7098c7fddec2659ac43422783e8d3fdde02a3ba4d3ff45d451d7001" }, { "contractName": "ComplexUpgrader", "bytecodePath": "zkout/ComplexUpgrader.sol/ComplexUpgrader.json", "sourceCodePath": "contracts-preprocessed/ComplexUpgrader.sol", - "bytecodeHash": "0x010000470769b6a1ab43e898daf381c7df9753c51e8001e06b6daa39357f42a8", + "bytecodeHash": "0x01000047cfddb4597ec1fcff6ce1b13c404b128f8c7349943f00c8e702fcecd5", "sourceCodeHash": "0x796046a914fb676ba2bbd337b2924311ee2177ce54571c18a2c3945755c83614" }, { "contractName": "Compressor", "bytecodePath": "zkout/Compressor.sol/Compressor.json", "sourceCodePath": "contracts-preprocessed/Compressor.sol", - "bytecodeHash": "0x0100013f2c94736cbc8e992f7e84df5e01a64d15bf2443c2dda5bee7476c9575", + "bytecodeHash": "0x0100013f5b38355d5720b282db0cf3869b78e2c8d631550ef7a0f33e5757f6be", "sourceCodeHash": "0xc6f7cd8b21aae52ed3dd5083c09b438a7af142a4ecda6067c586770e8be745a5" }, { "contractName": "ContractDeployer", "bytecodePath": "zkout/ContractDeployer.sol/ContractDeployer.json", "sourceCodePath": "contracts-preprocessed/ContractDeployer.sol", - "bytecodeHash": "0x01000673f8b088c2c27ab36f025b222a908368fd22b461bf97b12784753b2fea", - "sourceCodeHash": "0xbb9a2717e6fd1da15df4ef1862d2e55e661547f973478bb1fc3cab1ea3cca575" + "bytecodeHash": "0x01000655cfaee8879d6d5f020e8cac9b00e5830a8aef6d01f9406b4583fa4bd8", + "sourceCodeHash": "0x22f96404a0527177f635c81315349ee274806e7462c5e5ae087a005f991bc157" }, { "contractName": "Create2Factory", "bytecodePath": "zkout/Create2Factory.sol/Create2Factory.json", "sourceCodePath": "contracts-preprocessed/Create2Factory.sol", - "bytecodeHash": "0x0100003ff00c4656ed039bac6da4b2f56c01acf662faff586f7032d33de48634", + "bytecodeHash": "0x0100003f53ff30da1f9c344e63c5a031affbf8af76baf0a92c977fefc8665a0c", "sourceCodeHash": "0x114d9322a9ca654989f3e0b3b21f1311dbc4db84f443d054cd414f6414d84de3" }, { "contractName": "DefaultAccount", "bytecodePath": "zkout/DefaultAccount.sol/DefaultAccount.json", "sourceCodePath": "contracts-preprocessed/DefaultAccount.sol", - "bytecodeHash": "0x0100050bcb0eb0f55ec0821967b509b2ae60fa52ff94f0f934b4de464e2f3a5d", + "bytecodeHash": "0x0100050b06623d83e54b5752821bc70b493f31989359002205a2f9264dba83f4", "sourceCodeHash": "0x300c864fcb3bc6a562875c7b1d83df15d466515da0a878a426b1aaeac26f3656" }, { @@ -59,57 +59,57 @@ "contractName": "ImmutableSimulator", "bytecodePath": "zkout/ImmutableSimulator.sol/ImmutableSimulator.json", "sourceCodePath": "contracts-preprocessed/ImmutableSimulator.sol", - "bytecodeHash": "0x010000338218e48deb166b7e6486e558038239530c8f30bdbc0b15dffc671aa6", + "bytecodeHash": "0x0100003345f92c227817a46a1cb0ee12cac25cb8516251a028f24d6cb1feb77b", "sourceCodeHash": "0x9659e69f7db09e8f60a8bb95314b1ed26afcc689851665cf27f5408122f60c98" }, { "contractName": "KnownCodesStorage", "bytecodePath": "zkout/KnownCodesStorage.sol/KnownCodesStorage.json", "sourceCodePath": "contracts-preprocessed/KnownCodesStorage.sol", - "bytecodeHash": "0x010000cd7ef93ae3e09683ca91c705700694f3f9bd25f5d0d5fecd38d667eccf", + "bytecodeHash": "0x010000cde320e4772a0ef635bff69f07fd908a6140480cf2c17f2cf0214d86a3", "sourceCodeHash": "0x851fb5e170dfde39f1f9bc74654ec0b8f8f1d4c2fb20c06c77844c1e3ee0659a" }, { "contractName": "L1Messenger", "bytecodePath": "zkout/L1Messenger.sol/L1Messenger.json", "sourceCodePath": "contracts-preprocessed/L1Messenger.sol", - "bytecodeHash": "0x01000263345d82f95b6533501ee84340770418287866931d64899423815527f8", + "bytecodeHash": "0x0100026320ad1a050ca08117bb57a06684839b3ab3f3095e17deb1ebeb53d4ac", "sourceCodeHash": "0xa8768fdaac6d8804782f14e2a51bbe2b6be31dee9103b6d02d149ea8dc46eb6a" }, { "contractName": "L2BaseToken", "bytecodePath": "zkout/L2BaseToken.sol/L2BaseToken.json", "sourceCodePath": "contracts-preprocessed/L2BaseToken.sol", - "bytecodeHash": "0x010000dbc44fbd6fd01e930a4cbbb59a17b285bd86fc5dbe11f59d1f375f6286", + "bytecodeHash": "0x010000db58a5798e8cf03299e84c32288bd535f03140112d8461b84ec164887a", "sourceCodeHash": "0xdea518b1ea16718b0f0ec6155b227a8bc8f51374a9eebf7bc17cfe84433df740" }, { "contractName": "MsgValueSimulator", "bytecodePath": "zkout/MsgValueSimulator.sol/MsgValueSimulator.json", "sourceCodePath": "contracts-preprocessed/MsgValueSimulator.sol", - "bytecodeHash": "0x010000594d78e2e2a0f0fa224c8ba6b3fd8ab8b283bff7420c1b565fe8a61ee7", + "bytecodeHash": "0x0100005964d673fb20cd2c77df6f9aa4c178bd8ffa54eb582505df704b1f3b5b", "sourceCodeHash": "0x082f3dcbc2fe4d93706c86aae85faa683387097d1b676e7ebd00f71ee0f13b71" }, { "contractName": "NonceHolder", "bytecodePath": "zkout/NonceHolder.sol/NonceHolder.json", "sourceCodePath": "contracts-preprocessed/NonceHolder.sol", - "bytecodeHash": "0x010000cf17e28b461edeaf764b45bd824cf6b1a653478624bfa361c813a61b5d", + "bytecodeHash": "0x010000cfa9aff9356b0ef66e9ca32df21ae4bcbb2a8d03d3acf74e2d060a3028", "sourceCodeHash": "0xcd0c0366effebf2c98c58cf96322cc242a2d1c675620ef5514b7ed1f0a869edc" }, { "contractName": "PubdataChunkPublisher", "bytecodePath": "zkout/PubdataChunkPublisher.sol/PubdataChunkPublisher.json", "sourceCodePath": "contracts-preprocessed/PubdataChunkPublisher.sol", - "bytecodeHash": "0x01000041dab57304eb3d41b96948d580eb388f303bdf058c15b71afcef0ffac0", + "bytecodeHash": "0x010000419856be032b7143f70782d129e260d6e99e6bbe7c4787884ccd949ce9", "sourceCodeHash": "0xd7161e2c8092cf57b43c6220bc605c0e7e540bddcde1af24e2d90f75633b098e" }, { "contractName": "SystemContext", "bytecodePath": "zkout/SystemContext.sol/SystemContext.json", "sourceCodePath": "contracts-preprocessed/SystemContext.sol", - "bytecodeHash": "0x010001c54c88a8fb2427458c7b4caddc0c7927e396a60a5e690408d36a25eceb", - "sourceCodeHash": "0xe2f6eb015d260aafe9405b28ef3ec27921add4de7f329b7ef61e0aa6c9365e29" + "bytecodeHash": "0x010001a5305c969f525ba5afc3c7496c520d77ca71bdebc9c3b8e71c7a0d3364", + "sourceCodeHash": "0xaf04a52c660f48de04c29b6c88632b4e002e94f58e0f8de034fd73959671c984" }, { "contractName": "EventWriter", @@ -122,8 +122,8 @@ "contractName": "EvmEmulator", "bytecodePath": "zkout/EvmEmulator.yul/contracts-preprocessed/EvmEmulator.yul.json", "sourceCodePath": "contracts-preprocessed/EvmEmulator.yul", - "bytecodeHash": "0x01000c0750cd078b79c3bcf0ac3074e75a6824fe05e0e563e6df442feb879847", - "sourceCodeHash": "0x86296ecb81fc9edf5aac32613dfd645b538535e264e02a12ec7cdc751018de5d" + "bytecodeHash": "0x01000bef3afffa6dcca82a514f5f388101dd3498e9117be2073975d8ae791970", + "sourceCodeHash": "0x7cad60f966f85be729468ca5f3500ffd4a4b2d0ef6df5ca0656ac7f46c0d2402" }, { "contractName": "EvmGasManager", diff --git a/system-contracts/contracts/Constants.sol b/system-contracts/contracts/Constants.sol index 36309b111..fbaabc091 100644 --- a/system-contracts/contracts/Constants.sol +++ b/system-contracts/contracts/Constants.sol @@ -167,4 +167,6 @@ uint256 constant MAX_NUMBER_OF_BLOBS = 6; /// @dev Marker of EraVM bytecode uint8 constant ERA_VM_BYTECODE_FLAG = 1; /// @dev Marker of EVM bytecode -uint8 constant EVM_BYTECODE_FLAG = 2; \ No newline at end of file +uint8 constant EVM_BYTECODE_FLAG = 2; + +address constant SERVICE_CALL_PSEUDO_CALLER = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF; \ No newline at end of file diff --git a/system-contracts/contracts/ContractDeployer.sol b/system-contracts/contracts/ContractDeployer.sol index 9796b40d3..f909e3fb0 100644 --- a/system-contracts/contracts/ContractDeployer.sol +++ b/system-contracts/contracts/ContractDeployer.sol @@ -4,13 +4,13 @@ pragma solidity 0.8.24; import {ImmutableData} from "./interfaces/IImmutableSimulator.sol"; import {IContractDeployer} from "./interfaces/IContractDeployer.sol"; -import {CREATE2_PREFIX, CREATE_PREFIX, NONCE_HOLDER_SYSTEM_CONTRACT, ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT, FORCE_DEPLOYER, MAX_SYSTEM_CONTRACT_ADDRESS, KNOWN_CODE_STORAGE_CONTRACT, BASE_TOKEN_SYSTEM_CONTRACT, IMMUTABLE_SIMULATOR_SYSTEM_CONTRACT, COMPLEX_UPGRADER_CONTRACT, SYSTEM_CONTEXT_CONTRACT} from "./Constants.sol"; +import {CREATE2_PREFIX, CREATE_PREFIX, NONCE_HOLDER_SYSTEM_CONTRACT, ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT, FORCE_DEPLOYER, MAX_SYSTEM_CONTRACT_ADDRESS, KNOWN_CODE_STORAGE_CONTRACT, BASE_TOKEN_SYSTEM_CONTRACT, IMMUTABLE_SIMULATOR_SYSTEM_CONTRACT, COMPLEX_UPGRADER_CONTRACT, SERVICE_CALL_PSEUDO_CALLER} from "./Constants.sol"; import {Utils} from "./libraries/Utils.sol"; import {EfficientCall} from "./libraries/EfficientCall.sol"; import {SystemContractHelper} from "./libraries/SystemContractHelper.sol"; import {SystemContractBase} from "./abstract/SystemContractBase.sol"; -import {Unauthorized, InvalidAllowedBytecodeTypesMode, InvalidNonceOrderingChange, ValueMismatch, EmptyBytes32, EVMEmulationNotSupported, NotAllowedToDeployInKernelSpace, HashIsNonZero, NonEmptyAccount, UnknownCodeHash, NonEmptyMsgValue} from "./SystemContractErrors.sol"; +import {Unauthorized, InvalidNonceOrderingChange, ValueMismatch, EmptyBytes32, EVMEmulationNotSupported, NotAllowedToDeployInKernelSpace, HashIsNonZero, NonEmptyAccount, UnknownCodeHash, NonEmptyMsgValue} from "./SystemContractErrors.sol"; /** * @author Matter Labs @@ -365,23 +365,16 @@ contract ContractDeployer is IContractDeployer, SystemContractBase { /// @notice Changes what types of bytecodes are allowed to be deployed on the chain. Can be used only during upgrades. /// @param newAllowedBytecodeTypes The new allowed bytecode types mode. - function setAllowedBytecodeTypesToDeploy(uint256 newAllowedBytecodeTypes) external { + function setAllowedBytecodeTypesToDeploy(AllowedBytecodeTypes newAllowedBytecodeTypes) external { if ( msg.sender != FORCE_DEPLOYER && msg.sender != address(COMPLEX_UPGRADER_CONTRACT) && - msg.sender != address(SYSTEM_CONTEXT_CONTRACT) + msg.sender != SERVICE_CALL_PSEUDO_CALLER ) { revert Unauthorized(msg.sender); } - if ( - newAllowedBytecodeTypes != uint256(AllowedBytecodeTypes.EraVm) && - newAllowedBytecodeTypes != uint256(AllowedBytecodeTypes.EraVmAndEVM) - ) { - revert InvalidAllowedBytecodeTypesMode(); - } - - if (uint256(_getAllowedBytecodeTypesMode()) != newAllowedBytecodeTypes) { + if (_getAllowedBytecodeTypesMode() != newAllowedBytecodeTypes) { assembly { sstore(ALLOWED_BYTECODE_TYPES_MODE_SLOT, newAllowedBytecodeTypes) } diff --git a/system-contracts/contracts/SystemContext.sol b/system-contracts/contracts/SystemContext.sol index 10eef6901..2ce75419d 100644 --- a/system-contracts/contracts/SystemContext.sol +++ b/system-contracts/contracts/SystemContext.sol @@ -8,7 +8,7 @@ import {ISystemContext} from "./interfaces/ISystemContext.sol"; import {SystemContractBase} from "./abstract/SystemContractBase.sol"; import {ISystemContextDeprecated} from "./interfaces/ISystemContextDeprecated.sol"; import {SystemContractHelper} from "./libraries/SystemContractHelper.sol"; -import {BOOTLOADER_FORMAL_ADDRESS, DEPLOYER_SYSTEM_CONTRACT, SystemLogKey} from "./Constants.sol"; +import {BOOTLOADER_FORMAL_ADDRESS, SystemLogKey} from "./Constants.sol"; /** * @author Matter Labs @@ -90,17 +90,6 @@ contract SystemContext is ISystemContext, ISystemContextDeprecated, SystemContra chainId = _newChainId; } - /// @notice Set the chain configuration. - /// @param _newChainId The chainId - /// @param _newAllowedBytecodeTypes The new allowed bytecode types mode. - function setChainConfiguration( - uint256 _newChainId, - uint256 _newAllowedBytecodeTypes - ) external onlyCallFromForceDeployer { - chainId = _newChainId; - DEPLOYER_SYSTEM_CONTRACT.setAllowedBytecodeTypesToDeploy(_newAllowedBytecodeTypes); - } - /// @notice Number of current transaction in block. uint16 public txNumberInBlock; diff --git a/system-contracts/contracts/SystemContractErrors.sol b/system-contracts/contracts/SystemContractErrors.sol index 002069396..2ba8eed26 100644 --- a/system-contracts/contracts/SystemContractErrors.sol +++ b/system-contracts/contracts/SystemContractErrors.sol @@ -54,8 +54,6 @@ error IndexSizeError(); error InsufficientFunds(uint256 required, uint256 actual); // 0x1c26714c error InsufficientGas(); -// 0x8322ca79 -error InvalidAllowedBytecodeTypesMode(); // 0xae962d4e error InvalidCall(); // 0x6a84bc39 diff --git a/system-contracts/contracts/interfaces/IContractDeployer.sol b/system-contracts/contracts/interfaces/IContractDeployer.sol index 83bf2392e..fd0d8dec1 100644 --- a/system-contracts/contracts/interfaces/IContractDeployer.sol +++ b/system-contracts/contracts/interfaces/IContractDeployer.sol @@ -112,7 +112,7 @@ interface IContractDeployer { /// @notice Returns keccak of EVM bytecode at address if it is an EVM contract. Returns bytes32(0) if it isn't a EVM contract. function evmCodeHash(address) external view returns (bytes32); - /// @notice Changes what types of bytecodes are allowed to be deployed on the chain. Can be used only during upgrades. + /// @notice Changes what types of bytecodes are allowed to be deployed on the chain. /// @param newAllowedBytecodeTypes The new allowed bytecode types mode. - function setAllowedBytecodeTypesToDeploy(uint256 newAllowedBytecodeTypes) external; + function setAllowedBytecodeTypesToDeploy(AllowedBytecodeTypes newAllowedBytecodeTypes) external; }