From 066232ffa9179af8e255adfa10711d3009279815 Mon Sep 17 00:00:00 2001 From: kelemeno <34402761+kelemeno@users.noreply.github.com> Date: Wed, 26 Jun 2024 22:58:36 +0100 Subject: [PATCH 1/3] feat: more system contracts support, WIP (#2273) 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`. --------- Co-authored-by: Raid Ateir Co-authored-by: Raid5594 <52794079+Raid5594@users.noreply.github.com> Co-authored-by: Stanislav Breadless --- .github/workflows/vm-perf-comparison.yml | 98 +++++++++--------- contracts | 2 +- core/bin/zksync_server/src/main.rs | 2 +- core/lib/constants/src/contracts.rs | 14 ++- core/lib/contracts/src/lib.rs | 17 ++- core/lib/types/src/abi.rs | 2 +- core/lib/types/src/protocol_upgrade.rs | 37 +++++-- core/lib/types/src/system_contracts.rs | 35 ++++++- core/node/genesis/src/lib.rs | 27 ++++- core/node/state_keeper/src/keeper.rs | 6 +- core/node/state_keeper/src/tests/mod.rs | 2 +- core/tests/loadnext/src/sdk/abi/update-abi.sh | 2 +- docs/specs/l1_smart_contracts.md | 2 +- etc/env/base/chain.toml | 2 +- etc/env/base/contracts.toml | 6 +- .../fee_estimate.yul/fee_estimate.yul.zbin | Bin 76320 -> 76320 bytes .../gas_test.yul/gas_test.yul.zbin | Bin 72416 -> 72416 bytes .../playground_batch.yul.zbin | Bin 76512 -> 76512 bytes .../proved_batch.yul/proved_batch.yul.zbin | Bin 72928 -> 72928 bytes infrastructure/zk/src/config.ts | 3 +- 20 files changed, 171 insertions(+), 86 deletions(-) diff --git a/.github/workflows/vm-perf-comparison.yml b/.github/workflows/vm-perf-comparison.yml index 53dada123574..6dbaca40ae8b 100644 --- a/.github/workflows/vm-perf-comparison.yml +++ b/.github/workflows/vm-perf-comparison.yml @@ -18,61 +18,61 @@ jobs: fetch-depth: 0 ref: ${{ github.base_ref }} - - name: fetch PR branch - run: | - git remote add pr_repo ${{ github.event.pull_request.head.repo.clone_url }} - git fetch pr_repo ${{ github.event.pull_request.head.ref }} + # - name: fetch PR branch + # run: | + # git remote add pr_repo ${{ github.event.pull_request.head.repo.clone_url }} + # git fetch pr_repo ${{ github.event.pull_request.head.ref }} - - name: fetch merge-base SHA - id: merge_base - run: echo "sha=$(git merge-base HEAD FETCH_HEAD)" >> $GITHUB_OUTPUT + # - name: fetch merge-base SHA + # id: merge_base + # run: echo "sha=$(git merge-base HEAD FETCH_HEAD)" >> $GITHUB_OUTPUT - - name: checkout divergence point - run: git checkout ${{ steps.merge_base.outputs.sha }} --recurse-submodules + # - name: checkout divergence point + # run: git checkout ${{ steps.merge_base.outputs.sha }} --recurse-submodules - - name: setup-env - run: | - touch .env - echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV - echo $(pwd)/bin >> $GITHUB_PATH + # - name: setup-env + # run: | + # touch .env + # echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV + # echo $(pwd)/bin >> $GITHUB_PATH - - name: init - run: | - run_retried docker compose pull zk - docker compose up -d zk + # - name: init + # run: | + # run_retried docker compose pull zk + # docker compose up -d zk - - name: run benchmarks on base branch - shell: bash - run: | - ci_run zk - ci_run zk compiler system-contracts - ci_run cargo bench --package vm-benchmark --bench iai | tee base-iai - ci_run cargo run --package vm-benchmark --release --bin instruction-counts | tee base-opcodes || touch base-opcodes - ci_run yarn workspace system-contracts clean + # - name: run benchmarks on base branch + # shell: bash + # run: | + # ci_run zk + # ci_run zk compiler system-contracts + # ci_run cargo bench --package vm-benchmark --bench iai | tee base-iai + # ci_run cargo run --package vm-benchmark --release --bin instruction-counts | tee base-opcodes || touch base-opcodes + # ci_run yarn workspace system-contracts clean - - name: checkout PR - run: git checkout --force FETCH_HEAD --recurse-submodules + # - name: checkout PR + # run: git checkout --force FETCH_HEAD --recurse-submodules - - name: run benchmarks on PR - shell: bash - run: | - ci_run zk - ci_run zk compiler system-contracts - ci_run cargo bench --package vm-benchmark --bench iai | tee pr-iai - ci_run cargo run --package vm-benchmark --release --bin instruction-counts | tee pr-opcodes || touch pr-opcodes + # - name: run benchmarks on PR + # shell: bash + # run: | + # ci_run zk + # ci_run zk compiler system-contracts + # ci_run cargo bench --package vm-benchmark --bench iai | tee pr-iai + # ci_run cargo run --package vm-benchmark --release --bin instruction-counts | tee pr-opcodes || touch pr-opcodes - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) - echo "speedup<<$EOF" >> $GITHUB_OUTPUT - ci_run cargo run --package vm-benchmark --release --bin compare_iai_results base-iai pr-iai base-opcodes pr-opcodes >> $GITHUB_OUTPUT - echo "$EOF" >> $GITHUB_OUTPUT - id: comparison + # EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + # echo "speedup<<$EOF" >> $GITHUB_OUTPUT + # ci_run cargo run --package vm-benchmark --release --bin compare_iai_results base-iai pr-iai base-opcodes pr-opcodes >> $GITHUB_OUTPUT + # echo "$EOF" >> $GITHUB_OUTPUT + # id: comparison - - name: Comment on PR - uses: thollander/actions-comment-pull-request@v2 - with: - message: | - ${{ steps.comparison.outputs.speedup == '' && '## No performance difference detected (anymore)' || '## Detected VM performance changes' }} - ${{ steps.comparison.outputs.speedup }} - comment_tag: vm-performance-changes - mode: recreate - create_if_not_exists: ${{ steps.comparison.outputs.speedup != '' }} + # - name: Comment on PR + # uses: thollander/actions-comment-pull-request@v2 + # with: + # message: | + # ${{ steps.comparison.outputs.speedup == '' && '## No performance difference detected (anymore)' || '## Detected VM performance changes' }} + # ${{ steps.comparison.outputs.speedup }} + # comment_tag: vm-performance-changes + # mode: recreate + # create_if_not_exists: ${{ steps.comparison.outputs.speedup != '' }} diff --git a/contracts b/contracts index 42be7e5caa04..7b7f322ca272 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 42be7e5caa04ec263aaa21b190f499c4981e3913 +Subproject commit 7b7f322ca27260af6b79067736882176911336b7 diff --git a/core/bin/zksync_server/src/main.rs b/core/bin/zksync_server/src/main.rs index 20be8ca4be29..b6f9cac72e6d 100644 --- a/core/bin/zksync_server/src/main.rs +++ b/core/bin/zksync_server/src/main.rs @@ -204,7 +204,7 @@ async fn main() -> anyhow::Result<()> { &database_secrets, ) .await - .context("Failed to save SetChainId upgrade transaction")?; + .context("Failed to save Genesis upgrade transaction")?; } if opt.genesis { diff --git a/core/lib/constants/src/contracts.rs b/core/lib/constants/src/contracts.rs index 158249dddd47..7e82c97e8787 100644 --- a/core/lib/constants/src/contracts.rs +++ b/core/lib/constants/src/contracts.rs @@ -131,7 +131,7 @@ pub const CREATE2_FACTORY_ADDRESS: Address = H160([ 0x00, 0x01, 0x00, 0x00, ]); -pub const GENESIS_UPGRADE_ADDRESS: Address = H160([ +pub const L2_GENESIS_UPGRADE_ADDRESS: Address = H160([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, ]); @@ -139,6 +139,18 @@ pub const L2_BRIDGEHUB_ADDRESS: Address = H160([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, ]); +pub const L2_ASSET_ROUTER_ADDRESS: Address = H160([ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x03, +]); +pub const L2_NATIVE_TOKEN_VAULT_ADDRESS: Address = H160([ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x04, +]); +pub const L2_MESSAGE_ROOT_ADDRESS: Address = H160([ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x05, +]); 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, diff --git a/core/lib/contracts/src/lib.rs b/core/lib/contracts/src/lib.rs index 1956ef0c8fc8..8313cf8dc93e 100644 --- a/core/lib/contracts/src/lib.rs +++ b/core/lib/contracts/src/lib.rs @@ -399,7 +399,8 @@ impl BaseSystemContracts { pub fn playground_sync_layer() -> Self { let bootloader_bytecode = read_zbin_bytecode( - "etc/multivm_bootloaders/vm_sync_layer/playground_batch.yul/playground_batch.yul.zbin", + "contracts/system-contracts/bootloader/build/artifacts/playground_batch.yul.zbin", + // "etc/multivm_bootloaders/vm_sync_layer/playground_batch.yul/playground_batch.yul.zbin", ); BaseSystemContracts::load_with_bootloader(bootloader_bytecode) } @@ -469,7 +470,8 @@ impl BaseSystemContracts { pub fn estimate_gas_sync_layer() -> Self { let bootloader_bytecode = read_zbin_bytecode( - "etc/multivm_bootloaders/vm_sync_layer/fee_estimate.yul/fee_estimate.yul.zbin", + "contracts/system-contracts/bootloader/build/artifacts/fee_estimate.yul.zbin", + // "etc/multivm_bootloaders/vm_sync_layer/fee_estimate.yul/fee_estimate.yul.zbin", ); BaseSystemContracts::load_with_bootloader(bootloader_bytecode) } @@ -609,14 +611,14 @@ pub static PRE_BOOJUM_COMMIT_FUNCTION: Lazy = Lazy::new(|| { serde_json::from_str(abi).unwrap() }); -pub static SET_CHAIN_ID_EVENT: Lazy = Lazy::new(|| { +pub static GENESIS_UPGRADE_EVENT: Lazy = Lazy::new(|| { let abi = r#" { "anonymous": false, "inputs": [ { "indexed": true, - "name": "_stateTransitionChain", + "name": "_hyperchain", "type": "address" }, { @@ -694,9 +696,14 @@ pub static SET_CHAIN_ID_EVENT: Lazy = Lazy::new(|| { "indexed": true, "name": "_protocolVersion", "type": "uint256" + }, + { + "indexed": false, + "name": "_factoryDeps", + "type": "bytes[]" } ], - "name": "SetChainIdUpgrade", + "name": "GenesisUpgrade", "type": "event" }"#; serde_json::from_str(abi).unwrap() diff --git a/core/lib/types/src/abi.rs b/core/lib/types/src/abi.rs index 84f8aba64869..2931323fd60d 100644 --- a/core/lib/types/src/abi.rs +++ b/core/lib/types/src/abi.rs @@ -58,7 +58,7 @@ impl L2CanonicalTransaction { pub fn decode(token: Token) -> anyhow::Result { let tokens = token.into_tuple().context("not a tuple")?; anyhow::ensure!(tokens.len() == 16); - let mut t = tokens.into_iter(); + let mut t: std::vec::IntoIter = tokens.into_iter(); let mut next = || t.next().unwrap(); Ok(Self { tx_type: next().into_uint().context("tx_type")?, diff --git a/core/lib/types/src/protocol_upgrade.rs b/core/lib/types/src/protocol_upgrade.rs index c1bcc2f5cace..1e9190eccccb 100644 --- a/core/lib/types/src/protocol_upgrade.rs +++ b/core/lib/types/src/protocol_upgrade.rs @@ -15,8 +15,10 @@ use zksync_contracts::{ use zksync_utils::h256_to_u256; use crate::{ - abi, ethabi::ParamType, web3::Log, Address, Execute, ExecuteTransactionCommon, Transaction, - TransactionType, H256, U256, + abi, + ethabi::{ParamType, Token}, + web3::Log, + Address, Execute, ExecuteTransactionCommon, Transaction, TransactionType, H256, U256, }; /// Represents a call to be made during governance operation. @@ -135,12 +137,33 @@ impl ProtocolUpgrade { } } -pub fn decode_set_chain_id_event( +pub fn decode_genesis_upgrade_event( event: Log, ) -> Result<(ProtocolVersionId, ProtocolUpgradeTx), ethabi::Error> { - let tx = ethabi::decode(&[abi::L2CanonicalTransaction::schema()], &event.data.0)?; - let tx = abi::L2CanonicalTransaction::decode(tx.into_iter().next().unwrap()).unwrap(); - + let tokens = ethabi::decode( + &[ + abi::L2CanonicalTransaction::schema(), + ParamType::Array(Box::new(ParamType::Bytes)), + ], + &event.data.0, + )?; + let mut t: std::vec::IntoIter = tokens.into_iter(); + let mut next = || t.next().unwrap(); + + let tx = abi::L2CanonicalTransaction::decode(next()).unwrap(); + let factory_deps = next() + .into_array() + .context("factory_deps") + .unwrap() + // todo proper error + // .map_err(|e| ethabi::Error::Other(&e.to_sting().as_ref().into()))? + .into_iter() + .enumerate() + .map(|(i, t)| t.into_bytes().context(i)) + .collect::>, _>>() + .context("factory_deps") + .unwrap(); + // .map_err(|e| ethabi::Error::Other(e.to_string()))?; let full_version_id = h256_to_u256(event.topics[2]); let protocol_version = ProtocolVersionId::try_from_packed_semver(full_version_id) .unwrap_or_else(|_| panic!("Version is not supported, packed version: {full_version_id}")); @@ -152,7 +175,7 @@ pub fn decode_set_chain_id_event( .block_number .expect("Event block number is missing") .as_u64(), - factory_deps: vec![], + factory_deps, }) .unwrap() .try_into() diff --git a/core/lib/types/src/system_contracts.rs b/core/lib/types/src/system_contracts.rs index 7c088333e9ab..65df071521b4 100644 --- a/core/lib/types/src/system_contracts.rs +++ b/core/lib/types/src/system_contracts.rs @@ -5,8 +5,9 @@ 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, CREATE2_FACTORY_ADDRESS, - EVENT_WRITER_ADDRESS, GENESIS_UPGRADE_ADDRESS, P256VERIFY_PRECOMPILE_ADDRESS, - PUBDATA_CHUNK_PUBLISHER_ADDRESS, + EVENT_WRITER_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_BRIDGEHUB_ADDRESS, + L2_GENESIS_UPGRADE_ADDRESS, L2_MESSAGE_ROOT_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, + P256VERIFY_PRECOMPILE_ADDRESS, PUBDATA_CHUNK_PUBLISHER_ADDRESS, }; use crate::{ @@ -26,7 +27,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); 26] = [ +static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 30] = [ ( "", "AccountCodeStorage", @@ -171,8 +172,32 @@ static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 26] = [ ), ( "", - "GenesisUpgrade", - GENESIS_UPGRADE_ADDRESS, + "L2GenesisUpgrade", + L2_GENESIS_UPGRADE_ADDRESS, + ContractLanguage::Sol, + ), + ( + "../../../l1-contracts/artifacts-zk/contracts/bridgehub/", + "Bridgehub", + L2_BRIDGEHUB_ADDRESS, + ContractLanguage::Sol, + ), + ( + "../../../l1-contracts/artifacts-zk/contracts/bridgehub/", + "MessageRoot", + L2_MESSAGE_ROOT_ADDRESS, + ContractLanguage::Sol, + ), + ( + "../../../l2-contracts/artifacts-zk/contracts/bridge/", + "L2AssetRouter", + L2_ASSET_ROUTER_ADDRESS, + ContractLanguage::Sol, + ), + ( + "../../../l2-contracts/artifacts-zk/contracts/bridge/", + "L2NativeTokenVault", + L2_NATIVE_TOKEN_VAULT_ADDRESS, ContractLanguage::Sol, ), ]; diff --git a/core/node/genesis/src/lib.rs b/core/node/genesis/src/lib.rs index 324ee7d05df2..c153db8a736e 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -7,7 +7,7 @@ use std::fmt::Formatter; use anyhow::Context as _; use multivm::utils::get_max_gas_per_pubdata_byte; use zksync_config::{configs::DatabaseSecrets, GenesisConfig}; -use zksync_contracts::{BaseSystemContracts, BaseSystemContractsHashes, SET_CHAIN_ID_EVENT}; +use zksync_contracts::{BaseSystemContracts, BaseSystemContractsHashes, GENESIS_UPGRADE_EVENT}; use zksync_dal::{Connection, ConnectionPool, Core, CoreDal, DalError}; use zksync_eth_client::EthInterface; use zksync_merkle_tree::{domain::ZkSyncTree, TreeInstruction}; @@ -16,7 +16,7 @@ use zksync_types::{ block::{BlockGasCount, DeployedContract, L1BatchHeader, L2BlockHasher, L2BlockHeader}, commitment::{CommitmentInput, L1BatchCommitment}, fee_model::BatchFeeInput, - protocol_upgrade::decode_set_chain_id_event, + protocol_upgrade::decode_genesis_upgrade_event, protocol_version::{L1VerifierConfig, ProtocolSemanticVersion, VerifierParams}, system_contracts::get_system_smart_contracts, web3::{BlockNumber, FilterBuilder}, @@ -94,6 +94,16 @@ impl GenesisParams { base_system_contracts: BaseSystemContracts, system_contracts: Vec, ) -> Result { + println!( + " + bootloader_hash = \"{:?}\" + default_aa_hash = \"{:?}\" + GENESIS_PROTOCOL_SEMANTIC_VERSION = \"{:?}\" + ", + base_system_contracts.hashes().bootloader, + base_system_contracts.hashes().default_aa, + config.protocol_version.unwrap(), + ); let base_system_contracts_hashes = BaseSystemContractsHashes { bootloader: config .bootloader_hash @@ -290,7 +300,14 @@ pub async fn ensure_genesis_state( commitment, rollup_last_leaf_index, } = insert_genesis_batch(&mut transaction, genesis_params).await?; - + println!( + " + GENESIS_ROOT = \"{:?}\" + GENESIS_BATCH_COMMITMENT = \"{:?}\" + GENESIS_ROLLUP_LEAF_INDEX = \"{:?}\" + ", + root_hash, commitment, rollup_last_leaf_index + ); let expected_root_hash = genesis_params .config .genesis_root_hash @@ -424,7 +441,7 @@ pub async fn save_set_chain_id_tx( let filter = FilterBuilder::default() .address(vec![diamond_proxy_address]) .topics( - Some(vec![SET_CHAIN_ID_EVENT.signature()]), + Some(vec![GENESIS_UPGRADE_EVENT.signature()]), Some(vec![diamond_proxy_address.into()]), None, None, @@ -440,7 +457,7 @@ pub async fn save_set_chain_id_tx( logs ); let (version_id, upgrade_tx) = - decode_set_chain_id_event(logs.remove(0)).context("Chain id event is incorrect")?; + decode_genesis_upgrade_event(logs.remove(0)).context("Chain id event is incorrect")?; tracing::info!("New version id {:?}", version_id); storage diff --git a/core/node/state_keeper/src/keeper.rs b/core/node/state_keeper/src/keeper.rs index 6d44dd247c4d..d36472beaf56 100644 --- a/core/node/state_keeper/src/keeper.rs +++ b/core/node/state_keeper/src/keeper.rs @@ -223,7 +223,7 @@ impl ZkSyncStateKeeper { } /// This function is meant to be called only once during the state-keeper initialization. - /// It will check if we should load a protocol upgrade or a `setChainId` transaction, + /// It will check if we should load a protocol upgrade or a `GenesisUpgrade` transaction, /// perform some checks and return it. pub(super) async fn load_protocol_upgrade_tx( &mut self, @@ -232,9 +232,9 @@ impl ZkSyncStateKeeper { l1_batch_number: L1BatchNumber, ) -> Result, Error> { // After the Shared Bridge is integrated, - // there has to be a setChainId upgrade transaction after the chain genesis. + // there has to be a GenesisUpgrade upgrade transaction after the chain genesis. // It has to be the first transaction of the first batch. - // The setChainId upgrade does not bump the protocol version, but attaches an upgrade + // The GenesisUpgrade upgrade does not bump the protocol version, but attaches an upgrade // transaction to the genesis protocol version. let first_batch_in_shared_bridge = l1_batch_number == L1BatchNumber(1) && !protocol_version.is_pre_shared_bridge(); diff --git a/core/node/state_keeper/src/tests/mod.rs b/core/node/state_keeper/src/tests/mod.rs index b8efa8e0b9cc..8740ecfab441 100644 --- a/core/node/state_keeper/src/tests/mod.rs +++ b/core/node/state_keeper/src/tests/mod.rs @@ -472,7 +472,7 @@ async fn load_upgrade_tx() { // TODO: add one more test case for the shared bridge after it's integrated. // If we are processing the 1st batch while using the shared bridge, - // we should load the upgrade transaction -- that's the `SetChainIdUpgrade`. + // we should load the upgrade transaction -- that's the `GenesisUpgrade`. } /// Unconditionally seal the batch without triggering specific criteria. diff --git a/core/tests/loadnext/src/sdk/abi/update-abi.sh b/core/tests/loadnext/src/sdk/abi/update-abi.sh index 35d03a469dfd..bff3c1d673f3 100755 --- a/core/tests/loadnext/src/sdk/abi/update-abi.sh +++ b/core/tests/loadnext/src/sdk/abi/update-abi.sh @@ -7,7 +7,7 @@ cat $ZKSYNC_HOME/contracts/l1-contracts/artifacts/contracts/bridgehub/IBridgehub cat $ZKSYNC_HOME/contracts/l1-contracts/artifacts/contracts/state-transition/IStateTransitionManager.sol/IStateTransitionManager.json | jq '{ abi: .abi}' > IStateTransitionManager.json cat $ZKSYNC_HOME/contracts/l1-contracts/artifacts/contracts/state-transition/chain-interfaces/IZkSyncHyperchain.sol/IZkSyncHyperchain.json | jq '{ abi: .abi}' > IZkSyncHyperchain.json # Default L1 bridge -cat $ZKSYNC_HOME/contracts/l1-contracts/artifacts/contracts/bridge/interfaces/IL1SharedBridge.sol/IL1SharedBridge.json | jq '{ abi: .abi}' > IL1SharedBridge.json +cat $ZKSYNC_HOME/contracts/l1-contracts/artifacts/contracts/bridge/interfaces/IL1AssetRouter.sol/IL1AssetRouter.json | jq '{ abi: .abi}' > IL1AssetRouter.json cat $ZKSYNC_HOME/contracts/l1-contracts/artifacts/contracts/bridge/interfaces/IL1ERC20Bridge.sol/IL1ERC20Bridge.json | jq '{ abi: .abi}' > IL1ERC20Bridge.json # Paymaster interface cat $ZKSYNC_HOME/contracts/l2-contracts/artifacts-zk/contracts/interfaces/IPaymasterFlow.sol/IPaymasterFlow.json | jq '{ abi: .abi}' > IPaymasterFlow.json diff --git a/docs/specs/l1_smart_contracts.md b/docs/specs/l1_smart_contracts.md index 207920476602..c977821f4557 100644 --- a/docs/specs/l1_smart_contracts.md +++ b/docs/specs/l1_smart_contracts.md @@ -184,7 +184,7 @@ fee-on-transfer tokens or other custom logic for handling user balances. The owner of the L1ERC20Bridge is the Governance contract. -### L1SharedBridge +### L1AssetRouter The main bridge implementation handles transfers Ether, ERC20 tokens and of WETH tokens between the two domains. It is designed to streamline and enhance the user experience for bridging WETH tokens by minimizing the number of transactions diff --git a/etc/env/base/chain.toml b/etc/env/base/chain.toml index 5ddd4b613e55..834c69e48f64 100644 --- a/etc/env/base/chain.toml +++ b/etc/env/base/chain.toml @@ -90,7 +90,7 @@ fee_model_version = "V1" validation_computational_gas_limit = 300000 save_call_traces = true -bootloader_hash = "0x010008ebbfd1b493a9e7030a84799f367a68086f1750b19bcb2e9945752975ef" +bootloader_hash = "0x010008ebe92cafb31d44d1855fe97af98550f0f58bced18f29a7d74efd863b3f" default_aa_hash = "0x0100055df3908fa6efcfa0bdfce813d4224f4657b696bcfdea0c1dbac659ecf4" [chain.operations_manager] diff --git a/etc/env/base/contracts.toml b/etc/env/base/contracts.toml index 246bf7911b82..fb4c4f44450e 100644 --- a/etc/env/base/contracts.toml +++ b/etc/env/base/contracts.toml @@ -28,11 +28,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 = "0x4b0536c9d6b770162ff14bac734fa57e29ab70114d855fac4a6971f589d01cdf" -GENESIS_BATCH_COMMITMENT = "0x2275bbaba8783931c521a3bc99e3c86f2e396dbf829deb257dea983bf519a5be" +GENESIS_ROOT = "0xd4fd2efd7a4921fd9b4db87d2bcf34a9858d8753ce35010e7a077ebac0a29d35" +GENESIS_BATCH_COMMITMENT = "0xd17a2e540693be956f6d24aa7ac2fed578bd25ce02eee1c456ef4075440c2635" PRIORITY_TX_MAX_GAS_LIMIT = 72000000 DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = 10000000 -GENESIS_ROLLUP_LEAF_INDEX = "56" +GENESIS_ROLLUP_LEAF_INDEX = "64" GENESIS_PROTOCOL_VERSION = "25" GENESIS_PROTOCOL_SEMANTIC_VERSION = "0.25.1" L1_WETH_BRIDGE_IMPL_ADDR = "0x5E6D086F5eC079ADFF4FB3774CDf3e8D6a34F7E9" diff --git a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/fee_estimate.yul/fee_estimate.yul.zbin b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/fee_estimate.yul/fee_estimate.yul.zbin index 75ee6377bdb645532c55f06f0e883cc078b5bd2b..82cfdf96d3dcbe5cd57eef0ed7b3461964c1788c 100644 GIT binary patch delta 80 zcmV-W0I&a`)C8c^1c0;w!v-CtU59vwMpp?BEwiYutJIOD^EEF7$eyjM-IC_Ix8Mc= mAR{0i;18&-EGn3?Hn@(Oi!{6{*gdi_rolcg7P$Qg`oaO=awT>E delta 80 zcmV-W0I&a`)C8c^1c0;w!v-C*^24UR)vW-oDW}W3GTfuXAGQd!%~JUD1!_1)x8Mc= mAR{1zcQH(3Oeez6yXH}a$8MQ;1Ncjx9Nz#Kn24dEl^nfGIwrmV diff --git a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/gas_test.yul/gas_test.yul.zbin b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/gas_test.yul/gas_test.yul.zbin index 63898975f4825f551c49f2f7f1d9ac293132966d..c712f82cf0ec5145e4248c88cf8e48ac6a8761f9 100644 GIT binary patch delta 77 zcmV-T0J8t!wFKa`1h9kn9i?4|c!x$;2@fr^sIIHjk)`uBF9gV*t*hOV=DM?>_#h%6 j-(YF%{qB6{7R$+*N=9Q9l_qicu!YUc@Gi8L(dXlEL`5qK delta 77 zcmV-T0J8t!wFKa`1h9kn9kcSoroGjz0In&g%eyk%qr)Gz2(`^p`11v7I7hRf_#h%6 jy73)7D_ugL(hyhJ_<|n-!lEmoN-aa!txw|=0J|5~Sq3KV diff --git a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/playground_batch.yul/playground_batch.yul.zbin b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/playground_batch.yul/playground_batch.yul.zbin index b1a5e063d84b66ebea9a6e021ef42d29b1346760..06829ec6331681685fcd07f94c8bf9d5a0e3ac69 100644 GIT binary patch delta 80 zcmV-W0I&bx)db+x1c0;wBL^L&U59vwMpp?BEwiYutJIOD^EEF7$eyjM-IC_Iw?GF0 mfFmFUMVsD~7)u%i_>cPYp{rJ)KD*{ZGNJ&R!iDP3h{=rJOD6mP delta 80 zcmV-W0I&bx)db+x1c0;wBL^L`^24UR)vW-oDW}W3GTfuXAGQd!%~JUD1!_1)w?GF0 mfFmHtf0L(63WdYOS7J7@C~q5w@LxJ& diff --git a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/proved_batch.yul/proved_batch.yul.zbin b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/proved_batch.yul/proved_batch.yul.zbin index 26bb767d1b306421afbad07509e3e3e0b1e68f8c..4de1149c20af6e2a719fe121471f873a833497d6 100644 GIT binary patch delta 77 zcmV-T0J8t!xdh<31h5189i?4|c!x$;2@fr^sIIHjk)`uBF9gV*t*hOV=DM>W`k*2p jH;rzvxTnF<3ia_2jl_uN5XMY|2WZNEKcAsqkIj|G1nww^ delta 77 zcmV-T0J8t!xdh<31h5189kcSoroGjz0In&g%eyk%qr)Gz2(`^p`11v7I7hP}`k*2p jXc{9jR7OBR^0>~&a5T`->?Yn|vctJGM$vQ67&>EnJtHTy diff --git a/infrastructure/zk/src/config.ts b/infrastructure/zk/src/config.ts index 6f60b26bf668..f7baba27259b 100644 --- a/infrastructure/zk/src/config.ts +++ b/infrastructure/zk/src/config.ts @@ -266,7 +266,8 @@ command '"l2-inits/dev2.init.env"', `"l1-inits/${process.env.ZKSYNC_ENV!}.env", "l1-inits/${process.env .ZKSYNC_ENV!}-sync-layer.env", "l2-inits/${envName}.init.env"` - ); + ) + .replace('CONTRACTS_ERA_CHAIN_ID="270"', 'CONTRACTS_ERA_CHAIN_ID="9"'); const configFile = `etc/env/configs/${envName}.toml`; From 2b928a054c4e795c52e1188013eae86701eb4bd6 Mon Sep 17 00:00:00 2001 From: kelemeno <34402761+kelemeno@users.noreply.github.com> Date: Thu, 27 Jun 2024 15:23:55 +0100 Subject: [PATCH 2/3] feat: blobhash-compilation-fix-support (#2336) 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`. --- contracts | 2 +- etc/env/base/contracts.toml | 4 ++-- etc/env/configs/dev.toml | 2 +- infrastructure/zk/src/contract.ts | 1 + package.json | 2 ++ 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/contracts b/contracts index 7b7f322ca272..1cefe2842d38 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 7b7f322ca27260af6b79067736882176911336b7 +Subproject commit 1cefe2842d38c5d8bfb741c595d8b3891ac8d495 diff --git a/etc/env/base/contracts.toml b/etc/env/base/contracts.toml index fb4c4f44450e..16fa1120335b 100644 --- a/etc/env/base/contracts.toml +++ b/etc/env/base/contracts.toml @@ -28,8 +28,8 @@ RECURSION_NODE_LEVEL_VK_HASH = "0x1186ec268d49f1905f8d9c1e9d39fc33e98c74f91d91a2 RECURSION_LEAF_LEVEL_VK_HASH = "0x101e08b00193e529145ee09823378ef51a3bc8966504064f1f6ba3f1ba863210" RECURSION_CIRCUITS_SET_VKS_HASH = "0x18c1639094f58177409186e8c48d9f577c9410901d2f1d486b3e7d6cf553ae4c" GENESIS_TX_HASH = "0xb99ebfea46cbe05a21cd80fe5597d97b204befc52a16303f579c607dc1ac2e2e" -GENESIS_ROOT = "0xd4fd2efd7a4921fd9b4db87d2bcf34a9858d8753ce35010e7a077ebac0a29d35" -GENESIS_BATCH_COMMITMENT = "0xd17a2e540693be956f6d24aa7ac2fed578bd25ce02eee1c456ef4075440c2635" +GENESIS_ROOT = "0x16d65c78c2d82c22193cfdbd2891f2e2b17c7e3b8544a73130a89e8549753504" +GENESIS_BATCH_COMMITMENT = "0x0786da5572f74c74f836c7871f1bf97e033277fc4fa7831386230d09eb89dc7b" PRIORITY_TX_MAX_GAS_LIMIT = 72000000 DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = 10000000 GENESIS_ROLLUP_LEAF_INDEX = "64" diff --git a/etc/env/configs/dev.toml b/etc/env/configs/dev.toml index 69c945ecaee5..c69f4ee31abc 100644 --- a/etc/env/configs/dev.toml +++ b/etc/env/configs/dev.toml @@ -1,3 +1,3 @@ __imports__ = [ "base", "l1-inits/.init.env", "l1-inits/dev-sync-layer.env", "l2-inits/dev.init.env" ] -ETH_SENDER_SENDER_PUBDATA_SENDING_MODE = "Calldata" +ETH_SENDER_SENDER_PUBDATA_SENDING_MODE = "Blobs" diff --git a/infrastructure/zk/src/contract.ts b/infrastructure/zk/src/contract.ts index 3dace3b55e6c..249e199a58f3 100644 --- a/infrastructure/zk/src/contract.ts +++ b/infrastructure/zk/src/contract.ts @@ -7,6 +7,7 @@ export async function build(zkSyncNetwork: boolean): Promise { const additionalParams = zkSyncNetwork ? `CONTRACTS_BASE_NETWORK_ZKSYNC=true` : ''; await utils.spawn(`${additionalParams} yarn l1-contracts build`); await utils.spawn('yarn l2-contracts build'); + await utils.spawn('yarn da-contracts build'); } const syncLayerEnvVars = [ diff --git a/package.json b/package.json index b15675264d3e..66afd79fa09a 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "packages": [ "contracts", "contracts/l1-contracts", + "contracts/da-contracts", "contracts/l2-contracts", "contracts/system-contracts", "etc/contracts-test-data", @@ -29,6 +30,7 @@ "local-prep": "yarn workspace local-setup-preparation", "l1-contracts": "yarn workspace l1-contracts", "l2-contracts": "yarn workspace l2-contracts", + "da-contracts": "yarn workspace da-contracts", "revert-test": "yarn workspace revert-test", "upgrade-test": "yarn workspace upgrade-test", "recovery-test": "yarn workspace recovery-test", From e820f90f9130571d4c23484540523bc35c6e31dc Mon Sep 17 00:00:00 2001 From: kelemeno <34402761+kelemeno@users.noreply.github.com> Date: Thu, 27 Jun 2024 23:40:53 +0100 Subject: [PATCH 3/3] feat: bump contracts (#2342) 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`. --- contracts | 2 +- etc/env/base/contracts.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts b/contracts index 1cefe2842d38..42791131d616 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 1cefe2842d38c5d8bfb741c595d8b3891ac8d495 +Subproject commit 42791131d616d253de3098aa836b4b76f4bbfbf3 diff --git a/etc/env/base/contracts.toml b/etc/env/base/contracts.toml index 16fa1120335b..c758de099fa6 100644 --- a/etc/env/base/contracts.toml +++ b/etc/env/base/contracts.toml @@ -28,8 +28,8 @@ RECURSION_NODE_LEVEL_VK_HASH = "0x1186ec268d49f1905f8d9c1e9d39fc33e98c74f91d91a2 RECURSION_LEAF_LEVEL_VK_HASH = "0x101e08b00193e529145ee09823378ef51a3bc8966504064f1f6ba3f1ba863210" RECURSION_CIRCUITS_SET_VKS_HASH = "0x18c1639094f58177409186e8c48d9f577c9410901d2f1d486b3e7d6cf553ae4c" GENESIS_TX_HASH = "0xb99ebfea46cbe05a21cd80fe5597d97b204befc52a16303f579c607dc1ac2e2e" -GENESIS_ROOT = "0x16d65c78c2d82c22193cfdbd2891f2e2b17c7e3b8544a73130a89e8549753504" -GENESIS_BATCH_COMMITMENT = "0x0786da5572f74c74f836c7871f1bf97e033277fc4fa7831386230d09eb89dc7b" +GENESIS_ROOT = "0x8f31664cc9fc86d3980331a8bd15c3689aae22168cc5164e09213242ae9bc44e" +GENESIS_BATCH_COMMITMENT = "0xe147e1d0401420a249d813137d7ccce6041a0e3cd033864ab06ece1f22eb4bf6" PRIORITY_TX_MAX_GAS_LIMIT = 72000000 DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = 10000000 GENESIS_ROLLUP_LEAF_INDEX = "64"