From 1c02ec68427438718ac3f36c0f27c0d3172d511e Mon Sep 17 00:00:00 2001 From: Alex Ostrovski Date: Tue, 23 Apr 2024 22:42:49 +0300 Subject: [PATCH 1/2] fix(en): Revert using `liburing` for EN Docker image (#1767) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Removes `liburing` dependency in the EN image introduced in #1701. ## Why ❔ `liburing` doesn't lead to much performance improvement in practice, and it complicates using the EN executable outside Docker. ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). --- docker/external-node/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docker/external-node/Dockerfile b/docker/external-node/Dockerfile index f510295ae5ee..dc989f9ba4e7 100644 --- a/docker/external-node/Dockerfile +++ b/docker/external-node/Dockerfile @@ -4,12 +4,11 @@ FROM matterlabs/zksync-build-base:latest as builder WORKDIR /usr/src/zksync COPY . . - -RUN cargo build --release --features=rocksdb/io-uring +RUN cargo build --release FROM debian:bookworm-slim -RUN apt-get update && apt-get install -y curl libpq5 ca-certificates liburing-dev && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf /var/lib/apt/lists/* COPY --from=builder /usr/src/zksync/target/release/zksync_external_node /usr/bin COPY --from=builder /usr/src/zksync/target/release/block_reverter /usr/bin From 597280b8b698964a2a89b7f114f7f54de31bb133 Mon Sep 17 00:00:00 2001 From: Stanislav Bezkorovainyi Date: Tue, 23 Apr 2024 22:14:15 +0200 Subject: [PATCH 2/2] feat: Include create2 factory in genesis (#1775) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ ## Why ❔ ## Checklist - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`. - [ ] Spellcheck has been run via `zk spellcheck`. - [ ] Linkcheck has been run via `zk linkcheck`. --- core/lib/constants/src/contracts.rs | 6 ++++ core/lib/types/src/system_contracts.rs | 12 ++++++-- .../interfaces/ICreate2Factory.sol | 29 +++++++++++++++++++ .../tests/ts-integration/tests/system.test.ts | 23 +++++++++++++++ etc/env/base/contracts.toml | 6 ++-- 5 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 core/tests/ts-integration/contracts/custom-account/interfaces/ICreate2Factory.sol diff --git a/core/lib/constants/src/contracts.rs b/core/lib/constants/src/contracts.rs index d2c9f99bc90b..973a397b54c6 100644 --- a/core/lib/constants/src/contracts.rs +++ b/core/lib/constants/src/contracts.rs @@ -120,6 +120,12 @@ pub const CODE_ORACLE_ADDRESS: Address = H160([ 0x00, 0x00, 0x80, 0x12, ]); +/// Note, that the `Create2Factory` is explicitly deployed on a non-system-contract address. +pub const CREATE2_FACTORY_ADDRESS: Address = H160([ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, +]); + pub const ERC20_TRANSFER_TOPIC: H256 = H256([ 221, 242, 82, 173, 27, 226, 200, 155, 105, 194, 176, 104, 252, 55, 141, 170, 149, 43, 167, 241, 99, 196, 161, 22, 40, 245, 90, 77, 245, 35, 179, 239, diff --git a/core/lib/types/src/system_contracts.rs b/core/lib/types/src/system_contracts.rs index 3b51e447e59e..d798660c907d 100644 --- a/core/lib/types/src/system_contracts.rs +++ b/core/lib/types/src/system_contracts.rs @@ -4,8 +4,8 @@ use once_cell::sync::Lazy; use zksync_basic_types::{AccountTreeId, Address, U256}; use zksync_contracts::{read_sys_contract_bytecode, ContractLanguage, SystemContractsRepo}; use zksync_system_constants::{ - BOOTLOADER_UTILITIES_ADDRESS, CODE_ORACLE_ADDRESS, COMPRESSOR_ADDRESS, EVENT_WRITER_ADDRESS, - P256VERIFY_PRECOMPILE_ADDRESS, PUBDATA_CHUNK_PUBLISHER_ADDRESS, + BOOTLOADER_UTILITIES_ADDRESS, CODE_ORACLE_ADDRESS, COMPRESSOR_ADDRESS, CREATE2_FACTORY_ADDRESS, + EVENT_WRITER_ADDRESS, P256VERIFY_PRECOMPILE_ADDRESS, PUBDATA_CHUNK_PUBLISHER_ADDRESS, }; use crate::{ @@ -25,7 +25,7 @@ use crate::{ pub const TX_NONCE_INCREMENT: U256 = U256([1, 0, 0, 0]); // 1 pub const DEPLOYMENT_NONCE_INCREMENT: U256 = U256([0, 0, 1, 0]); // 2^128 -static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 23] = [ +static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 24] = [ ( "", "AccountCodeStorage", @@ -156,6 +156,12 @@ static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 23] = [ PUBDATA_CHUNK_PUBLISHER_ADDRESS, ContractLanguage::Sol, ), + ( + "", + "Create2Factory", + CREATE2_FACTORY_ADDRESS, + ContractLanguage::Sol, + ), ]; static SYSTEM_CONTRACTS: Lazy> = Lazy::new(|| { diff --git a/core/tests/ts-integration/contracts/custom-account/interfaces/ICreate2Factory.sol b/core/tests/ts-integration/contracts/custom-account/interfaces/ICreate2Factory.sol new file mode 100644 index 000000000000..fd36197fb94d --- /dev/null +++ b/core/tests/ts-integration/contracts/custom-account/interfaces/ICreate2Factory.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +import {IContractDeployer} from "./IContractDeployer.sol"; + +/// @custom:security-contact security@matterlabs.dev +/// @author Matter Labs +/// @notice The interface for the contract that can be used for deterministic contract deployment. +interface ICreate2Factory { + /// @notice Function that calls the `create2` method of the `ContractDeployer` contract. + /// @dev This function accepts the same parameters as the `create2` function of the ContractDeployer system contract, + /// so that we could efficiently relay the calldata. + function create2( + bytes32 _salt, + bytes32 _bytecodeHash, + bytes calldata _input + ) external payable returns (address); + + /// @notice Function that calls the `create2Account` method of the `ContractDeployer` contract. + /// @dev This function accepts the same parameters as the `create2Account` function of the ContractDeployer system contract, + /// so that we could efficiently relay the calldata. + function create2Account( + bytes32 _salt, + bytes32 _bytecodeHash, + bytes calldata _input, + IContractDeployer.AccountAbstractionVersion + ) external payable returns (address); +} diff --git a/core/tests/ts-integration/tests/system.test.ts b/core/tests/ts-integration/tests/system.test.ts index 5dcbf02c66d5..c6a76dadbd60 100644 --- a/core/tests/ts-integration/tests/system.test.ts +++ b/core/tests/ts-integration/tests/system.test.ts @@ -20,6 +20,8 @@ const contracts = { events: getTestContract('Emitter') }; +const BUILTIN_CREATE2_FACTORY_ADDRESS = '0x0000000000000000000000000000000000010000'; + describe('System behavior checks', () => { let testMaster: TestMaster; let alice: zksync.Wallet; @@ -315,6 +317,27 @@ describe('System behavior checks', () => { ).toBeRejected('exceeds block gas limit'); }); + it('Create2Factory should work', async () => { + // For simplicity, we'll just deploy a contract factory + const salt = ethers.utils.randomBytes(32); + + const bytecode = await alice.provider.getCode(BUILTIN_CREATE2_FACTORY_ADDRESS); + const abi = getTestContract('ICreate2Factory').abi; + const hash = hashBytecode(bytecode); + + const contractFactory = new ethers.Contract(BUILTIN_CREATE2_FACTORY_ADDRESS, abi, alice); + + const deploymentTx = await (await contractFactory.create2(salt, hash, [])).wait(); + + const deployedAddresses = zksync.utils.getDeployedContracts(deploymentTx); + expect(deployedAddresses.length).toEqual(1); + const deployedAddress = deployedAddresses[0]; + const correctCreate2Address = zksync.utils.create2Address(contractFactory.address, hash, salt, []); + + expect(deployedAddress.deployedAddress.toLocaleLowerCase()).toEqual(correctCreate2Address.toLocaleLowerCase()); + expect(await alice.provider.getCode(deployedAddress.deployedAddress)).toEqual(bytecode); + }); + afterAll(async () => { await testMaster.deinitialize(); }); diff --git a/etc/env/base/contracts.toml b/etc/env/base/contracts.toml index cbf3b104912e..ec1d4d7e9d57 100644 --- a/etc/env/base/contracts.toml +++ b/etc/env/base/contracts.toml @@ -26,11 +26,11 @@ RECURSION_NODE_LEVEL_VK_HASH = "0x1186ec268d49f1905f8d9c1e9d39fc33e98c74f91d91a2 RECURSION_LEAF_LEVEL_VK_HASH = "0x101e08b00193e529145ee09823378ef51a3bc8966504064f1f6ba3f1ba863210" RECURSION_CIRCUITS_SET_VKS_HASH = "0x18c1639094f58177409186e8c48d9f577c9410901d2f1d486b3e7d6cf553ae4c" GENESIS_TX_HASH = "0xb99ebfea46cbe05a21cd80fe5597d97b204befc52a16303f579c607dc1ac2e2e" -GENESIS_ROOT = "0x7fe280b1c2209f4b34a15db4cc74568f59db98d400c8e3f3282163acb74d4b14" -GENESIS_BATCH_COMMITMENT = "0x62a99e2685b08bd81eef940a3698ffba6289ec77882d7ac6d5e7bcdbbe6351cd" +GENESIS_ROOT = "0xa0aa5de6ded5c1911d5fee166ee17f3fef98c1ea796c608b9cbee4ce04aaf839" +GENESIS_BATCH_COMMITMENT = "0x3f9ceab98b3baecaa77ba9681919ef822c5a2a6ba97c3be1a68712e1ae63c2ac" PRIORITY_TX_MAX_GAS_LIMIT = 72000000 DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = 10000000 -GENESIS_ROLLUP_LEAF_INDEX = "50" +GENESIS_ROLLUP_LEAF_INDEX = "52" GENESIS_PROTOCOL_VERSION = "23" L1_WETH_BRIDGE_IMPL_ADDR = "0x5E6D086F5eC079ADFF4FB3774CDf3e8D6a34F7E9" L1_WETH_BRIDGE_PROXY_ADDR = "0x5E6D086F5eC079ADFF4FB3774CDf3e8D6a34F7E9"