From 8546f1c29329f1743ec15bbef61371a37c13adc4 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Thu, 3 Oct 2024 11:23:25 +0300 Subject: [PATCH 01/23] reduce sync-layer-stable diff --- Cargo.lock | 1 + core/bin/external_node/src/config/mod.rs | 8 + core/bin/external_node/src/node_builder.rs | 5 +- core/bin/snapshots_creator/src/tests.rs | 1 + .../system-constants-generator/src/utils.rs | 2 + core/bin/zksync_server/src/node_builder.rs | 6 +- core/lib/basic_types/src/commitment.rs | 24 +- core/lib/basic_types/src/protocol_version.rs | 7 + core/lib/basic_types/src/vm.rs | 1 + core/lib/config/src/configs/contracts.rs | 9 + core/lib/config/src/testonly.rs | 2 + core/lib/constants/src/contracts.rs | 27 +- core/lib/constants/src/system_logs.rs | 11 +- core/lib/contracts/src/lib.rs | 14 + ...264ca7b68c54d894fad9d760324455321080.json} | 28 +- ...4dbf3cec2bd9db8f277392600d5fbb26e338.json} | 18 +- ...11345ef888824e0ca3c5f39befbbc5bd0388.json} | 7 +- ...b480be336b68c127e442ee1bfd177597bd8b.json} | 28 +- ...fa60b5ca8ce096bfb79172b1b55264f6c987.json} | 28 +- ...4ada6239d0a710c07f875c030f6195164e3e.json} | 18 +- ...56d3cb8ad4d35470b82af536375c60eee725.json} | 8 +- ...2e6718eea8ba12757ec77889233542b15b40.json} | 28 +- ...ec32d637a8c11af6472b9b390c6ca2b68495.json} | 28 +- ...ba43fe8560be0c4aa7baa49e71b2a28187e7.json} | 16 +- ...27982ab744c7566645e9b0c69364f7021c5a.json} | 28 +- ...637fc33467fbd64da5a431ecab194409371c.json} | 28 +- ...52aed204a20c67a6b959b16c2a60c745321e.json} | 28 +- .../20240925103531_gateway_upgrade.down.sql | 8 + .../20240925103531_gateway_upgrade.up.sql | 11 + core/lib/dal/src/blocks_dal.rs | 92 +- core/lib/dal/src/consensus/mod.rs | 46 +- core/lib/dal/src/consensus/proto/mod.proto | 11 + core/lib/dal/src/consensus/tests.rs | 11 +- core/lib/dal/src/eth_watcher_dal.rs | 2 +- core/lib/dal/src/lib.rs | 4 +- core/lib/dal/src/models/storage_block.rs | 16 +- core/lib/dal/src/models/storage_sync.rs | 17 +- core/lib/dal/src/sync_dal.rs | 4 +- core/lib/dal/src/tests/mod.rs | 2 + core/lib/env_config/src/contracts.rs | 4 + core/lib/eth_client/src/clients/http/query.rs | 85 +- core/lib/eth_client/src/clients/mock.rs | 34 +- core/lib/multivm/Cargo.toml | 1 + core/lib/multivm/src/utils/mod.rs | 69 +- core/lib/multivm/src/versions/testonly.rs | 1 + .../vm_latest/bootloader_state/state.rs | 50 +- .../vm_latest/bootloader_state/utils.rs | 88 +- .../src/versions/vm_latest/constants.rs | 3 +- .../vm_latest/implementation/execution.rs | 1 + .../src/versions/vm_latest/tests/block_tip.rs | 4 +- .../vm_latest/tests/tester/vm_tester.rs | 7 + .../vm_latest/tracers/pubdata_tracer.rs | 18 +- .../versions/vm_latest/types/internals/mod.rs | 2 +- .../vm_latest/types/internals/pubdata.rs | 206 +- .../vm_latest/types/internals/vm_state.rs | 4 + core/lib/multivm/src/versions/vm_latest/vm.rs | 13 +- core/lib/multivm/src/vm_instance.rs | 9 + core/lib/protobuf_config/src/contracts.rs | 16 + .../src/proto/config/contracts.proto | 2 + core/lib/snapshots_applier/src/tests/utils.rs | 1 + core/lib/state/src/test_utils.rs | 1 + core/lib/tee_verifier/src/lib.rs | 1 + core/lib/types/src/api/en.rs | 4 +- core/lib/types/src/api/mod.rs | 1 + core/lib/types/src/block.rs | 3 +- core/lib/types/src/commitment/mod.rs | 108 +- core/lib/types/src/commitment/tests/mod.rs | 5 + .../tests/post_boojum_1_4_1_test.json | 11 +- .../tests/post_boojum_1_4_2_test.json | 11 +- .../tests/post_boojum_1_5_0_test.json | 25 +- .../commitment/tests/post_gateway_test.json | 1917 +++++++++++++++++ core/lib/types/src/l2_to_l1_log.rs | 14 +- core/lib/vm_executor/src/oneshot/block.rs | 4 + core/lib/vm_executor/src/oneshot/contracts.rs | 5 + core/lib/vm_executor/src/storage.rs | 8 +- .../src/types/inputs/system_env.rs | 4 +- core/node/api_server/src/web3/state.rs | 1 + core/node/block_reverter/src/tests.rs | 1 + core/node/commitment_generator/src/lib.rs | 32 +- core/node/commitment_generator/src/utils.rs | 91 +- core/node/consensus/src/storage/store.rs | 1 + core/node/consensus/src/testonly.rs | 5 +- core/node/db_pruner/src/tests.rs | 1 + core/node/eth_sender/src/tests.rs | 4 + core/node/eth_watch/src/lib.rs | 4 +- .../src/l1_gas_price/gas_adjuster/mod.rs | 4 +- core/node/genesis/src/lib.rs | 1 + core/node/logs_bloom_backfill/src/lib.rs | 1 + .../layers/state_keeper/mempool_io.rs | 10 +- .../layers/state_keeper/output_handler.rs | 50 +- core/node/node_sync/src/fetcher.rs | 7 +- core/node/node_sync/src/sync_action.rs | 1 + core/node/node_sync/src/tests.rs | 4 +- .../src/request_processor.rs | 92 +- core/node/proof_data_handler/src/tests.rs | 1 + core/node/state_keeper/src/io/mempool.rs | 26 +- core/node/state_keeper/src/io/mod.rs | 8 +- core/node/state_keeper/src/io/persistence.rs | 34 +- .../io/seal_logic/l2_block_seal_subtasks.rs | 17 +- .../state_keeper/src/io/seal_logic/mod.rs | 7 +- core/node/state_keeper/src/io/tests/mod.rs | 8 +- core/node/state_keeper/src/io/tests/tester.rs | 2 + .../src/testonly/test_batch_executor.rs | 1 + core/node/state_keeper/src/tests/mod.rs | 2 + core/node/state_keeper/src/updates/mod.rs | 14 +- core/node/test_utils/src/lib.rs | 9 + .../vm_runner/src/tests/output_handler.rs | 1 + core/tests/vm-benchmark/src/vm.rs | 1 + etc/multivm_bootloaders/vm_gateway/commit | 1 + .../fee_estimate.yul/fee_estimate.yul.zbin | Bin 0 -> 75296 bytes .../vm_gateway/gas_test.yul/gas_test.yul.zbin | Bin 0 -> 71392 bytes .../playground_batch.yul.zbin | Bin 0 -> 75424 bytes .../proved_batch.yul/proved_batch.yul.zbin | Bin 0 -> 71904 bytes prover/Cargo.lock | 1 + zk_toolbox/crates/config/src/contracts.rs | 2 + 115 files changed, 3526 insertions(+), 292 deletions(-) rename core/lib/dal/.sqlx/{query-2dc550a35fb0f0ddb1aded83d54a2e93066a5cffbb3857dfd3c6fe00c307eada.json => query-31308e6469a98e9662ff284a89ce264ca7b68c54d894fad9d760324455321080.json} (72%) rename core/lib/dal/.sqlx/{query-39a105cba1be0ec8f2b2b88d2f10c6286fcc824e84bb40a6e9f289c34b85fded.json => query-3968b375e3b99c807d0b7dba4cfb4dbf3cec2bd9db8f277392600d5fbb26e338.json} (81%) rename core/lib/dal/.sqlx/{query-55f4585be3d0f1a147cb10f6e59325fad494a512ba92df95439d2d7fe0f3a285.json => query-398598e20f1892b47bf749b220f611345ef888824e0ca3c5f39befbbc5bd0388.json} (65%) rename core/lib/dal/.sqlx/{query-ac4f1e7af7d866daf45b6997a8ce0a02a40c9f37be949bd4d088744f9c842ef3.json => query-4d1d409b2405a4105feb140720abb480be336b68c127e442ee1bfd177597bd8b.json} (69%) rename core/lib/dal/.sqlx/{query-932ec4483be7ebf34579f17694f6d14963cbfc84261824e47fbab1323895371d.json => query-4e1db16b582aa347dc33fccd8d8afa60b5ca8ce096bfb79172b1b55264f6c987.json} (77%) rename core/lib/dal/.sqlx/{query-45e52d05a4483def84c141e3529bab30553732953e589cd237595227044f438d.json => query-59500dce45171b753b0ff6dbcba84ada6239d0a710c07f875c030f6195164e3e.json} (82%) rename core/lib/dal/.sqlx/{query-c5480ba88a93bb7da027e36e0939f1fd7606fdf3e6d4c882cea76eb579c24a93.json => query-5fafacc2ad6a49b6aef5f53fbca756d3cb8ad4d35470b82af536375c60eee725.json} (53%) rename core/lib/dal/.sqlx/{query-5250341acd42582e41570b6d7e380ae6c8a26f425429116a62892be84c2ff9fb.json => query-66c2d8f27715ee11b0a7c4b9fd7e2e6718eea8ba12757ec77889233542b15b40.json} (78%) rename core/lib/dal/.sqlx/{query-60e68195b375775fc8bc293f6a053681759272f74c47836d34e0ee6de1f639f7.json => query-670f7d170122b6165ea521c482f2ec32d637a8c11af6472b9b390c6ca2b68495.json} (80%) rename core/lib/dal/.sqlx/{query-778f92b1ac91e1ae279f588053d75a9ac877fdd28bda99661e423405e695223d.json => query-9ea417e4ffef9e5d158089723692ba43fe8560be0c4aa7baa49e71b2a28187e7.json} (81%) rename core/lib/dal/.sqlx/{query-30268c71e4bd0d08015af6ae130d3ee5d5140714297401b4bde1e950ed6e971e.json => query-ce6d5796dcc7c105fe3b3081b70327982ab744c7566645e9b0c69364f7021c5a.json} (77%) rename core/lib/dal/.sqlx/{query-4ef330359df85ad6e0110a068ef3afa9cf50eafc7ac542975edea9bd592ce862.json => query-db3593883d5e1e636d65e25cc744637fc33467fbd64da5a431ecab194409371c.json} (76%) rename core/lib/dal/.sqlx/{query-ae30067056fe29febd68408c2ca2e604958488a41d3ee2bcbd05d269bcdfc7aa.json => query-dc9a3821560030a8daf8dbdafe5f52aed204a20c67a6b959b16c2a60c745321e.json} (72%) create mode 100644 core/lib/dal/migrations/20240925103531_gateway_upgrade.down.sql create mode 100644 core/lib/dal/migrations/20240925103531_gateway_upgrade.up.sql create mode 100644 core/lib/types/src/commitment/tests/post_gateway_test.json create mode 100644 etc/multivm_bootloaders/vm_gateway/commit create mode 100644 etc/multivm_bootloaders/vm_gateway/fee_estimate.yul/fee_estimate.yul.zbin create mode 100644 etc/multivm_bootloaders/vm_gateway/gas_test.yul/gas_test.yul.zbin create mode 100644 etc/multivm_bootloaders/vm_gateway/playground_batch.yul/playground_batch.yul.zbin create mode 100644 etc/multivm_bootloaders/vm_gateway/proved_batch.yul/proved_batch.yul.zbin diff --git a/Cargo.lock b/Cargo.lock index 127921ba3e9e..a92778a3afe7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10483,6 +10483,7 @@ dependencies = [ "zk_evm 0.150.5", "zksync_contracts", "zksync_eth_signer", + "zksync_mini_merkle_tree", "zksync_system_constants", "zksync_test_account", "zksync_types", diff --git a/core/bin/external_node/src/config/mod.rs b/core/bin/external_node/src/config/mod.rs index 9b1677c47c4d..06795d14a40d 100644 --- a/core/bin/external_node/src/config/mod.rs +++ b/core/bin/external_node/src/config/mod.rs @@ -110,7 +110,12 @@ pub(crate) struct RemoteENConfig { // the `l2_erc20_bridge_addr` and `l2_shared_bridge_addr` are basically the same contract, but with // a different name, with names adapted only for consistency. pub l1_shared_bridge_proxy_addr: Option
, + /// Contract address that serves as a shared bridge on L2. + /// It is expected that `L2SharedBridge` is used before gateway upgrade, and `L2AssetRouter` is used after. pub l2_shared_bridge_addr: Option
, + /// Address of `L2SharedBridge` that was used before gateway upgrade. + /// `None` if chain genesis used post-gateway protocol version. + pub l2_legacy_shared_bridge_addr: Option
, pub l1_erc20_bridge_proxy_addr: Option
, pub l2_erc20_bridge_addr: Option
, pub l1_weth_bridge_addr: Option
, @@ -189,6 +194,7 @@ impl RemoteENConfig { l2_erc20_bridge_addr: l2_erc20_default_bridge, l1_shared_bridge_proxy_addr: bridges.l1_shared_default_bridge, l2_shared_bridge_addr: l2_erc20_shared_bridge, + l2_legacy_shared_bridge_addr: bridges.l2_legacy_shared_bridge, l1_weth_bridge_addr: bridges.l1_weth_bridge, l2_weth_bridge_addr: bridges.l2_weth_bridge, base_token_addr, @@ -218,6 +224,7 @@ impl RemoteENConfig { l1_shared_bridge_proxy_addr: Some(Address::repeat_byte(5)), l1_weth_bridge_addr: None, l2_shared_bridge_addr: Some(Address::repeat_byte(6)), + l2_legacy_shared_bridge_addr: Some(Address::repeat_byte(7)), l1_batch_commit_data_generator_mode: L1BatchCommitmentMode::Rollup, dummy_verifier: true, } @@ -1395,6 +1402,7 @@ impl From<&ExternalNodeConfig> for InternalApiConfig { l2_erc20_default_bridge: config.remote.l2_erc20_bridge_addr, l1_shared_default_bridge: config.remote.l1_shared_bridge_proxy_addr, l2_shared_default_bridge: config.remote.l2_shared_bridge_addr, + l2_legacy_shared_bridge: config.remote.l2_legacy_shared_bridge_addr, l1_weth_bridge: config.remote.l1_weth_bridge_addr, l2_weth_bridge: config.remote.l2_weth_bridge_addr, }, diff --git a/core/bin/external_node/src/node_builder.rs b/core/bin/external_node/src/node_builder.rs index d0055896d42e..b17cd8651500 100644 --- a/core/bin/external_node/src/node_builder.rs +++ b/core/bin/external_node/src/node_builder.rs @@ -193,10 +193,7 @@ impl ExternalNodeBuilder { const OPTIONAL_BYTECODE_COMPRESSION: bool = true; let persistence_layer = OutputHandlerLayer::new( - self.config - .remote - .l2_shared_bridge_addr - .expect("L2 shared bridge address is not set"), + self.config.remote.l2_legacy_shared_bridge_addr, self.config.optional.l2_block_seal_queue_capacity, ) .with_pre_insert_txs(true) // EN requires txs to be pre-inserted. diff --git a/core/bin/snapshots_creator/src/tests.rs b/core/bin/snapshots_creator/src/tests.rs index a440d836b4c9..f3c191388803 100644 --- a/core/bin/snapshots_creator/src/tests.rs +++ b/core/bin/snapshots_creator/src/tests.rs @@ -167,6 +167,7 @@ async fn create_l2_block( base_fee_per_gas: 0, gas_per_pubdata_limit: 0, batch_fee_input: Default::default(), + pubdata_params: Default::default(), base_system_contracts_hashes: Default::default(), protocol_version: Some(Default::default()), virtual_blocks: 0, diff --git a/core/bin/system-constants-generator/src/utils.rs b/core/bin/system-constants-generator/src/utils.rs index 43ac9841c400..084c8037e2c6 100644 --- a/core/bin/system-constants-generator/src/utils.rs +++ b/core/bin/system-constants-generator/src/utils.rs @@ -231,6 +231,7 @@ pub(super) fn execute_internal_transfer_test() -> u32 { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::default(), + pubdata_params: Default::default(), }; let eth_token_sys_contract = load_sys_contract("L2BaseToken"); @@ -313,6 +314,7 @@ pub(super) fn execute_user_txs_in_test_gas_vm( execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::default(), + pubdata_params: Default::default(), }; let mut vm: Vm<_, HistoryEnabled> = diff --git a/core/bin/zksync_server/src/node_builder.rs b/core/bin/zksync_server/src/node_builder.rs index 4600b0f9e543..f40b267fc83c 100644 --- a/core/bin/zksync_server/src/node_builder.rs +++ b/core/bin/zksync_server/src/node_builder.rs @@ -239,9 +239,7 @@ impl MainNodeBuilder { let wallets = self.wallets.clone(); let sk_config = try_load_config!(self.configs.state_keeper_config); let persistence_layer = OutputHandlerLayer::new( - self.contracts_config - .l2_shared_bridge_addr - .context("L2 shared bridge address")?, + self.contracts_config.l2_legacy_shared_bridge_addr, sk_config.l2_block_seal_queue_capacity, ) .with_protective_reads_persistence_enabled(sk_config.protective_reads_persistence_enabled); @@ -250,6 +248,8 @@ impl MainNodeBuilder { sk_config.clone(), try_load_config!(self.configs.mempool_config), try_load_config!(wallets.state_keeper), + self.contracts_config.l2_da_validator_addr, + self.genesis_config.l1_batch_commit_data_generator_mode, ); let db_config = try_load_config!(self.configs.db_config); let experimental_vm_config = self diff --git a/core/lib/basic_types/src/commitment.rs b/core/lib/basic_types/src/commitment.rs index eca339f40f42..0eed46aad782 100644 --- a/core/lib/basic_types/src/commitment.rs +++ b/core/lib/basic_types/src/commitment.rs @@ -1,10 +1,12 @@ +use std::str::FromStr; + use serde::{Deserialize, Serialize}; use strum::{Display, EnumIter}; use crate::{ ethabi, web3::contract::{Detokenize, Error as ContractError}, - U256, + Address, U256, }; #[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, EnumIter, Display)] @@ -41,3 +43,23 @@ impl Detokenize for L1BatchCommitmentMode { } } } + +impl FromStr for L1BatchCommitmentMode { + type Err = &'static str; + + fn from_str(s: &str) -> Result { + match s { + "Rollup" => Ok(Self::Rollup), + "Validium" => Ok(Self::Validium), + _ => { + Err("Incorrect l1 batch commitment mode type; expected one of `Rollup`, `Validium`") + } + } + } +} + +#[derive(Default, Copy, Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct PubdataParams { + pub l2_da_validator_address: Address, + pub pubdata_type: L1BatchCommitmentMode, +} diff --git a/core/lib/basic_types/src/protocol_version.rs b/core/lib/basic_types/src/protocol_version.rs index 640a92c00da0..a44f8d043660 100644 --- a/core/lib/basic_types/src/protocol_version.rs +++ b/core/lib/basic_types/src/protocol_version.rs @@ -68,6 +68,7 @@ pub enum ProtocolVersionId { Version23, Version24, Version25, + Version26, } impl ProtocolVersionId { @@ -120,6 +121,7 @@ impl ProtocolVersionId { ProtocolVersionId::Version23 => VmVersion::Vm1_5_0SmallBootloaderMemory, ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory, ProtocolVersionId::Version25 => VmVersion::Vm1_5_0IncreasedBootloaderMemory, + ProtocolVersionId::Version26 => VmVersion::VmGateway, } } @@ -137,6 +139,10 @@ impl ProtocolVersionId { self <= &Self::Version22 } + pub fn is_pre_gateway(&self) -> bool { + self <= &Self::Version25 + } + pub fn is_1_4_0(&self) -> bool { self >= &ProtocolVersionId::Version18 && self < &ProtocolVersionId::Version20 } @@ -275,6 +281,7 @@ impl From for VmVersion { ProtocolVersionId::Version23 => VmVersion::Vm1_5_0SmallBootloaderMemory, ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory, ProtocolVersionId::Version25 => VmVersion::Vm1_5_0IncreasedBootloaderMemory, + ProtocolVersionId::Version26 => VmVersion::VmGateway, } } } diff --git a/core/lib/basic_types/src/vm.rs b/core/lib/basic_types/src/vm.rs index c753bbfc8183..f11f98596f18 100644 --- a/core/lib/basic_types/src/vm.rs +++ b/core/lib/basic_types/src/vm.rs @@ -16,6 +16,7 @@ pub enum VmVersion { Vm1_4_2, Vm1_5_0SmallBootloaderMemory, Vm1_5_0IncreasedBootloaderMemory, + VmGateway, } impl VmVersion { diff --git a/core/lib/config/src/configs/contracts.rs b/core/lib/config/src/configs/contracts.rs index b68720ebaefe..0bf7aab3bcab 100644 --- a/core/lib/config/src/configs/contracts.rs +++ b/core/lib/config/src/configs/contracts.rs @@ -29,7 +29,13 @@ pub struct ContractsConfig { pub diamond_proxy_addr: Address, pub validator_timelock_addr: Address, pub l1_shared_bridge_proxy_addr: Option
, + /// Contract address that serves as a shared bridge on L2. + /// It is expected that `L2SharedBridge` is used before gateway upgrade, and `L2AssetRouter` is used after. pub l2_shared_bridge_addr: Option
, + /// Address of `L2SharedBridge` that was used before gateway upgrade. + /// `None` if chain genesis used post-gateway protocol version. + /// If present it will be used as L2 token deployer address. + pub l2_legacy_shared_bridge_addr: Option
, pub l1_erc20_bridge_proxy_addr: Option
, pub l2_erc20_bridge_addr: Option
, pub l1_weth_bridge_proxy_addr: Option
, @@ -40,6 +46,7 @@ pub struct ContractsConfig { // Used by the RPC API and by the node builder in wiring the BaseTokenRatioProvider layer. pub base_token_addr: Option
, pub chain_admin_addr: Option
, + pub l2_da_validator_addr: Option
, } impl ContractsConfig { @@ -53,6 +60,7 @@ impl ContractsConfig { l2_erc20_bridge_addr: Some(Address::repeat_byte(0x0c)), l1_shared_bridge_proxy_addr: Some(Address::repeat_byte(0x0e)), l2_shared_bridge_addr: Some(Address::repeat_byte(0x0f)), + l2_legacy_shared_bridge_addr: Some(Address::repeat_byte(0x19)), l1_weth_bridge_proxy_addr: Some(Address::repeat_byte(0x0b)), l2_weth_bridge_addr: Some(Address::repeat_byte(0x0c)), l2_testnet_paymaster_addr: Some(Address::repeat_byte(0x11)), @@ -61,6 +69,7 @@ impl ContractsConfig { base_token_addr: Some(Address::repeat_byte(0x14)), ecosystem_contracts: Some(EcosystemContracts::for_tests()), chain_admin_addr: Some(Address::repeat_byte(0x18)), + l2_da_validator_addr: Some(Address::repeat_byte(0x1a)), } } } diff --git a/core/lib/config/src/testonly.rs b/core/lib/config/src/testonly.rs index 6fbbad9d8ff2..42c85b8de753 100644 --- a/core/lib/config/src/testonly.rs +++ b/core/lib/config/src/testonly.rs @@ -254,6 +254,7 @@ impl Distribution for EncodeDist { l2_erc20_bridge_addr: self.sample_opt(|| rng.gen()), l1_shared_bridge_proxy_addr: self.sample_opt(|| rng.gen()), l2_shared_bridge_addr: self.sample_opt(|| rng.gen()), + l2_legacy_shared_bridge_addr: self.sample_opt(|| rng.gen()), l1_weth_bridge_proxy_addr: self.sample_opt(|| rng.gen()), l2_weth_bridge_addr: self.sample_opt(|| rng.gen()), l2_testnet_paymaster_addr: self.sample_opt(|| rng.gen()), @@ -261,6 +262,7 @@ impl Distribution for EncodeDist { ecosystem_contracts: self.sample(rng), base_token_addr: self.sample_opt(|| rng.gen()), chain_admin_addr: self.sample_opt(|| rng.gen()), + l2_da_validator_addr: self.sample_opt(|| rng.gen()), } } } diff --git a/core/lib/constants/src/contracts.rs b/core/lib/constants/src/contracts.rs index 73b4a0ffaaa2..0a24454291bb 100644 --- a/core/lib/constants/src/contracts.rs +++ b/core/lib/constants/src/contracts.rs @@ -130,12 +130,37 @@ pub const CODE_ORACLE_ADDRESS: Address = H160([ 0x00, 0x00, 0x80, 0x12, ]); -/// Note, that the `Create2Factory` is explicitly deployed on a non-system-contract address. +/// Note, that the `Create2Factory` and higher are 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 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, +]); + +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, 99, 196, 161, 22, 40, 245, 90, 77, 245, 35, 179, 239, diff --git a/core/lib/constants/src/system_logs.rs b/core/lib/constants/src/system_logs.rs index bd4167b3d02c..aa2c2cc156cc 100644 --- a/core/lib/constants/src/system_logs.rs +++ b/core/lib/constants/src/system_logs.rs @@ -1,11 +1,8 @@ /// The key of the system log with value of the L2->L1 logs tree root hash pub const L2_TO_L1_LOGS_TREE_ROOT_KEY: u32 = 0; -/// The key of the system log with value of the state diff hash -pub const STATE_DIFF_HASH_KEY: u32 = 2; +/// The key of the system log with value of the state diff hash for pre-gateway protocol versions +pub const STATE_DIFF_HASH_KEY_PRE_GATEWAY: u32 = 2; -/// The key of the system log with value of the first blob linear hash -pub const BLOB1_LINEAR_HASH_KEY: u32 = 7; - -/// The key of the system log with value of the second blob linear hash -pub const BLOB2_LINEAR_HASH_KEY: u32 = 8; +/// The key of the system log with value of the first blob linear hash for pre-gateway protocol versions +pub const BLOB1_LINEAR_HASH_KEY_PRE_GATEWAY: u32 = 7; diff --git a/core/lib/contracts/src/lib.rs b/core/lib/contracts/src/lib.rs index a72b5c95d1bc..1d1e93562de2 100644 --- a/core/lib/contracts/src/lib.rs +++ b/core/lib/contracts/src/lib.rs @@ -408,6 +408,13 @@ impl BaseSystemContracts { BaseSystemContracts::load_with_bootloader(bootloader_bytecode) } + pub fn playground_gateway() -> Self { + let bootloader_bytecode = read_zbin_bytecode( + "etc/multivm_bootloaders/vm_gateway/playground_batch.yul/playground_batch.yul.zbin", + ); + BaseSystemContracts::load_with_bootloader(bootloader_bytecode) + } + pub fn estimate_gas_pre_virtual_blocks() -> Self { let bootloader_bytecode = read_zbin_bytecode( "etc/multivm_bootloaders/vm_1_3_2/fee_estimate.yul/fee_estimate.yul.zbin", @@ -471,6 +478,13 @@ impl BaseSystemContracts { BaseSystemContracts::load_with_bootloader(bootloader_bytecode) } + pub fn estimate_gas_gateway() -> Self { + let bootloader_bytecode = read_zbin_bytecode( + "etc/multivm_bootloaders/vm_gateway/fee_estimate.yul/fee_estimate.yul.zbin", + ); + BaseSystemContracts::load_with_bootloader(bootloader_bytecode) + } + pub fn hashes(&self) -> BaseSystemContractsHashes { BaseSystemContractsHashes { bootloader: self.bootloader.hash, diff --git a/core/lib/dal/.sqlx/query-2dc550a35fb0f0ddb1aded83d54a2e93066a5cffbb3857dfd3c6fe00c307eada.json b/core/lib/dal/.sqlx/query-31308e6469a98e9662ff284a89ce264ca7b68c54d894fad9d760324455321080.json similarity index 72% rename from core/lib/dal/.sqlx/query-2dc550a35fb0f0ddb1aded83d54a2e93066a5cffbb3857dfd3c6fe00c307eada.json rename to core/lib/dal/.sqlx/query-31308e6469a98e9662ff284a89ce264ca7b68c54d894fad9d760324455321080.json index 8bf22e1b6fb7..71da9df70be6 100644 --- a/core/lib/dal/.sqlx/query-2dc550a35fb0f0ddb1aded83d54a2e93066a5cffbb3857dfd3c6fe00c307eada.json +++ b/core/lib/dal/.sqlx/query-31308e6469a98e9662ff284a89ce264ca7b68c54d894fad9d760324455321080.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version\n WHERE\n eth_commit_tx_id IS NULL\n AND number != 0\n AND protocol_versions.bootloader_code_hash = $1\n AND protocol_versions.default_account_code_hash = $2\n AND commitment IS NOT NULL\n AND (\n protocol_versions.id = $3\n OR protocol_versions.upgrade_tx_hash IS NULL\n )\n ORDER BY\n number\n LIMIT\n $4\n ", + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input,\n aggregation_root,\n local_root,\n state_diff_hash,\n data_availability.inclusion_data\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version\n LEFT JOIN\n data_availability\n ON data_availability.l1_batch_number = l1_batches.number\n WHERE\n eth_commit_tx_id IS NULL\n AND number != 0\n AND protocol_versions.bootloader_code_hash = $1\n AND protocol_versions.default_account_code_hash = $2\n AND commitment IS NOT NULL\n AND (\n protocol_versions.id = $3\n OR protocol_versions.upgrade_tx_hash IS NULL\n )\n ORDER BY\n number\n LIMIT\n $4\n ", "describe": { "columns": [ { @@ -132,6 +132,26 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "aggregation_root", + "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "local_root", + "type_info": "Bytea" + }, + { + "ordinal": 28, + "name": "state_diff_hash", + "type_info": "Bytea" + }, + { + "ordinal": 29, + "name": "inclusion_data", + "type_info": "Bytea" } ], "parameters": { @@ -168,8 +188,12 @@ false, true, true, + true, + true, + true, + true, true ] }, - "hash": "2dc550a35fb0f0ddb1aded83d54a2e93066a5cffbb3857dfd3c6fe00c307eada" + "hash": "31308e6469a98e9662ff284a89ce264ca7b68c54d894fad9d760324455321080" } diff --git a/core/lib/dal/.sqlx/query-39a105cba1be0ec8f2b2b88d2f10c6286fcc824e84bb40a6e9f289c34b85fded.json b/core/lib/dal/.sqlx/query-3968b375e3b99c807d0b7dba4cfb4dbf3cec2bd9db8f277392600d5fbb26e338.json similarity index 81% rename from core/lib/dal/.sqlx/query-39a105cba1be0ec8f2b2b88d2f10c6286fcc824e84bb40a6e9f289c34b85fded.json rename to core/lib/dal/.sqlx/query-3968b375e3b99c807d0b7dba4cfb4dbf3cec2bd9db8f277392600d5fbb26e338.json index 26a3458bff9b..996b6af2dc39 100644 --- a/core/lib/dal/.sqlx/query-39a105cba1be0ec8f2b2b88d2f10c6286fcc824e84bb40a6e9f289c34b85fded.json +++ b/core/lib/dal/.sqlx/query-3968b375e3b99c807d0b7dba4cfb4dbf3cec2bd9db8f277392600d5fbb26e338.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n hash,\n l1_tx_count,\n l2_tx_count,\n fee_account_address AS \"fee_account_address!\",\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n gas_per_pubdata_limit,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n virtual_blocks,\n fair_pubdata_price,\n gas_limit,\n logs_bloom\n FROM\n miniblocks\n ORDER BY\n number DESC\n LIMIT\n 1\n ", + "query": "\n SELECT\n number,\n timestamp,\n hash,\n l1_tx_count,\n l2_tx_count,\n fee_account_address AS \"fee_account_address!\",\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n gas_per_pubdata_limit,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n virtual_blocks,\n fair_pubdata_price,\n gas_limit,\n logs_bloom,\n l2_da_validator_address,\n pubdata_type\n FROM\n miniblocks\n ORDER BY\n number DESC\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -87,6 +87,16 @@ "ordinal": 16, "name": "logs_bloom", "type_info": "Bytea" + }, + { + "ordinal": 17, + "name": "l2_da_validator_address", + "type_info": "Bytea" + }, + { + "ordinal": 18, + "name": "pubdata_type", + "type_info": "Text" } ], "parameters": { @@ -109,8 +119,10 @@ false, true, true, - true + true, + false, + false ] }, - "hash": "39a105cba1be0ec8f2b2b88d2f10c6286fcc824e84bb40a6e9f289c34b85fded" + "hash": "3968b375e3b99c807d0b7dba4cfb4dbf3cec2bd9db8f277392600d5fbb26e338" } diff --git a/core/lib/dal/.sqlx/query-55f4585be3d0f1a147cb10f6e59325fad494a512ba92df95439d2d7fe0f3a285.json b/core/lib/dal/.sqlx/query-398598e20f1892b47bf749b220f611345ef888824e0ca3c5f39befbbc5bd0388.json similarity index 65% rename from core/lib/dal/.sqlx/query-55f4585be3d0f1a147cb10f6e59325fad494a512ba92df95439d2d7fe0f3a285.json rename to core/lib/dal/.sqlx/query-398598e20f1892b47bf749b220f611345ef888824e0ca3c5f39befbbc5bd0388.json index ecf54f0417b8..ffe785d754ca 100644 --- a/core/lib/dal/.sqlx/query-55f4585be3d0f1a147cb10f6e59325fad494a512ba92df95439d2d7fe0f3a285.json +++ b/core/lib/dal/.sqlx/query-398598e20f1892b47bf749b220f611345ef888824e0ca3c5f39befbbc5bd0388.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n UPDATE l1_batches\n SET\n commitment = $1,\n aux_data_hash = $2,\n pass_through_data_hash = $3,\n meta_parameters_hash = $4,\n l2_l1_merkle_root = $5,\n zkporter_is_available = $6,\n compressed_state_diffs = $7,\n compressed_initial_writes = $8,\n compressed_repeated_writes = $9,\n updated_at = NOW()\n WHERE\n number = $10\n AND commitment IS NULL\n ", + "query": "\n UPDATE l1_batches\n SET\n commitment = $1,\n aux_data_hash = $2,\n pass_through_data_hash = $3,\n meta_parameters_hash = $4,\n l2_l1_merkle_root = $5,\n zkporter_is_available = $6,\n compressed_state_diffs = $7,\n compressed_initial_writes = $8,\n compressed_repeated_writes = $9,\n state_diff_hash = $10,\n aggregation_root = $11,\n local_root = $12,\n updated_at = NOW()\n WHERE\n number = $13\n AND commitment IS NULL\n ", "describe": { "columns": [], "parameters": { @@ -14,10 +14,13 @@ "Bytea", "Bytea", "Bytea", + "Bytea", + "Bytea", + "Bytea", "Int8" ] }, "nullable": [] }, - "hash": "55f4585be3d0f1a147cb10f6e59325fad494a512ba92df95439d2d7fe0f3a285" + "hash": "398598e20f1892b47bf749b220f611345ef888824e0ca3c5f39befbbc5bd0388" } diff --git a/core/lib/dal/.sqlx/query-ac4f1e7af7d866daf45b6997a8ce0a02a40c9f37be949bd4d088744f9c842ef3.json b/core/lib/dal/.sqlx/query-4d1d409b2405a4105feb140720abb480be336b68c127e442ee1bfd177597bd8b.json similarity index 69% rename from core/lib/dal/.sqlx/query-ac4f1e7af7d866daf45b6997a8ce0a02a40c9f37be949bd4d088744f9c842ef3.json rename to core/lib/dal/.sqlx/query-4d1d409b2405a4105feb140720abb480be336b68c127e442ee1bfd177597bd8b.json index 671b56760d6b..c5b5afe85e4f 100644 --- a/core/lib/dal/.sqlx/query-ac4f1e7af7d866daf45b6997a8ce0a02a40c9f37be949bd4d088744f9c842ef3.json +++ b/core/lib/dal/.sqlx/query-4d1d409b2405a4105feb140720abb480be336b68c127e442ee1bfd177597bd8b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.l1_batch_number = l1_batches.number\n JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version\n WHERE\n eth_commit_tx_id IS NULL\n AND number != 0\n AND protocol_versions.bootloader_code_hash = $1\n AND protocol_versions.default_account_code_hash = $2\n AND commitment IS NOT NULL\n AND (\n protocol_versions.id = $3\n OR protocol_versions.upgrade_tx_hash IS NULL\n )\n AND events_queue_commitment IS NOT NULL\n AND bootloader_initial_content_commitment IS NOT NULL\n AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", + "query": "\n SELECT\n number,\n l1_batches.timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n l1_batches.bootloader_code_hash,\n l1_batches.default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input,\n aggregation_root,\n local_root,\n state_diff_hash,\n data_availability.inclusion_data\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.l1_batch_number = l1_batches.number\n JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version\n WHERE\n eth_commit_tx_id IS NULL\n AND number != 0\n AND protocol_versions.bootloader_code_hash = $1\n AND protocol_versions.default_account_code_hash = $2\n AND commitment IS NOT NULL\n AND (\n protocol_versions.id = $3\n OR protocol_versions.upgrade_tx_hash IS NULL\n )\n AND events_queue_commitment IS NOT NULL\n AND bootloader_initial_content_commitment IS NOT NULL\n AND (\n data_availability.inclusion_data IS NOT NULL\n OR $4 IS FALSE\n )\n ORDER BY\n number\n LIMIT\n $5\n ", "describe": { "columns": [ { @@ -132,6 +132,26 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "aggregation_root", + "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "local_root", + "type_info": "Bytea" + }, + { + "ordinal": 28, + "name": "state_diff_hash", + "type_info": "Bytea" + }, + { + "ordinal": 29, + "name": "inclusion_data", + "type_info": "Bytea" } ], "parameters": { @@ -169,8 +189,12 @@ false, true, true, + true, + true, + true, + true, true ] }, - "hash": "ac4f1e7af7d866daf45b6997a8ce0a02a40c9f37be949bd4d088744f9c842ef3" + "hash": "4d1d409b2405a4105feb140720abb480be336b68c127e442ee1bfd177597bd8b" } diff --git a/core/lib/dal/.sqlx/query-932ec4483be7ebf34579f17694f6d14963cbfc84261824e47fbab1323895371d.json b/core/lib/dal/.sqlx/query-4e1db16b582aa347dc33fccd8d8afa60b5ca8ce096bfb79172b1b55264f6c987.json similarity index 77% rename from core/lib/dal/.sqlx/query-932ec4483be7ebf34579f17694f6d14963cbfc84261824e47fbab1323895371d.json rename to core/lib/dal/.sqlx/query-4e1db16b582aa347dc33fccd8d8afa60b5ca8ce096bfb79172b1b55264f6c987.json index 0b1daaa10e5f..0c6bb9ca4d26 100644 --- a/core/lib/dal/.sqlx/query-932ec4483be7ebf34579f17694f6d14963cbfc84261824e47fbab1323895371d.json +++ b/core/lib/dal/.sqlx/query-4e1db16b582aa347dc33fccd8d8afa60b5ca8ce096bfb79172b1b55264f6c987.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n number BETWEEN $1 AND $2\n ORDER BY\n number\n LIMIT\n $3\n ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input,\n aggregation_root,\n local_root,\n state_diff_hash,\n data_availability.inclusion_data\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.l1_batch_number = l1_batches.number\n WHERE\n number BETWEEN $1 AND $2\n ORDER BY\n number\n LIMIT\n $3\n ", "describe": { "columns": [ { @@ -132,6 +132,26 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "aggregation_root", + "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "local_root", + "type_info": "Bytea" + }, + { + "ordinal": 28, + "name": "state_diff_hash", + "type_info": "Bytea" + }, + { + "ordinal": 29, + "name": "inclusion_data", + "type_info": "Bytea" } ], "parameters": { @@ -167,8 +187,12 @@ false, true, true, + true, + true, + true, + true, true ] }, - "hash": "932ec4483be7ebf34579f17694f6d14963cbfc84261824e47fbab1323895371d" + "hash": "4e1db16b582aa347dc33fccd8d8afa60b5ca8ce096bfb79172b1b55264f6c987" } diff --git a/core/lib/dal/.sqlx/query-45e52d05a4483def84c141e3529bab30553732953e589cd237595227044f438d.json b/core/lib/dal/.sqlx/query-59500dce45171b753b0ff6dbcba84ada6239d0a710c07f875c030f6195164e3e.json similarity index 82% rename from core/lib/dal/.sqlx/query-45e52d05a4483def84c141e3529bab30553732953e589cd237595227044f438d.json rename to core/lib/dal/.sqlx/query-59500dce45171b753b0ff6dbcba84ada6239d0a710c07f875c030f6195164e3e.json index 74a6187e6444..644ff5ac16bb 100644 --- a/core/lib/dal/.sqlx/query-45e52d05a4483def84c141e3529bab30553732953e589cd237595227044f438d.json +++ b/core/lib/dal/.sqlx/query-59500dce45171b753b0ff6dbcba84ada6239d0a710c07f875c030f6195164e3e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n hash,\n l1_tx_count,\n l2_tx_count,\n fee_account_address AS \"fee_account_address!\",\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n gas_per_pubdata_limit,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n virtual_blocks,\n fair_pubdata_price,\n gas_limit,\n logs_bloom\n FROM\n miniblocks\n WHERE\n number = $1\n ", + "query": "\n SELECT\n number,\n timestamp,\n hash,\n l1_tx_count,\n l2_tx_count,\n fee_account_address AS \"fee_account_address!\",\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n gas_per_pubdata_limit,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n virtual_blocks,\n fair_pubdata_price,\n gas_limit,\n logs_bloom,\n l2_da_validator_address,\n pubdata_type\n FROM\n miniblocks\n WHERE\n number = $1\n ", "describe": { "columns": [ { @@ -87,6 +87,16 @@ "ordinal": 16, "name": "logs_bloom", "type_info": "Bytea" + }, + { + "ordinal": 17, + "name": "l2_da_validator_address", + "type_info": "Bytea" + }, + { + "ordinal": 18, + "name": "pubdata_type", + "type_info": "Text" } ], "parameters": { @@ -111,8 +121,10 @@ false, true, true, - true + true, + false, + false ] }, - "hash": "45e52d05a4483def84c141e3529bab30553732953e589cd237595227044f438d" + "hash": "59500dce45171b753b0ff6dbcba84ada6239d0a710c07f875c030f6195164e3e" } diff --git a/core/lib/dal/.sqlx/query-c5480ba88a93bb7da027e36e0939f1fd7606fdf3e6d4c882cea76eb579c24a93.json b/core/lib/dal/.sqlx/query-5fafacc2ad6a49b6aef5f53fbca756d3cb8ad4d35470b82af536375c60eee725.json similarity index 53% rename from core/lib/dal/.sqlx/query-c5480ba88a93bb7da027e36e0939f1fd7606fdf3e6d4c882cea76eb579c24a93.json rename to core/lib/dal/.sqlx/query-5fafacc2ad6a49b6aef5f53fbca756d3cb8ad4d35470b82af536375c60eee725.json index 09e34a7e33ac..6e86ee979fe6 100644 --- a/core/lib/dal/.sqlx/query-c5480ba88a93bb7da027e36e0939f1fd7606fdf3e6d4c882cea76eb579c24a93.json +++ b/core/lib/dal/.sqlx/query-5fafacc2ad6a49b6aef5f53fbca756d3cb8ad4d35470b82af536375c60eee725.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n INSERT INTO\n miniblocks (\n number,\n timestamp,\n hash,\n l1_tx_count,\n l2_tx_count,\n fee_account_address,\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n gas_per_pubdata_limit,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n virtual_blocks,\n fair_pubdata_price,\n gas_limit,\n logs_bloom,\n created_at,\n updated_at\n )\n VALUES\n (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10,\n $11,\n $12,\n $13,\n $14,\n $15,\n $16,\n $17,\n NOW(),\n NOW()\n )\n ", + "query": "\n INSERT INTO\n miniblocks (\n number,\n timestamp,\n hash,\n l1_tx_count,\n l2_tx_count,\n fee_account_address,\n base_fee_per_gas,\n l1_gas_price,\n l2_fair_gas_price,\n gas_per_pubdata_limit,\n bootloader_code_hash,\n default_aa_code_hash,\n protocol_version,\n virtual_blocks,\n fair_pubdata_price,\n gas_limit,\n logs_bloom,\n l2_da_validator_address,\n pubdata_type,\n created_at,\n updated_at\n )\n VALUES\n (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10,\n $11,\n $12,\n $13,\n $14,\n $15,\n $16,\n $17,\n $18,\n $19,\n NOW(),\n NOW()\n )\n ", "describe": { "columns": [], "parameters": { @@ -21,10 +21,12 @@ "Int8", "Int8", "Int8", - "Bytea" + "Bytea", + "Bytea", + "Text" ] }, "nullable": [] }, - "hash": "c5480ba88a93bb7da027e36e0939f1fd7606fdf3e6d4c882cea76eb579c24a93" + "hash": "5fafacc2ad6a49b6aef5f53fbca756d3cb8ad4d35470b82af536375c60eee725" } diff --git a/core/lib/dal/.sqlx/query-5250341acd42582e41570b6d7e380ae6c8a26f425429116a62892be84c2ff9fb.json b/core/lib/dal/.sqlx/query-66c2d8f27715ee11b0a7c4b9fd7e2e6718eea8ba12757ec77889233542b15b40.json similarity index 78% rename from core/lib/dal/.sqlx/query-5250341acd42582e41570b6d7e380ae6c8a26f425429116a62892be84c2ff9fb.json rename to core/lib/dal/.sqlx/query-66c2d8f27715ee11b0a7c4b9fd7e2e6718eea8ba12757ec77889233542b15b40.json index 93d522f5fb73..e26688c658e1 100644 --- a/core/lib/dal/.sqlx/query-5250341acd42582e41570b6d7e380ae6c8a26f425429116a62892be84c2ff9fb.json +++ b/core/lib/dal/.sqlx/query-66c2d8f27715ee11b0a7c4b9fd7e2e6718eea8ba12757ec77889233542b15b40.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n eth_commit_tx_id IS NOT NULL\n AND eth_prove_tx_id IS NULL\n ORDER BY\n number\n LIMIT\n $1\n ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input,\n aggregation_root,\n local_root,\n state_diff_hash,\n data_availability.inclusion_data\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.l1_batch_number = l1_batches.number\n WHERE\n eth_commit_tx_id IS NOT NULL\n AND eth_prove_tx_id IS NULL\n ORDER BY\n number\n LIMIT\n $1\n ", "describe": { "columns": [ { @@ -132,6 +132,26 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "aggregation_root", + "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "local_root", + "type_info": "Bytea" + }, + { + "ordinal": 28, + "name": "state_diff_hash", + "type_info": "Bytea" + }, + { + "ordinal": 29, + "name": "inclusion_data", + "type_info": "Bytea" } ], "parameters": { @@ -165,8 +185,12 @@ false, true, true, + true, + true, + true, + true, true ] }, - "hash": "5250341acd42582e41570b6d7e380ae6c8a26f425429116a62892be84c2ff9fb" + "hash": "66c2d8f27715ee11b0a7c4b9fd7e2e6718eea8ba12757ec77889233542b15b40" } diff --git a/core/lib/dal/.sqlx/query-60e68195b375775fc8bc293f6a053681759272f74c47836d34e0ee6de1f639f7.json b/core/lib/dal/.sqlx/query-670f7d170122b6165ea521c482f2ec32d637a8c11af6472b9b390c6ca2b68495.json similarity index 80% rename from core/lib/dal/.sqlx/query-60e68195b375775fc8bc293f6a053681759272f74c47836d34e0ee6de1f639f7.json rename to core/lib/dal/.sqlx/query-670f7d170122b6165ea521c482f2ec32d637a8c11af6472b9b390c6ca2b68495.json index a9eae0bd01dc..74a426f20393 100644 --- a/core/lib/dal/.sqlx/query-60e68195b375775fc8bc293f6a053681759272f74c47836d34e0ee6de1f639f7.json +++ b/core/lib/dal/.sqlx/query-670f7d170122b6165ea521c482f2ec32d637a8c11af6472b9b390c6ca2b68495.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n system_logs,\n compressed_state_diffs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n number = $1\n ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n system_logs,\n compressed_state_diffs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input,\n aggregation_root,\n local_root,\n state_diff_hash,\n data_availability.inclusion_data\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.l1_batch_number = l1_batches.number\n WHERE\n number = $1\n ", "describe": { "columns": [ { @@ -132,6 +132,26 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "aggregation_root", + "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "local_root", + "type_info": "Bytea" + }, + { + "ordinal": 28, + "name": "state_diff_hash", + "type_info": "Bytea" + }, + { + "ordinal": 29, + "name": "inclusion_data", + "type_info": "Bytea" } ], "parameters": { @@ -165,8 +185,12 @@ true, true, true, + true, + true, + true, + true, true ] }, - "hash": "60e68195b375775fc8bc293f6a053681759272f74c47836d34e0ee6de1f639f7" + "hash": "670f7d170122b6165ea521c482f2ec32d637a8c11af6472b9b390c6ca2b68495" } diff --git a/core/lib/dal/.sqlx/query-778f92b1ac91e1ae279f588053d75a9ac877fdd28bda99661e423405e695223d.json b/core/lib/dal/.sqlx/query-9ea417e4ffef9e5d158089723692ba43fe8560be0c4aa7baa49e71b2a28187e7.json similarity index 81% rename from core/lib/dal/.sqlx/query-778f92b1ac91e1ae279f588053d75a9ac877fdd28bda99661e423405e695223d.json rename to core/lib/dal/.sqlx/query-9ea417e4ffef9e5d158089723692ba43fe8560be0c4aa7baa49e71b2a28187e7.json index aa7d4c65a39d..ebed8e99f5bc 100644 --- a/core/lib/dal/.sqlx/query-778f92b1ac91e1ae279f588053d75a9ac877fdd28bda99661e423405e695223d.json +++ b/core/lib/dal/.sqlx/query-9ea417e4ffef9e5d158089723692ba43fe8560be0c4aa7baa49e71b2a28187e7.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n miniblocks.number,\n COALESCE(\n miniblocks.l1_batch_number,\n (\n SELECT\n (MAX(number) + 1)\n FROM\n l1_batches\n ),\n (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n )\n ) AS \"l1_batch_number!\",\n (miniblocks.l1_tx_count + miniblocks.l2_tx_count) AS \"tx_count!\",\n miniblocks.timestamp,\n miniblocks.l1_gas_price,\n miniblocks.l2_fair_gas_price,\n miniblocks.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.virtual_blocks,\n miniblocks.hash,\n miniblocks.protocol_version AS \"protocol_version!\",\n miniblocks.fee_account_address AS \"fee_account_address!\"\n FROM\n miniblocks\n WHERE\n miniblocks.number BETWEEN $1 AND $2\n ", + "query": "\n SELECT\n miniblocks.number,\n COALESCE(\n miniblocks.l1_batch_number,\n (\n SELECT\n (MAX(number) + 1)\n FROM\n l1_batches\n ),\n (\n SELECT\n MAX(l1_batch_number) + 1\n FROM\n snapshot_recovery\n )\n ) AS \"l1_batch_number!\",\n (miniblocks.l1_tx_count + miniblocks.l2_tx_count) AS \"tx_count!\",\n miniblocks.timestamp,\n miniblocks.l1_gas_price,\n miniblocks.l2_fair_gas_price,\n miniblocks.fair_pubdata_price,\n miniblocks.bootloader_code_hash,\n miniblocks.default_aa_code_hash,\n miniblocks.virtual_blocks,\n miniblocks.hash,\n miniblocks.protocol_version AS \"protocol_version!\",\n miniblocks.fee_account_address AS \"fee_account_address!\",\n miniblocks.l2_da_validator_address AS \"l2_da_validator_address!\",\n miniblocks.pubdata_type AS \"pubdata_type!\"\n FROM\n miniblocks\n WHERE\n miniblocks.number BETWEEN $1 AND $2\n ", "describe": { "columns": [ { @@ -67,6 +67,16 @@ "ordinal": 12, "name": "fee_account_address!", "type_info": "Bytea" + }, + { + "ordinal": 13, + "name": "l2_da_validator_address!", + "type_info": "Bytea" + }, + { + "ordinal": 14, + "name": "pubdata_type!", + "type_info": "Text" } ], "parameters": { @@ -88,8 +98,10 @@ false, false, true, + false, + false, false ] }, - "hash": "778f92b1ac91e1ae279f588053d75a9ac877fdd28bda99661e423405e695223d" + "hash": "9ea417e4ffef9e5d158089723692ba43fe8560be0c4aa7baa49e71b2a28187e7" } diff --git a/core/lib/dal/.sqlx/query-30268c71e4bd0d08015af6ae130d3ee5d5140714297401b4bde1e950ed6e971e.json b/core/lib/dal/.sqlx/query-ce6d5796dcc7c105fe3b3081b70327982ab744c7566645e9b0c69364f7021c5a.json similarity index 77% rename from core/lib/dal/.sqlx/query-30268c71e4bd0d08015af6ae130d3ee5d5140714297401b4bde1e950ed6e971e.json rename to core/lib/dal/.sqlx/query-ce6d5796dcc7c105fe3b3081b70327982ab744c7566645e9b0c69364f7021c5a.json index a96d94a5c55f..c3a238fb8ba2 100644 --- a/core/lib/dal/.sqlx/query-30268c71e4bd0d08015af6ae130d3ee5d5140714297401b4bde1e950ed6e971e.json +++ b/core/lib/dal/.sqlx/query-ce6d5796dcc7c105fe3b3081b70327982ab744c7566645e9b0c69364f7021c5a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n number = 0\n OR eth_commit_tx_id IS NOT NULL\n AND commitment IS NOT NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input,\n aggregation_root,\n local_root,\n state_diff_hash,\n data_availability.inclusion_data\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.l1_batch_number = l1_batches.number\n WHERE\n number = 0\n OR eth_commit_tx_id IS NOT NULL\n AND commitment IS NOT NULL\n ORDER BY\n number DESC\n LIMIT\n 1\n ", "describe": { "columns": [ { @@ -132,6 +132,26 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "aggregation_root", + "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "local_root", + "type_info": "Bytea" + }, + { + "ordinal": 28, + "name": "state_diff_hash", + "type_info": "Bytea" + }, + { + "ordinal": 29, + "name": "inclusion_data", + "type_info": "Bytea" } ], "parameters": { @@ -163,8 +183,12 @@ false, true, true, + true, + true, + true, + true, true ] }, - "hash": "30268c71e4bd0d08015af6ae130d3ee5d5140714297401b4bde1e950ed6e971e" + "hash": "ce6d5796dcc7c105fe3b3081b70327982ab744c7566645e9b0c69364f7021c5a" } diff --git a/core/lib/dal/.sqlx/query-4ef330359df85ad6e0110a068ef3afa9cf50eafc7ac542975edea9bd592ce862.json b/core/lib/dal/.sqlx/query-db3593883d5e1e636d65e25cc744637fc33467fbd64da5a431ecab194409371c.json similarity index 76% rename from core/lib/dal/.sqlx/query-4ef330359df85ad6e0110a068ef3afa9cf50eafc7ac542975edea9bd592ce862.json rename to core/lib/dal/.sqlx/query-db3593883d5e1e636d65e25cc744637fc33467fbd64da5a431ecab194409371c.json index 10e2a76618f6..40ed6af677aa 100644 --- a/core/lib/dal/.sqlx/query-4ef330359df85ad6e0110a068ef3afa9cf50eafc7ac542975edea9bd592ce862.json +++ b/core/lib/dal/.sqlx/query-db3593883d5e1e636d65e25cc744637fc33467fbd64da5a431ecab194409371c.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n eth_prove_tx_id IS NOT NULL\n AND eth_execute_tx_id IS NULL\n ORDER BY\n number\n LIMIT\n $1\n ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n protocol_version,\n compressed_state_diffs,\n system_logs,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input,\n aggregation_root,\n local_root,\n state_diff_hash,\n data_availability.inclusion_data\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n LEFT JOIN\n data_availability\n ON data_availability.l1_batch_number = l1_batches.number\n WHERE\n eth_prove_tx_id IS NOT NULL\n AND eth_execute_tx_id IS NULL\n ORDER BY\n number\n LIMIT\n $1\n ", "describe": { "columns": [ { @@ -132,6 +132,26 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "aggregation_root", + "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "local_root", + "type_info": "Bytea" + }, + { + "ordinal": 28, + "name": "state_diff_hash", + "type_info": "Bytea" + }, + { + "ordinal": 29, + "name": "inclusion_data", + "type_info": "Bytea" } ], "parameters": { @@ -165,8 +185,12 @@ false, true, true, + true, + true, + true, + true, true ] }, - "hash": "4ef330359df85ad6e0110a068ef3afa9cf50eafc7ac542975edea9bd592ce862" + "hash": "db3593883d5e1e636d65e25cc744637fc33467fbd64da5a431ecab194409371c" } diff --git a/core/lib/dal/.sqlx/query-ae30067056fe29febd68408c2ca2e604958488a41d3ee2bcbd05d269bcdfc7aa.json b/core/lib/dal/.sqlx/query-dc9a3821560030a8daf8dbdafe5f52aed204a20c67a6b959b16c2a60c745321e.json similarity index 72% rename from core/lib/dal/.sqlx/query-ae30067056fe29febd68408c2ca2e604958488a41d3ee2bcbd05d269bcdfc7aa.json rename to core/lib/dal/.sqlx/query-dc9a3821560030a8daf8dbdafe5f52aed204a20c67a6b959b16c2a60c745321e.json index 9e212249490c..269c3ebb3289 100644 --- a/core/lib/dal/.sqlx/query-ae30067056fe29febd68408c2ca2e604958488a41d3ee2bcbd05d269bcdfc7aa.json +++ b/core/lib/dal/.sqlx/query-dc9a3821560030a8daf8dbdafe5f52aed204a20c67a6b959b16c2a60c745321e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n system_logs,\n compressed_state_diffs,\n protocol_version,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input\n FROM\n (\n SELECT\n l1_batches.*,\n ROW_NUMBER() OVER (\n ORDER BY\n number ASC\n ) AS row_number\n FROM\n l1_batches\n WHERE\n eth_commit_tx_id IS NOT NULL\n AND l1_batches.skip_proof = TRUE\n AND l1_batches.number > $1\n ORDER BY\n number\n LIMIT\n $2\n ) inn\n LEFT JOIN commitments ON commitments.l1_batch_number = inn.number\n WHERE\n number - row_number = $1\n ", + "query": "\n SELECT\n number,\n timestamp,\n l1_tx_count,\n l2_tx_count,\n bloom,\n priority_ops_onchain_data,\n hash,\n commitment,\n l2_to_l1_messages,\n used_contract_hashes,\n compressed_initial_writes,\n compressed_repeated_writes,\n l2_l1_merkle_root,\n rollup_last_leaf_index,\n zkporter_is_available,\n bootloader_code_hash,\n default_aa_code_hash,\n aux_data_hash,\n pass_through_data_hash,\n meta_parameters_hash,\n system_logs,\n compressed_state_diffs,\n protocol_version,\n events_queue_commitment,\n bootloader_initial_content_commitment,\n pubdata_input,\n aggregation_root,\n local_root,\n state_diff_hash,\n data_availability.inclusion_data\n FROM\n (\n SELECT\n l1_batches.*,\n ROW_NUMBER() OVER (\n ORDER BY\n number ASC\n ) AS row_number\n FROM\n l1_batches\n WHERE\n eth_commit_tx_id IS NOT NULL\n AND l1_batches.skip_proof = TRUE\n AND l1_batches.number > $1\n ORDER BY\n number\n LIMIT\n $2\n ) inn\n LEFT JOIN commitments ON commitments.l1_batch_number = inn.number\n LEFT JOIN data_availability ON data_availability.l1_batch_number = inn.number\n WHERE\n number - row_number = $1\n ", "describe": { "columns": [ { @@ -132,6 +132,26 @@ "ordinal": 25, "name": "pubdata_input", "type_info": "Bytea" + }, + { + "ordinal": 26, + "name": "aggregation_root", + "type_info": "Bytea" + }, + { + "ordinal": 27, + "name": "local_root", + "type_info": "Bytea" + }, + { + "ordinal": 28, + "name": "state_diff_hash", + "type_info": "Bytea" + }, + { + "ordinal": 29, + "name": "inclusion_data", + "type_info": "Bytea" } ], "parameters": { @@ -166,8 +186,12 @@ true, true, true, + true, + true, + true, + true, true ] }, - "hash": "ae30067056fe29febd68408c2ca2e604958488a41d3ee2bcbd05d269bcdfc7aa" + "hash": "dc9a3821560030a8daf8dbdafe5f52aed204a20c67a6b959b16c2a60c745321e" } diff --git a/core/lib/dal/migrations/20240925103531_gateway_upgrade.down.sql b/core/lib/dal/migrations/20240925103531_gateway_upgrade.down.sql new file mode 100644 index 000000000000..9af34d7dc8ee --- /dev/null +++ b/core/lib/dal/migrations/20240925103531_gateway_upgrade.down.sql @@ -0,0 +1,8 @@ +ALTER TABLE l1_batches DROP COLUMN IF EXISTS state_diff_hash BYTEA; + +ALTER TABLE l1_batches DROP COLUMN IF EXISTS aggregation_root; +ALTER TABLE l1_batches DROP COLUMN IF EXISTS local_root; + +ALTER TABLE miniblocks + DROP COLUMN IF EXISTS l2_da_validator_address, + DROP COLUMN IF EXISTS pubdata_type; diff --git a/core/lib/dal/migrations/20240925103531_gateway_upgrade.up.sql b/core/lib/dal/migrations/20240925103531_gateway_upgrade.up.sql new file mode 100644 index 000000000000..a58464f6ebb3 --- /dev/null +++ b/core/lib/dal/migrations/20240925103531_gateway_upgrade.up.sql @@ -0,0 +1,11 @@ +ALTER TABLE l1_batches ADD COLUMN IF NOT EXISTS state_diff_hash BYTEA; + +ALTER TABLE l1_batches ADD COLUMN IF NOT EXISTS aggregation_root BYTEA; +ALTER TABLE l1_batches ADD COLUMN IF NOT EXISTS local_root BYTEA; + +ALTER TABLE miniblocks + ADD COLUMN IF NOT EXISTS l2_da_validator_address BYTEA NOT NULL DEFAULT '\x0000000000000000000000000000000000000000'::bytea, + -- There are miniblocks that used the `Rollup' type, but were actually used on a Validium chain. + -- This is okay, since this field represents how the VM works with the DA, rather what is committed on L1. + ADD COLUMN IF NOT EXISTS pubdata_type TEXT NOT NULL DEFAULT 'Rollup'; +-- ^ Add a default value so that DB queries don't fail even if the DB migration is not completed. diff --git a/core/lib/dal/src/blocks_dal.rs b/core/lib/dal/src/blocks_dal.rs index 5b351511a06d..cb291da7313c 100644 --- a/core/lib/dal/src/blocks_dal.rs +++ b/core/lib/dal/src/blocks_dal.rs @@ -333,10 +333,17 @@ impl BlocksDal<'_, '_> { compressed_state_diffs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + aggregation_root, + local_root, + state_diff_hash, + data_availability.inclusion_data FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + LEFT JOIN + data_availability + ON data_availability.l1_batch_number = l1_batches.number WHERE number = $1 "#, @@ -708,6 +715,8 @@ impl BlocksDal<'_, '_> { fair_pubdata_price, gas_limit, logs_bloom, + l2_da_validator_address, + pubdata_type, created_at, updated_at ) @@ -730,6 +739,8 @@ impl BlocksDal<'_, '_> { $15, $16, $17, + $18, + $19, NOW(), NOW() ) @@ -757,6 +768,11 @@ impl BlocksDal<'_, '_> { l2_block_header.batch_fee_input.fair_pubdata_price() as i64, l2_block_header.gas_limit as i64, l2_block_header.logs_bloom.as_bytes(), + l2_block_header + .pubdata_params + .l2_da_validator_address + .as_bytes(), + l2_block_header.pubdata_params.pubdata_type.to_string(), ); instrumentation.with(query).execute(self.storage).await?; @@ -784,7 +800,9 @@ impl BlocksDal<'_, '_> { virtual_blocks, fair_pubdata_price, gas_limit, - logs_bloom + logs_bloom, + l2_da_validator_address, + pubdata_type FROM miniblocks ORDER BY @@ -824,7 +842,9 @@ impl BlocksDal<'_, '_> { virtual_blocks, fair_pubdata_price, gas_limit, - logs_bloom + logs_bloom, + l2_da_validator_address, + pubdata_type FROM miniblocks WHERE @@ -921,9 +941,12 @@ impl BlocksDal<'_, '_> { compressed_state_diffs = $7, compressed_initial_writes = $8, compressed_repeated_writes = $9, + state_diff_hash = $10, + aggregation_root = $11, + local_root = $12, updated_at = NOW() WHERE - number = $10 + number = $13 AND commitment IS NULL "#, commitment_artifacts.commitment_hash.commitment.as_bytes(), @@ -941,6 +964,9 @@ impl BlocksDal<'_, '_> { commitment_artifacts.compressed_state_diffs, commitment_artifacts.compressed_initial_writes, commitment_artifacts.compressed_repeated_writes, + commitment_artifacts.state_diff_hash.as_bytes(), + commitment_artifacts.aggregation_root.as_bytes(), + commitment_artifacts.local_root.as_bytes(), i64::from(number.0), ) .instrument("save_l1_batch_commitment_artifacts") @@ -1046,10 +1072,17 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + aggregation_root, + local_root, + state_diff_hash, + data_availability.inclusion_data FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + LEFT JOIN + data_availability + ON data_availability.l1_batch_number = l1_batches.number WHERE number = 0 OR eth_commit_tx_id IS NOT NULL @@ -1232,10 +1265,17 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + aggregation_root, + local_root, + state_diff_hash, + data_availability.inclusion_data FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + LEFT JOIN + data_availability + ON data_availability.l1_batch_number = l1_batches.number WHERE eth_commit_tx_id IS NOT NULL AND eth_prove_tx_id IS NULL @@ -1312,7 +1352,11 @@ impl BlocksDal<'_, '_> { protocol_version, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + aggregation_root, + local_root, + state_diff_hash, + data_availability.inclusion_data FROM ( SELECT @@ -1333,6 +1377,7 @@ impl BlocksDal<'_, '_> { $2 ) inn LEFT JOIN commitments ON commitments.l1_batch_number = inn.number + LEFT JOIN data_availability ON data_availability.l1_batch_number = inn.number WHERE number - row_number = $1 "#, @@ -1385,10 +1430,17 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + aggregation_root, + local_root, + state_diff_hash, + data_availability.inclusion_data FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + LEFT JOIN + data_availability + ON data_availability.l1_batch_number = l1_batches.number WHERE eth_prove_tx_id IS NOT NULL AND eth_execute_tx_id IS NULL @@ -1512,10 +1564,17 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + aggregation_root, + local_root, + state_diff_hash, + data_availability.inclusion_data FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number + LEFT JOIN + data_availability + ON data_availability.l1_batch_number = l1_batches.number WHERE number BETWEEN $1 AND $2 ORDER BY @@ -1576,11 +1635,18 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + aggregation_root, + local_root, + state_diff_hash, + data_availability.inclusion_data FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number JOIN protocol_versions ON protocol_versions.id = l1_batches.protocol_version + LEFT JOIN + data_availability + ON data_availability.l1_batch_number = l1_batches.number WHERE eth_commit_tx_id IS NULL AND number != 0 @@ -1654,7 +1720,11 @@ impl BlocksDal<'_, '_> { system_logs, events_queue_commitment, bootloader_initial_content_commitment, - pubdata_input + pubdata_input, + aggregation_root, + local_root, + state_diff_hash, + data_availability.inclusion_data FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number diff --git a/core/lib/dal/src/consensus/mod.rs b/core/lib/dal/src/consensus/mod.rs index f01655d56a95..fd56209a1f59 100644 --- a/core/lib/dal/src/consensus/mod.rs +++ b/core/lib/dal/src/consensus/mod.rs @@ -12,7 +12,9 @@ use zksync_concurrency::net; use zksync_consensus_roles::{attester, node, validator}; use zksync_protobuf::{read_required, required, ProtoFmt, ProtoRepr}; use zksync_types::{ - abi, ethabi, + abi, + commitment::{L1BatchCommitmentMode, PubdataParams}, + ethabi, fee::Fee, l1::{OpProcessingType, PriorityQueueType}, l2::TransactionType, @@ -112,6 +114,22 @@ impl ProtoFmt for AttestationStatus { } } +impl proto::L1BatchCommitDataGeneratorMode { + pub(crate) fn new(n: &L1BatchCommitmentMode) -> Self { + match n { + L1BatchCommitmentMode::Rollup => Self::Rollup, + L1BatchCommitmentMode::Validium => Self::Validium, + } + } + + pub(crate) fn parse(&self) -> L1BatchCommitmentMode { + match self { + Self::Rollup => L1BatchCommitmentMode::Rollup, + Self::Validium => L1BatchCommitmentMode::Validium, + } + } +} + /// L2 block (= miniblock) payload. #[derive(Debug, PartialEq)] pub struct Payload { @@ -126,6 +144,7 @@ pub struct Payload { pub operator_address: Address, pub transactions: Vec, pub last_in_batch: bool, + pub pubdata_params: Option, } impl ProtoFmt for Payload { @@ -161,6 +180,20 @@ impl ProtoFmt for Payload { } } + let pubdata_params = if let Some(pubdata_params) = &r.pubdata_params { + Some(PubdataParams { + l2_da_validator_address: required(&pubdata_params.l2_da_validator_address) + .and_then(|a| parse_h160(a)) + .context("operator_address")?, + pubdata_type: required(&pubdata_params.pubdata_type) + .and_then(|x| Ok(proto::L1BatchCommitDataGeneratorMode::try_from(*x)?)) + .context("l1_batch_commit_data_generator_mode")? + .parse(), + }) + } else { + None + }; + Ok(Self { protocol_version, hash: required(&r.hash) @@ -179,6 +212,7 @@ impl ProtoFmt for Payload { .context("operator_address")?, transactions, last_in_batch: *required(&r.last_in_batch).context("last_in_batch")?, + pubdata_params, }) } @@ -197,6 +231,16 @@ impl ProtoFmt for Payload { transactions: vec![], transactions_v25: vec![], last_in_batch: Some(self.last_in_batch), + pubdata_params: self + .pubdata_params + .map(|pubdata_params| proto::PubdataParams { + l2_da_validator_address: Some( + pubdata_params.l2_da_validator_address.as_bytes().into(), + ), + pubdata_type: Some(proto::L1BatchCommitDataGeneratorMode::new( + &pubdata_params.pubdata_type, + ) as i32), + }), }; match self.protocol_version { v if v >= ProtocolVersionId::Version25 => { diff --git a/core/lib/dal/src/consensus/proto/mod.proto b/core/lib/dal/src/consensus/proto/mod.proto index ab1245f3ef6a..52642b3af9b7 100644 --- a/core/lib/dal/src/consensus/proto/mod.proto +++ b/core/lib/dal/src/consensus/proto/mod.proto @@ -22,6 +22,12 @@ message Payload { // Set for protocol_version >= 25. repeated TransactionV25 transactions_v25 = 12; optional bool last_in_batch = 10; // required + optional PubdataParams pubdata_params = 13; // optional +} + +message PubdataParams { + optional bytes l2_da_validator_address = 1; // required; H160 + optional L1BatchCommitDataGeneratorMode pubdata_type = 2; // required } message L1Transaction { @@ -138,3 +144,8 @@ message AttestationStatus { optional roles.validator.GenesisHash genesis = 1; // required optional uint64 next_batch_to_attest = 2; // required } + +enum L1BatchCommitDataGeneratorMode { + Rollup = 0; + Validium = 1; +} diff --git a/core/lib/dal/src/consensus/tests.rs b/core/lib/dal/src/consensus/tests.rs index 7059f1a74ea0..e50ff5b1caeb 100644 --- a/core/lib/dal/src/consensus/tests.rs +++ b/core/lib/dal/src/consensus/tests.rs @@ -9,7 +9,9 @@ use zksync_protobuf::{ }; use zksync_test_account::Account; use zksync_types::{ - web3::Bytes, Execute, ExecuteTransactionCommon, L1BatchNumber, ProtocolVersionId, Transaction, + commitment::{L1BatchCommitmentMode, PubdataParams}, + web3::Bytes, + Execute, ExecuteTransactionCommon, L1BatchNumber, ProtocolVersionId, Transaction, }; use super::{proto, AttestationStatus, Payload}; @@ -51,6 +53,13 @@ fn payload(rng: &mut impl Rng, protocol_version: ProtocolVersionId) -> Payload { }) .collect(), last_in_batch: rng.gen(), + pubdata_params: Some(PubdataParams { + pubdata_type: match rng.gen_range(0..2) { + 0 => L1BatchCommitmentMode::Rollup, + _ => L1BatchCommitmentMode::Validium, + }, + l2_da_validator_address: rng.gen(), + }), } } diff --git a/core/lib/dal/src/eth_watcher_dal.rs b/core/lib/dal/src/eth_watcher_dal.rs index bdfc7f24c7b5..062ad47219d8 100644 --- a/core/lib/dal/src/eth_watcher_dal.rs +++ b/core/lib/dal/src/eth_watcher_dal.rs @@ -107,7 +107,7 @@ mod tests { async fn test_get_or_set_next_block_to_process_with_different_event_types() { let pool = ConnectionPool::::test_pool().await; let mut conn = pool.connection().await.unwrap(); - let mut dal = conn.processed_events_dal(); + let mut dal = conn.eth_watcher_dal(); // Test with ProtocolUpgrades let next_block = dal diff --git a/core/lib/dal/src/lib.rs b/core/lib/dal/src/lib.rs index f0d2f0c16711..a57ebd9e48ac 100644 --- a/core/lib/dal/src/lib.rs +++ b/core/lib/dal/src/lib.rs @@ -135,7 +135,7 @@ where fn base_token_dal(&mut self) -> BaseTokenDal<'_, 'a>; - fn processed_events_dal(&mut self) -> EthWatcherDal<'_, 'a>; + fn eth_watcher_dal(&mut self) -> EthWatcherDal<'_, 'a>; } #[derive(Clone, Debug)] @@ -263,7 +263,7 @@ impl<'a> CoreDal<'a> for Connection<'a, Core> { BaseTokenDal { storage: self } } - fn processed_events_dal(&mut self) -> EthWatcherDal<'_, 'a> { + fn eth_watcher_dal(&mut self) -> EthWatcherDal<'_, 'a> { EthWatcherDal { storage: self } } } diff --git a/core/lib/dal/src/models/storage_block.rs b/core/lib/dal/src/models/storage_block.rs index 34e14387ca61..7c9a6491cd8c 100644 --- a/core/lib/dal/src/models/storage_block.rs +++ b/core/lib/dal/src/models/storage_block.rs @@ -7,7 +7,7 @@ use zksync_contracts::BaseSystemContractsHashes; use zksync_types::{ api, block::{L1BatchHeader, L2BlockHeader}, - commitment::{L1BatchMetaParameters, L1BatchMetadata}, + commitment::{L1BatchCommitmentMode, L1BatchMetaParameters, L1BatchMetadata, PubdataParams}, fee_model::{BatchFeeInput, L1PeggedBatchFeeModelInput, PubdataIndependentBatchFeeModelInput}, l2_to_l1_log::{L2ToL1Log, SystemL2ToL1Log, UserL2ToL1Log}, Address, Bloom, L1BatchNumber, L2BlockNumber, ProtocolVersionId, H256, @@ -147,6 +147,10 @@ pub(crate) struct StorageL1Batch { pub events_queue_commitment: Option>, pub bootloader_initial_content_commitment: Option>, pub pubdata_input: Option>, + pub aggregation_root: Option>, + pub local_root: Option>, + pub state_diff_hash: Option>, + pub inclusion_data: Option>, } impl StorageL1Batch { @@ -249,6 +253,10 @@ impl TryFrom for L1BatchMetadata { bootloader_initial_content_commitment: batch .bootloader_initial_content_commitment .map(|v| H256::from_slice(&v)), + state_diff_hash: batch.state_diff_hash.map(|v| H256::from_slice(&v)), + local_root: batch.local_root.map(|v| H256::from_slice(&v)), + aggregation_root: batch.aggregation_root.map(|v| H256::from_slice(&v)), + da_inclusion_data: batch.inclusion_data, }) } } @@ -434,6 +442,8 @@ pub(crate) struct StorageL2BlockHeader { /// This value should bound the maximal amount of gas that can be spent by transactions in the miniblock. pub gas_limit: Option, pub logs_bloom: Option>, + pub l2_da_validator_address: Vec, + pub pubdata_type: String, } impl From for L2BlockHeader { @@ -480,6 +490,10 @@ impl From for L2BlockHeader { .logs_bloom .map(|b| Bloom::from_slice(&b)) .unwrap_or_default(), + pubdata_params: PubdataParams { + l2_da_validator_address: Address::from_slice(&row.l2_da_validator_address), + pubdata_type: L1BatchCommitmentMode::from_str(&row.pubdata_type).unwrap(), + }, } } } diff --git a/core/lib/dal/src/models/storage_sync.rs b/core/lib/dal/src/models/storage_sync.rs index 688a6f997904..8f7679fe2cc8 100644 --- a/core/lib/dal/src/models/storage_sync.rs +++ b/core/lib/dal/src/models/storage_sync.rs @@ -1,7 +1,11 @@ +use std::str::FromStr; + use zksync_contracts::BaseSystemContractsHashes; use zksync_db_connection::error::SqlxContext; use zksync_types::{ - api::en, Address, L1BatchNumber, L2BlockNumber, ProtocolVersionId, Transaction, H256, + api::en, + commitment::{L1BatchCommitmentMode, PubdataParams}, + Address, L1BatchNumber, L2BlockNumber, ProtocolVersionId, Transaction, H256, }; use crate::{ @@ -26,6 +30,8 @@ pub(crate) struct StorageSyncBlock { pub protocol_version: i32, pub virtual_blocks: i64, pub hash: Vec, + pub l2_da_validator_address: Vec, + pub pubdata_type: String, } pub(crate) struct SyncBlock { @@ -41,6 +47,7 @@ pub(crate) struct SyncBlock { pub virtual_blocks: u32, pub hash: H256, pub protocol_version: ProtocolVersionId, + pub pubdata_params: PubdataParams, } impl TryFrom for SyncBlock { @@ -84,6 +91,12 @@ impl TryFrom for SyncBlock { .decode_column("virtual_blocks")?, hash: parse_h256(&block.hash).decode_column("hash")?, protocol_version: parse_protocol_version(block.protocol_version)?, + pubdata_params: PubdataParams { + pubdata_type: L1BatchCommitmentMode::from_str(&block.pubdata_type) + .expect("Invalid pubdata type"), + l2_da_validator_address: parse_h160(&block.l2_da_validator_address) + .decode_column("l2_da_validator_address")?, + }, }) } } @@ -104,6 +117,7 @@ impl SyncBlock { virtual_blocks: Some(self.virtual_blocks), hash: Some(self.hash), protocol_version: self.protocol_version, + pubdata_params: Some(self.pubdata_params), } } @@ -120,6 +134,7 @@ impl SyncBlock { operator_address: self.fee_account_address, transactions, last_in_batch: self.last_in_batch, + pubdata_params: Some(self.pubdata_params), } } } diff --git a/core/lib/dal/src/sync_dal.rs b/core/lib/dal/src/sync_dal.rs index ec6ee0f92812..c4043b6641e0 100644 --- a/core/lib/dal/src/sync_dal.rs +++ b/core/lib/dal/src/sync_dal.rs @@ -53,7 +53,9 @@ impl SyncDal<'_, '_> { miniblocks.virtual_blocks, miniblocks.hash, miniblocks.protocol_version AS "protocol_version!", - miniblocks.fee_account_address AS "fee_account_address!" + miniblocks.fee_account_address AS "fee_account_address!", + miniblocks.l2_da_validator_address AS "l2_da_validator_address!", + miniblocks.pubdata_type AS "pubdata_type!" FROM miniblocks WHERE diff --git a/core/lib/dal/src/tests/mod.rs b/core/lib/dal/src/tests/mod.rs index dc672fa1f807..505f46250de0 100644 --- a/core/lib/dal/src/tests/mod.rs +++ b/core/lib/dal/src/tests/mod.rs @@ -4,6 +4,7 @@ use zksync_contracts::BaseSystemContractsHashes; use zksync_db_connection::connection_pool::ConnectionPool; use zksync_types::{ block::{L1BatchHeader, L2BlockHasher, L2BlockHeader}, + commitment::PubdataParams, fee::Fee, fee_model::BatchFeeInput, helpers::unix_timestamp_ms, @@ -52,6 +53,7 @@ pub(crate) fn create_l2_block_header(number: u32) -> L2BlockHeader { virtual_blocks: 1, gas_limit: 0, logs_bloom: Default::default(), + pubdata_params: PubdataParams::default(), } } pub(crate) fn create_l1_batch_header(number: u32) -> L1BatchHeader { diff --git a/core/lib/env_config/src/contracts.rs b/core/lib/env_config/src/contracts.rs index 298c43b80ccd..3792f356be4e 100644 --- a/core/lib/env_config/src/contracts.rs +++ b/core/lib/env_config/src/contracts.rs @@ -63,6 +63,7 @@ mod tests { l2_weth_bridge_addr: Some(addr("8656770FA78c830456B00B4fFCeE6b1De0e1b888")), l1_shared_bridge_proxy_addr: Some(addr("8656770FA78c830456B00B4fFCeE6b1De0e1b888")), l2_shared_bridge_addr: Some(addr("8656770FA78c830456B00B4fFCeE6b1De0e1b888")), + l2_legacy_shared_bridge_addr: Some(addr("8656770FA78c830456B00B4fFCeE6b1De0e1b888")), l2_testnet_paymaster_addr: Some(addr("FC073319977e314F251EAE6ae6bE76B0B3BAeeCF")), l1_multicall3_addr: addr("0xcA11bde05977b3631167028862bE2a173976CA11"), ecosystem_contracts: Some(EcosystemContracts { @@ -72,6 +73,7 @@ mod tests { }), base_token_addr: Some(SHARED_BRIDGE_ETHER_TOKEN_ADDRESS), chain_admin_addr: Some(addr("0xdd6fa5c14e7550b4caf2aa2818d24c69cbc347ff")), + l2_da_validator_addr: Some(addr("0xed6fa5c14e7550b4caf2aa2818d24c69cbc347ff")), } } @@ -93,11 +95,13 @@ CONTRACTS_L2_CONSENSUS_REGISTRY_ADDR="D64e136566a9E04eb05B30184fF577F52682D182" CONTRACTS_L1_MULTICALL3_ADDR="0xcA11bde05977b3631167028862bE2a173976CA11" CONTRACTS_L1_SHARED_BRIDGE_PROXY_ADDR="0x8656770FA78c830456B00B4fFCeE6b1De0e1b888" CONTRACTS_L2_SHARED_BRIDGE_ADDR="0x8656770FA78c830456B00B4fFCeE6b1De0e1b888" +CONTRACTS_L2_LEGACY_SHARED_BRIDGE_ADDR="0x8656770FA78c830456B00B4fFCeE6b1De0e1b888" CONTRACTS_BRIDGEHUB_PROXY_ADDR="0x35ea7f92f4c5f433efe15284e99c040110cf6297" CONTRACTS_STATE_TRANSITION_PROXY_ADDR="0xd90f1c081c6117241624e97cb6147257c3cb2097" CONTRACTS_TRANSPARENT_PROXY_ADMIN_ADDR="0xdd6fa5c14e7550b4caf2aa2818d24c69cbc347e5" CONTRACTS_BASE_TOKEN_ADDR="0x0000000000000000000000000000000000000001" CONTRACTS_CHAIN_ADMIN_ADDR="0xdd6fa5c14e7550b4caf2aa2818d24c69cbc347ff" +CONTRACTS_L2_DA_VALIDATOR_ADDR="0xed6fa5c14e7550b4caf2aa2818d24c69cbc347ff" "#; lock.set_env(config); diff --git a/core/lib/eth_client/src/clients/http/query.rs b/core/lib/eth_client/src/clients/http/query.rs index 54419f3b5626..2b1fb3e819c8 100644 --- a/core/lib/eth_client/src/clients/http/query.rs +++ b/core/lib/eth_client/src/clients/http/query.rs @@ -15,7 +15,7 @@ use crate::{ BaseFees, EthFeeInterface, EthInterface, RawTransactionBytes, }; -const FEE_HISTORY_MAX_REQUEST_CHUNK: usize = 1024; +const FEE_HISTORY_MAX_REQUEST_CHUNK: usize = 1023; #[async_trait] impl EthInterface for T @@ -304,14 +304,14 @@ where COUNTERS.call[&(Method::BaseFeeHistory, client.component())].inc(); let latency = LATENCIES.direct[&Method::BaseFeeHistory].start(); let mut history = Vec::with_capacity(block_count); - let from_block = upto_block.saturating_sub(block_count); + let from_block = upto_block.saturating_sub(block_count - 1); // Here we are requesting `fee_history` from blocks // `(from_block; upto_block)` in chunks of size `MAX_REQUEST_CHUNK` // starting from the oldest block. for chunk_start in (from_block..=upto_block).step_by(FEE_HISTORY_MAX_REQUEST_CHUNK) { let chunk_end = (chunk_start + FEE_HISTORY_MAX_REQUEST_CHUNK).min(upto_block); - let chunk_size = chunk_end - chunk_start; + let chunk_size = chunk_end - chunk_start + 1; let fee_history = client .fee_history( @@ -324,22 +324,50 @@ where .with_arg("block", &chunk_end) .await?; - // Check that the lengths are the same. + if fee_history.oldest_block != web3::BlockNumber::Number(chunk_start.into()) { + let oldest_block = match fee_history.oldest_block { + web3::BlockNumber::Number(oldest_block) => oldest_block.to_string(), + _ => format!("{:?}", fee_history.oldest_block), + }; + let message = + format!("unexpected `oldest_block`, expected: {chunk_start}, got {oldest_block}"); + return Err(EnrichedClientError::custom(message, "l1_fee_history") + .with_arg("chunk_size", &chunk_size) + .with_arg("chunk_end", &chunk_end)); + } + + if fee_history.base_fee_per_gas.len() != chunk_size + 1 { + let message = format!( + "unexpected `base_fee_per_gas.len()`, expected: {}, got {}", + chunk_size + 1, + fee_history.base_fee_per_gas.len() + ); + return Err(EnrichedClientError::custom(message, "l1_fee_history") + .with_arg("chunk_size", &chunk_size) + .with_arg("chunk_end", &chunk_end)); + } + // Per specification, the values should always be provided, and must be 0 for blocks // prior to EIP-4844. // https://ethereum.github.io/execution-apis/api-documentation/ - if fee_history.base_fee_per_gas.len() != fee_history.base_fee_per_blob_gas.len() { - tracing::error!( - "base_fee_per_gas and base_fee_per_blob_gas have different lengths: {} and {}", - fee_history.base_fee_per_gas.len(), + if fee_history.base_fee_per_blob_gas.len() != chunk_size + 1 { + let message = format!( + "unexpected `base_fee_per_blob_gas.len()`, expected: {}, got {}", + chunk_size + 1, fee_history.base_fee_per_blob_gas.len() ); + return Err(EnrichedClientError::custom(message, "l1_fee_history") + .with_arg("chunk_size", &chunk_size) + .with_arg("chunk_end", &chunk_end)); } + // We take `chunk_size` entries for consistency with `l2_base_fee_history` which doesn't + // have correct data for block with number `upto_block + 1`. for (base, blob) in fee_history .base_fee_per_gas .into_iter() .zip(fee_history.base_fee_per_blob_gas) + .take(chunk_size) { let fees = BaseFees { base_fee_per_gas: cast_to_u64(base, "base_fee_per_gas")?, @@ -387,14 +415,14 @@ where COUNTERS.call[&(Method::L2FeeHistory, client.component())].inc(); let latency = LATENCIES.direct[&Method::BaseFeeHistory].start(); let mut history = Vec::with_capacity(block_count); - let from_block = upto_block.saturating_sub(block_count); + let from_block = upto_block.saturating_sub(block_count - 1); // Here we are requesting `fee_history` from blocks // `(from_block; upto_block)` in chunks of size `FEE_HISTORY_MAX_REQUEST_CHUNK` // starting from the oldest block. for chunk_start in (from_block..=upto_block).step_by(FEE_HISTORY_MAX_REQUEST_CHUNK) { let chunk_end = (chunk_start + FEE_HISTORY_MAX_REQUEST_CHUNK).min(upto_block); - let chunk_size = chunk_end - chunk_start; + let chunk_size = chunk_end - chunk_start + 1; let fee_history = EthNamespaceClient::fee_history( client, @@ -407,19 +435,46 @@ where .with_arg("block", &chunk_end) .await?; - // Check that the lengths are the same. - if fee_history.inner.base_fee_per_gas.len() != fee_history.l2_pubdata_price.len() { - tracing::error!( - "base_fee_per_gas and pubdata_price have different lengths: {} and {}", - fee_history.inner.base_fee_per_gas.len(), + if fee_history.inner.oldest_block != web3::BlockNumber::Number(chunk_start.into()) { + let oldest_block = match fee_history.inner.oldest_block { + web3::BlockNumber::Number(oldest_block) => oldest_block.to_string(), + _ => format!("{:?}", fee_history.inner.oldest_block), + }; + let message = + format!("unexpected `oldest_block`, expected: {chunk_start}, got {oldest_block}"); + return Err(EnrichedClientError::custom(message, "l2_fee_history") + .with_arg("chunk_size", &chunk_size) + .with_arg("chunk_end", &chunk_end)); + } + + if fee_history.inner.base_fee_per_gas.len() != chunk_size + 1 { + let message = format!( + "unexpected `base_fee_per_gas.len()`, expected: {}, got {}", + chunk_size + 1, + fee_history.inner.base_fee_per_gas.len() + ); + return Err(EnrichedClientError::custom(message, "l2_fee_history") + .with_arg("chunk_size", &chunk_size) + .with_arg("chunk_end", &chunk_end)); + } + + if fee_history.l2_pubdata_price.len() != chunk_size { + let message = format!( + "unexpected `l2_pubdata_price.len()`, expected: {}, got {}", + chunk_size + 1, fee_history.l2_pubdata_price.len() ); + return Err(EnrichedClientError::custom(message, "l2_fee_history") + .with_arg("chunk_size", &chunk_size) + .with_arg("chunk_end", &chunk_end)); } + // We take `chunk_size` entries because base fee for block `upto_block + 1` may change. for (base, l2_pubdata_price) in fee_history .inner .base_fee_per_gas .into_iter() + .take(chunk_size) .zip(fee_history.l2_pubdata_price) { let fees = BaseFees { diff --git a/core/lib/eth_client/src/clients/mock.rs b/core/lib/eth_client/src/clients/mock.rs index b33554b6292c..8e81b6c6f209 100644 --- a/core/lib/eth_client/src/clients/mock.rs +++ b/core/lib/eth_client/src/clients/mock.rs @@ -415,25 +415,35 @@ fn l2_eth_fee_history( let from_block = from_block.as_usize(); let start_block = from_block.saturating_sub(block_count.as_usize() - 1); + // duplicates last value to follow `feeHistory` response format, it should return `block_count + 1` values + let base_fee_per_gas = base_fee_history[start_block..=from_block] + .iter() + .chain([&base_fee_history[from_block]]) + .map(|fee| U256::from(fee.base_fee_per_gas)) + .collect(); + + // duplicates last value to follow `feeHistory` response format, it should return `block_count + 1` values + let base_fee_per_blob_gas = base_fee_history[start_block..=from_block] + .iter() + .chain([&base_fee_history[from_block]]) // duplicate last value + .map(|fee| fee.base_fee_per_blob_gas) + .collect(); + + let l2_pubdata_price = base_fee_history[start_block..=from_block] + .iter() + .map(|fee| fee.l2_pubdata_price) + .collect(); + FeeHistory { inner: web3::FeeHistory { oldest_block: start_block.into(), - base_fee_per_gas: base_fee_history[start_block..=from_block] - .iter() - .map(|fee| U256::from(fee.base_fee_per_gas)) - .collect(), - base_fee_per_blob_gas: base_fee_history[start_block..=from_block] - .iter() - .map(|fee| fee.base_fee_per_blob_gas) - .collect(), + base_fee_per_gas, + base_fee_per_blob_gas, gas_used_ratio: vec![], // not used blob_gas_used_ratio: vec![], // not used reward: None, }, - l2_pubdata_price: base_fee_history[start_block..=from_block] - .iter() - .map(|fee| fee.l2_pubdata_price) - .collect(), + l2_pubdata_price, } } diff --git a/core/lib/multivm/Cargo.toml b/core/lib/multivm/Cargo.toml index 2c2cd4f044b9..3bb8fd9b11f9 100644 --- a/core/lib/multivm/Cargo.toml +++ b/core/lib/multivm/Cargo.toml @@ -28,6 +28,7 @@ zksync_types.workspace = true zksync_contracts.workspace = true zksync_utils.workspace = true zksync_system_constants.workspace = true +zksync_mini_merkle_tree.workspace = true zksync_vm_interface.workspace = true anyhow.workspace = true diff --git a/core/lib/multivm/src/utils/mod.rs b/core/lib/multivm/src/utils/mod.rs index 5d8fba7a2acd..a55adb16c85a 100644 --- a/core/lib/multivm/src/utils/mod.rs +++ b/core/lib/multivm/src/utils/mod.rs @@ -53,7 +53,9 @@ pub fn derive_base_fee_and_gas_per_pubdata( VmVersion::Vm1_4_2 => crate::vm_1_4_2::utils::fee::derive_base_fee_and_gas_per_pubdata( batch_fee_input.into_pubdata_independent(), ), - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => { crate::vm_latest::utils::fee::derive_base_fee_and_gas_per_pubdata( batch_fee_input.into_pubdata_independent(), ) @@ -81,9 +83,9 @@ pub fn get_batch_base_fee(l1_batch_env: &L1BatchEnv, vm_version: VmVersion) -> u } VmVersion::Vm1_4_1 => crate::vm_1_4_1::utils::fee::get_batch_base_fee(l1_batch_env), VmVersion::Vm1_4_2 => crate::vm_1_4_2::utils::fee::get_batch_base_fee(l1_batch_env), - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { - crate::vm_latest::utils::fee::get_batch_base_fee(l1_batch_env) - } + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => crate::vm_latest::utils::fee::get_batch_base_fee(l1_batch_env), } } @@ -209,9 +211,9 @@ pub fn derive_overhead( } VmVersion::Vm1_4_1 => crate::vm_1_4_1::utils::overhead::derive_overhead(encoded_len), VmVersion::Vm1_4_2 => crate::vm_1_4_2::utils::overhead::derive_overhead(encoded_len), - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { - crate::vm_latest::utils::overhead::derive_overhead(encoded_len) - } + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => crate::vm_latest::utils::overhead::derive_overhead(encoded_len), } } @@ -245,6 +247,9 @@ pub fn get_bootloader_encoding_space(version: VmVersion) -> u32 { crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory, ) } + VmVersion::VmGateway => crate::vm_latest::constants::get_bootloader_tx_encoding_space( + crate::vm_latest::MultiVMSubversion::Gateway, + ), } } @@ -264,9 +269,9 @@ pub fn get_bootloader_max_txs_in_batch(version: VmVersion) -> usize { VmVersion::VmBoojumIntegration => crate::vm_boojum_integration::constants::MAX_TXS_IN_BLOCK, VmVersion::Vm1_4_1 => crate::vm_1_4_1::constants::MAX_TXS_IN_BATCH, VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::MAX_TXS_IN_BATCH, - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { - crate::vm_latest::constants::MAX_TXS_IN_BATCH - } + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => crate::vm_latest::constants::MAX_TXS_IN_BATCH, } } @@ -287,9 +292,9 @@ pub fn gas_bootloader_batch_tip_overhead(version: VmVersion) -> u32 { } VmVersion::Vm1_4_1 => crate::vm_1_4_1::constants::BOOTLOADER_BATCH_TIP_OVERHEAD, VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::BOOTLOADER_BATCH_TIP_OVERHEAD, - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { - crate::vm_latest::constants::BOOTLOADER_BATCH_TIP_OVERHEAD - } + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => crate::vm_latest::constants::BOOTLOADER_BATCH_TIP_OVERHEAD, } } @@ -310,7 +315,9 @@ pub fn circuit_statistics_bootloader_batch_tip_overhead(version: VmVersion) -> u VmVersion::Vm1_4_2 => { crate::vm_1_4_2::constants::BOOTLOADER_BATCH_TIP_CIRCUIT_STATISTICS_OVERHEAD as usize } - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => { crate::vm_latest::constants::BOOTLOADER_BATCH_TIP_CIRCUIT_STATISTICS_OVERHEAD as usize } } @@ -333,7 +340,9 @@ pub fn execution_metrics_bootloader_batch_tip_overhead(version: VmVersion) -> us VmVersion::Vm1_4_2 => { crate::vm_1_4_2::constants::BOOTLOADER_BATCH_TIP_METRICS_SIZE_OVERHEAD as usize } - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => { crate::vm_latest::constants::BOOTLOADER_BATCH_TIP_METRICS_SIZE_OVERHEAD as usize } } @@ -357,9 +366,9 @@ pub fn get_max_gas_per_pubdata_byte(version: VmVersion) -> u64 { } VmVersion::Vm1_4_1 => crate::vm_1_4_1::constants::MAX_GAS_PER_PUBDATA_BYTE, VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::MAX_GAS_PER_PUBDATA_BYTE, - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { - crate::vm_latest::constants::MAX_GAS_PER_PUBDATA_BYTE - } + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => crate::vm_latest::constants::MAX_GAS_PER_PUBDATA_BYTE, } } @@ -393,6 +402,9 @@ pub fn get_used_bootloader_memory_bytes(version: VmVersion) -> usize { crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory, ) } + VmVersion::VmGateway => crate::vm_latest::constants::get_used_bootloader_memory_bytes( + crate::vm_latest::MultiVMSubversion::Gateway, + ), } } @@ -426,6 +438,9 @@ pub fn get_used_bootloader_memory_words(version: VmVersion) -> usize { crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory, ) } + VmVersion::VmGateway => crate::vm_latest::constants::get_used_bootloader_memory_bytes( + crate::vm_latest::MultiVMSubversion::Gateway, + ), } } @@ -447,9 +462,9 @@ pub fn get_max_batch_gas_limit(version: VmVersion) -> u64 { } VmVersion::Vm1_4_1 => crate::vm_1_4_1::constants::BLOCK_GAS_LIMIT as u64, VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::BLOCK_GAS_LIMIT as u64, - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { - crate::vm_latest::constants::BATCH_GAS_LIMIT - } + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => crate::vm_latest::constants::BATCH_GAS_LIMIT, } } @@ -473,9 +488,9 @@ pub fn get_eth_call_gas_limit(version: VmVersion) -> u64 { } VmVersion::Vm1_4_1 => crate::vm_1_4_1::constants::ETH_CALL_GAS_LIMIT as u64, VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::ETH_CALL_GAS_LIMIT as u64, - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { - crate::vm_latest::constants::ETH_CALL_GAS_LIMIT - } + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => crate::vm_latest::constants::ETH_CALL_GAS_LIMIT, } } @@ -496,9 +511,9 @@ pub fn get_max_batch_base_layer_circuits(version: VmVersion) -> usize { // We avoid providing `0` for the old versions to avoid potential errors when working with old versions. crate::vm_1_4_2::constants::MAX_BASE_LAYER_CIRCUITS } - VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory => { - crate::vm_latest::constants::MAX_BASE_LAYER_CIRCUITS - } + VmVersion::Vm1_5_0SmallBootloaderMemory + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => crate::vm_latest::constants::MAX_BASE_LAYER_CIRCUITS, } } diff --git a/core/lib/multivm/src/versions/testonly.rs b/core/lib/multivm/src/versions/testonly.rs index 51a4d0842d90..6d3ee5571775 100644 --- a/core/lib/multivm/src/versions/testonly.rs +++ b/core/lib/multivm/src/versions/testonly.rs @@ -21,6 +21,7 @@ pub(super) fn default_system_env() -> SystemEnv { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::from(270), + pubdata_params: Default::default(), } } diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs index 4ba27b14bad6..b2cb50c653e4 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs @@ -1,9 +1,12 @@ use std::cmp::Ordering; use once_cell::sync::OnceCell; -use zksync_types::{L2ChainId, U256}; +use zksync_types::{commitment::PubdataParams, L2ChainId, U256}; -use super::{tx::BootloaderTx, utils::apply_pubdata_to_memory}; +use super::{ + tx::BootloaderTx, + utils::{apply_pubdata_to_memory, get_encoded_pubdata}, +}; use crate::{ interface::{BootloaderMemory, CompressedBytecodeInfo, L2BlockEnv, TxExecutionMode}, vm_latest::{ @@ -15,6 +18,7 @@ use crate::{ constants::TX_DESCRIPTION_OFFSET, types::internals::{PubdataInput, TransactionData}, utils::l2_blocks::assert_next_block, + MultiVMSubversion, }, }; @@ -45,6 +49,10 @@ pub struct BootloaderState { free_tx_offset: usize, /// Information about the the pubdata that will be needed to supply to the L1Messenger pubdata_information: OnceCell, + /// Params related to how the pubdata should be processed by the bootloader in the batch + pubdata_params: PubdataParams, + /// VM subversion + subversion: MultiVMSubversion, } impl BootloaderState { @@ -52,6 +60,8 @@ impl BootloaderState { execution_mode: TxExecutionMode, initial_memory: BootloaderMemory, first_l2_block: L2BlockEnv, + pubdata_params: PubdataParams, + subversion: MultiVMSubversion, ) -> Self { let l2_block = BootloaderL2Block::new(first_l2_block, 0); Self { @@ -62,6 +72,8 @@ impl BootloaderState { execution_mode, free_tx_offset: 0, pubdata_information: Default::default(), + pubdata_params, + subversion, } } @@ -135,12 +147,31 @@ impl BootloaderState { pub(crate) fn last_l2_block(&self) -> &BootloaderL2Block { self.l2_blocks.last().unwrap() } + pub(crate) fn get_pubdata_information(&self) -> &PubdataInput { self.pubdata_information .get() .expect("Pubdata information is not set") } + pub(crate) fn get_encoded_pubdata(&self) -> Vec { + let pubdata_information = self + .pubdata_information + .get() + .expect("Pubdata information is not set") + .clone(); + + match self.subversion { + MultiVMSubversion::SmallBootloaderMemory + | MultiVMSubversion::IncreasedBootloaderMemory => { + pubdata_information.build_pubdata_pre_gateway(false) + } + MultiVMSubversion::Gateway => { + get_encoded_pubdata(pubdata_information, self.pubdata_params, false) + } + } + } + fn last_mut_l2_block(&mut self) -> &mut BootloaderL2Block { self.l2_blocks.last_mut().unwrap() } @@ -178,7 +209,12 @@ impl BootloaderState { .into_inner() .expect("Empty pubdata information"); - apply_pubdata_to_memory(&mut initial_memory, pubdata_information); + apply_pubdata_to_memory( + &mut initial_memory, + pubdata_information, + self.pubdata_params, + self.subversion, + ); initial_memory } @@ -291,4 +327,12 @@ impl BootloaderState { ); } } + + pub(crate) fn get_pubdata_params(&self) -> PubdataParams { + self.pubdata_params + } + + pub(crate) fn get_vm_subversion(&self) -> MultiVMSubversion { + self.subversion + } } diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs index 4931082d6daf..9f2ad19b089b 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs @@ -1,4 +1,7 @@ -use zksync_types::{ethabi, U256}; +use zksync_types::{ + commitment::{L1BatchCommitmentMode, PubdataParams}, + ethabi, U256, +}; use zksync_utils::{bytes_to_be_words, h256_to_u256}; use super::tx::BootloaderTx; @@ -14,7 +17,11 @@ use crate::{ TX_DESCRIPTION_OFFSET, TX_OPERATOR_L2_BLOCK_INFO_OFFSET, TX_OPERATOR_SLOTS_PER_L2_BLOCK_INFO, TX_OVERHEAD_OFFSET, TX_TRUSTED_GAS_LIMIT_OFFSET, }, - types::internals::PubdataInput, + types::internals::{ + pubdata::{PubdataBuilder, RollupPubdataBuilder, ValidiumPubdataBuilder}, + PubdataInput, + }, + MultiVMSubversion, }, }; @@ -124,26 +131,71 @@ fn apply_l2_block_inner( ]) } +pub(crate) fn get_encoded_pubdata( + pubdata_information: PubdataInput, + pubdata_params: PubdataParams, + l2_version: bool, +) -> Vec { + let pubdata_bytes: Vec = if pubdata_params.pubdata_type == L1BatchCommitmentMode::Rollup { + RollupPubdataBuilder.build_pubdata(pubdata_information, l2_version) + } else { + ValidiumPubdataBuilder.build_pubdata(pubdata_information, l2_version) + }; + + if l2_version { + ethabi::encode(&[ + ethabi::Token::Address(pubdata_params.l2_da_validator_address), + ethabi::Token::Bytes(pubdata_bytes), + ]) + .to_vec() + } else { + pubdata_bytes + } +} + pub(crate) fn apply_pubdata_to_memory( memory: &mut BootloaderMemory, pubdata_information: PubdataInput, + pubdata_params: PubdataParams, + subversion: MultiVMSubversion, ) { - // Skipping two slots as they will be filled by the bootloader itself: - // - One slot is for the selector of the call to the L1Messenger. - // - The other slot is for the 0x20 offset for the calldata. - let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 2; - - // Need to skip first word as it represents array offset - // while bootloader expects only [len || data] - let pubdata = ethabi::encode(&[ethabi::Token::Bytes( - pubdata_information.build_pubdata(true), - )])[32..] - .to_vec(); - - assert!( - pubdata.len() / 32 <= OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS - 2, - "The encoded pubdata is too big" - ); + let (l1_messenger_pubdata_start_slot, pubdata) = match subversion { + MultiVMSubversion::SmallBootloaderMemory | MultiVMSubversion::IncreasedBootloaderMemory => { + // Skipping two slots as they will be filled by the bootloader itself: + // - One slot is for the selector of the call to the L1Messenger. + // - The other slot is for the 0x20 offset for the calldata. + let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 2; + + // Need to skip first word as it represents array offset + // while bootloader expects only [len || data] + let pubdata = ethabi::encode(&[ethabi::Token::Bytes( + pubdata_information.build_pubdata_pre_gateway(true), + )])[32..] + .to_vec(); + + assert!( + pubdata.len() / 32 <= OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS - 2, + "The encoded pubdata is too big" + ); + + (l1_messenger_pubdata_start_slot, pubdata) + } + MultiVMSubversion::Gateway => { + // Skipping the first slot as it will be filled by the bootloader itself: + // It is for the selector of the call to the L1Messenger. + let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 1; + + let pubdata = get_encoded_pubdata(pubdata_information, pubdata_params, true); + + assert!( + // Note that unlike the previous version, the difference is `1`, since now it also includes the offset + pubdata.len() / 32 < OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS, + "The encoded pubdata is too big" + ); + + (l1_messenger_pubdata_start_slot, pubdata) + } + }; pubdata .chunks(32) diff --git a/core/lib/multivm/src/versions/vm_latest/constants.rs b/core/lib/multivm/src/versions/vm_latest/constants.rs index 01f697ec91a2..c047e6ffa3b0 100644 --- a/core/lib/multivm/src/versions/vm_latest/constants.rs +++ b/core/lib/multivm/src/versions/vm_latest/constants.rs @@ -26,6 +26,7 @@ pub(crate) const fn get_used_bootloader_memory_bytes(subversion: MultiVMSubversi match subversion { MultiVMSubversion::SmallBootloaderMemory => 59_000_000, MultiVMSubversion::IncreasedBootloaderMemory => 63_800_000, + MultiVMSubversion::Gateway => 63_800_000, } } @@ -201,6 +202,6 @@ pub(crate) const TX_SLOT_OVERHEAD_GAS: u32 = 10_000; /// getting often sealed due to the memory limit being reached, the L2 fair gas price will be increased. pub(crate) const TX_MEMORY_OVERHEAD_GAS: u32 = 10; -const ZK_SYNC_BYTES_PER_BLOB: usize = BLOB_CHUNK_SIZE * ELEMENTS_PER_4844_BLOCK; +pub(crate) const ZK_SYNC_BYTES_PER_BLOB: usize = BLOB_CHUNK_SIZE * ELEMENTS_PER_4844_BLOCK; pub const MAX_BLOBS_PER_BATCH: usize = 6; pub const MAX_VM_PUBDATA_PER_BATCH: usize = MAX_BLOBS_PER_BATCH * ZK_SYNC_BYTES_PER_BLOB; diff --git a/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs b/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs index b8242fa7ca85..2f23bfb89f0b 100644 --- a/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs +++ b/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs @@ -64,6 +64,7 @@ impl Vm { self.batch_env.clone(), execution_mode, self.subversion, + self.system_env.version, )) }), self.subversion, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs b/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs index 9909ca24937f..8ce00229332e 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs @@ -9,7 +9,8 @@ use zksync_system_constants::{ }; use zksync_types::{ commitment::SerializeCommitment, fee_model::BatchFeeInput, get_code_key, - l2_to_l1_log::L2ToL1Log, writes::StateDiffRecord, Address, Execute, H256, U256, + l2_to_l1_log::L2ToL1Log, writes::StateDiffRecord, Address, Execute, ProtocolVersionId, H256, + U256, }; use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u256_to_h256}; @@ -193,6 +194,7 @@ fn execute_test(test_data: L1MessengerTestData) -> TestStatistics { VmExecutionMode::Batch, test_data.state_diffs.clone(), crate::vm_latest::MultiVMSubversion::latest(), + ProtocolVersionId::latest(), ); let result = vm.vm.inspect_inner( diff --git a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs index 1fe4232c7780..91a2a9256411 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs @@ -3,6 +3,7 @@ use std::marker::PhantomData; use zksync_contracts::BaseSystemContracts; use zksync_types::{ block::L2BlockHasher, + commitment::PubdataParams, fee_model::BatchFeeInput, get_code_key, get_is_account_key, helpers::unix_timestamp_ms, @@ -146,6 +147,7 @@ impl VmTesterBuilder { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::from(270), + pubdata_params: Default::default(), }, deployer: None, rich_accounts: vec![], @@ -216,6 +218,11 @@ impl VmTesterBuilder { self } + pub(crate) fn with_custom_pubdata_params(mut self, pubdata_params: PubdataParams) -> Self { + self.system_env.pubdata_params = pubdata_params; + self + } + pub(crate) fn build(self) -> VmTester { let l1_batch_env = self .l1_batch_env diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs index 32f3984834c8..9e620f96af2b 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs @@ -5,7 +5,10 @@ use zk_evm_1_5_0::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, }; -use zksync_types::{writes::StateDiffRecord, AccountTreeId, StorageKey, L1_MESSENGER_ADDRESS}; +use zksync_types::{ + l2_to_l1_log::l2_to_l1_logs_tree_size, writes::StateDiffRecord, AccountTreeId, + ProtocolVersionId, StorageKey, L1_MESSENGER_ADDRESS, +}; use zksync_utils::{h256_to_u256, u256_to_bytes_be, u256_to_h256}; use crate::{ @@ -41,6 +44,7 @@ pub(crate) struct PubdataTracer { // to the L1Messenger. enforced_state_diffs: Option>, subversion: MultiVMSubversion, + protocol_version: ProtocolVersionId, _phantom_data: PhantomData, } @@ -49,6 +53,7 @@ impl PubdataTracer { l1_batch_env: L1BatchEnv, execution_mode: VmExecutionMode, subversion: MultiVMSubversion, + protocol_version: ProtocolVersionId, ) -> Self { Self { l1_batch_env, @@ -56,6 +61,7 @@ impl PubdataTracer { execution_mode, enforced_state_diffs: None, subversion, + protocol_version, _phantom_data: Default::default(), } } @@ -68,6 +74,7 @@ impl PubdataTracer { execution_mode: VmExecutionMode, forced_state_diffs: Vec, subversion: MultiVMSubversion, + protocol_version: ProtocolVersionId, ) -> Self { Self { l1_batch_env, @@ -75,6 +82,7 @@ impl PubdataTracer { execution_mode, enforced_state_diffs: Some(forced_state_diffs), subversion, + protocol_version, _phantom_data: Default::default(), } } @@ -184,6 +192,7 @@ impl PubdataTracer { l2_to_l1_messages: self.get_total_l1_messenger_messages(state), published_bytecodes: self.get_total_published_bytecodes(state), state_diffs: self.get_state_diffs(&state.storage), + l2_to_l1_logs_tree_size: l2_to_l1_logs_tree_size(self.protocol_version), } } } @@ -227,7 +236,12 @@ impl VmTracer for PubdataTracer { // Apply the pubdata to the current memory let mut memory_to_apply = vec![]; - apply_pubdata_to_memory(&mut memory_to_apply, pubdata_input); + apply_pubdata_to_memory( + &mut memory_to_apply, + pubdata_input, + bootloader_state.get_pubdata_params(), + bootloader_state.get_vm_subversion(), + ); state.memory.populate_page( BOOTLOADER_HEAP_PAGE as usize, memory_to_apply, diff --git a/core/lib/multivm/src/versions/vm_latest/types/internals/mod.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/mod.rs index 7dc60ec5b0fb..0b9f704e8dbf 100644 --- a/core/lib/multivm/src/versions/vm_latest/types/internals/mod.rs +++ b/core/lib/multivm/src/versions/vm_latest/types/internals/mod.rs @@ -3,7 +3,7 @@ pub(crate) use snapshot::VmSnapshot; pub(crate) use transaction_data::TransactionData; pub(crate) use vm_state::new_vm_state; pub use vm_state::ZkSyncVmState; -mod pubdata; +pub(crate) mod pubdata; mod snapshot; mod transaction_data; mod vm_state; diff --git a/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs index d07732ae4350..a6252ca62fa5 100644 --- a/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs +++ b/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs @@ -1,4 +1,10 @@ -use zksync_types::writes::{compress_state_diffs, StateDiffRecord}; +use zksync_mini_merkle_tree::MiniMerkleTree; +use zksync_types::{ + ethabi::{self, Token}, + web3::keccak256, + writes::{compress_state_diffs, StateDiffRecord}, +}; +use zksync_utils::bytecode::hash_bytecode; use crate::utils::events::L1MessengerL2ToL1Log; @@ -9,10 +15,11 @@ pub(crate) struct PubdataInput { pub(crate) l2_to_l1_messages: Vec>, pub(crate) published_bytecodes: Vec>, pub(crate) state_diffs: Vec, + pub(crate) l2_to_l1_logs_tree_size: usize, } impl PubdataInput { - pub(crate) fn build_pubdata(self, with_uncompressed_state_diffs: bool) -> Vec { + pub(crate) fn build_pubdata_pre_gateway(self, with_uncompressed_state_diffs: bool) -> Vec { let mut l1_messenger_pubdata = vec![]; let PubdataInput { @@ -20,6 +27,7 @@ impl PubdataInput { l2_to_l1_messages, published_bytecodes, state_diffs, + .. } = self; // Encoding user L2->L1 logs. @@ -61,9 +69,199 @@ impl PubdataInput { } } +pub trait PubdataBuilder { + // when `l2_version` is true it will return the data to be sent to the L1_MESSENGER + // otherwise it returns the array of bytes to be sent to settlement layer inside the operator input. + fn build_pubdata(&self, input: PubdataInput, l2_version: bool) -> Vec; +} + +#[derive(Debug)] +pub struct RollupPubdataBuilder; + +impl PubdataBuilder for RollupPubdataBuilder { + fn build_pubdata(&self, input: PubdataInput, l2_version: bool) -> Vec { + let mut l1_messenger_pubdata = vec![]; + let mut l2_da_header = vec![]; + + let PubdataInput { + user_logs, + l2_to_l1_messages, + published_bytecodes, + state_diffs, + l2_to_l1_logs_tree_size, + } = input; + + if l2_version { + let chained_log_hash = build_chained_log_hash(user_logs.clone()); + let log_root_hash = build_logs_root(user_logs.clone(), l2_to_l1_logs_tree_size); + let chained_msg_hash = build_chained_message_hash(l2_to_l1_messages.clone()); + let chained_bytecodes_hash = build_chained_bytecode_hash(published_bytecodes.clone()); + + l2_da_header.push(Token::FixedBytes(chained_log_hash)); + l2_da_header.push(Token::FixedBytes(log_root_hash)); + l2_da_header.push(Token::FixedBytes(chained_msg_hash)); + l2_da_header.push(Token::FixedBytes(chained_bytecodes_hash)); + } + + l1_messenger_pubdata.extend(encode_user_logs(user_logs)); + + // Encoding L2->L1 messages + // Format: `[(numberOfMessages as u32) || (messages[1].len() as u32) || messages[1] || ... || (messages[n].len() as u32) || messages[n]]` + l1_messenger_pubdata.extend((l2_to_l1_messages.len() as u32).to_be_bytes()); + for message in l2_to_l1_messages { + l1_messenger_pubdata.extend((message.len() as u32).to_be_bytes()); + l1_messenger_pubdata.extend(message); + } + // Encoding bytecodes + // Format: `[(numberOfBytecodes as u32) || (bytecodes[1].len() as u32) || bytecodes[1] || ... || (bytecodes[n].len() as u32) || bytecodes[n]]` + l1_messenger_pubdata.extend((published_bytecodes.len() as u32).to_be_bytes()); + for bytecode in published_bytecodes { + l1_messenger_pubdata.extend((bytecode.len() as u32).to_be_bytes()); + l1_messenger_pubdata.extend(bytecode); + } + // Encoding state diffs + // Format: `[size of compressed state diffs u32 || compressed state diffs || (# state diffs: intial + repeated) as u32 || sorted state diffs by ]` + let state_diffs_compressed = compress_state_diffs(state_diffs.clone()); + l1_messenger_pubdata.extend(state_diffs_compressed); + + if l2_version { + l1_messenger_pubdata.extend((state_diffs.len() as u32).to_be_bytes()); + for state_diff in state_diffs { + l1_messenger_pubdata.extend(state_diff.encode_padded()); + } + + // Selector of `IL2DAValidator::validatePubdata`. + let func_selector = vec![0x89, 0xf9, 0xa0, 0x72]; + + l2_da_header.push(ethabi::Token::Bytes(l1_messenger_pubdata)); + + l1_messenger_pubdata = [func_selector, ethabi::encode(&l2_da_header)] + .concat() + .to_vec(); + } + + l1_messenger_pubdata + } +} + +#[derive(Debug)] +pub struct ValidiumPubdataBuilder; + +impl PubdataBuilder for ValidiumPubdataBuilder { + fn build_pubdata(&self, input: PubdataInput, l2_version: bool) -> Vec { + let mut l1_messenger_pubdata = vec![]; + let mut l2_da_header = vec![]; + + let PubdataInput { + user_logs, + l2_to_l1_messages, + published_bytecodes, + state_diffs, + l2_to_l1_logs_tree_size, + } = input; + + if l2_version { + let chained_log_hash = build_chained_log_hash(user_logs.clone()); + let log_root_hash = build_logs_root(user_logs.clone(), l2_to_l1_logs_tree_size); + let chained_msg_hash = build_chained_message_hash(l2_to_l1_messages.clone()); + let chained_bytecodes_hash = build_chained_bytecode_hash(published_bytecodes.clone()); + l2_da_header.push(Token::FixedBytes(chained_log_hash)); + l2_da_header.push(Token::FixedBytes(log_root_hash)); + l2_da_header.push(Token::FixedBytes(chained_msg_hash)); + l2_da_header.push(Token::FixedBytes(chained_bytecodes_hash)); + } + + l1_messenger_pubdata.extend(encode_user_logs(user_logs)); + + if l2_version { + // Selector of `IL2DAValidator::validatePubdata`. + let func_selector = vec![0x89, 0xf9, 0xa0, 0x72]; + + l2_da_header.push(ethabi::Token::Bytes(l1_messenger_pubdata)); + + [func_selector, ethabi::encode(&l2_da_header)] + .concat() + .to_vec() + } else { + let state_diffs_packed = state_diffs + .into_iter() + .flat_map(|diff| diff.encode_padded()) + .collect::>(); + + keccak256(&state_diffs_packed).to_vec() + } + } +} + +fn build_chained_log_hash(user_logs: Vec) -> Vec { + let mut chained_log_hash = vec![0u8; 32]; + + for log in user_logs { + let log_bytes = log.packed_encoding(); + let hash = keccak256(&log_bytes); + + chained_log_hash = keccak256(&[chained_log_hash, hash.to_vec()].concat()).to_vec(); + } + + chained_log_hash +} + +fn build_logs_root( + user_logs: Vec, + l2_to_l1_logs_tree_size: usize, +) -> Vec { + let logs = user_logs.iter().map(|log| { + let encoded = log.packed_encoding(); + let mut slice = [0u8; 88]; + slice.copy_from_slice(&encoded); + slice + }); + MiniMerkleTree::new(logs, Some(l2_to_l1_logs_tree_size)) + .merkle_root() + .as_bytes() + .to_vec() +} + +fn build_chained_message_hash(l2_to_l1_messages: Vec>) -> Vec { + let mut chained_msg_hash = vec![0u8; 32]; + + for msg in l2_to_l1_messages { + let hash = keccak256(&msg); + + chained_msg_hash = keccak256(&[chained_msg_hash, hash.to_vec()].concat()).to_vec(); + } + + chained_msg_hash +} + +fn build_chained_bytecode_hash(published_bytecodes: Vec>) -> Vec { + let mut chained_bytecode_hash = vec![0u8; 32]; + + for bytecode in published_bytecodes { + let hash = hash_bytecode(&bytecode).to_fixed_bytes(); + + chained_bytecode_hash = + keccak256(&[chained_bytecode_hash, hash.to_vec()].concat()).to_vec(); + } + + chained_bytecode_hash +} + +fn encode_user_logs(user_logs: Vec) -> Vec { + // Encoding user L2->L1 logs. + // Format: `[(numberOfL2ToL1Logs as u32) || l2tol1logs[1] || ... || l2tol1logs[n]]` + let mut result = vec![]; + result.extend((user_logs.len() as u32).to_be_bytes()); + for l2tol1log in user_logs { + result.extend(l2tol1log.packed_encoding()); + } + result +} + #[cfg(test)] mod tests { use zksync_system_constants::{ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS}; + use zksync_types::{l2_to_l1_log::l2_to_l1_logs_tree_size, ProtocolVersionId}; use zksync_utils::u256_to_h256; use super::*; @@ -113,10 +311,12 @@ mod tests { l2_to_l1_messages, published_bytecodes, state_diffs, + l2_to_l1_logs_tree_size: l2_to_l1_logs_tree_size(ProtocolVersionId::latest()), }; let pubdata = - ethabi::encode(&[ethabi::Token::Bytes(input.build_pubdata(true))])[32..].to_vec(); + ethabi::encode(&[ethabi::Token::Bytes(input.build_pubdata_pre_gateway(true))])[32..] + .to_vec(); assert_eq!(hex::encode(pubdata), "00000000000000000000000000000000000000000000000000000000000002c700000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000004aaaabbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901000000020000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009b000000000000000000000000000000000000000000000000000000000000007d000000000000000c000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000007e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); } diff --git a/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs index 6f9522572ad8..b6e5e127c857 100644 --- a/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs +++ b/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs @@ -33,6 +33,7 @@ use crate::{ oracles::storage::StorageOracle, types::l1_batch::bootloader_initial_memory, utils::l2_blocks::{assert_next_block, load_last_l2_block}, + MultiVMSubversion, }, }; @@ -64,6 +65,7 @@ pub(crate) fn new_vm_state( storage: StoragePtr, system_env: &SystemEnv, l1_batch_env: &L1BatchEnv, + subversion: MultiVMSubversion, ) -> (ZkSyncVmState, BootloaderState) { let last_l2_block = if let Some(last_l2_block) = load_last_l2_block(&storage) { last_l2_block @@ -181,6 +183,8 @@ pub(crate) fn new_vm_state( system_env.execution_mode, bootloader_initial_memory, first_l2_block, + system_env.pubdata_params, + subversion, ); (vm, bootloader_state) diff --git a/core/lib/multivm/src/versions/vm_latest/vm.rs b/core/lib/multivm/src/versions/vm_latest/vm.rs index 506b6666ecd9..e43dcf31d802 100644 --- a/core/lib/multivm/src/versions/vm_latest/vm.rs +++ b/core/lib/multivm/src/versions/vm_latest/vm.rs @@ -36,6 +36,8 @@ pub(crate) enum MultiVMSubversion { SmallBootloaderMemory, /// The final correct version of v1.5.0 IncreasedBootloaderMemory, + /// VM for post-gateway versions. + Gateway, } impl MultiVMSubversion { @@ -53,6 +55,7 @@ impl TryFrom for MultiVMSubversion { match value { VmVersion::Vm1_5_0SmallBootloaderMemory => Ok(Self::SmallBootloaderMemory), VmVersion::Vm1_5_0IncreasedBootloaderMemory => Ok(Self::IncreasedBootloaderMemory), + VmVersion::VmGateway => Ok(Self::Gateway), _ => Err(VmVersionIsNotVm150Error), } } @@ -173,12 +176,7 @@ impl VmInterface for Vm { block_tip_execution_result: result, final_execution_state: execution_state, final_bootloader_memory: Some(bootloader_memory), - pubdata_input: Some( - self.bootloader_state - .get_pubdata_information() - .clone() - .build_pubdata(false), - ), + pubdata_input: Some(self.bootloader_state.get_encoded_pubdata()), state_diffs: Some( self.bootloader_state .get_pubdata_information() @@ -208,7 +206,8 @@ impl Vm { storage: StoragePtr, subversion: MultiVMSubversion, ) -> Self { - let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); + let (state, bootloader_state) = + new_vm_state(storage.clone(), &system_env, &batch_env, subversion); Self { bootloader_state, state, diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs index 8dd67e1ac4e2..bfb121a740e6 100644 --- a/core/lib/multivm/src/vm_instance.rs +++ b/core/lib/multivm/src/vm_instance.rs @@ -211,6 +211,15 @@ impl LegacyVmInstance { ); Self::Vm1_5_0(vm) } + VmVersion::VmGateway => { + let vm = crate::vm_latest::Vm::new_with_subversion( + l1_batch_env, + system_env, + storage_view, + crate::vm_latest::MultiVMSubversion::Gateway, + ); + Self::Vm1_5_0(vm) + } } } } diff --git a/core/lib/protobuf_config/src/contracts.rs b/core/lib/protobuf_config/src/contracts.rs index 84c404367503..84f03c5afe3a 100644 --- a/core/lib/protobuf_config/src/contracts.rs +++ b/core/lib/protobuf_config/src/contracts.rs @@ -76,6 +76,12 @@ impl ProtoRepr for proto::Contracts { .map(|x| parse_h160(x)) .transpose() .context("l2_shared_bridge_addr")?, + l2_legacy_shared_bridge_addr: l2 + .legacy_shared_bridge_addr + .as_ref() + .map(|x| parse_h160(x)) + .transpose() + .context("l2_legacy_shared_bridge_addr")?, l1_weth_bridge_proxy_addr: weth_bridge .as_ref() .and_then(|bridge| bridge.l1_address.as_ref().map(|x| parse_h160(x))) @@ -107,6 +113,12 @@ impl ProtoRepr for proto::Contracts { .map(|x| parse_h160(x)) .transpose() .context("chain_admin_addr")?, + l2_da_validator_addr: l2 + .da_validator_addr + .as_ref() + .map(|x| parse_h160(x)) + .transpose() + .context("l2_da_validator_addr")?, }) } @@ -142,6 +154,10 @@ impl ProtoRepr for proto::Contracts { }), l2: Some(proto::L2 { testnet_paymaster_addr: this.l2_testnet_paymaster_addr.map(|a| format!("{:?}", a)), + da_validator_addr: this.l2_da_validator_addr.map(|a| format!("{:?}", a)), + legacy_shared_bridge_addr: this + .l2_legacy_shared_bridge_addr + .map(|a| format!("{:?}", a)), }), bridges: Some(proto::Bridges { shared: Some(proto::Bridge { diff --git a/core/lib/protobuf_config/src/proto/config/contracts.proto b/core/lib/protobuf_config/src/proto/config/contracts.proto index f4488c7901a1..6ab03e6aa11b 100644 --- a/core/lib/protobuf_config/src/proto/config/contracts.proto +++ b/core/lib/protobuf_config/src/proto/config/contracts.proto @@ -21,6 +21,8 @@ message L1 { message L2 { optional string testnet_paymaster_addr = 1; // optional; H160 + optional string da_validator_addr = 2; // optional; H160 + optional string legacy_shared_bridge_addr = 3; // optional; H160 } message Bridge { diff --git a/core/lib/snapshots_applier/src/tests/utils.rs b/core/lib/snapshots_applier/src/tests/utils.rs index 2c9b1440af2a..cf68d2e181a6 100644 --- a/core/lib/snapshots_applier/src/tests/utils.rs +++ b/core/lib/snapshots_applier/src/tests/utils.rs @@ -182,6 +182,7 @@ pub(super) fn mock_l2_block_header(l2_block_number: L2BlockNumber) -> L2BlockHea virtual_blocks: 0, gas_limit: 0, logs_bloom: Default::default(), + pubdata_params: Default::default(), } } diff --git a/core/lib/state/src/test_utils.rs b/core/lib/state/src/test_utils.rs index decb2a0f403d..a12508f615f0 100644 --- a/core/lib/state/src/test_utils.rs +++ b/core/lib/state/src/test_utils.rs @@ -88,6 +88,7 @@ pub(crate) async fn create_l2_block( virtual_blocks: 0, gas_limit: 0, logs_bloom: Default::default(), + pubdata_params: Default::default(), }; conn.blocks_dal() diff --git a/core/lib/tee_verifier/src/lib.rs b/core/lib/tee_verifier/src/lib.rs index 68b25416d668..595480687e9c 100644 --- a/core/lib/tee_verifier/src/lib.rs +++ b/core/lib/tee_verifier/src/lib.rs @@ -311,6 +311,7 @@ mod tests { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: 0, chain_id: Default::default(), + pubdata_params: Default::default(), }, vec![(H256([1; 32]), vec![0, 1, 2, 3, 4])], ); diff --git a/core/lib/types/src/api/en.rs b/core/lib/types/src/api/en.rs index 9391c8627573..52d66a29458d 100644 --- a/core/lib/types/src/api/en.rs +++ b/core/lib/types/src/api/en.rs @@ -1,7 +1,7 @@ //! API types related to the External Node specific methods. use serde::{Deserialize, Serialize}; -use zksync_basic_types::{Address, L1BatchNumber, L2BlockNumber, H256}; +use zksync_basic_types::{commitment::PubdataParams, Address, L1BatchNumber, L2BlockNumber, H256}; use zksync_contracts::BaseSystemContractsHashes; use crate::ProtocolVersionId; @@ -42,6 +42,8 @@ pub struct SyncBlock { pub hash: Option, /// Version of the protocol used for this block. pub protocol_version: ProtocolVersionId, + /// Pubdata params used for this batch + pub pubdata_params: Option, } /// Global configuration of the consensus served by the main node to the external nodes. diff --git a/core/lib/types/src/api/mod.rs b/core/lib/types/src/api/mod.rs index 1e5a1b3fe65d..f7a276a9a864 100644 --- a/core/lib/types/src/api/mod.rs +++ b/core/lib/types/src/api/mod.rs @@ -205,6 +205,7 @@ pub struct BridgeAddresses { pub l2_erc20_default_bridge: Option
, pub l1_weth_bridge: Option
, pub l2_weth_bridge: Option
, + pub l2_legacy_shared_bridge: Option
, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] diff --git a/core/lib/types/src/block.rs b/core/lib/types/src/block.rs index 9c1609bf1756..4bed75f8a4ca 100644 --- a/core/lib/types/src/block.rs +++ b/core/lib/types/src/block.rs @@ -1,7 +1,7 @@ use std::{fmt, ops}; use serde::{Deserialize, Serialize}; -use zksync_basic_types::{Address, Bloom, BloomInput, H256, U256}; +use zksync_basic_types::{commitment::PubdataParams, Address, Bloom, BloomInput, H256, U256}; use zksync_contracts::BaseSystemContractsHashes; use zksync_system_constants::SYSTEM_BLOCK_INFO_BLOCK_NUMBER_MULTIPLIER; use zksync_utils::concat_and_hash; @@ -91,6 +91,7 @@ pub struct L2BlockHeader { /// amount of gas can be spent on pubdata. pub gas_limit: u64, pub logs_bloom: Bloom, + pub pubdata_params: PubdataParams, } /// Structure that represents the data is returned by the storage oracle during batch execution. diff --git a/core/lib/types/src/commitment/mod.rs b/core/lib/types/src/commitment/mod.rs index 63d1bad486f3..544d21ba7d26 100644 --- a/core/lib/types/src/commitment/mod.rs +++ b/core/lib/types/src/commitment/mod.rs @@ -9,11 +9,12 @@ use std::{collections::HashMap, convert::TryFrom}; use serde::{Deserialize, Serialize}; -pub use zksync_basic_types::commitment::L1BatchCommitmentMode; +pub use zksync_basic_types::commitment::{L1BatchCommitmentMode, PubdataParams}; use zksync_contracts::BaseSystemContractsHashes; +use zksync_crypto_primitives::hasher::{keccak::KeccakHasher, Hasher}; use zksync_mini_merkle_tree::MiniMerkleTree; use zksync_system_constants::{ - KNOWN_CODES_STORAGE_ADDRESS, L2_TO_L1_LOGS_TREE_ROOT_KEY, STATE_DIFF_HASH_KEY, + KNOWN_CODES_STORAGE_ADDRESS, L2_TO_L1_LOGS_TREE_ROOT_KEY, STATE_DIFF_HASH_KEY_PRE_GATEWAY, ZKPORTER_IS_AVAILABLE, }; use zksync_utils::u256_to_h256; @@ -22,8 +23,8 @@ use crate::{ blob::num_blobs_required, block::{L1BatchHeader, L1BatchTreeData}, l2_to_l1_log::{ - l2_to_l1_logs_tree_size, parse_system_logs_for_blob_hashes, L2ToL1Log, SystemL2ToL1Log, - UserL2ToL1Log, + l2_to_l1_logs_tree_size, parse_system_logs_for_blob_hashes_pre_gateway, L2ToL1Log, + SystemL2ToL1Log, UserL2ToL1Log, }, web3::keccak256, writes::{ @@ -92,6 +93,16 @@ pub struct L1BatchMetadata { /// commitment to the transactions in the batch. pub bootloader_initial_content_commitment: Option, pub state_diffs_compressed: Vec, + /// Hash of packed state diffs. It's present only for post-gateway batches. + pub state_diff_hash: Option, + /// Root hash of the local logs tree. Tree contains logs that were produced on this chain. + /// It's present only for post-gateway batches. + pub local_root: Option, + /// Root hash of the aggregated logs tree. Tree aggregates `local_root`s of chains that settle on this chain. + /// It's present only for post-gateway batches. + pub aggregation_root: Option, + /// Data Availability inclusion proof, that has to be verified on the settlement layer. + pub da_inclusion_data: Option>, } impl L1BatchMetadata { @@ -285,6 +296,8 @@ pub enum L1BatchAuxiliaryOutput { aux_commitments: AuxCommitments, blob_linear_hashes: Vec, blob_commitments: Vec, + aggregated_root: H256, + local_root: H256, }, } @@ -334,16 +347,23 @@ impl L1BatchAuxiliaryOutput { state_diffs, aux_commitments, blob_commitments, + blob_linear_hashes, + aggregated_root, } => { let l2_l1_logs_compressed = serialize_commitments(&common_input.l2_to_l1_logs); let merkle_tree_leaves = l2_l1_logs_compressed .chunks(UserL2ToL1Log::SERIALIZED_SIZE) .map(|chunk| <[u8; UserL2ToL1Log::SERIALIZED_SIZE]>::try_from(chunk).unwrap()); - let l2_l1_logs_merkle_root = MiniMerkleTree::new( + let local_root = MiniMerkleTree::new( merkle_tree_leaves, Some(l2_to_l1_logs_tree_size(common_input.protocol_version)), ) .merkle_root(); + let l2_l1_logs_merkle_root = if common_input.protocol_version.is_pre_gateway() { + local_root + } else { + KeccakHasher.compress(&local_root, &aggregated_root) + }; let common_output = L1BatchAuxiliaryCommonOutput { l2_l1_logs_merkle_root, @@ -357,22 +377,31 @@ impl L1BatchAuxiliaryOutput { let state_diffs_hash = H256::from(keccak256(&(state_diffs_packed))); let state_diffs_compressed = compress_state_diffs(state_diffs); - let blob_linear_hashes = - parse_system_logs_for_blob_hashes(&common_input.protocol_version, &system_logs); - // Sanity checks. System logs are empty for the genesis batch, so we can't do checks for it. if !system_logs.is_empty() { - let state_diff_hash_from_logs = system_logs - .iter() - .find_map(|log| { - (log.0.key == u256_to_h256(STATE_DIFF_HASH_KEY.into())) - .then_some(log.0.value) - }) - .expect("Failed to find state diff hash in system logs"); - assert_eq!( - state_diffs_hash, state_diff_hash_from_logs, - "State diff hash mismatch" - ); + if common_input.protocol_version.is_pre_gateway() { + let state_diff_hash_from_logs = system_logs + .iter() + .find_map(|log| { + (log.0.key == u256_to_h256(STATE_DIFF_HASH_KEY_PRE_GATEWAY.into())) + .then_some(log.0.value) + }) + .expect("Failed to find state diff hash in system logs"); + assert_eq!( + state_diffs_hash, state_diff_hash_from_logs, + "State diff hash mismatch" + ); + + let blob_linear_hashes_from_logs = + parse_system_logs_for_blob_hashes_pre_gateway( + &common_input.protocol_version, + &system_logs, + ); + assert_eq!( + blob_linear_hashes, blob_linear_hashes_from_logs, + "Blob linear hashes mismatch" + ); + } let l2_to_l1_logs_tree_root_from_logs = system_logs .iter() @@ -401,11 +430,38 @@ impl L1BatchAuxiliaryOutput { aux_commitments, blob_linear_hashes, blob_commitments, + local_root, + aggregated_root, } } } } + pub fn get_local_root(&self) -> H256 { + match self { + Self::PreBoojum { common, .. } => common.l2_l1_logs_merkle_root, + Self::PostBoojum { local_root, .. } => *local_root, + } + } + + pub fn get_aggregated_root(&self) -> H256 { + match self { + Self::PreBoojum { .. } => H256::zero(), + Self::PostBoojum { + aggregated_root, .. + } => *aggregated_root, + } + } + + pub fn get_state_diff_hash(&self) -> H256 { + match self { + Self::PreBoojum { .. } => H256::zero(), + Self::PostBoojum { + state_diffs_hash, .. + } => *state_diffs_hash, + } + } + pub fn to_bytes(&self) -> Vec { let mut result = Vec::new(); @@ -634,6 +690,9 @@ impl L1BatchCommitment { aux_commitments: self.aux_commitments(), compressed_initial_writes, compressed_repeated_writes, + local_root: self.auxiliary_output.get_local_root(), + aggregation_root: self.auxiliary_output.get_aggregated_root(), + state_diff_hash: self.auxiliary_output.get_state_diff_hash(), } } } @@ -670,6 +729,8 @@ pub enum CommitmentInput { state_diffs: Vec, aux_commitments: AuxCommitments, blob_commitments: Vec, + blob_linear_hashes: Vec, + aggregated_root: H256, }, } @@ -715,6 +776,12 @@ impl CommitmentInput { vec![H256::zero(); num_blobs] }, + blob_linear_hashes: { + let num_blobs = num_blobs_required(&protocol_version); + + vec![H256::zero(); num_blobs] + }, + aggregated_root: H256::zero(), } } } @@ -729,4 +796,7 @@ pub struct L1BatchCommitmentArtifacts { pub compressed_repeated_writes: Option>, pub zkporter_is_available: bool, pub aux_commitments: Option, + pub aggregation_root: H256, + pub local_root: H256, + pub state_diff_hash: H256, } diff --git a/core/lib/types/src/commitment/tests/mod.rs b/core/lib/types/src/commitment/tests/mod.rs index 34e308cfd0a9..b416e21c4ab9 100644 --- a/core/lib/types/src/commitment/tests/mod.rs +++ b/core/lib/types/src/commitment/tests/mod.rs @@ -50,3 +50,8 @@ fn post_boojum_1_4_2() { fn post_boojum_1_5_0() { run_test("post_boojum_1_5_0_test"); } + +#[test] +fn post_gateway() { + run_test("post_gateway_test"); +} diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json b/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json index c5eccbce038a..87f7c9e51ea2 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json @@ -193,7 +193,12 @@ "blob_commitments": [ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000" - ] + ], + "blob_linear_hashes": [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, "pass_through_data": { @@ -255,7 +260,9 @@ "blob_commitments": [ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000" - ] + ], + "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000", + "local_root": "0xe52d57bd64cabf6c588b30365512da2bf10912c106e7a06483b236d05ac4037e" } }, "hashes": { diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json b/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json index 4983bbeca143..4ae5b361b7cb 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json @@ -209,7 +209,12 @@ "blob_commitments": [ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000002" - ] + ], + "blob_linear_hashes": [ + "0x0000000000000000000000000000000000000000000000000000000000000003", + "0x0000000000000000000000000000000000000000000000000000000000000004" + ], + "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, "pass_through_data": { @@ -271,7 +276,9 @@ "blob_commitments": [ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000002" - ] + ], + "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000", + "local_root": "0x0b6e1ad4643cc2bee06b5e173184ec822d80826e5720f5715172898350433299" } }, "hashes": { diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json b/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json index 59a24b7c90ce..78f7afb372d2 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json @@ -255,7 +255,26 @@ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000" - ] + ], + "blob_linear_hashes": [ + "0x0000000000000000000000000000000000000000000000000000000000000003", + "0x0000000000000000000000000000000000000000000000000000000000000004", + "0x0000000000000000000000000000000000000000000000000000000000000005", + "0x0000000000000000000000000000000000000000000000000000000000000006", + "0x0000000000000000000000000000000000000000000000000000000000000007", + "0x0000000000000000000000000000000000000000000000000000000000000008", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, "pass_through_data": { @@ -345,7 +364,9 @@ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000" - ] + ], + "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000", + "local_root": "0x30ba728b1aac22b122de4f32589dd2711da264412cb90e35bf7b1f735dd357ff" } }, "hashes": { diff --git a/core/lib/types/src/commitment/tests/post_gateway_test.json b/core/lib/types/src/commitment/tests/post_gateway_test.json new file mode 100644 index 000000000000..a421bd41f95f --- /dev/null +++ b/core/lib/types/src/commitment/tests/post_gateway_test.json @@ -0,0 +1,1917 @@ +{ + "hashes": { + "pass_through_data": "0x756c1660f611302295f6a56a8f4b9d68f2ebf51f8278f225d6b7e64bb9364be0", + "aux_output": "0xcccf1ef8192054cb1b5fb668868ce4e069a695a1394b9486ebd3031cec12fe12", + "meta_parameters": "0xdb298fa55c75b134333cee0b39f77aea956553a1eb861a5777dc7a66ad7a55b9", + "commitment": "0xd6615c5447c817a320c69c6a5af12c472fd4d5bc2ef4de7806d40afe384ddc27" + }, + "auxiliary_output": { + "PostBoojum": { + "common": { + "l2_l1_logs_merkle_root": "0x38eaeef3afe69b6f6b2fa22c92da8137f1e405a1e1861b7de7cfa30c7d7462dd", + "protocol_version": "Version25" + }, + "system_logs_linear_hash": "0xe8460ce1ed47b77cfee3cadf803aa089c144c506ea2bdd358a6a38ff2c7bc8e3", + "state_diffs_compressed": [ + 1,0,27,89,4,0,148,112,120,89,162,183,230,11,175,17,100,223,232,175,83,47,195,198,157,29,129,145,197,186,61,127,17,109,250,141,181,206,45,0,1,0,1,67,6,51,197,115,134,143,51,94,49,6,252,85,139,173,197,6,118,46,184,24,78,249,206,120,93,239,110,206,130,208,215,121,46,249,196,126,160,123,216,26,86,45,8,246,35,74,8,171,141,141,223,145,137,150,142,180,236,158,154,37,0,1,0,14,207,174,184,55,189,9,139,207,155,222,111,194,204,216,232,169,53,90,27,112,230,1,172,24,205,8,158,179,8,246,11,47,22,184,171,230,29,125,57,179,213,44,191,157,128,184,167,253,5,55,217,60,33,8,75,147,188,5,4,171,60,0,1,0,0,195,40,243,40,221,130,10,29,214,152,4,122,127,125,73,135,77,130,89,25,110,39,53,23,67,10,248,244,128,203,204,98,199,195,136,172,152,215,47,208,131,209,215,32,206,186,255,203,162,198,108,114,94,200,185,197,197,240,116,111,138,0,1,0,0,91,142,88,121,116,4,61,89,191,251,246,50,208,32,231,100,149,154,190,98,228,194,56,216,223,46,98,178,181,235,143,74,199,189,78,241,151,159,154,102,86,114,178,92,208,123,30,61,99,122,89,162,199,107,26,34,232,91,117,146,65,0,1,0,1,67,6,51,197,115,134,143,51,94,49,6,252,85,139,173,197,6,118,46,184,24,78,249,206,120,93,239,110,206,66,202,106,148,168,163,117,186,10,227,150,70,185,29,164,88,23,175,73,33,116,119,174,107,73,193,3,53,191,78,11,115,0,1,0,1,179,126,95,140,175,172,146,75,62,102,55,121,225,44,128,218,206,138,2,177,210,115,174,112,143,39,90,214,42,71,164,52,102,233,54,181,135,193,191,158,16,243,13,105,123,17,66,228,89,233,6,51,219,18,27,114,127,245,180,121,43,0,1,0,0,103,85,79,83,198,102,14,83,189,151,41,240,10,238,1,137,1,13,254,184,104,250,60,189,72,18,50,72,12,95,233,138,250,154,14,193,124,34,99,2,123,232,159,70,229,238,83,58,30,33,169,31,255,76,177,68,204,74,239,33,188,0,1,0,5,181,151,235,2,5,139,35,12,238,106,156,223,71,5,65,13,21,26,209,234,106,211,226,222,119,132,26,207,194,142,107,134,4,159,177,116,20,22,26,103,250,177,44,27,34,144,68,85,154,16,112,202,176,23,66,216,18,18,139,156,190,0,1,0,0,103,85,79,83,198,102,14,83,189,151,41,240,10,238,1,137,1,13,254,184,104,250,60,189,72,18,50,72,12,140,78,248,13,214,150,89,51,34,40,248,136,164,249,180,131,12,12,50,27,140,170,45,67,53,35,250,200,97,150,181,207,0,1,0,4,139,241,177,101,244,200,80,208,30,184,30,92,4,15,112,234,1,220,160,25,231,128,168,127,128,236,120,151,195,235,96,109,232,32,223,19,108,89,177,255,121,225,223,146,96,66,108,164,143,175,146,74,70,53,36,33,31,183,195,161,165,0,1,0,2,1,233,35,243,228,122,223,167,196,240,246,30,168,221,66,86,246,109,16,153,151,11,205,49,72,146,134,73,23,95,127,60,252,81,90,137,254,204,8,97,6,46,254,57,252,48,104,36,27,116,128,26,163,170,147,245,100,172,98,242,54,0,1,0,6,29,196,13,11,194,203,129,144,94,107,193,66,30,189,75,216,183,154,172,184,218,79,157,113,69,178,136,103,79,207,14,96,187,125,119,111,198,230,184,241,1,19,161,190,119,25,192,44,34,151,163,108,216,124,11,59,35,121,140,74,95,0,1,0,7,15,28,212,226,131,6,7,175,48,25,39,67,145,15,223,171,241,221,0,74,128,115,148,66,117,129,157,29,254,53,89,195,90,167,22,152,246,194,202,70,67,239,232,80,69,169,73,79,38,45,119,238,103,193,61,215,52,230,38,48,90,0,1,0,1,67,6,51,197,115,134,143,51,94,49,6,252,85,139,173,197,6,118,46,184,24,78,249,206,120,93,239,110,206,186,93,97,46,65,80,43,253,205,126,211,179,176,210,212,177,245,200,248,185,15,209,21,42,187,224,222,192,14,162,61,7,0,1,0,4,139,241,177,101,244,200,80,208,30,184,30,92,4,15,112,234,1,220,160,25,231,128,168,127,128,236,120,151,195,44,61,141,160,220,54,28,84,148,218,146,175,212,98,94,116,25,190,241,121,131,189,209,145,214,33,89,62,212,173,57,47,0,1,0,3,35,183,38,99,20,185,211,236,56,125,91,205,149,144,165,11,224,14,120,136,55,202,90,136,13,151,227,238,131,48,100,113,86,255,138,164,229,100,8,99,14,34,251,194,115,119,250,250,242,7,188,204,248,210,254,18,115,9,165,229,233,0,1,0,2,21,205,111,48,109,117,125,93,47,219,180,96,198,15,41,133,132,23,158,236,192,113,150,199,174,142,79,141,100,200,51,40,178,38,74,180,112,167,221,220,163,38,200,255,61,159,78,76,252,60,226,78,168,221,216,201,180,12,20,188,185,0,1,0,2,1,233,35,243,228,122,223,167,196,240,246,30,168,221,66,86,246,109,16,153,151,11,205,49,72,146,134,73,23,229,176,77,5,169,51,88,54,33,49,122,209,137,227,159,45,116,33,7,146,238,29,46,153,91,171,175,162,128,71,14,27,0,1,0,1,83,6,251,15,11,95,222,33,153,150,85,28,128,114,198,113,27,186,83,0,178,102,154,235,15,14,76,116,69,250,253,202,115,87,157,171,40,23,48,73,193,157,78,81,69,162,232,29,120,68,42,125,135,121,254,156,149,143,198,173,119,0,1,0,0,53,186,49,237,22,194,17,96,120,10,192,151,99,191,213,147,177,116,143,105,230,131,169,251,16,146,26,164,157,188,67,139,78,87,51,241,113,6,164,3,59,144,48,243,76,127,49,1,147,79,102,218,253,36,37,149,91,92,247,35,64,0,1,0,0,237,48,107,41,18,142,6,90,253,206,115,235,200,224,236,208,140,217,24,253,192,247,76,3,246,77,81,94,72,6,115,118,133,155,130,106,66,115,187,68,69,230,28,222,77,91,95,90,23,4,86,255,161,95,247,195,108,233,152,241,190,0,1,0,1,63,74,44,150,76,113,212,159,45,136,118,161,30,238,75,244,232,209,146,49,101,47,199,117,178,202,228,58,33,129,4,114,76,225,212,61,128,125,223,69,48,213,107,167,249,183,181,194,21,67,99,215,247,166,215,108,189,158,61,249,130,0,1,0,0,103,33,171,145,26,65,216,181,37,2,234,76,223,66,236,153,229,229,41,190,106,62,102,243,173,178,20,60,90,51,232,118,240,225,158,242,19,13,216,95,254,79,35,196,212,101,148,164,24,219,221,10,181,111,253,164,76,93,72,246,206,0,1,0,5,187,116,113,160,1,107,28,51,15,118,122,94,115,173,12,51,9,52,105,76,173,0,124,90,163,249,38,190,101,25,143,99,94,50,239,35,14,215,12,184,219,25,32,81,51,246,142,27,126,246,157,133,33,13,119,172,197,111,163,43,234,0,1,0,5,21,101,126,190,1,77,145,81,72,7,18,222,122,16,141,155,14,26,122,121,141,61,162,148,91,165,60,209,3,90,251,120,52,143,255,91,253,53,60,239,129,160,65,213,230,214,195,241,114,123,145,145,220,232,75,132,91,7,118,101,237,0,1,0,6,49,18,87,196,3,187,186,126,42,239,10,162,8,34,98,124,130,236,116,132,252,179,27,135,221,140,88,42,169,240,163,222,200,2,37,101,9,35,172,42,74,77,142,96,167,8,137,208,171,61,234,142,107,218,41,37,203,138,127,216,252,137,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,174,229,34,198,20,187,1,37,21,66,226,45,128,16,30,45,151,85,103,77,143,214,69,38,254,154,44,77,223,171,97,143,137,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,159,186,133,75,226,253,235,173,50,111,19,111,136,219,244,177,114,214,77,28,237,51,180,171,99,164,148,28,226,73,151,137,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,172,113,10,243,67,127,194,244,249,48,131,50,164,72,10,88,81,76,45,149,28,73,119,114,174,142,141,132,8,175,27,137,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,182,81,125,81,147,30,201,86,98,178,2,213,133,189,82,214,234,207,27,118,113,82,28,46,150,32,45,104,62,223,226,99,137,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,170,140,159,117,250,84,163,177,210,240,18,225,217,234,99,118,79,112,157,28,25,151,121,72,28,143,77,92,237,107,62,9,1,45,86,211,71,72,250,222,240,196,161,223,115,65,15,173,85,177,255,211,89,90,168,146,255,238,205,12,128,137,196,203,27,9,1,12,138,2,247,115,213,230,144,244,253,93,195,182,20,84,243,71,244,71,24,244,103,128,231,65,233,198,173,128,126,246,169,9,1,185,67,192,97,81,170,106,240,157,23,26,106,216,228,65,120,68,165,135,110,2,31,216,158,187,67,79,105,151,157,234,15,9,1,12,91,247,177,168,165,63,93,186,29,121,106,121,167,27,50,198,22,230,125,252,159,77,132,92,155,115,251,100,87,112,147,9,1,127,216,219,101,110,162,74,65,114,24,131,123,143,204,15,44,36,72,8,136,170,255,39,231,108,143,128,71,65,95,117,4,9,1,4,27,221,133,245,254,194,84,195,88,19,141,109,233,58,225,116,116,251,225,170,44,159,23,28,181,85,238,6,151,63,144,9,1,130,114,163,11,234,79,36,77,175,198,107,147,58,183,234,134,122,178,61,205,225,34,184,146,138,50,221,70,198,19,2,191,9,1,41,151,245,131,127,195,211,240,254,148,60,106,169,97,173,173,118,116,195,243,213,115,169,17,155,83,25,181,108,68,48,51,9,1,236,254,112,114,24,207,172,186,132,163,119,198,20,66,226,51,51,142,39,212,88,198,68,118,92,136,138,204,26,155,11,165,9,1,215,116,3,65,140,246,136,209,81,15,184,214,188,49,94,63,81,57,12,135,108,143,41,137,113,88,11,84,15,30,158,184,9,1,50,203,140,60,152,140,103,117,103,130,42,29,70,236,110,49,211,18,247,40,117,35,54,107,171,190,233,18,117,69,68,43,9,1,95,50,92,228,81,22,16,190,182,42,66,158,131,165,204,25,25,20,143,210,29,170,143,129,94,111,129,132,227,28,102,180,9,1,96,153,155,64,152,142,147,161,102,88,190,194,238,147,14,243,71,26,33,184,193,50,249,29,88,2,52,157,179,7,69,77,9,1,212,255,51,143,196,70,53,156,98,221,171,235,82,21,252,198,242,28,2,246,195,67,6,91,2,240,95,173,200,49,66,89,9,1,58,212,15,123,117,242,193,79,217,63,177,112,56,232,153,140,93,188,111,168,108,138,82,113,212,107,209,150,246,205,191,157,9,1,204,180,39,152,129,136,139,125,156,240,127,28,205,2,65,12,140,132,177,76,5,4,95,204,205,9,179,77,57,148,6,231,9,1,249,145,142,225,129,214,86,160,12,71,51,28,109,238,246,115,57,184,6,234,138,46,107,81,103,128,201,242,101,51,179,68,9,1,17,109,102,169,143,117,42,93,149,160,20,188,122,34,0,140,248,73,206,232,146,65,183,250,61,35,40,54,167,63,173,215,9,1,58,197,183,31,149,121,187,250,193,140,202,222,69,149,235,105,78,113,59,213,78,241,15,40,62,137,46,19,193,78,85,31,9,1,209,81,122,212,165,252,102,254,115,58,127,209,26,21,188,113,69,3,30,255,154,72,181,219,97,7,227,96,209,19,138,181,9,1,151,245,134,14,100,30,161,175,227,142,158,71,197,157,213,103,198,28,241,51,173,107,242,84,76,53,176,101,132,26,29,60,9,1,72,239,59,253,40,148,227,213,236,98,100,14,198,212,71,148,180,209,64,152,228,196,11,209,109,231,183,97,135,156,172,241,9,1,205,107,120,198,53,118,206,64,8,204,37,15,58,43,95,189,38,38,203,212,73,105,50,160,21,160,38,124,10,233,46,22,17,1,14,204,0,103,138,56,182,245,161,43,137,56,202,232,138,228,30,242,80,214,237,253,8,17,251,148,203,85,106,127,162,114,20,161,98,175,120,161,168,109,95,168,170,123,117,238,24,132,211,108,163,195,25,58,89,16,198,41,13,94,89,2,119,169,28,80,179,104,66,21,38,252,16,146,163,159,122,68,234,161,165,150,251,139,57,4,0,82,244,49,170,53,221,128,152,46,60,102,97,65,18,80,60,162,198,227,68,116,95,74,43,207,201,189,126,9,199,85,132,67,87,214,19,120,116,147,47,78,236,178,95,23,23,1,171,197,181,63,197,52,162,224,221,93,223,35,243,248,138,100,215,25,1,0,2,94,249,142,243,210,28,27,218,191,10,139,245,66,107,2,111,153,125,18,238,76,249,208,69,34,173,165,21,177,18,82,239,17,1,14,217,248,73,34,237,151,158,186,178,226,225,234,58,186,218,7,175,174,60,185,248,248,25,28,51,154,61,168,213,77,242,169,0,82,244,49,170,53,221,128,152,46,60,102,97,65,18,80,60,162,198,227,68,116,95,74,43,207,201,189,126,9,199,85,132,194,179,227,24,162,84,191,59,100,89,207,244,98,199,135,44,91,35,210,22,182,249,66,219,89,32,250,61,112,54,16,141,161,98,175,120,161,168,109,95,168,170,123,117,238,24,132,211,108,163,195,25,58,60,170,232,127,53,17,58,173,142,247,89,247,207,149,119,134,64,14,158,82,18,231,188,179,163,89,11,174,81,43,46,153,9,9,132,119,216,135,171,185,255,65,210,32,46,77,152,229,32,71,244,141,39,140,188,245,22,25,184,28,198,202,132,222,174,160,25,1,0,2,119,228,107,44,53,217,61,182,86,125,189,169,81,109,32,249,139,212,234,72,144,24,135,118,89,121,216,219,24,207,66,168,17,1,14,213,5,71,76,80,42,16,77,105,27,101,50,79,76,38,232,167,55,134,79,128,251,113,33,35,116,77,254,28,6,176,0,0,82,244,49,170,53,221,128,152,46,60,102,97,65,18,80,60,162,198,227,68,116,95,74,43,207,201,189,126,9,199,85,132,110,177,116,132,158,116,7,177,77,240,138,82,212,212,241,43,54,8,1,75,42,104,243,5,241,73,226,60,72,169,2,41,25,1,0,3,73,127,150,33,212,30,131,171,90,28,221,170,53,22,176,210,81,154,146,160,81,67,188,184,7,13,240,169,97,51,230,181,9,100,71,111,167,179,223,229,107,45,223,184,100,207,103,16,106,234,217,25,120,51,156,12,142,28,186,4,134,110,182,28,191,11,9,9,62,169,255,238,205,94,99,210,162,31,213,85,158,233,223,231,174,18,241,77,26,133,255,75,40,190,65,163,26,48,53,196,25,1,0,2,232,83,248,233,232,89,11,170,74,117,125,224,222,189,198,137,244,49,205,228,155,200,97,42,160,89,8,63,109,25,91,168,9,9,255,134,239,235,78,5,0,110,98,20,109,14,192,231,250,72,49,145,191,114,177,51,38,242,67,121,217,71,114,50,124,171,9,9,209,167,69,145,2,139,203,92,187,46,4,30,218,0,85,77,176,3,253,201,73,229,148,92,229,57,32,59,244,12,109,96,9,9,113,233,23,33,249,145,133,118,215,96,240,47,3,202,196,124,111,64,3,49,96,49,132,142,60,29,153,230,232,58,71,67,65,14,41,230,74,233,195,128,0,49,87,111,239,58,195,179,2,237,163,15,66,168,74,199,52,200,236,175,1,55,3,126,248,127,239,193,246,133,27,151,79,57,134,3,21,27,16,164,160,185,211,150,83,253,116,26,253,56,22,83,204,70,30,122,203,221,134,84,251,39,141,138,17,246,159,212,31,236,239,75,201,65,5,60,24,80,250,182,152,192,250,91,168,183,69,6,78,180,185,147,215,10,134,34,96,243,26,77,158,213,121,211,188,200,73,204,177,205,8,52,178,106,57,74,136,235,186,254,43,32,141,97,126,192,90,203,191,95,226,69,41,166,75,35,133,169,106,173,67,240,155,225,173,169,44,112,64,49,220,193,72,27,65,8,29,65,249,24,254,23,128,162,84,32,193,217,215,5,53,140,19,76,198,1,217,209,132,203,77,253,222,126,28,172,43,195,212,211,139,249,236,68,230,33,5,245,225,0,18,59,175,197,134,247,119,100,72,140,210,76,106,119,84,110,90,15,232,189,251,79,162,3,207,175,252,54,204,228,221,91,137,1,0,0,0,0,0,0,0,0,0,0,0,0,102,252,2,65,142,125,208,106,197,183,59,71,59,230,188,90,81,3,15,76,116,55,101,124,183,178,155,243,118,197,100,184,209,103,90,94,137,2,0,0,0,0,0,0,0,0,0,0,0,0,102,252,2,66,75,168,78,31,55,208,65,188,110,85,186,57,104,38,204,73,78,132,212,129,91,109,181,38,144,66,46,234,115,134,49,79,0,232,231,118,38,88,111,115,185,85,54,76,123,75,191,11,183,247,104,94,189,64,232,82,177,100,99,58,74,203,211,36,76,61,226,32,44,203,98,106,211,135,215,7,34,230,79,190,68,86,46,47,35,26,41,12,8,83,43,141,106,186,64,47,245,0,242,170,235,6,192,229,86,67,74,201,60,35,47,55,221,139,224,167,191,159,67,15,118,235,86,77,249,252,183,112,196,95,121,9,53,136,208,232,71,239,167,58,16,206,32,228,121,159,177,228,102,66,214,86,23,199,229,33,63,160,73,137,217,45,137,2,0,0,0,0,0,0,0,0,0,0,0,0,102,252,2,66,135,222,210,71,225,102,15,130,112,113,199,241,55,25,52,88,151,81,8,83,132,252,159,68,98,193,241,137,124,92,62,239,137,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,134,36,129,147,235,77,210,168,206,129,95,135,108,18,77,72,53,149,34,240,133,77,149,216,7,46,175,240,211,125,85,189,17,3,32,62,137,13,108,44,59,173,166,238,204,150,3,169,156,28,98,89,237,90,100,2,241,199,108,193,139,86,140,58,239,186,15,17,34,169,145,29,210,173,116,63,242,55,212,17,100,138,15,227,44,109,116,238,192,96,113,106,42,116,53,47,107,28,67,91,93,103,0,249,3,11,120,197,191,90,201,151,167,105,98,170,50,201,10,109,142,142,188,233,131,140,142,235,56,141,115,225,247,101,154,214,116,246,54,163,90,111,26,81,86,78,195,55,27,156,77,163,18,109,90,208,186,227,80,207,199,250,234,199,99,99,184,9,255,104,98,246,102,108,85,7,252,51,21,214,132,35,158,2,38,112,107,69,195,65,114,145,245,183,172,194,211,57,80,82,17,161,138,214,89,21,244,44,6,173,6,242,62,51,254,238,79,87,6,12,210,73,180,68,244,119,54,206,136,162,78,107,80,251,5,29,192,174,93,179,175,68,217,8,246,220,217,160,21,208,74,126,225,227,25,1,0,3,59,172,224,22,174,10,65,231,169,237,9,168,91,33,85,109,38,187,242,242,75,76,32,165,75,187,165,27,95,83,162,158,25,1,0,5,237,36,132,158,202,168,131,171,106,32,214,79,172,224,148,150,15,71,73,102,217,162,19,183,2,117,192,112,196,76,181,34,161,61,185,77,114,162,95,100,135,66,67,175,119,110,6,244,73,213,91,169,221,83,157,81,206,111,89,151,62,178,167,63,16,226,11,189,169,125,149,14,110,8,62,221,87,116,233,142,217,139,253,153,16,9,1,186,154,222,88,248,170,108,168,43,242,42,43,72,15,245,221,236,232,166,232,99,81,164,123,16,213,143,51,128,251,219,183,9,1,103,185,128,156,225,233,200,126,96,129,32,179,163,131,84,200,153,155,236,34,245,43,19,243,165,109,226,10,22,113,50,131,9,1,203,224,11,159,230,121,179,34,119,46,123,13,250,7,202,214,183,18,124,144,172,158,237,255,172,53,228,144,236,81,142,168,161,44,60,95,185,9,118,123,106,246,85,186,215,47,93,102,56,245,245,208,160,183,144,135,107,116,64,90,68,61,138,52,178,244,96,20,237,96,5,52,90,158,129,172,204,39,175,55,18,74,73,29,222,9,255,36,49,6,86,93,12,79,206,248,151,94,121,177,178,35,12,1,159,78,58,178,122,63,78,124,169,48,107,159,98,153,132,161,138,214,89,21,244,44,6,173,6,242,62,51,254,238,79,87,6,12,210,73,208,111,9,167,39,114,89,78,179,210,171,35,115,181,211,197,236,176,132,184,74,77,237,45,48,18,241,69,222,221,138,25,161,93,224,137,41,163,192,131,82,50,167,205,32,29,51,131,23,202,171,216,115,199,117,193,115,55,85,171,245,34,173,219,214,151,226,215,10,91,97,70,75,209,104,27,41,137,81,196,246,13,142,199,12,25,1,0,4,113,24,36,136,41,22,138,100,28,59,149,105,31,231,215,27,33,193,211,238,215,254,44,202,236,107,125,180,46,38,146,200,25,1,0,2,38,182,122,48,1,162,205,218,95,52,172,146,222,81,199,193,42,178,228,105,133,88,214,83,137,237,66,230,119,250,5,85,9,255,253,39,5,238,88,207,60,229,238,92,28,224,63,70,109,126,152,54,188,71,18,186,162,153,21,61,132,71,202,121,113,207,161,138,214,89,21,244,44,6,173,6,242,62,51,254,238,79,87,6,12,210,73,191,14,175,103,174,227,73,235,177,89,118,163,111,237,172,26,74,6,101,80,58,211,113,127,243,254,106,224,120,179,101,156,161,76,72,189,176,20,90,137,189,135,248,136,79,63,168,193,228,45,88,94,117,184,2,226,247,10,56,240,40,136,100,146,139,246,198,195,194,209,164,217,45,202,10,147,86,175,254,198,249,92,64,121,164,0,1,0,0,253,83,6,143,195,92,106,35,254,224,103,188,253,63,192,216,128,186,79,121,216,182,90,175,191,240,47,48,93,168,74,2,141,105,206,208,33,164,189,140,91,38,36,168,242,80,217,18,184,248,245,157,129,85,249,94,94,229,138,101,38,9,1,47,241,202,110,153,206,246,252,92,214,119,95,159,94,245,61,243,40,240,8,26,143,180,81,247,55,255,244,73,12,229,83,9,1,95,192,113,95,216,242,21,235,124,16,227,245,80,217,178,9,241,140,170,135,64,175,84,27,211,70,239,73,100,139,20,245,9,1,201,169,20,123,206,251,168,141,33,64,175,106,246,185,19,185,53,101,125,53,5,87,5,184,7,21,91,61,208,130,42,131,9,1,183,44,52,109,222,204,99,77,172,182,15,29,40,214,131,168,39,33,227,213,36,163,61,162,168,47,3,62,136,241,101,126,9,1,133,79,165,174,6,191,41,30,209,5,109,104,28,93,197,246,247,13,23,242,234,3,204,110,233,229,198,255,131,62,203,105,0,9,36,146,140,19,119,166,207,36,195,156,45,70,248,235,157,242,62,129,27,38,220,53,39,229,72,57,111,212,225,115,177,211,102,235,93,180,24,37,200,29,129,191,72,73,93,114,116,50,181,244,253,225,248,223,46,101,251,180,223,113,77,242,139,0,70,112,11,77,64,172,92,53,175,44,34,221,162,120,122,145,235,86,123,6,201,36,168,251,138,233,160,91,32,192,140,33,228,96,52,194,207,181,181,131,126,57,95,233,204,152,190,4,82,34,235,53,200,202,40,109,252,73,189,213,239,94,126,130,9,1,27,8,240,147,212,200,27,37,231,124,191,110,45,189,91,214,149,171,253,138,221,47,115,230,14,214,92,143,87,109,114,128,17,1,249,248,63,134,138,17,62,7,250,227,100,52,50,139,214,30,153,110,204,16,117,222,9,119,59,220,202,187,15,30,237,162,217,9,1,207,50,50,89,38,214,97,46,146,127,167,239,70,37,230,216,37,111,63,130,63,184,65,242,102,240,65,120,90,218,241,226,9,1,247,124,190,104,95,142,126,239,68,219,69,165,161,237,129,135,165,5,236,239,227,84,140,240,18,4,129,67,95,125,116,254,0,70,112,11,77,64,172,92,53,175,44,34,221,162,120,122,145,235,86,123,6,201,36,168,251,138,233,160,91,32,192,140,33,64,31,45,164,25,35,131,214,111,103,185,66,123,36,77,209,130,54,238,77,124,250,76,42,126,68,137,156,53,223,112,84,9,1,172,109,18,138,162,172,98,227,191,233,228,200,186,6,38,31,205,90,238,83,85,200,140,40,95,174,70,100,236,184,92,217,161,244,45,89,208,100,220,62,250,92,105,132,16,63,83,84,164,87,143,157,56,238,206,71,73,61,115,66,84,21,49,226,43,98,209,124,67,230,245,74,241,47,105,36,12,239,120,5,217,170,54,156,84,161,240,229,12,107,226,171,19,248,82,37,157,153,49,126,15,161,81,30,210,115,133,159,227,100,212,172,149,230,75,232,210,108,56,145,60,23,37,166,185,84,193,191,193,253,113,198,103,19,58,1,211,88,161,138,214,89,21,244,44,6,173,6,242,62,51,254,238,79,87,6,12,210,73,244,204,176,178,59,175,3,143,139,2,242,240,21,87,122,194,191,65,151,96,89,50,229,228,174,155,172,240,102,252,221,88,161,54,97,92,243,73,215,246,52,72,145,177,231,202,124,114,136,63,93,192,73,97,131,206,41,240,31,150,151,163,154,135,110,104,89,178,252,214,86,245,40,217,82,157,194,186,14,137,246,116,87,3,221,0,88,209,228,65,175,80,39,254,110,76,107,116,157,222,72,114,28,239,59,179,26,8,211,214,75,156,110,156,114,90,188,114,36,198,234,1,57,238,186,239,33,185,70,78,68,110,74,247,188,177,180,151,164,216,15,115,133,254,13,247,190,87,17,67,0,232,148,145,23,177,217,122,193,138,141,18,36,190,30,64,69,198,123,105,131,146,212,237,192,61,179,237,70,185,233,70,115,24,243,123,134,88,68,215,142,127,133,2,149,85,85,176,160,214,111,3,112,143,142,78,137,211,79,138,29,6,66,209,69,161,250,30,45,145,12,250,62,92,70,95,125,127,105,194,36,213,66,224,165,152,168,81,60,218,234,227,67,148,118,29,59,147,53,55,78,40,8,227,39,217,122,18,110,222,78,162,140,204,238,55,6,95,41,25,0,0,0,0,144,32,12,17,126,234,225,99,200,138,138,108,231,51,212,1,171,8,94,147,139,188,115,131,162,159,107,192,34,19,171,180,161,151,178,33,144,104,181,16,79,208,222,10,42,70,102,179,246,243,151,172,167,86,83,107,175,210,186,181,198,128,36,151,56,29,81,196,245,31,168,78,1,68,190,24,94,31,195,247,20,122,219,85,214,0,172,224,132,217,231,157,205,174,1,20,9,234,148,84,215,130,24,9,46,11,24,156,214,165,23,59,68,102,116,0,213,17,230,13,150,23,44,152,198,242,109,118,74,176,93,184,102,158,85,104,138,31,78,160,214,75,29,223,239,114,74,97,156,59,161,94,69,18,60,117,174,107,34,34,42,46,244,10,252,240,128,232,79,90,245,105,207,185,63,169,21,50,218,22,157,164,50,155,208,136,29,218,73,246,12,13,209,254,95,239,141,35,221,253,207,221,212,9,1,248,135,166,243,99,75,238,65,244,69,142,255,92,110,93,81,203,0,116,149,135,131,96,149,14,49,60,161,204,107,128,214,10,1,164,102,179,128,123,95,250,209,85,215,47,223,202,234,9,179,137,135,46,66,252,162,20,55,210,106,243,173,46,40,178,89,161,54,97,92,243,73,215,246,52,72,145,177,231,202,124,114,136,63,93,192,73,156,179,78,101,253,32,134,94,34,150,203,47,196,201,136,120,12,142,64,149,165,101,204,29,186,80,109,39,8,84,79,232,161,128,2,205,152,207,181,99,73,42,111,179,231,200,36,59,123,154,212,204,146,140,190,129,206,40,197,26,241,53,110,14,80,134,5,37,204,178,45,166,159,129,221,136,86,105,96,102,217,243,16,89,249,161,104,60,252,156,182,35,11,128,137,157,188,182,24,21,145,214,144,137,216,164,177,52,180,226,24,99,117,67,64,64,241,12,41,231,167,74,209,204,218,129,255,34,102,39,251,93,142,41,145,92,203,50,161,138,214,89,21,244,44,6,173,6,242,62,51,254,238,79,87,6,12,210,73,164,143,172,103,50,238,187,229,211,197,117,198,212,234,78,82,14,197,48,46,66,117,89,74,193,245,113,83,209,177,183,217,161,81,125,159,102,197,100,210,237,244,60,182,87,66,79,114,241,194,13,59,255,230,154,81,238,249,118,81,47,67,167,51,81,39,137,145,76,187,230,155,155,70,102,153,242,27,165,84,224,218,253,106,44,9,255,60,175,19,171,24,127,90,244,102,215,109,52,163,108,87,248,78,75,87,18,254,157,225,108,251,34,166,46,135,226,155,114,9,1,137,66,124,98,185,206,118,62,215,166,225,249,150,252,161,203,0,217,115,193,56,251,207,17,2,102,50,45,221,187,226,50,177,93,224,137,41,163,192,131,82,50,167,205,32,29,51,131,23,202,171,216,115,0,2,86,146,226,162,251,7,31,172,102,81,196,200,22,126,55,247,235,106,113,202,76,139,128,246,85,114,151,178,101,95,159,191,161,51,139,210,222,212,86,156,86,143,33,218,23,74,206,199,11,130,110,85,12,238,250,55,221,42,57,86,177,201,103,75,239,3,21,25,161,11,112,13,117,46,113,1,71,100,17,102,72,32,125,98,78,0,1,0,0,253,83,6,143,195,92,106,35,254,224,103,188,253,63,192,216,128,186,79,121,216,182,90,175,191,240,47,48,93,22,155,114,188,54,101,62,87,11,121,52,68,25,197,106,219,1,155,20,238,224,223,45,229,125,209,123,117,113,166,132,12,161,220,14,214,252,191,229,28,159,132,166,98,230,79,209,52,119,54,170,116,134,81,122,205,57,136,220,234,247,156,218,204,189,130,97,114,48,48,160,227,48,48,64,28,58,212,244,195,137,255,228,64,41,161,128,2,205,152,207,181,99,73,42,111,179,231,200,36,59,123,154,212,204,146,237,236,215,194,80,85,137,94,24,27,243,41,116,140,187,70,33,135,209,48,214,17,9,198,53,117,79,21,244,235,240,208,9,255,219,215,135,89,179,97,218,60,174,210,247,236,175,60,97,114,55,143,26,104,199,6,53,175,153,170,254,4,26,49,33,168,161,54,97,92,243,73,215,246,52,72,145,177,231,202,124,114,136,63,93,192,73,131,75,158,95,145,124,241,215,162,81,17,8,190,214,110,90,15,123,1,214,244,31,200,40,196,119,19,72,17,44,27,219,161,44,60,95,185,9,118,123,106,246,85,186,215,47,93,102,56,245,245,208,160,62,110,21,209,63,190,73,44,77,121,157,143,198,176,46,157,199,11,251,128,18,248,171,99,94,148,201,218,67,21,70,232,9,255,16,46,124,130,188,155,165,96,66,61,124,176,157,94,180,222,164,199,68,147,148,121,54,59,60,181,162,4,74,28,114,103,9,1,0,0,0,60,9,235 + ], + "state_diffs_hash": "0xc83cac9cd98a4216cbc0d0830e63c4956e4a1c45c122ebbc88af7ea3b496c406", + "aux_commitments": { + "events_queue_commitment": "0xec82208c87a937d88768a0067b2a80f0525eca8288dad2cf96cf8bbe6a1aa565", + "bootloader_initial_content_commitment": "0x97df88dcecbcd29b49773c042cdee7a44c57a741e64913fff5aa1b3484232f28" + }, + "blob_linear_hashes": [ + "0xff4feb4bef9401731ab9db3626c2e015baa6880d7b1c4382d03b30da3a0fd75e", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "blob_commitments": [ + "0xf840cf3f6b7dc92729b2b9ef3b399e7b896d553b746362fe81c4eb911013570d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "aggregated_root": "0x0924928c1377a6cf24c39c2d46f8eb9df23e811b26dc3527e548396fd4e173b1", + "local_root": "0xd4790efa9052ea67dcb473de870e3522e2fc340374e6293ad4646fde312c8c76" + } + }, + "meta_parameters": { + "zkporter_is_available": false, + "bootloader_code_hash": "0x010008c753336bc8d1ddca235602b9f31d346412b2d463cd342899f7bfb73baf", + "default_aa_code_hash": "0x0100055d760f11a3d737e7fd1816e600a4cd874a9f17f7a225d1f1c537c51a1e", + "protocol_version": "Version25" + }, + "pass_through_data": { + "shared_states": [ + { + "last_leaf_index": 212, + "root_hash": "0x0332d2acc43785a44b2b84fc010372c8f3e4ff4d0ca5f312de142ffe74189500" + }, + { + "last_leaf_index": 0, + "root_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + ] + }, + "input": { + "PostBoojum": { + "common": { + "l2_to_l1_logs": [ + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 0, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x91ac392a7af99b6df974efe2d6b40e35dc79156fa3b75ea257df4976da0c26e8", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 1, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xa088c0c1710f2244aad45e356742e7ac7773a153cf23db6cec4ded7e8da05d69", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 2, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xccdf8bf8f4bf596f8fbb7ed18d67ef6208919707de498d0cae4d2c01c50e2305", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 3, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xe43e076103a2a867921c20b43365e7729003f1a00558c3dc51b31b25c90b2b2a", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 4, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x3eba0d3506eba94a8b328b82b3a32623c2ef77e253bfbb82d2667b163c8714c7", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 5, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xdaf8935b934fe9513d112e3ca61a728dbfae2fdb5ea1edf8e6f56b8283aa4cd8", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 6, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x5527767da575eb332ed996603486300af0f55116f2a177b0c05ed31518a23d77", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 7, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x15f4d69332763eaaf4d80e05e88b04d45d38d0854381f58e4c01688496e03f63", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 8, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x96a04ccc56dc1cea06a00fe97af3231766aee89c948c86f0c16eeebcdddc0aa3", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 9, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x886292e17714665013e6c7fc19b12b15a69676394ec88ceb5d1698a0b198a7dd", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 10, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x9e84bba4d8497ea90d8c5513063912bdbd9cc85ac68185ee1715a7b15ca01f17", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 11, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x3795b197a06415b6b00d2bde238a25741ecc9791269d899c97ff983d88dcd5e6", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 12, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x0e5be5348f9a9fd4e936c4fad6793e0e4395f5642d1b5f9a08e1a3703226f8ef", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 13, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xec3e691650319cdf9fbc5410f388ea24f2c9325b0d7b4ce37db2a1c5957bd86b", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 14, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xfa448e8ac5560693b992b70fae5e08f3e9cae510c8e1fa69d2c212dd1811bf05", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 15, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x6c5a74345d321eb4edebdf43f42a11bc409613a9b92cbfe96730498217b12d43", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 16, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x7912d592b280f7f7a5d04c68eaddae09b518816a0a6d97bc89b143ae3109e78f", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 17, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x3c1fad3b48be6cb9503048860557f3ef99dccdf1f51dfbf26570f630469b1a98", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 18, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xb7e755892fbe6870e93cbd3c0945d772e141b94ee50aa75a2d7bb7219fb53266", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 19, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xb81f1f0fbe80e956956132771d1a99c35bd52856adbf932cc061d3980a79c124", + "value": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 20, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x8f5a7c0d48c9b82137c446c9db31ce5ef4e1a30166dd3ae09580c33595bbe2b7", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 21, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x2f6516d033cfa362a407a7d2d2279c62fa185eaae6742bc6f51fdcb51606094e", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 22, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x82eb8a4152ff724ef814c3ddacea2a65e6e6d09a00d72e57fff9e12b7857461d", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 23, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x08a95d3f4505e0e3fb90a2002a81750c0bae658a5d4a290acaeacdfc2691560a", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 24, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xb8c38e08db553411378fc77ca81f20da7d5b1be77fb316393e33bfe0c08565dd", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 25, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xd54d7593c4d133e4903becb318f109246537ddab2646148ac51ac7c94e25ef8c", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 26, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x3e86b6ddb211d47e057c4e246810e2dbb10061c2679e52ae7e4b647c9c98bf08", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 27, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0xe1cee6c0528143fa82ff667c9655d2d775dccdb4204791956096a6225059c9b8", + "value": "0x0000000000000000000000000000000000000000000000000000000000000001" + } + ], + "rollup_last_leaf_index": 212, + "rollup_root_hash": "0x0332d2acc43785a44b2b84fc010372c8f3e4ff4d0ca5f312de142ffe74189500", + "bootloader_code_hash": "0x010008c753336bc8d1ddca235602b9f31d346412b2d463cd342899f7bfb73baf", + "default_aa_code_hash": "0x0100055d760f11a3d737e7fd1816e600a4cd874a9f17f7a225d1f1c537c51a1e", + "protocol_version": "Version25" + }, + "system_logs": [ + { + "shard_id": 0, + "is_service": false, + "tx_number_in_block": 0, + "sender": "0x000000000000000000000000000000000000800b", + "key": "0x0000000000000000000000000000000000000000000000000000000000000002", + "value": "0xf9030b78c5bf5ac997a76962aa32c90a6d8e8ebce9838c8eeb388d73e1f7659a" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 0, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x0000000000000000000000000000000000000000000000000000000000000007", + "value": "0x91ac392a7af99b6df974efe2d6b40e35dc79156fa3b75ea257df4976da0c26e8" + }, + { + "shard_id": 0, + "is_service": false, + "tx_number_in_block": 28, + "sender": "0x000000000000000000000000000000000000800b", + "key": "0x0000000000000000000000000000000000000000000000000000000000000001", + "value": "0x00000000000000000000000066fc024100000000000000000000000066fc0242" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 28, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x0000000000000000000000000000000000000000000000000000000000000003", + "value": "0x190bda1fde651ac21cf771cb9f125f486678abbab229cce182a7c9a07361afbe" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 28, + "sender": "0x0000000000000000000000000000000000008001", + "key": "0x0000000000000000000000000000000000000000000000000000000000000004", + "value": "0x000000000000000000000000000000000000000000000000000000000000001b" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 28, + "sender": "0x0000000000000000000000000000000000008008", + "key": "0x0000000000000000000000000000000000000000000000000000000000000000", + "value": "0x38eaeef3afe69b6f6b2fa22c92da8137f1e405a1e1861b7de7cfa30c7d7462dd" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 28, + "sender": "0x0000000000000000000000000000000000008008", + "key": "0x0000000000000000000000000000000000000000000000000000000000000006", + "value": "0x000000000000000000000000cc4b013229ffd6cb5eae5876251874172cafed0a" + }, + { + "shard_id": 0, + "is_service": true, + "tx_number_in_block": 28, + "sender": "0x0000000000000000000000000000000000008008", + "key": "0x0000000000000000000000000000000000000000000000000000000000000005", + "value": "0x335f4f11c3e55bb502bcbdedfd8e63b8e5c84bea465c984a5c664a8eca7d4a7a" + } + ], + "state_diffs": [ + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x3e013dc3eb10bbd48a8f9c94758f04d081563b6", + "derived_key": [ + 112,120,89,162,183,230,11,175,17,100,223,232,175,83,47,195,198,157,29,129,145,197,186,61,127,17,109,250,141,181,206,45 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10001430633c573868f335e3106fc558badc506762eb8184ef9ce785def6ece" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x868a8819e738818dabe8bfb671ae8e027372dd7", + "derived_key": [ + 130,208,215,121,46,249,196,126,160,123,216,26,86,45,8,246,35,74,8,171,141,141,223,145,137,150,142,180,236,158,154,37 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1000ecfaeb837bd098bcf9bde6fc2ccd8e8a9355a1b70e601ac18cd089eb308" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x9af32a0f1b0914742c84d68795a9be9abd6bbd5", + "derived_key": [ + 246,11,47,22,184,171,230,29,125,57,179,213,44,191,157,128,184,167,253,5,55,217,60,33,8,75,147,188,5,4,171,60 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10000c328f328dd820a1dd698047a7f7d49874d8259196e273517430af8f480" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x22acca3c358a523c1ecbf1491d131a597aada298", + "derived_key": [ + 203,204,98,199,195,136,172,152,215,47,208,131,209,215,32,206,186,255,203,162,198,108,114,94,200,185,197,197,240,116,111,138 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100005b8e587974043d59bffbf632d020e764959abe62e4c238d8df2e62b2b5" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "derived_key": [ + 235,143,74,199,189,78,241,151,159,154,102,86,114,178,92,208,123,30,61,99,122,89,162,199,107,26,34,232,91,117,146,65 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10001430633c573868f335e3106fc558badc506762eb8184ef9ce785def6ece" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x30439cdc8796fb3cecb53f4bf5b133f581b5b40f", + "derived_key": [ + 66,202,106,148,168,163,117,186,10,227,150,70,185,29,164,88,23,175,73,33,116,119,174,107,73,193,3,53,191,78,11,115 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10001b37e5f8cafac924b3e663779e12c80dace8a02b1d273ae708f275ad62a" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x338bd2ded4569c568f21da174acec70b826e550c", + "derived_key": [ + 71,164,52,102,233,54,181,135,193,191,158,16,243,13,105,123,17,66,228,89,233,6,51,219,18,27,114,127,245,180,121,43 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1000067554f53c6660e53bd9729f00aee0189010dfeb868fa3cbd481232480c" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x48a6f6788413af58f1bdf8c963cb67a4346f5fd8", + "derived_key": [ + 95,233,138,250,154,14,193,124,34,99,2,123,232,159,70,229,238,83,58,30,33,169,31,255,76,177,68,204,74,239,33,188 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10005b597eb02058b230cee6a9cdf4705410d151ad1ea6ad3e2de77841acfc2" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x4c48bdb0145a89bd87f8884f3fa8c1e42d585e75", + "derived_key": [ + 142,107,134,4,159,177,116,20,22,26,103,250,177,44,27,34,144,68,85,154,16,112,202,176,23,66,216,18,18,139,156,190 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1000067554f53c6660e53bd9729f00aee0189010dfeb868fa3cbd481232480c" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x517d9f66c564d2edf43cb657424f72f1c20d3bff", + "derived_key": [ + 140,78,248,13,214,150,89,51,34,40,248,136,164,249,180,131,12,12,50,27,140,170,45,67,53,35,250,200,97,150,181,207 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100048bf1b165f4c850d01eb81e5c040f70ea01dca019e780a87f80ec7897c3" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x55f6f01d04a21e76cbd2de9d4a9ff6ee9f8893a6", + "derived_key": [ + 235,96,109,232,32,223,19,108,89,177,255,121,225,223,146,96,66,108,164,143,175,146,74,70,53,36,33,31,183,195,161,165 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1000201e923f3e47adfa7c4f0f61ea8dd4256f66d1099970bcd314892864917" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x5caf5f2b06ca757c7cebacdcd6f163af45a6bb83", + "derived_key": [ + 95,127,60,252,81,90,137,254,204,8,97,6,46,254,57,252,48,104,36,27,116,128,26,163,170,147,245,100,172,98,242,54 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100061dc40d0bc2cb81905e6bc1421ebd4bd8b79aacb8da4f9d7145b288674f" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x5e45123c75ae6b22222a2ef40afcf080e84f5af5", + "derived_key": [ + 207,14,96,187,125,119,111,198,230,184,241,1,19,161,190,119,25,192,44,34,151,163,108,216,124,11,59,35,121,140,74,95 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100070f1cd4e2830607af30192743910fdfabf1dd004a8073944275819d1dfe" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x62af78a1a86d5fa8aa7b75ee1884d36ca3c3193a", + "derived_key": [ + 53,89,195,90,167,22,152,246,194,202,70,67,239,232,80,69,169,73,79,38,45,119,238,103,193,61,215,52,230,38,48,90 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10001430633c573868f335e3106fc558badc506762eb8184ef9ce785def6ece" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x683cfc9cb6230b80899dbcb6181591d69089d8a4", + "derived_key": [ + 186,93,97,46,65,80,43,253,205,126,211,179,176,210,212,177,245,200,248,185,15,209,21,42,187,224,222,192,14,162,61,7 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100048bf1b165f4c850d01eb81e5c040f70ea01dca019e780a87f80ec7897c3" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x7cf7e4a85a7a677f6a5b2fe169e6d5eef29219c5", + "derived_key": [ + 44,61,141,160,220,54,28,84,148,218,146,175,212,98,94,116,25,190,241,121,131,189,209,145,214,33,89,62,212,173,57,47 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1000323b7266314b9d3ec387d5bcd9590a50be00e788837ca5a880d97e3ee83" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x97b2219068b5104fd0de0a2a4666b3f6f397aca7", + "derived_key": [ + 48,100,113,86,255,138,164,229,100,8,99,14,34,251,194,115,119,250,250,242,7,188,204,248,210,254,18,115,9,165,229,233 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1000215cd6f306d757d5d2fdbb460c60f298584179eecc07196c7ae8e4f8d64" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0x9961618bfad393730ea065a18399303330f1395f", + "derived_key": [ + 200,51,40,178,38,74,180,112,167,221,220,163,38,200,255,61,159,78,76,252,60,226,78,168,221,216,201,180,12,20,188,185 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1000201e923f3e47adfa7c4f0f61ea8dd4256f66d1099970bcd314892864917" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0xcc4b013229ffd6cb5eae5876251874172cafed0a", + "derived_key": [ + 229,176,77,5,169,51,88,54,33,49,122,209,137,227,159,45,116,33,7,146,238,29,46,153,91,171,175,162,128,71,14,27 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100015306fb0f0b5fde219996551c8072c6711bba5300b2669aeb0f0e4c7445" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0xcc8e14c05825cde94522515a0303e4c2e07ca6f9", + "derived_key": [ + 250,253,202,115,87,157,171,40,23,48,73,193,157,78,81,69,162,232,29,120,68,42,125,135,121,254,156,149,143,198,173,119 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1000035ba31ed16c21160780ac09763bfd593b1748f69e683a9fb10921aa49d" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0xdb5b25a5c3ff135d39df0dd3417a6b26724d2b24", + "derived_key": [ + 188,67,139,78,87,51,241,113,6,164,3,59,144,48,243,76,127,49,1,147,79,102,218,253,36,37,149,91,92,247,35,64 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10000ed306b29128e065afdce73ebc8e0ecd08cd918fdc0f74c03f64d515e48" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0xdc0ed6fcbfe51c9f84a662e64fd1347736aa7486", + "derived_key": [ + 6,115,118,133,155,130,106,66,115,187,68,69,230,28,222,77,91,95,90,23,4,86,255,161,95,247,195,108,233,152,241,190 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100013f4a2c964c71d49f2d8876a11eee4bf4e8d19231652fc775b2cae43a21" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0xe024f9e4e8fa2f08f768c1cb56bc4a6e3cbd8834", + "derived_key": [ + 129,4,114,76,225,212,61,128,125,223,69,48,213,107,167,249,183,181,194,21,67,99,215,247,166,215,108,189,158,61,249,130 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100006721ab911a41d8b52502ea4cdf42ec99e5e529be6a3e66f3adb2143c5a" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0xe300eb4b0834a551cac3e93f30380643ce153408", + "derived_key": [ + 51,232,118,240,225,158,242,19,13,216,95,254,79,35,196,212,101,148,164,24,219,221,10,181,111,253,164,76,93,72,246,206 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10005bb7471a0016b1c330f767a5e73ad0c330934694cad007c5aa3f926be65" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0xf0e50c6be2ab13f852259d99317e0fa1511ed273", + "derived_key": [ + 25,143,99,94,50,239,35,14,215,12,184,219,25,32,81,51,246,142,27,126,246,157,133,33,13,119,172,197,111,163,43,234 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1000515657ebe014d9151480712de7a108d9b0e1a7a798d3da2945ba53cd103" + }, + { + "address": "0x0000000000000000000000000000000000008002", + "key": "0xfa1e2d910cfa3e5c465f7d7f69c224d542e0a598", + "derived_key": [ + 90,251,120,52,143,255,91,253,53,60,239,129,160,65,213,230,214,195,241,114,123,145,145,220,232,75,132,91,7,118,101,237 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10006311257c403bbba7e2aef0aa20822627c82ec7484fcb31b87dd8c582aa9" + }, + { + "address": "0x0000000000000000000000000000000000008003", + "key": "0x64534fbb7489d8b2e0974a2a70dee20ad40795d90f17c1a6d62ba36ea19e007", + "derived_key": [ + 240,163,222,200,2,37,101,9,35,172,42,74,77,142,96,167,8,137,208,171,61,234,142,107,218,41,37,203,138,127,216,252 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x200000000000000000000000000000000" + }, + { + "address": "0x0000000000000000000000000000000000008003", + "key": "0x1b458e5ab877fea2e4abf98d12b31ec3f7c93fd4856e807f684322e8cf11fdf7", + "derived_key": [ + 174,229,34,198,20,187,1,37,21,66,226,45,128,16,30,45,151,85,103,77,143,214,69,38,254,154,44,77,223,171,97,143 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100000000000000000000000000000000" + }, + { + "address": "0x0000000000000000000000000000000000008003", + "key": "0x810ca1ae825b138452fb743e9948f909b6286cbfadd5a899190fcb21a75443ab", + "derived_key": [ + 0,159,186,133,75,226,253,235,173,50,111,19,111,136,219,244,177,114,214,77,28,237,51,180,171,99,164,148,28,226,73,151 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x700000000000000000000000000000000" + }, + { + "address": "0x0000000000000000000000000000000000008003", + "key": "0xe6d904d46c5d8b2934bf40eee45740c707124a9797010ceae3f79534391b6de5", + "derived_key": [ + 201,172,113,10,243,67,127,194,244,249,48,131,50,164,72,10,88,81,76,45,149,28,73,119,114,174,142,141,132,8,175,27 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x200000000000000000000000000000000" + }, + { + "address": "0x0000000000000000000000000000000000008003", + "key": "0xeaa2b2fbf0b42c559059e5e9510edc15755f1c1883f0e41d5ba5f9aea4ac201a", + "derived_key": [ + 182,81,125,81,147,30,201,86,98,178,2,213,133,189,82,214,234,207,27,118,113,82,28,46,150,32,45,104,62,223,226,99 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xe00000000000000000000000000000000" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x1000035ba31ed16c21160780ac09763bfd593b1748f69e683a9fb10921aa49d", + "derived_key": [ + 28,170,140,159,117,250,84,163,177,210,240,18,225,217,234,99,118,79,112,157,28,25,151,121,72,28,143,77,92,237,107,62 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x100005b8e587974043d59bffbf632d020e764959abe62e4c238d8df2e62b2b5", + "derived_key": [ + 45,86,211,71,72,250,222,240,196,161,223,115,65,15,173,85,177,255,211,89,90,168,146,255,238,205,12,128,137,196,203,27 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x100006721ab911a41d8b52502ea4cdf42ec99e5e529be6a3e66f3adb2143c5a", + "derived_key": [ + 12,138,2,247,115,213,230,144,244,253,93,195,182,20,84,243,71,244,71,24,244,103,128,231,65,233,198,173,128,126,246,169 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x1000067554f53c6660e53bd9729f00aee0189010dfeb868fa3cbd481232480c", + "derived_key": [ + 185,67,192,97,81,170,106,240,157,23,26,106,216,228,65,120,68,165,135,110,2,31,216,158,187,67,79,105,151,157,234,15 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x10000c328f328dd820a1dd698047a7f7d49874d8259196e273517430af8f480", + "derived_key": [ + 12,91,247,177,168,165,63,93,186,29,121,106,121,167,27,50,198,22,230,125,252,159,77,132,92,155,115,251,100,87,112,147 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x10000ed306b29128e065afdce73ebc8e0ecd08cd918fdc0f74c03f64d515e48", + "derived_key": [ + 127,216,219,101,110,162,74,65,114,24,131,123,143,204,15,44,36,72,8,136,170,255,39,231,108,143,128,71,65,95,117,4 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x10000fd53068fc35c6a23fee067bcfd3fc0d880ba4f79d8b65aafbff02f305d", + "derived_key": [ + 4,27,221,133,245,254,194,84,195,88,19,141,109,233,58,225,116,116,251,225,170,44,159,23,28,181,85,238,6,151,63,144 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x100013f4a2c964c71d49f2d8876a11eee4bf4e8d19231652fc775b2cae43a21", + "derived_key": [ + 130,114,163,11,234,79,36,77,175,198,107,147,58,183,234,134,122,178,61,205,225,34,184,146,138,50,221,70,198,19,2,191 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x10001430633c573868f335e3106fc558badc506762eb8184ef9ce785def6ece", + "derived_key": [ + 41,151,245,131,127,195,211,240,254,148,60,106,169,97,173,173,118,116,195,243,213,115,169,17,155,83,25,181,108,68,48,51 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x100015306fb0f0b5fde219996551c8072c6711bba5300b2669aeb0f0e4c7445", + "derived_key": [ + 236,254,112,114,24,207,172,186,132,163,119,198,20,66,226,51,51,142,39,212,88,198,68,118,92,136,138,204,26,155,11,165 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x10001b37e5f8cafac924b3e663779e12c80dace8a02b1d273ae708f275ad62a", + "derived_key": [ + 215,116,3,65,140,246,136,209,81,15,184,214,188,49,94,63,81,57,12,135,108,143,41,137,113,88,11,84,15,30,158,184 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x1000201e923f3e47adfa7c4f0f61ea8dd4256f66d1099970bcd314892864917", + "derived_key": [ + 50,203,140,60,152,140,103,117,103,130,42,29,70,236,110,49,211,18,247,40,117,35,54,107,171,190,233,18,117,69,68,43 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x1000215cd6f306d757d5d2fdbb460c60f298584179eecc07196c7ae8e4f8d64", + "derived_key": [ + 95,50,92,228,81,22,16,190,182,42,66,158,131,165,204,25,25,20,143,210,29,170,143,129,94,111,129,132,227,28,102,180 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x100023dc5e29b1af44a05d231db67a62a8bfd0c06217caa29b061daa7f2913f", + "derived_key": [ + 96,153,155,64,152,142,147,161,102,88,190,194,238,147,14,243,71,26,33,184,193,50,249,29,88,2,52,157,179,7,69,77 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x1000323b7266314b9d3ec387d5bcd9590a50be00e788837ca5a880d97e3ee83", + "derived_key": [ + 212,255,51,143,196,70,53,156,98,221,171,235,82,21,252,198,242,28,2,246,195,67,6,91,2,240,95,173,200,49,66,89 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x100048bf1b165f4c850d01eb81e5c040f70ea01dca019e780a87f80ec7897c3", + "derived_key": [ + 58,212,15,123,117,242,193,79,217,63,177,112,56,232,153,140,93,188,111,168,108,138,82,113,212,107,209,150,246,205,191,157 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x1000515657ebe014d9151480712de7a108d9b0e1a7a798d3da2945ba53cd103", + "derived_key": [ + 204,180,39,152,129,136,139,125,156,240,127,28,205,2,65,12,140,132,177,76,5,4,95,204,205,9,179,77,57,148,6,231 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x10005b597eb02058b230cee6a9cdf4705410d151ad1ea6ad3e2de77841acfc2", + "derived_key": [ + 249,145,142,225,129,214,86,160,12,71,51,28,109,238,246,115,57,184,6,234,138,46,107,81,103,128,201,242,101,51,179,68 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x10005bb7471a0016b1c330f767a5e73ad0c330934694cad007c5aa3f926be65", + "derived_key": [ + 17,109,102,169,143,117,42,93,149,160,20,188,122,34,0,140,248,73,206,232,146,65,183,250,61,35,40,54,167,63,173,215 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x100061dc40d0bc2cb81905e6bc1421ebd4bd8b79aacb8da4f9d7145b288674f", + "derived_key": [ + 58,197,183,31,149,121,187,250,193,140,202,222,69,149,235,105,78,113,59,213,78,241,15,40,62,137,46,19,193,78,85,31 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x10006311257c403bbba7e2aef0aa20822627c82ec7484fcb31b87dd8c582aa9", + "derived_key": [ + 209,81,122,212,165,252,102,254,115,58,127,209,26,21,188,113,69,3,30,255,154,72,181,219,97,7,227,96,209,19,138,181 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x100070f1cd4e2830607af30192743910fdfabf1dd004a8073944275819d1dfe", + "derived_key": [ + 151,245,134,14,100,30,161,175,227,142,158,71,197,157,213,103,198,28,241,51,173,107,242,84,76,53,176,101,132,26,29,60 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008004", + "key": "0x1000ecfaeb837bd098bcf9bde6fc2ccd8e8a9355a1b70e601ac18cd089eb308", + "derived_key": [ + 72,239,59,253,40,148,227,213,236,98,100,14,198,212,71,148,180,209,64,152,228,196,11,209,109,231,183,97,135,156,172,241 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0xe778a21bcfe90796edfc6e5dba276e58537d4ff192bc30765e18d9ef2aa9a55", + "derived_key": [ + 205,107,120,198,53,118,206,64,8,204,37,15,58,43,95,189,38,38,203,212,73,105,50,160,21,160,38,124,10,233,46,22 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10e" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x201f2e5549e69135c92587d30523c730fd01553abf72828402fad9b12c172e10", + "derived_key": [ + 204,0,103,138,56,182,245,161,43,137,56,202,232,138,228,30,242,80,214,237,253,8,17,251,148,203,85,106,127,162,114,20 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x62af78a1a86d5fa8aa7b75ee1884d36ca3c3193a" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x35dc0a033f8f3476b52059199e9babf078fddd76cb3c290e05ae42462bfc33eb", + "derived_key": [ + 89,16,198,41,13,94,89,2,119,169,28,80,179,104,66,21,38,252,16,146,163,159,122,68,234,161,165,150,251,139,57,4 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x52f431aa35dd80982e3c66614112503ca2c6e344745f4a2bcfc9bd7e09c75584" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x3859fd065954dbed7c74a1359d0e5bc38403ea4cdf0274ae615ce0e3e2afec6b", + "derived_key": [ + 67,87,214,19,120,116,147,47,78,236,178,95,23,23,1,171,197,181,63,197,52,162,224,221,93,223,35,243,248,138,100,215 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10002" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x41c023ccaa2a67013d253ba3488447c2db3843b3f988653fdf8d7c7268862ca9", + "derived_key": [ + 94,249,142,243,210,28,27,218,191,10,139,245,66,107,2,111,153,125,18,238,76,249,208,69,34,173,165,21,177,18,82,239 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10e" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x4792eb7ea10cfac9f83a8d12d965c903854b51c5cb0783e082741ecf0c20dcfe", + "derived_key": [ + 217,248,73,34,237,151,158,186,178,226,225,234,58,186,218,7,175,174,60,185,248,248,25,28,51,154,61,168,213,77,242,169 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x52f431aa35dd80982e3c66614112503ca2c6e344745f4a2bcfc9bd7e09c75584" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x5bad0400c1a2cec7acfd85c5c5c25108540c42f405d3ae6ea01209dfbcc63c29", + "derived_key": [ + 194,179,227,24,162,84,191,59,100,89,207,244,98,199,135,44,91,35,210,22,182,249,66,219,89,32,250,61,112,54,16,141 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x62af78a1a86d5fa8aa7b75ee1884d36ca3c3193a" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x71d2d9399f0017d99e02441b51c782e6f5613748934c615622bc6f2327b79b8d", + "derived_key": [ + 60,170,232,127,53,17,58,173,142,247,89,247,207,149,119,134,64,14,158,82,18,231,188,179,163,89,11,174,81,43,46,153 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x9" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x75579ad6152f71bd465c7f980c773c6df73f53d82aebf8b69c1173f678af2d81", + "derived_key": [ + 132,119,216,135,171,185,255,65,210,32,46,77,152,229,32,71,244,141,39,140,188,245,22,25,184,28,198,202,132,222,174,160 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10002" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x87c06ae8fd6d2ee9919bb86c39ee03f70b0d87028d77b914408152f07043c769", + "derived_key": [ + 119,228,107,44,53,217,61,182,86,125,189,169,81,109,32,249,139,212,234,72,144,24,135,118,89,121,216,219,24,207,66,168 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10e" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x962d8512b88c87f0272660761794a46a130b867d7d15b38fc1adc33433e4fce8", + "derived_key": [ + 213,5,71,76,80,42,16,77,105,27,101,50,79,76,38,232,167,55,134,79,128,251,113,33,35,116,77,254,28,6,176,0 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x52f431aa35dd80982e3c66614112503ca2c6e344745f4a2bcfc9bd7e09c75584" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0x9f4693a69c182083198dd36e2803bc42bbe3f851aa03cb0f0de7687a2171336b", + "derived_key": [ + 110,177,116,132,158,116,7,177,77,240,138,82,212,212,241,43,54,8,1,75,42,104,243,5,241,73,226,60,72,169,2,41 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10003" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0xb35ae26426d210bd3178c283cdcb50ce0cdbff27177eb0786fc3fe0f45083b1d", + "derived_key": [ + 73,127,150,33,212,30,131,171,90,28,221,170,53,22,176,210,81,154,146,160,81,67,188,184,7,13,240,169,97,51,230,181 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x64" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0xb62ada1fb8084bc5425b2aea59d59080ac3d0a10a1cc368978230741dca77a19", + "derived_key": [ + 71,111,167,179,223,229,107,45,223,184,100,207,103,16,106,234,217,25,120,51,156,12,142,28,186,4,134,110,182,28,191,11 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x9" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0xcb5ca2f778293159761b941dc7b8f7fd374e3632c39b35a0fd4b1aa20ed4a091", + "derived_key": [ + 62,169,255,238,205,94,99,210,162,31,213,85,158,233,223,231,174,18,241,77,26,133,255,75,40,190,65,163,26,48,53,196 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10002" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0xd8fc94fc3444dd0233f4f4f74b08d69d0079035017309fa37c5b30a7cabb729b", + "derived_key": [ + 232,83,248,233,232,89,11,170,74,117,125,224,222,189,198,137,244,49,205,228,155,200,97,42,160,89,8,63,109,25,91,168 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x9" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0xd9ba5de301f3948ee34a04905cc32b778b54dac455410e096889003b0770d47c", + "derived_key": [ + 255,134,239,235,78,5,0,110,98,20,109,14,192,231,250,72,49,145,191,114,177,51,38,242,67,121,217,71,114,50,124,171 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x9" + }, + { + "address": "0x0000000000000000000000000000000000008005", + "key": "0xf7fa34f014959c990f8cabd865f6012c5ad2ae9390bd21dc8ab2c3ee9c340257", + "derived_key": [ + 209,167,69,145,2,139,203,92,187,46,4,30,218,0,85,77,176,3,253,201,73,229,148,92,229,57,32,59,244,12,109,96 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x9" + }, + { + "address": "0x000000000000000000000000000000000000800a", + "key": "0x1", + "derived_key": [ + 113,233,23,33,249,145,133,118,215,96,240,47,3,202,196,124,111,64,3,49,96,49,132,142,60,29,153,230,232,58,71,67 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xe29e64ae9c38000" + }, + { + "address": "0x000000000000000000000000000000000000800a", + "key": "0x1b458e5ab877fea2e4abf98d12b31ec3f7c93fd4856e807f684322e8cf11fdf7", + "derived_key": [ + 49,87,111,239,58,195,179,2,237,163,15,66,168,74,199,52,200,236,175,1,55,3,126,248,127,239,193,246,133,27,151,79 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x8603151b10a4a0" + }, + { + "address": "0x000000000000000000000000000000000000800a", + "key": "0x810ca1ae825b138452fb743e9948f909b6286cbfadd5a899190fcb21a75443ab", + "derived_key": [ + 185,211,150,83,253,116,26,253,56,22,83,204,70,30,122,203,221,134,84,251,39,141,138,17,246,159,212,31,236,239,75,201 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x53c1850fab698c0" + }, + { + "address": "0x000000000000000000000000000000000000800a", + "key": "0xafe379b9510a75924647deef7e3d3d3ebf948699c9f84eda83c07c71414098b8", + "derived_key": [ + 250,91,168,183,69,6,78,180,185,147,215,10,134,34,96,243,26,77,158,213,121,211,188,200,73,204,177,205,8,52,178,106 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x4a88ebbafe2b20" + }, + { + "address": "0x000000000000000000000000000000000000800a", + "key": "0xeaa2b2fbf0b42c559059e5e9510edc15755f1c1883f0e41d5ba5f9aea4ac201a", + "derived_key": [ + 141,97,126,192,90,203,191,95,226,69,41,166,75,35,133,169,106,173,67,240,155,225,173,169,44,112,64,49,220,193,72,27 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x81d41f918fe1780" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0x0", + "derived_key": [ + 150,46,36,83,88,148,64,235,173,169,107,3,33,223,255,240,191,103,10,254,52,186,74,130,141,51,66,227,241,78,210,217 + ], + "enumeration_index": 60, + "initial_value": "0x10e", + "final_value": "0x1f9" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0x6", + "derived_key": [ + 162,84,32,193,217,215,5,53,140,19,76,198,1,217,209,132,203,77,253,222,126,28,172,43,195,212,211,139,249,236,68,230 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x5f5e100" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0x7", + "derived_key": [ + 18,59,175,197,134,247,119,100,72,140,210,76,106,119,84,110,90,15,232,189,251,79,162,3,207,175,252,54,204,228,221,91 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100000000000000000000000066fc0241" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0x9", + "derived_key": [ + 142,125,208,106,197,183,59,71,59,230,188,90,81,3,15,76,116,55,101,124,183,178,155,243,118,197,100,184,209,103,90,94 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x200000000000000000000000066fc0242" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0xb", + "derived_key": [ + 75,168,78,31,55,208,65,188,110,85,186,57,104,38,204,73,78,132,212,129,91,109,181,38,144,66,46,234,115,134,49,79 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xe8e77626586f73b955364c7b4bbf0bb7f7685ebd40e852b164633a4acbd3244c" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0xc", + "derived_key": [ + 61,226,32,44,203,98,106,211,135,215,7,34,230,79,190,68,86,46,47,35,26,41,12,8,83,43,141,106,186,64,47,245 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xf2aaeb06c0e556434ac93c232f37dd8be0a7bf9f430f76eb564df9fcb770c45f" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0x10c", + "derived_key": [ + 121,9,53,136,208,232,71,239,167,58,16,206,32,228,121,159,177,228,102,66,214,86,23,199,229,33,63,160,73,137,217,45 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x200000000000000000000000066fc0242" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0x10d", + "derived_key": [ + 135,222,210,71,225,102,15,130,112,113,199,241,55,25,52,88,151,81,8,83,132,252,159,68,98,193,241,137,124,92,62,239 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x100000000000000000000000000000001" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0x10f", + "derived_key": [ + 134,36,129,147,235,77,210,168,206,129,95,135,108,18,77,72,53,149,34,240,133,77,149,216,7,46,175,240,211,125,85,189 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x320" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0x110", + "derived_key": [ + 62,137,13,108,44,59,173,166,238,204,150,3,169,156,28,98,89,237,90,100,2,241,199,108,193,139,86,140,58,239,186,15 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x22a9" + }, + { + "address": "0x000000000000000000000000000000000000800b", + "key": "0x5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c7", + "derived_key": [ + 145,29,210,173,116,63,242,55,212,17,100,138,15,227,44,109,116,238,192,96,113,106,42,116,53,47,107,28,67,91,93,103 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xf9030b78c5bf5ac997a76962aa32c90a6d8e8ebce9838c8eeb388d73e1f7659a" + }, + { + "address": "0x0000000000000000000000000000000000010002", + "key": "0x0", + "derived_key": [ + 214,116,246,54,163,90,111,26,81,86,78,195,55,27,156,77,163,18,109,90,208,186,227,80,207,199,250,234,199,99,99,184 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xff" + }, + { + "address": "0x0000000000000000000000000000000000010002", + "key": "0x33", + "derived_key": [ + 104,98,246,102,108,85,7,252,51,21,214,132,35,158,2,38,112,107,69,195,65,114,145,245,183,172,194,211,57,80,82,17 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x8ad65915f42c06ad06f23e33feee4f57060cd249" + }, + { + "address": "0x0000000000000000000000000000000000010002", + "key": "0xc9", + "derived_key": [ + 180,68,244,119,54,206,136,162,78,107,80,251,5,29,192,174,93,179,175,68,217,8,246,220,217,160,21,208,74,126,225,227 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10003" + }, + { + "address": "0x0000000000000000000000000000000000010002", + "key": "0xd3", + "derived_key": [ + 59,172,224,22,174,10,65,231,169,237,9,168,91,33,85,109,38,187,242,242,75,76,32,165,75,187,165,27,95,83,162,158 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10005" + }, + { + "address": "0x0000000000000000000000000000000000010002", + "key": "0xd5", + "derived_key": [ + 237,36,132,158,202,168,131,171,106,32,214,79,172,224,148,150,15,71,73,102,217,162,19,183,2,117,192,112,196,76,181,34 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x3db94d72a25f64874243af776e06f449d55ba9dd" + }, + { + "address": "0x0000000000000000000000000000000000010002", + "key": "0x4d7101ab951ded1d6f6a567c6e539f8f6a2a675fe1d5eba86fefe5192175b131", + "derived_key": [ + 83,157,81,206,111,89,151,62,178,167,63,16,226,11,189,169,125,149,14,110,8,62,221,87,116,233,142,217,139,253,153,16 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010002", + "key": "0x8e94fed44239eb2314ab7a406345e6c5a8f0ccedf3b600de3d004e672c33abf4", + "derived_key": [ + 186,154,222,88,248,170,108,168,43,242,42,43,72,15,245,221,236,232,166,232,99,81,164,123,16,213,143,51,128,251,219,183 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010002", + "key": "0x99d6a8ff20aa8acdd49c8fb0cc74f2b2b57e0fa371d5aadb8e266a8cf9157ef5", + "derived_key": [ + 103,185,128,156,225,233,200,126,96,129,32,179,163,131,84,200,153,155,236,34,245,43,19,243,165,109,226,10,22,113,50,131 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010002", + "key": "0xca59cc8f90e9fd91e0bc61c0c980b4b130ad1217252dd3bc209e6dfa57a05f63", + "derived_key": [ + 203,224,11,159,230,121,179,34,119,46,123,13,250,7,202,214,183,18,124,144,172,158,237,255,172,53,228,144,236,81,142,168 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0" + }, + { + "address": "0x0000000000000000000000000000000000010003", + "key": "0x0", + "derived_key": [ + 183,144,135,107,116,64,90,68,61,138,52,178,244,96,20,237,96,5,52,90,158,129,172,204,39,175,55,18,74,73,29,222 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xff" + }, + { + "address": "0x0000000000000000000000000000000000010003", + "key": "0x33", + "derived_key": [ + 36,49,6,86,93,12,79,206,248,151,94,121,177,178,35,12,1,159,78,58,178,122,63,78,124,169,48,107,159,98,153,132 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x8ad65915f42c06ad06f23e33feee4f57060cd249" + }, + { + "address": "0x0000000000000000000000000000000000010003", + "key": "0xfa", + "derived_key": [ + 208,111,9,167,39,114,89,78,179,210,171,35,115,181,211,197,236,176,132,184,74,77,237,45,48,18,241,69,222,221,138,25 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x5de08929a3c0835232a7cd201d338317caabd873" + }, + { + "address": "0x0000000000000000000000000000000000010003", + "key": "0x56ca7d7fc0d180f3d83f99276f19310b5c00992edd8618fb359971a7ecb99ab3", + "derived_key": [ + 199,117,193,115,55,85,171,245,34,173,219,214,151,226,215,10,91,97,70,75,209,104,27,41,137,81,196,246,13,142,199,12 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10004" + }, + { + "address": "0x0000000000000000000000000000000000010003", + "key": "0x635799b36cb7719b903c111d5790821f9e51e29061bc47a57c7988be806aff32", + "derived_key": [ + 113,24,36,136,41,22,138,100,28,59,149,105,31,231,215,27,33,193,211,238,215,254,44,202,236,107,125,180,46,38,146,200 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10002" + }, + { + "address": "0x0000000000000000000000000000000000010004", + "key": "0x0", + "derived_key": [ + 38,182,122,48,1,162,205,218,95,52,172,146,222,81,199,193,42,178,228,105,133,88,214,83,137,237,66,230,119,250,5,85 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xff" + }, + { + "address": "0x0000000000000000000000000000000000010004", + "key": "0x33", + "derived_key": [ + 253,39,5,238,88,207,60,229,238,92,28,224,63,70,109,126,152,54,188,71,18,186,162,153,21,61,132,71,202,121,113,207 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x8ad65915f42c06ad06f23e33feee4f57060cd249" + }, + { + "address": "0x0000000000000000000000000000000000010004", + "key": "0xc9", + "derived_key": [ + 191,14,175,103,174,227,73,235,177,89,118,163,111,237,172,26,74,6,101,80,58,211,113,127,243,254,106,224,120,179,101,156 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x4c48bdb0145a89bd87f8884f3fa8c1e42d585e75" + }, + { + "address": "0x0000000000000000000000000000000000010004", + "key": "0xfb", + "derived_key": [ + 184,2,226,247,10,56,240,40,136,100,146,139,246,198,195,194,209,164,217,45,202,10,147,86,175,254,198,249,92,64,121,164 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10000fd53068fc35c6a23fee067bcfd3fc0d880ba4f79d8b65aafbff02f305d" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0x0", + "derived_key": [ + 168,74,2,141,105,206,208,33,164,189,140,91,38,36,168,242,80,217,18,184,248,245,157,129,85,249,94,94,229,138,101,38 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0x4", + "derived_key": [ + 47,241,202,110,153,206,246,252,92,214,119,95,159,94,245,61,243,40,240,8,26,143,180,81,247,55,255,244,73,12,229,83 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0x5", + "derived_key": [ + 95,192,113,95,216,242,21,235,124,16,227,245,80,217,178,9,241,140,170,135,64,175,84,27,211,70,239,73,100,139,20,245 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0x6", + "derived_key": [ + 201,169,20,123,206,251,168,141,33,64,175,106,246,185,19,185,53,101,125,53,5,87,5,184,7,21,91,61,208,130,42,131 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0x36b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0", + "derived_key": [ + 183,44,52,109,222,204,99,77,172,182,15,29,40,214,131,168,39,33,227,213,36,163,61,162,168,47,3,62,136,241,101,126 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0x16db2e4b9f8dc120de98f8491964203ba76de27b27b29c2d25f85a325cd37477", + "derived_key": [ + 133,79,165,174,6,191,41,30,209,5,109,104,28,93,197,246,247,13,23,242,234,3,204,110,233,229,198,255,131,62,203,105 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x924928c1377a6cf24c39c2d46f8eb9df23e811b26dc3527e548396fd4e173b1" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0x7bbeda1ca523343d5e888708327d45f8c743f6cb29e139a7e03dc5068543e6c4", + "derived_key": [ + 211,102,235,93,180,24,37,200,29,129,191,72,73,93,114,116,50,181,244,253,225,248,223,46,101,251,180,223,113,77,242,139 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x46700b4d40ac5c35af2c22dda2787a91eb567b06c924a8fb8ae9a05b20c08c21" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0x8e94fed44239eb2314ab7a406345e6c5a8f0ccedf3b600de3d004e672c33abf4", + "derived_key": [ + 228,96,52,194,207,181,181,131,126,57,95,233,204,152,190,4,82,34,235,53,200,202,40,109,252,73,189,213,239,94,126,130 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0xac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b", + "derived_key": [ + 27,8,240,147,212,200,27,37,231,124,191,110,45,189,91,214,149,171,253,138,221,47,115,230,14,214,92,143,87,109,114,128 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1f9" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0xe14c171e271191dbbbddd568a762a4325466b12116e776c3243375f110708d73", + "derived_key": [ + 248,63,134,138,17,62,7,250,227,100,52,50,139,214,30,153,110,204,16,117,222,9,119,59,220,202,187,15,30,237,162,217 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0xe14c171e271191dbbbddd568a762a4325466b12116e776c3243375f110708d74", + "derived_key": [ + 207,50,50,89,38,214,97,46,146,127,167,239,70,37,230,216,37,111,63,130,63,184,65,242,102,240,65,120,90,218,241,226 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x0000000000000000000000000000000000010005", + "key": "0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f", + "derived_key": [ + 247,124,190,104,95,142,126,239,68,219,69,165,161,237,129,135,165,5,236,239,227,84,140,240,18,4,129,67,95,125,116,254 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x46700b4d40ac5c35af2c22dda2787a91eb567b06c924a8fb8ae9a05b20c08c21" + }, + { + "address": "0x03e013dc3eb10bbd48a8f9c94758f04d081563b6", + "key": "0x0", + "derived_key": [ + 64,31,45,164,25,35,131,214,111,103,185,66,123,36,77,209,130,54,238,77,124,250,76,42,126,68,137,156,53,223,112,84 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x03e013dc3eb10bbd48a8f9c94758f04d081563b6", + "key": "0x33", + "derived_key": [ + 172,109,18,138,162,172,98,227,191,233,228,200,186,6,38,31,205,90,238,83,85,200,140,40,95,174,70,100,236,184,92,217 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xf42d59d064dc3efa5c6984103f5354a4578f9d38" + }, + { + "address": "0x03e013dc3eb10bbd48a8f9c94758f04d081563b6", + "key": "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc", + "derived_key": [ + 238,206,71,73,61,115,66,84,21,49,226,43,98,209,124,67,230,245,74,241,47,105,36,12,239,120,5,217,170,54,156,84 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xf0e50c6be2ab13f852259d99317e0fa1511ed273" + }, + { + "address": "0x03e013dc3eb10bbd48a8f9c94758f04d081563b6", + "key": "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103", + "derived_key": [ + 133,159,227,100,212,172,149,230,75,232,210,108,56,145,60,23,37,166,185,84,193,191,193,253,113,198,103,19,58,1,211,88 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x8ad65915f42c06ad06f23e33feee4f57060cd249" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0x33", + "derived_key": [ + 244,204,176,178,59,175,3,143,139,2,242,240,21,87,122,194,191,65,151,96,89,50,229,228,174,155,172,240,102,252,221,88 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x36615cf349d7f6344891b1e7ca7c72883f5dc049" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0x9a", + "derived_key": [ + 97,131,206,41,240,31,150,151,163,154,135,110,104,89,178,252,214,86,245,40,217,82,157,194,186,14,137,246,116,87,3,221 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x58d1e441af5027fe6e4c6b749dde48721cef3bb31a08d3d64b9c6e9c725abc72" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0x9b", + "derived_key": [ + 36,198,234,1,57,238,186,239,33,185,70,78,68,110,74,247,188,177,180,151,164,216,15,115,133,254,13,247,190,87,17,67 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xe8949117b1d97ac18a8d1224be1e4045c67b698392d4edc03db3ed46b9e94673" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0x9c", + "derived_key": [ + 24,243,123,134,88,68,215,142,127,133,2,149,85,85,176,160,214,111,3,112,143,142,78,137,211,79,138,29,6,66,209,69 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xfa1e2d910cfa3e5c465f7d7f69c224d542e0a598" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0x9d", + "derived_key": [ + 168,81,60,218,234,227,67,148,118,29,59,147,53,55,78,40,8,227,39,217,122,18,110,222,78,162,140,204,238,55,6,95 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1900000000" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0x9f", + "derived_key": [ + 144,32,12,17,126,234,225,99,200,138,138,108,231,51,212,1,171,8,94,147,139,188,115,131,162,159,107,192,34,19,171,180 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x97b2219068b5104fd0de0a2a4666b3f6f397aca7" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0xa3", + "derived_key": [ + 86,83,107,175,210,186,181,198,128,36,151,56,29,81,196,245,31,168,78,1,68,190,24,94,31,195,247,20,122,219,85,214 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xace084d9e79dcdae011409ea9454d78218092e0b189cd6a5173b44667400d511" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc", + "derived_key": [ + 230,13,150,23,44,152,198,242,109,118,74,176,93,184,102,158,85,104,138,31,78,160,214,75,29,223,239,114,74,97,156,59 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x5e45123c75ae6b22222a2ef40afcf080e84f5af5" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0x8e94fed44239eb2314ab7a406345e6c5a8f0ccedf3b600de3d004e672c33abf4", + "derived_key": [ + 105,207,185,63,169,21,50,218,22,157,164,50,155,208,136,29,218,73,246,12,13,209,254,95,239,141,35,221,253,207,221,212 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0xa2493ae5fceab9e59e3829df3da317d9a236c9b8b11dc1da94cb0e047a357cad", + "derived_key": [ + 248,135,166,243,99,75,238,65,244,69,142,255,92,110,93,81,203,0,116,149,135,131,96,149,14,49,60,161,204,107,128,214 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + }, + { + "address": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0", + "key": "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103", + "derived_key": [ + 164,102,179,128,123,95,250,209,85,215,47,223,202,234,9,179,137,135,46,66,252,162,20,55,210,106,243,173,46,40,178,89 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x36615cf349d7f6344891b1e7ca7c72883f5dc049" + }, + { + "address": "0x338bd2ded4569c568f21da174acec70b826e550c", + "key": "0x0", + "derived_key": [ + 156,179,78,101,253,32,134,94,34,150,203,47,196,201,136,120,12,142,64,149,165,101,204,29,186,80,109,39,8,84,79,232 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x8002cd98cfb563492a6fb3e7c8243b7b9ad4cc92" + }, + { + "address": "0x338bd2ded4569c568f21da174acec70b826e550c", + "key": "0x1", + "derived_key": [ + 140,190,129,206,40,197,26,241,53,110,14,80,134,5,37,204,178,45,166,159,129,221,136,86,105,96,102,217,243,16,89,249 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x683cfc9cb6230b80899dbcb6181591d69089d8a4" + }, + { + "address": "0x4c48bdb0145a89bd87f8884f3fa8c1e42d585e75", + "key": "0x0", + "derived_key": [ + 177,52,180,226,24,99,117,67,64,64,241,12,41,231,167,74,209,204,218,129,255,34,102,39,251,93,142,41,145,92,203,50 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x8ad65915f42c06ad06f23e33feee4f57060cd249" + }, + { + "address": "0x4c48bdb0145a89bd87f8884f3fa8c1e42d585e75", + "key": "0x1", + "derived_key": [ + 164,143,172,103,50,238,187,229,211,197,117,198,212,234,78,82,14,197,48,46,66,117,89,74,193,245,113,83,209,177,183,217 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x517d9f66c564d2edf43cb657424f72f1c20d3bff" + }, + { + "address": "0x517d9f66c564d2edf43cb657424f72f1c20d3bff", + "key": "0x0", + "derived_key": [ + 230,154,81,238,249,118,81,47,67,167,51,81,39,137,145,76,187,230,155,155,70,102,153,242,27,165,84,224,218,253,106,44 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xff" + }, + { + "address": "0x5e45123c75ae6b22222a2ef40afcf080e84f5af5", + "key": "0x8e94fed44239eb2314ab7a406345e6c5a8f0ccedf3b600de3d004e672c33abf4", + "derived_key": [ + 60,175,19,171,24,127,90,244,102,215,109,52,163,108,87,248,78,75,87,18,254,157,225,108,251,34,166,46,135,226,155,114 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + }, + { + "address": "0x62af78a1a86d5fa8aa7b75ee1884d36ca3c3193a", + "key": "0x0", + "derived_key": [ + 137,66,124,98,185,206,118,62,215,166,225,249,150,252,161,203,0,217,115,193,56,251,207,17,2,102,50,45,221,187,226,50 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x5de08929a3c0835232a7cd201d338317caabd8730002" + }, + { + "address": "0x62af78a1a86d5fa8aa7b75ee1884d36ca3c3193a", + "key": "0x1", + "derived_key": [ + 86,146,226,162,251,7,31,172,102,81,196,200,22,126,55,247,235,106,113,202,76,139,128,246,85,114,151,178,101,95,159,191 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x338bd2ded4569c568f21da174acec70b826e550c" + }, + { + "address": "0x62af78a1a86d5fa8aa7b75ee1884d36ca3c3193a", + "key": "0x2", + "derived_key": [ + 238,250,55,221,42,57,86,177,201,103,75,239,3,21,25,161,11,112,13,117,46,113,1,71,100,17,102,72,32,125,98,78 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x10000fd53068fc35c6a23fee067bcfd3fc0d880ba4f79d8b65aafbff02f305d" + }, + { + "address": "0x62af78a1a86d5fa8aa7b75ee1884d36ca3c3193a", + "key": "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc", + "derived_key": [ + 22,155,114,188,54,101,62,87,11,121,52,68,25,197,106,219,1,155,20,238,224,223,45,229,125,209,123,117,113,166,132,12 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xdc0ed6fcbfe51c9f84a662e64fd1347736aa7486" + }, + { + "address": "0x62af78a1a86d5fa8aa7b75ee1884d36ca3c3193a", + "key": "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103", + "derived_key": [ + 81,122,205,57,136,220,234,247,156,218,204,189,130,97,114,48,48,160,227,48,48,64,28,58,212,244,195,137,255,228,64,41 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x8002cd98cfb563492a6fb3e7c8243b7b9ad4cc92" + }, + { + "address": "0x683cfc9cb6230b80899dbcb6181591d69089d8a4", + "key": "0x0", + "derived_key": [ + 237,236,215,194,80,85,137,94,24,27,243,41,116,140,187,70,33,135,209,48,214,17,9,198,53,117,79,21,244,235,240,208 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xff" + }, + { + "address": "0x97b2219068b5104fd0de0a2a4666b3f6f397aca7", + "key": "0x0", + "derived_key": [ + 219,215,135,89,179,97,218,60,174,210,247,236,175,60,97,114,55,143,26,104,199,6,53,175,153,170,254,4,26,49,33,168 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x36615cf349d7f6344891b1e7ca7c72883f5dc049" + }, + { + "address": "0x97b2219068b5104fd0de0a2a4666b3f6f397aca7", + "key": "0x2", + "derived_key": [ + 131,75,158,95,145,124,241,215,162,81,17,8,190,214,110,90,15,123,1,214,244,31,200,40,196,119,19,72,17,44,27,219 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x2c3c5fb909767b6af655bad72f5d6638f5f5d0a0" + }, + { + "address": "0xdc0ed6fcbfe51c9f84a662e64fd1347736aa7486", + "key": "0x0", + "derived_key": [ + 62,110,21,209,63,190,73,44,77,121,157,143,198,176,46,157,199,11,251,128,18,248,171,99,94,148,201,218,67,21,70,232 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0xff" + }, + { + "address": "0xe024f9e4e8fa2f08f768c1cb56bc4a6e3cbd8834", + "key": "0x8e94fed44239eb2314ab7a406345e6c5a8f0ccedf3b600de3d004e672c33abf4", + "derived_key": [ + 16,46,124,130,188,155,165,96,66,61,124,176,157,94,180,222,164,199,68,147,148,121,54,59,60,181,162,4,74,28,114,103 + ], + "enumeration_index": 0, + "initial_value": "0x0", + "final_value": "0x1" + } + ], + "aux_commitments": { + "events_queue_commitment": "0xec82208c87a937d88768a0067b2a80f0525eca8288dad2cf96cf8bbe6a1aa565", + "bootloader_initial_content_commitment": "0x97df88dcecbcd29b49773c042cdee7a44c57a741e64913fff5aa1b3484232f28" + }, + "blob_commitments": [ + "0xf840cf3f6b7dc92729b2b9ef3b399e7b896d553b746362fe81c4eb911013570d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "blob_linear_hashes": [ + "0xff4feb4bef9401731ab9db3626c2e015baa6880d7b1c4382d03b30da3a0fd75e", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000" + ], + "aggregated_root": "0x0924928c1377a6cf24c39c2d46f8eb9df23e811b26dc3527e548396fd4e173b1" + } + } +} diff --git a/core/lib/types/src/l2_to_l1_log.rs b/core/lib/types/src/l2_to_l1_log.rs index 59ade8873cd1..05b27c421ef0 100644 --- a/core/lib/types/src/l2_to_l1_log.rs +++ b/core/lib/types/src/l2_to_l1_log.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use zksync_system_constants::{BLOB1_LINEAR_HASH_KEY, PUBDATA_CHUNK_PUBLISHER_ADDRESS}; +use zksync_system_constants::{BLOB1_LINEAR_HASH_KEY_PRE_GATEWAY, PUBDATA_CHUNK_PUBLISHER_ADDRESS}; use crate::{ blob::{num_blobs_created, num_blobs_required}, @@ -80,10 +80,14 @@ pub fn l2_to_l1_logs_tree_size(protocol_version: ProtocolVersionId) -> usize { } /// Returns the blob hashes parsed out from the system logs -pub fn parse_system_logs_for_blob_hashes( +pub fn parse_system_logs_for_blob_hashes_pre_gateway( protocol_version: &ProtocolVersionId, system_logs: &[SystemL2ToL1Log], ) -> Vec { + if !protocol_version.is_pre_gateway() { + panic!("Cannot parse blob linear hashes from system logs for post gateway"); + } + let num_required_blobs = num_blobs_required(protocol_version) as u32; let num_created_blobs = num_blobs_created(protocol_version) as u32; @@ -95,9 +99,11 @@ pub fn parse_system_logs_for_blob_hashes( .iter() .filter(|log| { log.0.sender == PUBDATA_CHUNK_PUBLISHER_ADDRESS - && log.0.key >= H256::from_low_u64_be(BLOB1_LINEAR_HASH_KEY as u64) + && log.0.key >= H256::from_low_u64_be(BLOB1_LINEAR_HASH_KEY_PRE_GATEWAY as u64) && log.0.key - < H256::from_low_u64_be((BLOB1_LINEAR_HASH_KEY + num_created_blobs) as u64) + < H256::from_low_u64_be( + (BLOB1_LINEAR_HASH_KEY_PRE_GATEWAY + num_created_blobs) as u64, + ) }) .map(|log| (log.0.key, log.0.value)) .collect::>(); diff --git a/core/lib/vm_executor/src/oneshot/block.rs b/core/lib/vm_executor/src/oneshot/block.rs index 8ba77305ad7d..cab64289e5ee 100644 --- a/core/lib/vm_executor/src/oneshot/block.rs +++ b/core/lib/vm_executor/src/oneshot/block.rs @@ -7,6 +7,7 @@ use zksync_multivm::{ use zksync_types::{ api, block::{unpack_block_info, L2BlockHasher}, + commitment::PubdataParams, fee_model::BatchFeeInput, AccountTreeId, L1BatchNumber, L2BlockNumber, ProtocolVersionId, StorageKey, H256, SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, @@ -141,6 +142,7 @@ impl BlockInfo { l1_batch_timestamp, protocol_version, is_pending: self.is_pending_l2_block(), + pubdata_params: l2_block_header.pubdata_params, }) } } @@ -154,6 +156,7 @@ pub struct ResolvedBlockInfo { l1_batch_timestamp: u64, protocol_version: ProtocolVersionId, is_pending: bool, + pubdata_params: PubdataParams, } impl ResolvedBlockInfo { @@ -219,6 +222,7 @@ impl OneshotEnvParameters { execution_mode, default_validation_computational_gas_limit: validation_computational_gas_limit, chain_id, + pubdata_params: resolved_block_info.pubdata_params, }; let l1_batch_env = L1BatchEnv { previous_batch_hash: None, diff --git a/core/lib/vm_executor/src/oneshot/contracts.rs b/core/lib/vm_executor/src/oneshot/contracts.rs index 3b3a65fe30ba..7c3e6192b91a 100644 --- a/core/lib/vm_executor/src/oneshot/contracts.rs +++ b/core/lib/vm_executor/src/oneshot/contracts.rs @@ -22,6 +22,8 @@ pub(super) struct MultiVMBaseSystemContracts { vm_1_5_0_small_memory: BaseSystemContracts, /// Contracts to be used after the 1.5.0 upgrade vm_1_5_0_increased_memory: BaseSystemContracts, + /// Contracts to be used after the gateway upgrade + gateway: BaseSystemContracts, } impl MultiVMBaseSystemContracts { @@ -54,6 +56,7 @@ impl MultiVMBaseSystemContracts { ProtocolVersionId::Version24 | ProtocolVersionId::Version25 => { &self.vm_1_5_0_increased_memory } + ProtocolVersionId::Version26 => &self.gateway, } } @@ -70,6 +73,7 @@ impl MultiVMBaseSystemContracts { vm_1_5_0_small_memory: BaseSystemContracts::estimate_gas_1_5_0_small_memory(), vm_1_5_0_increased_memory: BaseSystemContracts::estimate_gas_post_1_5_0_increased_memory(), + gateway: BaseSystemContracts::estimate_gas_gateway(), } } @@ -86,6 +90,7 @@ impl MultiVMBaseSystemContracts { vm_1_5_0_small_memory: BaseSystemContracts::playground_1_5_0_small_memory(), vm_1_5_0_increased_memory: BaseSystemContracts::playground_post_1_5_0_increased_memory( ), + gateway: BaseSystemContracts::playground_gateway(), } } } diff --git a/core/lib/vm_executor/src/storage.rs b/core/lib/vm_executor/src/storage.rs index a2369820a5b4..19514bd5fa8b 100644 --- a/core/lib/vm_executor/src/storage.rs +++ b/core/lib/vm_executor/src/storage.rs @@ -7,8 +7,9 @@ use zksync_contracts::BaseSystemContracts; use zksync_dal::{Connection, Core, CoreDal, DalError}; use zksync_multivm::interface::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode}; use zksync_types::{ - block::L2BlockHeader, fee_model::BatchFeeInput, snapshots::SnapshotRecoveryStatus, Address, - L1BatchNumber, L2BlockNumber, L2ChainId, ProtocolVersionId, H256, ZKPORTER_IS_AVAILABLE, + block::L2BlockHeader, commitment::PubdataParams, fee_model::BatchFeeInput, + snapshots::SnapshotRecoveryStatus, Address, L1BatchNumber, L2BlockNumber, L2ChainId, + ProtocolVersionId, H256, ZKPORTER_IS_AVAILABLE, }; const BATCH_COMPUTATIONAL_GAS_LIMIT: u32 = u32::MAX; @@ -53,6 +54,7 @@ pub fn l1_batch_params( protocol_version: ProtocolVersionId, virtual_blocks: u32, chain_id: L2ChainId, + pubdata_params: PubdataParams, ) -> (SystemEnv, L1BatchEnv) { ( SystemEnv { @@ -63,6 +65,7 @@ pub fn l1_batch_params( execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: validation_computational_gas_limit, chain_id, + pubdata_params, }, L1BatchEnv { previous_batch_hash: Some(previous_batch_hash), @@ -329,6 +332,7 @@ impl L1BatchParamsProvider { .context("`protocol_version` must be set for L2 block")?, first_l2_block_in_batch.header.virtual_blocks, chain_id, + first_l2_block_in_batch.header.pubdata_params, )) } diff --git a/core/lib/vm_interface/src/types/inputs/system_env.rs b/core/lib/vm_interface/src/types/inputs/system_env.rs index 5a0496752d54..67d555f9bc0f 100644 --- a/core/lib/vm_interface/src/types/inputs/system_env.rs +++ b/core/lib/vm_interface/src/types/inputs/system_env.rs @@ -2,7 +2,7 @@ use std::fmt::Debug; use serde::{Deserialize, Serialize}; use zksync_contracts::BaseSystemContracts; -use zksync_types::{L2ChainId, ProtocolVersionId}; +use zksync_types::{commitment::PubdataParams, L2ChainId, ProtocolVersionId}; /// Params related to the execution process, not batch it self #[derive(Clone, PartialEq, Serialize, Deserialize)] @@ -15,6 +15,7 @@ pub struct SystemEnv { pub execution_mode: TxExecutionMode, pub default_validation_computational_gas_limit: u32, pub chain_id: L2ChainId, + pub pubdata_params: PubdataParams, } impl Debug for SystemEnv { @@ -33,6 +34,7 @@ impl Debug for SystemEnv { ) .field("execution_mode", &self.execution_mode) .field("chain_id", &self.chain_id) + .field("pubdata_params", &self.pubdata_params) .finish() } } diff --git a/core/node/api_server/src/web3/state.rs b/core/node/api_server/src/web3/state.rs index 8cbb75103cd9..fb1a19570af8 100644 --- a/core/node/api_server/src/web3/state.rs +++ b/core/node/api_server/src/web3/state.rs @@ -145,6 +145,7 @@ impl InternalApiConfig { .l1_weth_bridge_proxy_addr .unwrap_or_default(), ), + l2_legacy_shared_bridge: contracts_config.l2_legacy_shared_bridge_addr, }, bridgehub_proxy_addr: contracts_config .ecosystem_contracts diff --git a/core/node/block_reverter/src/tests.rs b/core/node/block_reverter/src/tests.rs index b29d01af39a4..5db0ab2bff87 100644 --- a/core/node/block_reverter/src/tests.rs +++ b/core/node/block_reverter/src/tests.rs @@ -67,6 +67,7 @@ async fn setup_storage(storage: &mut Connection<'_, Core>, storage_logs: &[Stora virtual_blocks: 1, gas_limit: 0, logs_bloom: Default::default(), + pubdata_params: Default::default(), }; storage .blocks_dal() diff --git a/core/node/commitment_generator/src/lib.rs b/core/node/commitment_generator/src/lib.rs index 6cb14cfda531..f16714e4ebf5 100644 --- a/core/node/commitment_generator/src/lib.rs +++ b/core/node/commitment_generator/src/lib.rs @@ -19,7 +19,10 @@ use zksync_utils::h256_to_u256; use crate::{ metrics::{CommitmentStage, METRICS}, - utils::{convert_vm_events_to_log_queries, CommitmentComputer, RealCommitmentComputer}, + utils::{ + convert_vm_events_to_log_queries, pubdata_to_blob_linear_hashes, read_aggregation_root, + CommitmentComputer, RealCommitmentComputer, + }, }; mod metrics; @@ -262,22 +265,42 @@ impl CommitmentGenerator { } state_diffs.sort_unstable_by_key(|rec| (rec.address, rec.key)); - let blob_commitments = if protocol_version.is_post_1_4_2() { + let (blob_commitments, blob_linear_hashes) = if protocol_version.is_post_1_4_2() { let pubdata_input = header.pubdata_input.with_context(|| { format!("`pubdata_input` is missing for L1 batch #{l1_batch_number}") })?; - pubdata_to_blob_commitments(num_blobs_required(&protocol_version), &pubdata_input) + let commitments = pubdata_to_blob_commitments( + num_blobs_required(&protocol_version), + &pubdata_input, + ); + let linear_hashes = pubdata_to_blob_linear_hashes( + num_blobs_required(&protocol_version), + pubdata_input, + ); + + (commitments, linear_hashes) } else { - vec![H256::zero(); num_blobs_required(&protocol_version)] + ( + vec![H256::zero(); num_blobs_required(&protocol_version)], + vec![H256::zero(); num_blobs_required(&protocol_version)], + ) }; + let mut connection = self + .connection_pool + .connection_tagged("commitment_generator") + .await?; + let aggregated_root = read_aggregation_root(&mut connection, l1_batch_number).await?; + CommitmentInput::PostBoojum { common, system_logs: header.system_logs, state_diffs, aux_commitments, blob_commitments, + blob_linear_hashes, + aggregated_root, } }; @@ -356,7 +379,6 @@ impl CommitmentGenerator { (L1BatchCommitmentMode::Rollup, _) => { // Do nothing } - ( L1BatchCommitmentMode::Validium, CommitmentInput::PostBoojum { diff --git a/core/node/commitment_generator/src/utils.rs b/core/node/commitment_generator/src/utils.rs index 86643b6b581b..9ed6682733c3 100644 --- a/core/node/commitment_generator/src/utils.rs +++ b/core/node/commitment_generator/src/utils.rs @@ -2,6 +2,7 @@ use std::fmt; +use anyhow::Context; use itertools::Itertools; use zk_evm_1_3_3::{ aux_structures::Timestamp as Timestamp_1_3_3, @@ -15,13 +16,17 @@ use zk_evm_1_5_0::{ aux_structures::Timestamp as Timestamp_1_5_0, zk_evm_abstractions::queries::LogQuery as LogQuery_1_5_0, }; +use zksync_dal::{Connection, Core, CoreDal}; +use zksync_l1_contract_interface::i_executor::commit::kzg::ZK_SYNC_BYTES_PER_BLOB; use zksync_multivm::{interface::VmEvent, utils::get_used_bootloader_memory_bytes}; use zksync_types::{ vm::VmVersion, + web3::keccak256, zk_evm_types::{LogQuery, Timestamp}, - ProtocolVersionId, EVENT_WRITER_ADDRESS, H256, U256, + AccountTreeId, L1BatchNumber, ProtocolVersionId, StorageKey, EVENT_WRITER_ADDRESS, H256, + L2_MESSAGE_ROOT_ADDRESS, U256, }; -use zksync_utils::{address_to_u256, expand_memory_contents, h256_to_u256}; +use zksync_utils::{address_to_u256, expand_memory_contents, h256_to_u256, u256_to_h256}; /// Encapsulates computations of commitment components. /// @@ -68,7 +73,8 @@ impl CommitmentComputer for RealCommitmentComputer { ), )), VmVersion::Vm1_5_0SmallBootloaderMemory - | VmVersion::Vm1_5_0IncreasedBootloaderMemory => Ok(H256( + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => Ok(H256( circuit_sequencer_api_1_5_0::commitments::events_queue_commitment_fixed( &events_queue .iter() @@ -106,7 +112,8 @@ impl CommitmentComputer for RealCommitmentComputer { ), )), VmVersion::Vm1_5_0SmallBootloaderMemory - | VmVersion::Vm1_5_0IncreasedBootloaderMemory => Ok(H256( + | VmVersion::Vm1_5_0IncreasedBootloaderMemory + | VmVersion::VmGateway => Ok(H256( circuit_sequencer_api_1_5_0::commitments::initial_heap_content_commitment_fixed( &full_bootloader_memory, ), @@ -234,3 +241,79 @@ pub(crate) fn convert_vm_events_to_log_queries(events: &[VmEvent]) -> Vec, +) -> Vec { + // Now, we need to calculate the linear hashes of the blobs. + // Firstly, let's pad the pubdata to the size of the blob. + if pubdata_input.len() % ZK_SYNC_BYTES_PER_BLOB != 0 { + let padding = + vec![0u8; ZK_SYNC_BYTES_PER_BLOB - pubdata_input.len() % ZK_SYNC_BYTES_PER_BLOB]; + pubdata_input.extend(padding); + } + + let mut result = vec![H256::zero(); blobs_required]; + + pubdata_input + .chunks(ZK_SYNC_BYTES_PER_BLOB) + .enumerate() + .for_each(|(i, chunk)| { + result[i] = H256(keccak256(chunk)); + }); + + result +} + +pub(crate) async fn read_aggregation_root( + connection: &mut Connection<'_, Core>, + l1_batch_number: L1BatchNumber, +) -> anyhow::Result { + // Position of `FullTree::_height` in `MessageRoot`'s storage layout. + const AGG_TREE_HEIGHT_KEY: usize = 3; + + // Position of `FullTree::nodes` in `MessageRoot`'s storage layout. + const AGG_TREE_NODES_KEY: usize = 5; + + let (_, last_l2_block) = connection + .blocks_dal() + .get_l2_block_range_of_l1_batch(l1_batch_number) + .await? + .context("No range for batch")?; + + let agg_tree_height_slot = StorageKey::new( + AccountTreeId::new(L2_MESSAGE_ROOT_ADDRESS), + u256_to_h256(AGG_TREE_HEIGHT_KEY.into()), + ); + + let agg_tree_height = connection + .storage_web3_dal() + .get_historical_value_unchecked(agg_tree_height_slot.hashed_key(), last_l2_block) + .await?; + let agg_tree_height = h256_to_u256(agg_tree_height); + + // `nodes[height][0]` + let agg_tree_root_hash_key = + n_dim_array_key_in_layout(AGG_TREE_NODES_KEY, &[agg_tree_height, U256::zero()]); + let agg_tree_root_hash_slot = StorageKey::new( + AccountTreeId::new(L2_MESSAGE_ROOT_ADDRESS), + agg_tree_root_hash_key, + ); + + Ok(connection + .storage_web3_dal() + .get_historical_value_unchecked(agg_tree_root_hash_slot.hashed_key(), last_l2_block) + .await?) +} + +fn n_dim_array_key_in_layout(array_key: usize, indices: &[U256]) -> H256 { + let mut key: H256 = u256_to_h256(array_key.into()); + + for index in indices { + key = H256(keccak256(key.as_bytes())); + key = u256_to_h256(h256_to_u256(key).overflowing_add(*index).0); + } + + key +} diff --git a/core/node/consensus/src/storage/store.rs b/core/node/consensus/src/storage/store.rs index cb8e039d7d01..96a47f5abe7e 100644 --- a/core/node/consensus/src/storage/store.rs +++ b/core/node/consensus/src/storage/store.rs @@ -35,6 +35,7 @@ fn to_fetched_block( l1_gas_price: payload.l1_gas_price, l2_fair_gas_price: payload.l2_fair_gas_price, fair_pubdata_price: payload.fair_pubdata_price, + pubdata_params: payload.pubdata_params.unwrap_or_default(), virtual_blocks: payload.virtual_blocks, operator_address: payload.operator_address, transactions: payload diff --git a/core/node/consensus/src/testonly.rs b/core/node/consensus/src/testonly.rs index 04a2dfbc0835..1996928b26e0 100644 --- a/core/node/consensus/src/testonly.rs +++ b/core/node/consensus/src/testonly.rs @@ -293,6 +293,7 @@ impl StateKeeper { timestamp: self.last_timestamp, virtual_blocks: 1, }, + pubdata_params: Default::default(), }, number: self.last_batch, first_l2_block_number: self.last_block, @@ -568,7 +569,7 @@ impl StateKeeperRunner { let (stop_send, stop_recv) = sync::watch::channel(false); let (persistence, l2_block_sealer) = StateKeeperPersistence::new( self.pool.0.clone(), - ethabi::Address::repeat_byte(11), + Some(ethabi::Address::repeat_byte(11)), 5, ); @@ -675,7 +676,7 @@ impl StateKeeperRunner { let (stop_send, stop_recv) = sync::watch::channel(false); let (persistence, l2_block_sealer) = StateKeeperPersistence::new( self.pool.0.clone(), - ethabi::Address::repeat_byte(11), + Some(ethabi::Address::repeat_byte(11)), 5, ); let tree_writes_persistence = TreeWritesPersistence::new(self.pool.0.clone()); diff --git a/core/node/db_pruner/src/tests.rs b/core/node/db_pruner/src/tests.rs index a5458e996e1e..99fbada423dc 100644 --- a/core/node/db_pruner/src/tests.rs +++ b/core/node/db_pruner/src/tests.rs @@ -122,6 +122,7 @@ async fn insert_l2_blocks( virtual_blocks: 0, gas_limit: 0, logs_bloom: Default::default(), + pubdata_params: Default::default(), }; conn.blocks_dal() diff --git a/core/node/eth_sender/src/tests.rs b/core/node/eth_sender/src/tests.rs index e03532458f18..01c17c6b2ca1 100644 --- a/core/node/eth_sender/src/tests.rs +++ b/core/node/eth_sender/src/tests.rs @@ -82,6 +82,10 @@ pub(crate) fn default_l1_batch_metadata() -> L1BatchMetadata { events_queue_commitment: Some(H256::zero()), bootloader_initial_content_commitment: Some(H256::zero()), state_diffs_compressed: vec![], + state_diff_hash: Some(H256::default()), + local_root: Some(H256::default()), + aggregation_root: Some(H256::default()), + da_inclusion_data: Some(vec![]), } } diff --git a/core/node/eth_watch/src/lib.rs b/core/node/eth_watch/src/lib.rs index a832733b3559..4185878d2ac4 100644 --- a/core/node/eth_watch/src/lib.rs +++ b/core/node/eth_watch/src/lib.rs @@ -140,7 +140,7 @@ impl EthWatch { let finalized_block = client.finalized_block_number().await?; let from_block = storage - .processed_events_dal() + .eth_watcher_dal() .get_or_set_next_block_to_process( processor.event_type(), chain_id, @@ -180,7 +180,7 @@ impl EthWatch { }; storage - .processed_events_dal() + .eth_watcher_dal() .update_next_block_to_process( processor.event_type(), chain_id, diff --git a/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs b/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs index e6842b92fdba..e43de3e34bf5 100644 --- a/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs +++ b/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs @@ -85,8 +85,8 @@ impl GasAdjuster { anyhow::ensure!(client.gateway_mode, "Must be L2 client in L2 mode"); anyhow::ensure!( - matches!(pubdata_sending_mode, PubdataSendingMode::RelayedL2Calldata), - "Only relayed L2 calldata is available for L2 mode, got: {pubdata_sending_mode:?}" + matches!(pubdata_sending_mode, PubdataSendingMode::RelayedL2Calldata | PubdataSendingMode::Custom), + "Only relayed L2 calldata or Custom is available for L2 mode, got: {pubdata_sending_mode:?}" ); } else { anyhow::ensure!(!client.gateway_mode, "Must be L1 client in L1 mode"); diff --git a/core/node/genesis/src/lib.rs b/core/node/genesis/src/lib.rs index 1f30d314bb06..9c863a1015d8 100644 --- a/core/node/genesis/src/lib.rs +++ b/core/node/genesis/src/lib.rs @@ -402,6 +402,7 @@ pub async fn create_genesis_l1_batch( virtual_blocks: 0, gas_limit: 0, logs_bloom: Bloom::zero(), + pubdata_params: Default::default(), }; let mut transaction = storage.start_transaction().await?; diff --git a/core/node/logs_bloom_backfill/src/lib.rs b/core/node/logs_bloom_backfill/src/lib.rs index 4337c0b8dc97..368d2edaf698 100644 --- a/core/node/logs_bloom_backfill/src/lib.rs +++ b/core/node/logs_bloom_backfill/src/lib.rs @@ -158,6 +158,7 @@ mod tests { virtual_blocks: 0, gas_limit: 0, logs_bloom: Default::default(), + pubdata_params: Default::default(), }; conn.blocks_dal() diff --git a/core/node/node_framework/src/implementations/layers/state_keeper/mempool_io.rs b/core/node/node_framework/src/implementations/layers/state_keeper/mempool_io.rs index ec2c415b9bbd..77992f34c7f5 100644 --- a/core/node/node_framework/src/implementations/layers/state_keeper/mempool_io.rs +++ b/core/node/node_framework/src/implementations/layers/state_keeper/mempool_io.rs @@ -4,7 +4,7 @@ use zksync_config::configs::{ wallets, }; use zksync_state_keeper::{MempoolFetcher, MempoolGuard, MempoolIO, SequencerSealer}; -use zksync_types::L2ChainId; +use zksync_types::{commitment::L1BatchCommitmentMode, Address, L2ChainId}; use crate::{ implementations::resources::{ @@ -39,6 +39,8 @@ pub struct MempoolIOLayer { state_keeper_config: StateKeeperConfig, mempool_config: MempoolConfig, wallets: wallets::StateKeeper, + l2_da_validator_addr: Option
, + l1_batch_commit_data_generator_mode: L1BatchCommitmentMode, } #[derive(Debug, FromContext)] @@ -63,12 +65,16 @@ impl MempoolIOLayer { state_keeper_config: StateKeeperConfig, mempool_config: MempoolConfig, wallets: wallets::StateKeeper, + l2_da_validator_addr: Option
, + l1_batch_commit_data_generator_mode: L1BatchCommitmentMode, ) -> Self { Self { zksync_network_id, state_keeper_config, mempool_config, wallets, + l2_da_validator_addr, + l1_batch_commit_data_generator_mode, } } @@ -129,6 +135,8 @@ impl WiringLayer for MempoolIOLayer { self.wallets.fee_account.address(), self.mempool_config.delay_interval(), self.zksync_network_id, + self.l2_da_validator_addr, + self.l1_batch_commit_data_generator_mode, )?; // Create sealer. diff --git a/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs b/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs index 5f63e4e19475..7a0de6193643 100644 --- a/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs +++ b/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs @@ -1,10 +1,12 @@ use anyhow::Context as _; +use zksync_dal::{Core, CoreDal}; +use zksync_db_connection::connection_pool::ConnectionPool; use zksync_node_framework_derive::FromContext; use zksync_state_keeper::{ io::seal_logic::l2_block_seal_subtasks::L2BlockSealProcess, L2BlockSealerTask, OutputHandler, StateKeeperPersistence, TreeWritesPersistence, }; -use zksync_types::Address; +use zksync_types::{Address, ProtocolVersionId}; use crate::{ implementations::resources::{ @@ -35,7 +37,7 @@ use crate::{ /// - `L2BlockSealerTask` #[derive(Debug)] pub struct OutputHandlerLayer { - l2_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, l2_block_seal_queue_capacity: usize, /// Whether transactions should be pre-inserted to DB. /// Should be set to `true` for EN's IO as EN doesn't store transactions in DB @@ -63,9 +65,12 @@ pub struct Output { } impl OutputHandlerLayer { - pub fn new(l2_shared_bridge_addr: Address, l2_block_seal_queue_capacity: usize) -> Self { + pub fn new( + l2_legacy_shared_bridge_addr: Option
, + l2_block_seal_queue_capacity: usize, + ) -> Self { Self { - l2_shared_bridge_addr, + l2_legacy_shared_bridge_addr, l2_block_seal_queue_capacity, pre_insert_txs: false, protective_reads_persistence_enabled: false, @@ -84,6 +89,38 @@ impl OutputHandlerLayer { self.protective_reads_persistence_enabled = protective_reads_persistence_enabled; self } + + async fn validate_l2_legacy_shared_bridge_addr( + &self, + pool: &ConnectionPool, + ) -> Result<(), WiringError> { + let mut connection = pool.connection().await.context("Get DB connection")?; + + if let Some(l2_block) = connection + .blocks_dal() + .get_earliest_l2_block_number() + .await + .context("failed to load earliest l2 block number")? + { + let header = connection + .blocks_dal() + .get_l2_block_header(l2_block) + .await + .context("failed to load L2 block header")? + .context("missing L2 block header")?; + let protocol_version = header + .protocol_version + .unwrap_or_else(ProtocolVersionId::last_potentially_undefined); + + if protocol_version.is_pre_gateway() && self.l2_legacy_shared_bridge_addr.is_none() { + return Err(WiringError::Configuration( + "Missing `l2_legacy_shared_bridge_addr` for chain that was initialized before gateway upgrade".to_string() + )); + } + } + + Ok(()) + } } #[async_trait::async_trait] @@ -103,9 +140,12 @@ impl WiringLayer for OutputHandlerLayer { .get_custom(L2BlockSealProcess::subtasks_len()) .await .context("Get master pool")?; + self.validate_l2_legacy_shared_bridge_addr(&persistence_pool) + .await?; + let (mut persistence, l2_block_sealer) = StateKeeperPersistence::new( persistence_pool.clone(), - self.l2_shared_bridge_addr, + self.l2_legacy_shared_bridge_addr, self.l2_block_seal_queue_capacity, ); if self.pre_insert_txs { diff --git a/core/node/node_sync/src/fetcher.rs b/core/node/node_sync/src/fetcher.rs index 51b9f7c7a060..08e3d4262433 100644 --- a/core/node/node_sync/src/fetcher.rs +++ b/core/node/node_sync/src/fetcher.rs @@ -2,8 +2,8 @@ use zksync_dal::{Connection, Core, CoreDal}; use zksync_shared_metrics::{TxStage, APP_METRICS}; use zksync_state_keeper::io::{common::IoCursor, L1BatchParams, L2BlockParams}; use zksync_types::{ - api::en::SyncBlock, block::L2BlockHasher, fee_model::BatchFeeInput, helpers::unix_timestamp_ms, - Address, L1BatchNumber, L2BlockNumber, ProtocolVersionId, H256, + api::en::SyncBlock, block::L2BlockHasher, commitment::PubdataParams, fee_model::BatchFeeInput, + helpers::unix_timestamp_ms, Address, L1BatchNumber, L2BlockNumber, ProtocolVersionId, H256, }; use super::{ @@ -51,6 +51,7 @@ pub struct FetchedBlock { pub virtual_blocks: u32, pub operator_address: Address, pub transactions: Vec, + pub pubdata_params: PubdataParams, } impl FetchedBlock { @@ -93,6 +94,7 @@ impl TryFrom for FetchedBlock { .into_iter() .map(FetchedTransaction::new) .collect(), + pubdata_params: block.pubdata_params.unwrap_or_default(), }) } } @@ -165,6 +167,7 @@ impl IoCursorExt for IoCursor { timestamp: block.timestamp, virtual_blocks: block.virtual_blocks, }, + pubdata_params: block.pubdata_params, }, number: block.l1_batch_number, first_l2_block_number: block.number, diff --git a/core/node/node_sync/src/sync_action.rs b/core/node/node_sync/src/sync_action.rs index 8cb90d24fe84..4505dbb93aba 100644 --- a/core/node/node_sync/src/sync_action.rs +++ b/core/node/node_sync/src/sync_action.rs @@ -186,6 +186,7 @@ mod tests { timestamp: 1, virtual_blocks: 1, }, + pubdata_params: Default::default(), }, number: L1BatchNumber(1), first_l2_block_number: L2BlockNumber(1), diff --git a/core/node/node_sync/src/tests.rs b/core/node/node_sync/src/tests.rs index d9a98c2bce36..3322dbf0f9b7 100644 --- a/core/node/node_sync/src/tests.rs +++ b/core/node/node_sync/src/tests.rs @@ -43,6 +43,7 @@ fn open_l1_batch(number: u32, timestamp: u64, first_l2_block_number: u32) -> Syn timestamp, virtual_blocks: 1, }, + pubdata_params: Default::default(), }, number: L1BatchNumber(number), first_l2_block_number: L2BlockNumber(first_l2_block_number), @@ -66,6 +67,7 @@ impl MockMainNodeClient { virtual_blocks: Some(0), hash: Some(snapshot.l2_block_hash), protocol_version: ProtocolVersionId::latest(), + pubdata_params: Default::default(), }; Self { @@ -105,7 +107,7 @@ impl StateKeeperHandles { let sync_state = SyncState::default(); let (persistence, l2_block_sealer) = - StateKeeperPersistence::new(pool.clone(), Address::repeat_byte(1), 5); + StateKeeperPersistence::new(pool.clone(), Some(Address::repeat_byte(1)), 5); let tree_writes_persistence = TreeWritesPersistence::new(pool.clone()); let output_handler = OutputHandler::new(Box::new(persistence.with_tx_insertion())) .with_handler(Box::new(tree_writes_persistence)) diff --git a/core/node/proof_data_handler/src/request_processor.rs b/core/node/proof_data_handler/src/request_processor.rs index ee266a88971e..1c4a1833766c 100644 --- a/core/node/proof_data_handler/src/request_processor.rs +++ b/core/node/proof_data_handler/src/request_processor.rs @@ -17,7 +17,7 @@ use zksync_types::{ basic_fri_types::Eip4844Blobs, commitment::{serialize_commitments, L1BatchCommitmentMode}, web3::keccak256, - L1BatchNumber, H256, + L1BatchNumber, ProtocolVersionId, H256, STATE_DIFF_HASH_KEY_PRE_GATEWAY, }; use crate::{errors::RequestProcessorError, metrics::METRICS}; @@ -226,58 +226,64 @@ impl RequestProcessor { .unwrap() .expect("Proved block without metadata"); - let is_pre_boojum = l1_batch + let protocol_version = l1_batch .header .protocol_version - .map(|v| v.is_pre_boojum()) - .unwrap_or(true); - if !is_pre_boojum { - let events_queue_state = l1_batch - .metadata - .events_queue_commitment - .expect("No events_queue_commitment"); - let bootloader_heap_initial_content = l1_batch - .metadata - .bootloader_initial_content_commitment - .expect("No bootloader_initial_content_commitment"); - - if events_queue_state != events_queue_state_from_prover - || bootloader_heap_initial_content - != bootloader_heap_initial_content_from_prover - { - let server_values = format!("events_queue_state = {events_queue_state}, bootloader_heap_initial_content = {bootloader_heap_initial_content}"); - let prover_values = format!("events_queue_state = {events_queue_state_from_prover}, bootloader_heap_initial_content = {bootloader_heap_initial_content_from_prover}"); - panic!( - "Auxilary output doesn't match, server values: {} prover values: {}", - server_values, prover_values - ); - } + .unwrap_or_else(ProtocolVersionId::last_potentially_undefined); + + let events_queue_state = l1_batch + .metadata + .events_queue_commitment + .expect("No events_queue_commitment"); + let bootloader_heap_initial_content = l1_batch + .metadata + .bootloader_initial_content_commitment + .expect("No bootloader_initial_content_commitment"); + + if events_queue_state != events_queue_state_from_prover + || bootloader_heap_initial_content + != bootloader_heap_initial_content_from_prover + { + let server_values = format!("events_queue_state = {events_queue_state}, bootloader_heap_initial_content = {bootloader_heap_initial_content}"); + let prover_values = format!("events_queue_state = {events_queue_state_from_prover}, bootloader_heap_initial_content = {bootloader_heap_initial_content_from_prover}"); + panic!( + "Auxilary output doesn't match, server values: {} prover values: {}", + server_values, prover_values + ); } let system_logs = serialize_commitments(&l1_batch.header.system_logs); let system_logs_hash = H256(keccak256(&system_logs)); - if !is_pre_boojum { - let state_diff_hash = l1_batch + let state_diff_hash = if protocol_version.is_pre_gateway() { + l1_batch .header .system_logs - .into_iter() - .find(|elem| elem.0.key == H256::from_low_u64_be(2)) - .expect("No state diff hash key") - .0 - .value; - - if state_diff_hash != state_diff_hash_from_prover - || system_logs_hash != system_logs_hash_from_prover - { - let server_values = format!("system_logs_hash = {system_logs_hash}, state_diff_hash = {state_diff_hash}"); - let prover_values = format!("system_logs_hash = {system_logs_hash_from_prover}, state_diff_hash = {state_diff_hash_from_prover}"); - panic!( - "Auxilary output doesn't match, server values: {} prover values: {}", - server_values, prover_values - ); - } + .iter() + .find_map(|log| { + (log.0.key + == H256::from_low_u64_be(STATE_DIFF_HASH_KEY_PRE_GATEWAY as u64)) + .then_some(log.0.value) + }) + .expect("Failed to get state_diff_hash from system logs") + } else { + l1_batch + .metadata + .state_diff_hash + .expect("Failed to get state_diff_hash from metadata") + }; + + if state_diff_hash != state_diff_hash_from_prover + || system_logs_hash != system_logs_hash_from_prover + { + let server_values = format!("system_logs_hash = {system_logs_hash}, state_diff_hash = {state_diff_hash}"); + let prover_values = format!("system_logs_hash = {system_logs_hash_from_prover}, state_diff_hash = {state_diff_hash_from_prover}"); + panic!( + "Auxilary output doesn't match, server values: {} prover values: {}", + server_values, prover_values + ); } + storage .proof_generation_dal() .save_proof_artifacts_metadata(l1_batch_number, &blob_url) diff --git a/core/node/proof_data_handler/src/tests.rs b/core/node/proof_data_handler/src/tests.rs index 86cc53234486..4319fce6216d 100644 --- a/core/node/proof_data_handler/src/tests.rs +++ b/core/node/proof_data_handler/src/tests.rs @@ -67,6 +67,7 @@ async fn request_tee_proof_inputs() { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: 0, chain_id: Default::default(), + pubdata_params: Default::default(), }, vec![(H256([1; 32]), vec![0, 1, 2, 3, 4])], ); diff --git a/core/node/state_keeper/src/io/mempool.rs b/core/node/state_keeper/src/io/mempool.rs index 108283122bce..1114000e8d13 100644 --- a/core/node/state_keeper/src/io/mempool.rs +++ b/core/node/state_keeper/src/io/mempool.rs @@ -14,8 +14,10 @@ use zksync_mempool::L2TxFilter; use zksync_multivm::{interface::Halt, utils::derive_base_fee_and_gas_per_pubdata}; use zksync_node_fee_model::BatchFeeModelInputProvider; use zksync_types::{ - protocol_upgrade::ProtocolUpgradeTx, utils::display_timestamp, Address, L1BatchNumber, - L2BlockNumber, L2ChainId, ProtocolVersionId, Transaction, H256, U256, + commitment::{L1BatchCommitmentMode, PubdataParams}, + protocol_upgrade::ProtocolUpgradeTx, + utils::display_timestamp, + Address, L1BatchNumber, L2BlockNumber, L2ChainId, ProtocolVersionId, Transaction, H256, U256, }; // TODO (SMA-1206): use seconds instead of milliseconds. use zksync_utils::time::millis_since_epoch; @@ -55,6 +57,8 @@ pub struct MempoolIO { // Used to keep track of gas prices to set accepted price per pubdata byte in blocks. batch_fee_input_provider: Arc, chain_id: L2ChainId, + l2_da_validator_address: Option
, + pubdata_type: L1BatchCommitmentMode, } impl IoSealCriteria for MempoolIO { @@ -191,6 +195,18 @@ impl StateKeeperIO for MempoolIO { continue; } + let pubdata_params = match ( + protocol_version.is_pre_gateway(), + self.l2_da_validator_address, + ) { + (true, _) => PubdataParams::default(), + (false, Some(l2_da_validator_address)) => PubdataParams { + l2_da_validator_address, + pubdata_type: self.pubdata_type, + }, + (false, None) => anyhow::bail!("L2 DA validator address not found"), + }; + return Ok(Some(L1BatchParams { protocol_version, validation_computational_gas_limit: self.validation_computational_gas_limit, @@ -201,6 +217,7 @@ impl StateKeeperIO for MempoolIO { // This value is effectively ignored by the protocol. virtual_blocks: 1, }, + pubdata_params, })); } Ok(None) @@ -408,6 +425,7 @@ async fn sleep_past(timestamp: u64, l2_block: L2BlockNumber) -> u64 { } impl MempoolIO { + #[allow(clippy::too_many_arguments)] pub fn new( mempool: MempoolGuard, batch_fee_input_provider: Arc, @@ -416,6 +434,8 @@ impl MempoolIO { fee_account: Address, delay_interval: Duration, chain_id: L2ChainId, + l2_da_validator_address: Option
, + pubdata_type: L1BatchCommitmentMode, ) -> anyhow::Result { Ok(Self { mempool, @@ -431,6 +451,8 @@ impl MempoolIO { delay_interval, batch_fee_input_provider, chain_id, + l2_da_validator_address, + pubdata_type, }) } } diff --git a/core/node/state_keeper/src/io/mod.rs b/core/node/state_keeper/src/io/mod.rs index f8106fd2423b..947d05ec800f 100644 --- a/core/node/state_keeper/src/io/mod.rs +++ b/core/node/state_keeper/src/io/mod.rs @@ -4,8 +4,9 @@ use async_trait::async_trait; use zksync_contracts::BaseSystemContracts; use zksync_multivm::interface::{L1BatchEnv, SystemEnv}; use zksync_types::{ - block::L2BlockExecutionData, fee_model::BatchFeeInput, protocol_upgrade::ProtocolUpgradeTx, - Address, L1BatchNumber, L2ChainId, ProtocolVersionId, Transaction, H256, + block::L2BlockExecutionData, commitment::PubdataParams, fee_model::BatchFeeInput, + protocol_upgrade::ProtocolUpgradeTx, Address, L1BatchNumber, L2ChainId, ProtocolVersionId, + Transaction, H256, }; use zksync_vm_executor::storage::l1_batch_params; @@ -70,6 +71,8 @@ pub struct L1BatchParams { pub fee_input: BatchFeeInput, /// Parameters of the first L2 block in the batch. pub first_l2_block: L2BlockParams, + /// Params related to how the pubdata should be processed by the bootloader in the batch. + pub pubdata_params: PubdataParams, } impl L1BatchParams { @@ -93,6 +96,7 @@ impl L1BatchParams { self.protocol_version, self.first_l2_block.virtual_blocks, chain_id, + self.pubdata_params, ) } } diff --git a/core/node/state_keeper/src/io/persistence.rs b/core/node/state_keeper/src/io/persistence.rs index 24b1ffca631c..dc854c9e58f1 100644 --- a/core/node/state_keeper/src/io/persistence.rs +++ b/core/node/state_keeper/src/io/persistence.rs @@ -29,7 +29,7 @@ struct Completable { #[derive(Debug)] pub struct StateKeeperPersistence { pool: ConnectionPool, - l2_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, pre_insert_txs: bool, insert_protective_reads: bool, commands_sender: mpsc::Sender>, @@ -45,7 +45,7 @@ impl StateKeeperPersistence { /// `command_capacity` for unprocessed sealing commands. pub fn new( pool: ConnectionPool, - l2_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, mut command_capacity: usize, ) -> (Self, L2BlockSealerTask) { let is_sync = command_capacity == 0; @@ -60,7 +60,7 @@ impl StateKeeperPersistence { }; let this = Self { pool, - l2_shared_bridge_addr, + l2_legacy_shared_bridge_addr, pre_insert_txs: false, insert_protective_reads: true, commands_sender, @@ -157,8 +157,8 @@ impl StateKeeperOutputHandler for StateKeeperPersistence { } async fn handle_l2_block(&mut self, updates_manager: &UpdatesManager) -> anyhow::Result<()> { - let command = - updates_manager.seal_l2_block_command(self.l2_shared_bridge_addr, self.pre_insert_txs); + let command = updates_manager + .seal_l2_block_command(self.l2_legacy_shared_bridge_addr, self.pre_insert_txs); self.submit_l2_block(command).await; Ok(()) } @@ -174,7 +174,7 @@ impl StateKeeperOutputHandler for StateKeeperPersistence { updates_manager .seal_l1_batch( self.pool.clone(), - self.l2_shared_bridge_addr, + self.l2_legacy_shared_bridge_addr, self.insert_protective_reads, ) .await @@ -392,8 +392,11 @@ mod tests { .unwrap(); drop(storage); - let (persistence, l2_block_sealer) = - StateKeeperPersistence::new(pool.clone(), Address::default(), l2_block_sealer_capacity); + let (persistence, l2_block_sealer) = StateKeeperPersistence::new( + pool.clone(), + Some(Address::default()), + l2_block_sealer_capacity, + ); let mut output_handler = OutputHandler::new(Box::new(persistence)) .with_handler(Box::new(TreeWritesPersistence::new(pool.clone()))); tokio::spawn(l2_block_sealer.run()); @@ -527,7 +530,7 @@ mod tests { drop(storage); let (mut persistence, l2_block_sealer) = - StateKeeperPersistence::new(pool.clone(), Address::default(), 1); + StateKeeperPersistence::new(pool.clone(), Some(Address::default()), 1); persistence = persistence.with_tx_insertion().without_protective_reads(); let mut output_handler = OutputHandler::new(Box::new(persistence)); tokio::spawn(l2_block_sealer.run()); @@ -566,11 +569,11 @@ mod tests { async fn l2_block_sealer_handle_blocking() { let pool = ConnectionPool::constrained_test_pool(1).await; let (mut persistence, mut sealer) = - StateKeeperPersistence::new(pool, Address::default(), 1); + StateKeeperPersistence::new(pool, Some(Address::default()), 1); // The first command should be successfully submitted immediately. let mut updates_manager = create_updates_manager(); - let seal_command = updates_manager.seal_l2_block_command(Address::default(), false); + let seal_command = updates_manager.seal_l2_block_command(Some(Address::default()), false); persistence.submit_l2_block(seal_command).await; // The second command should lead to blocking @@ -578,7 +581,7 @@ mod tests { timestamp: 2, virtual_blocks: 1, }); - let seal_command = updates_manager.seal_l2_block_command(Address::default(), false); + let seal_command = updates_manager.seal_l2_block_command(Some(Address::default()), false); { let submit_future = persistence.submit_l2_block(seal_command); futures::pin_mut!(submit_future); @@ -606,7 +609,7 @@ mod tests { timestamp: 3, virtual_blocks: 1, }); - let seal_command = updates_manager.seal_l2_block_command(Address::default(), false); + let seal_command = updates_manager.seal_l2_block_command(Some(Address::default()), false); persistence.submit_l2_block(seal_command).await; let command = sealer.commands_receiver.recv().await.unwrap(); command.completion_sender.send(()).unwrap(); @@ -617,12 +620,13 @@ mod tests { async fn l2_block_sealer_handle_parallel_processing() { let pool = ConnectionPool::constrained_test_pool(1).await; let (mut persistence, mut sealer) = - StateKeeperPersistence::new(pool, Address::default(), 5); + StateKeeperPersistence::new(pool, Some(Address::default()), 5); // 5 L2 block sealing commands can be submitted without blocking. let mut updates_manager = create_updates_manager(); for i in 1..=5 { - let seal_command = updates_manager.seal_l2_block_command(Address::default(), false); + let seal_command = + updates_manager.seal_l2_block_command(Some(Address::default()), false); updates_manager.push_l2_block(L2BlockParams { timestamp: i, virtual_blocks: 1, diff --git a/core/node/state_keeper/src/io/seal_logic/l2_block_seal_subtasks.rs b/core/node/state_keeper/src/io/seal_logic/l2_block_seal_subtasks.rs index 7ef466805e36..4fc58bce5c9e 100644 --- a/core/node/state_keeper/src/io/seal_logic/l2_block_seal_subtasks.rs +++ b/core/node/state_keeper/src/io/seal_logic/l2_block_seal_subtasks.rs @@ -3,7 +3,7 @@ use async_trait::async_trait; use once_cell::sync::Lazy; use zksync_dal::{Connection, Core, CoreDal}; use zksync_multivm::interface::VmEvent; -use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; +use zksync_system_constants::{CONTRACT_DEPLOYER_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS}; use zksync_types::{ ethabi, tokens::{TokenInfo, TokenMetadata}, @@ -18,7 +18,7 @@ use crate::{ }; fn extract_added_tokens( - l2_shared_bridge_addr: Address, + l2_token_deployer_addr: Address, all_generated_events: &[VmEvent], ) -> Vec { let deployed_tokens = all_generated_events @@ -28,7 +28,7 @@ fn extract_added_tokens( event.address == CONTRACT_DEPLOYER_ADDRESS && event.indexed_topics.len() == 4 && event.indexed_topics[0] == VmEvent::DEPLOY_EVENT_SIGNATURE - && h256_to_account_address(&event.indexed_topics[1]) == l2_shared_bridge_addr + && h256_to_account_address(&event.indexed_topics[1]) == l2_token_deployer_addr }) .map(|event| h256_to_account_address(&event.indexed_topics[3])); @@ -334,8 +334,10 @@ impl L2BlockSealSubtask for InsertTokensSubtask { ) -> anyhow::Result<()> { let is_fictive = command.is_l2_block_fictive(); let progress = L2_BLOCK_METRICS.start(L2BlockSealStage::ExtractAddedTokens, is_fictive); - let added_tokens = - extract_added_tokens(command.l2_shared_bridge_addr, &command.l2_block.events); + let token_deployer_address = command + .l2_legacy_shared_bridge_addr + .unwrap_or(L2_NATIVE_TOKEN_VAULT_ADDRESS); + let added_tokens = extract_added_tokens(token_deployer_address, &command.l2_block.events); progress.observe(added_tokens.len()); let progress = L2_BLOCK_METRICS.start(L2BlockSealStage::InsertTokens, is_fictive); @@ -464,6 +466,7 @@ mod tests { use zksync_node_test_utils::create_l2_transaction; use zksync_types::{ block::L2BlockHeader, + commitment::PubdataParams, l2_to_l1_log::{L2ToL1Log, UserL2ToL1Log}, AccountTreeId, Address, L1BatchNumber, ProtocolVersionId, StorageKey, StorageLog, StorageLogKind, StorageLogWithPreviousValue, @@ -552,8 +555,9 @@ mod tests { base_fee_per_gas: Default::default(), base_system_contracts_hashes: Default::default(), protocol_version: Some(ProtocolVersionId::latest()), - l2_shared_bridge_addr: Default::default(), + l2_legacy_shared_bridge_addr: Default::default(), pre_insert_txs: false, + pubdata_params: PubdataParams::default(), }; // Run. @@ -616,6 +620,7 @@ mod tests { virtual_blocks: l2_block_seal_command.l2_block.virtual_blocks, gas_limit: get_max_batch_gas_limit(VmVersion::latest()), logs_bloom: Default::default(), + pubdata_params: l2_block_seal_command.pubdata_params, }; connection .protocol_versions_dal() diff --git a/core/node/state_keeper/src/io/seal_logic/mod.rs b/core/node/state_keeper/src/io/seal_logic/mod.rs index 0dae7fae908a..3cbad6525ba6 100644 --- a/core/node/state_keeper/src/io/seal_logic/mod.rs +++ b/core/node/state_keeper/src/io/seal_logic/mod.rs @@ -46,7 +46,7 @@ impl UpdatesManager { pub(super) async fn seal_l1_batch( &self, pool: ConnectionPool, - l2_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, insert_protective_reads: bool, ) -> anyhow::Result<()> { let started_at = Instant::now(); @@ -59,7 +59,7 @@ impl UpdatesManager { let progress = L1_BATCH_METRICS.start(L1BatchSealStage::FictiveL2Block); // Seal fictive L2 block with last events and storage logs. let l2_block_command = self.seal_l2_block_command( - l2_shared_bridge_addr, + l2_legacy_shared_bridge_addr, false, // fictive L2 blocks don't have txs, so it's fine to pass `false` here. ); @@ -334,8 +334,6 @@ impl L2BlockSealCommand { /// that are created after the last processed tx in the L1 batch: after the last transaction is processed, /// the bootloader enters the "tip" phase in which it can still generate events (e.g., /// one for sending fees to the operator). - /// - /// `l2_shared_bridge_addr` is required to extract the information on newly added tokens. async fn seal_inner( &self, strategy: &mut SealStrategy<'_>, @@ -392,6 +390,7 @@ impl L2BlockSealCommand { virtual_blocks: self.l2_block.virtual_blocks, gas_limit: get_max_batch_gas_limit(definite_vm_version), logs_bloom, + pubdata_params: self.pubdata_params, }; let mut connection = strategy.connection().await?; diff --git a/core/node/state_keeper/src/io/tests/mod.rs b/core/node/state_keeper/src/io/tests/mod.rs index 7ea01e6af1e8..0f1f5dd4f518 100644 --- a/core/node/state_keeper/src/io/tests/mod.rs +++ b/core/node/state_keeper/src/io/tests/mod.rs @@ -284,8 +284,9 @@ async fn processing_storage_logs_when_sealing_l2_block() { base_fee_per_gas: 10, base_system_contracts_hashes: BaseSystemContractsHashes::default(), protocol_version: Some(ProtocolVersionId::latest()), - l2_shared_bridge_addr: Address::default(), + l2_legacy_shared_bridge_addr: Some(Address::default()), pre_insert_txs: false, + pubdata_params: Default::default(), }; connection_pool .connection() @@ -373,8 +374,9 @@ async fn processing_events_when_sealing_l2_block() { base_fee_per_gas: 10, base_system_contracts_hashes: BaseSystemContractsHashes::default(), protocol_version: Some(ProtocolVersionId::latest()), - l2_shared_bridge_addr: Address::default(), + l2_legacy_shared_bridge_addr: Some(Address::default()), pre_insert_txs: false, + pubdata_params: Default::default(), }; pool.connection() .await @@ -463,7 +465,7 @@ async fn l2_block_processing_after_snapshot_recovery(commitment_mode: L1BatchCom ); let (mut persistence, l2_block_sealer) = - StateKeeperPersistence::new(connection_pool.clone(), Address::default(), 0); + StateKeeperPersistence::new(connection_pool.clone(), Some(Address::default()), 0); tokio::spawn(l2_block_sealer.run()); persistence.handle_l2_block(&updates).await.unwrap(); diff --git a/core/node/state_keeper/src/io/tests/tester.rs b/core/node/state_keeper/src/io/tests/tester.rs index 2dc45a5eaaa0..13b9eed6ad92 100644 --- a/core/node/state_keeper/src/io/tests/tester.rs +++ b/core/node/state_keeper/src/io/tests/tester.rs @@ -136,6 +136,8 @@ impl Tester { wallets.state_keeper.unwrap().fee_account.address(), Duration::from_secs(1), L2ChainId::from(270), + Some(Default::default()), + Default::default(), ) .unwrap(); diff --git a/core/node/state_keeper/src/testonly/test_batch_executor.rs b/core/node/state_keeper/src/testonly/test_batch_executor.rs index ffca8dff8643..4a58e9e0a952 100644 --- a/core/node/state_keeper/src/testonly/test_batch_executor.rs +++ b/core/node/state_keeper/src/testonly/test_batch_executor.rs @@ -700,6 +700,7 @@ impl StateKeeperIO for TestIO { timestamp: self.timestamp, virtual_blocks: 1, }, + pubdata_params: Default::default(), }; self.l2_block_number += 1; self.timestamp += 1; diff --git a/core/node/state_keeper/src/tests/mod.rs b/core/node/state_keeper/src/tests/mod.rs index 80de0f0beff9..552e6ec37996 100644 --- a/core/node/state_keeper/src/tests/mod.rs +++ b/core/node/state_keeper/src/tests/mod.rs @@ -58,6 +58,7 @@ pub(crate) fn pending_batch_data(pending_l2_blocks: Vec) - execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::from(270), + pubdata_params: Default::default(), }, pending_l2_blocks, } @@ -72,6 +73,7 @@ pub(super) fn default_system_env() -> SystemEnv { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::from(270), + pubdata_params: Default::default(), } } diff --git a/core/node/state_keeper/src/updates/mod.rs b/core/node/state_keeper/src/updates/mod.rs index 2fad56a99299..9996741a6268 100644 --- a/core/node/state_keeper/src/updates/mod.rs +++ b/core/node/state_keeper/src/updates/mod.rs @@ -7,8 +7,8 @@ use zksync_multivm::{ utils::{get_batch_base_fee, StorageWritesDeduplicator}, }; use zksync_types::{ - block::BlockGasCount, fee_model::BatchFeeInput, Address, L1BatchNumber, L2BlockNumber, - ProtocolVersionId, Transaction, + block::BlockGasCount, commitment::PubdataParams, fee_model::BatchFeeInput, Address, + L1BatchNumber, L2BlockNumber, ProtocolVersionId, Transaction, }; pub(crate) use self::{l1_batch_updates::L1BatchUpdates, l2_block_updates::L2BlockUpdates}; @@ -39,6 +39,7 @@ pub struct UpdatesManager { pub l1_batch: L1BatchUpdates, pub l2_block: L2BlockUpdates, pub storage_writes_deduplicator: StorageWritesDeduplicator, + pubdata_params: PubdataParams, } impl UpdatesManager { @@ -61,6 +62,7 @@ impl UpdatesManager { ), storage_writes_deduplicator: StorageWritesDeduplicator::new(), storage_view_cache: None, + pubdata_params: system_env.pubdata_params, } } @@ -83,7 +85,7 @@ impl UpdatesManager { pub(crate) fn seal_l2_block_command( &self, - l2_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, pre_insert_txs: bool, ) -> L2BlockSealCommand { L2BlockSealCommand { @@ -95,8 +97,9 @@ impl UpdatesManager { base_fee_per_gas: self.base_fee_per_gas, base_system_contracts_hashes: self.base_system_contract_hashes, protocol_version: Some(self.protocol_version), - l2_shared_bridge_addr, + l2_legacy_shared_bridge_addr, pre_insert_txs, + pubdata_params: self.pubdata_params, } } @@ -206,11 +209,12 @@ pub struct L2BlockSealCommand { pub base_fee_per_gas: u64, pub base_system_contracts_hashes: BaseSystemContractsHashes, pub protocol_version: Option, - pub l2_shared_bridge_addr: Address, + pub l2_legacy_shared_bridge_addr: Option
, /// Whether transactions should be pre-inserted to DB. /// Should be set to `true` for EN's IO as EN doesn't store transactions in DB /// before they are included into L2 blocks. pub pre_insert_txs: bool, + pub pubdata_params: PubdataParams, } #[cfg(test)] diff --git a/core/node/test_utils/src/lib.rs b/core/node/test_utils/src/lib.rs index b9984b782111..7832e3c6dfd4 100644 --- a/core/node/test_utils/src/lib.rs +++ b/core/node/test_utils/src/lib.rs @@ -45,6 +45,7 @@ pub fn create_l2_block(number: u32) -> L2BlockHeader { virtual_blocks: 1, gas_limit: 0, logs_bloom: Default::default(), + pubdata_params: Default::default(), } } @@ -96,6 +97,10 @@ pub fn create_l1_batch_metadata(number: u32) -> L1BatchMetadata { events_queue_commitment: Some(H256::zero()), bootloader_initial_content_commitment: Some(H256::zero()), state_diffs_compressed: vec![], + state_diff_hash: Some(H256::zero()), + local_root: Some(H256::zero()), + aggregation_root: Some(H256::zero()), + da_inclusion_data: Some(vec![]), } } @@ -126,6 +131,9 @@ pub fn l1_batch_metadata_to_commitment_artifacts( } _ => None, }, + local_root: metadata.local_root.unwrap(), + aggregation_root: metadata.aggregation_root.unwrap(), + state_diff_hash: metadata.state_diff_hash.unwrap(), } } @@ -211,6 +219,7 @@ impl Snapshot { virtual_blocks: 1, gas_limit: 0, logs_bloom: Default::default(), + pubdata_params: Default::default(), }; Snapshot { l1_batch, diff --git a/core/node/vm_runner/src/tests/output_handler.rs b/core/node/vm_runner/src/tests/output_handler.rs index 1bf30effdbe5..131089d0f796 100644 --- a/core/node/vm_runner/src/tests/output_handler.rs +++ b/core/node/vm_runner/src/tests/output_handler.rs @@ -71,6 +71,7 @@ impl OutputHandlerTester { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: 0, chain_id: Default::default(), + pubdata_params: Default::default(), }; let mut output_handler = self diff --git a/core/tests/vm-benchmark/src/vm.rs b/core/tests/vm-benchmark/src/vm.rs index f4a0010f29eb..410c0e071b49 100644 --- a/core/tests/vm-benchmark/src/vm.rs +++ b/core/tests/vm-benchmark/src/vm.rs @@ -143,6 +143,7 @@ impl Default for BenchmarkingVm { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::from(270), + pubdata_params: Default::default(), }, &STORAGE, )) diff --git a/etc/multivm_bootloaders/vm_gateway/commit b/etc/multivm_bootloaders/vm_gateway/commit new file mode 100644 index 000000000000..a3547f577034 --- /dev/null +++ b/etc/multivm_bootloaders/vm_gateway/commit @@ -0,0 +1 @@ +a8bf0ca28d43899882a2e123e2fdf1379f0fd656 diff --git a/etc/multivm_bootloaders/vm_gateway/fee_estimate.yul/fee_estimate.yul.zbin b/etc/multivm_bootloaders/vm_gateway/fee_estimate.yul/fee_estimate.yul.zbin new file mode 100644 index 0000000000000000000000000000000000000000..fb6017f69cf03b963d490070a1d33555531e5d30 GIT binary patch literal 75296 zcmeHw3w&Hhb@$wT>8@-`vTVtcELm4XNpK-xnA?A$)a!QUbK}14;`8VgoJjQeNdz9xeoE3*}h|B!IvFIcMfRX7AnA zYF7@wekl3*?wvDpX6DS9^P0z1DMf!N)vup;q#f0ZM=8A~HK~-_nO@`Es~n`PO<#+D z9mjL-QEG9kQYSCN`-!Z|(6f}0XCW<5uSK3fo_Px3vpIfumpLVMpHdxPQ|c&{JMNhD z4o?3MPG1Q~P7QFqDLj=rCHbfU>S}Ib8tK&TEW`IJRR%tHIhtBTDyqm_pnC9ZVR%MO zW-iCuuv){<4XVJ;-D)d6-A+>u?Oo3O_NYA|jx$U2IN^Ay4y1QE9nOc*okbwsNar>W zeap0~KICxHJMeFxqtZ8WyB(%i$>|U}st)J1jJE^y^y#RMF&(KN)F0(`Q#(4Z^q$0c zmAeA^=rzl@$dFsjZ zOsA=SM>!qpPJUk|>CQ6A=M z`79?$ju73Y9jgg%=jOzDCi5VG+w%-;g?Sjj?RoY)HSqUaXXvrWYQJ&s~Sv z0=c;Om0Et6Al-QWrFh-|&T@0{S2cW=;ce6)9v7waEz|i#-a`+xX*}sRYPb88)Echm zry9=*#^VNfWS+X`rwWvB3CMAj`1jNjjVHT=@tmL9%5ZQX!5zhTKoqMz>vG)gCE#_= zcPdACRv;hgA$sJPp8dHJ&5zV@bki0OLV&^6b>`3Bt*=}BlSnOB#i9MQ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uC(S%c?K_>*;I1x#Gf|*R}6DG&cO~ MqpQDmPU|E84^E!&RR910 literal 0 HcmV?d00001 diff --git a/etc/multivm_bootloaders/vm_gateway/gas_test.yul/gas_test.yul.zbin b/etc/multivm_bootloaders/vm_gateway/gas_test.yul/gas_test.yul.zbin new file mode 100644 index 0000000000000000000000000000000000000000..c1726d8301ff2ffc1e8dc3dfdf1552926080a3a3 GIT binary patch literal 71392 zcmeHw3wT{eb?)r*+FO<_$+9I&vSe=&hv1eF+a#oN5^_##ISDmHj-908Wt~{Zwy-V9 zlI++4ief@iXrL)j0!a!=NJ%I(q$H(nNQix*J_4&C{`K;XgIk}>-%nKP`ipx*o z9_8IT)4sY(sg`3(-AMJ7o1uQ-d7huYji0BvCd1Py_1mhIN-~}`N)_q3lk(MDQ17mk zkAAC94s7zBE_$9`r~0UH=6uw{pPQa0{CB0tsGL$8HmI)wpQC(rkxJ7O#@mgbYw0G% z^;+(bal7|{bOm~@{LFc3C9XLxpHYLEixst))%_a4y;7T13txxSI=Z@dIJ!Q@znt!6 z{AkCSLcc&)Kh=Wg_d6}lrFp@j?Wpulri#P!Gw8I)yr~xF zj~Q-QWqZQ*&?nm_V2d(FSZu+Ynl6ZbC&U#qj~r92+xzBk^U;`$Nz`z&}C_4^|5={Vf| zSQY%Bn_3&GUn72^yV{4*bP0bfI;i=tgYXg&QV#fBfkOJ;Ig9viG3NdR^KY*kp$oXk zX;HTVKBVD!XAJzB0|t>R2p-{cKMt;doGd;|%gG>SoB2AG(r}ie#nT!-#qcH6A?8P= z%iRe%Av_<}<)*pZ;u+;0O-nhneIxbzc$(T<0Cvb2r!9g5@CoOnBo?FM|eovP>nWJ)TC@1ozayi1Mx^sg>=hT#|+sPef`o5Ft zmqm#N>0i#}@~gc;(p%~wJx>>-KGDr@P^2$V{9T~9YP?g!RqiP3LFK+n>kGyAj;r!i z&vD0C58kKeEA38^ygCZ~c{9O1jn_Tm{2k$UZ*fQu_}-wj=Xu;O1vuJOk4U?X=$}J$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(I*zH8I%KfikGpS} zr)VS?Yli8}L26M6{F40ihacfgXm+OKfrV_RW70$2K2DSieofIo>!qx_dO_*WI+I z`~cpybC-`R?#H!%yv65b96YFBw3wYoQm+`h4B8EIM{?Z{jE+rTbb-zohR@c1II?LY zwBDPocl&jronXBWJ^6_bTS=8(BjYRRKY2Rd*24&K?DN))k4+a3k+)6@WvBX=9Bds~ zQlW6V0{rT+J!9iHkI}Sg`tZc;(Y+zRb=&s!Th^`HzIDUKZ55DNVE7+iiTItb!>7uJ zXH;RTtol@i^6s~qs9>P{_>vz8h<3t($@4W~eosWkL_r2m^<=ylf5Kt5^yjz)SDH2wDT-S_A- z?t}k$-P)t~e(v_aSunYEPxt2AHa>FVsfcEgxCT52($( z(25kIm>z{6H(l5_ArV(`=6>hiPyaBcn4hHEKOtyBIJ7U=3EJYE|f~!Jtg|*HK=k4X4QOqpLq;5(EAk z60uu5#r;I4r6yyEC+4HO3Zs*OWcVXj3IKl){A1CHX4pDinB)LdU_qJ?l()a-a6fQY&-co~lXnh&C|fQAV3em^mX2~jz*;K6%QCk@*>C)?>xump{9|m( zEc=JG^s;|CG6D4iNuMt3O3lUt=k+Du_-5(g&g>GAl&{~{en+H!xVMoEc-gRH$COyKRnDI^gS>@+8rGn@5csZz2zjfu->#ka}eNBGbn#;Fe zwJyH}KR0X$${%?peZQvkAEGG*{`}ydzVZ2=%H4A8Pi}c^>0kZeYyS`P CQ2T@c literal 0 HcmV?d00001 diff --git a/etc/multivm_bootloaders/vm_gateway/proved_batch.yul/proved_batch.yul.zbin b/etc/multivm_bootloaders/vm_gateway/proved_batch.yul/proved_batch.yul.zbin new file mode 100644 index 0000000000000000000000000000000000000000..2506ce065d74fc6a610beac3843b6c147c63cf10 GIT binary patch literal 71904 zcmeHw3w#|%b@%Lj?aHzxS+-|?Zd zudeTv!;c@zFW$R5GiPSb`<$7bRT)Kp8P%t+xMUsGgUfJsZDv9#_wMXk=XT}b$-3p zC+n*_l#o%6I4&B_3PEw0MAjr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6NeJBX5kPHO&<(z5`G<;PLCfC?N6Uygn!m0@n03Q9*l(CikQI; zO5_KuI;&s!cko?eu0K~W<+Clnv=8Ht(dntmzFD-a;+6!Xfbu(7x8l{UU;KRMLVCn zrF0p7Zrf&BV+Y~2%TnbZ*_G)_CXl|Fp7aOKg9MFL5Qtw8tZ830n$G{b_NI$C94fKD z(S@jRc&Wd>(|u@VIgpg(sx{WnewEy+n{~ImXCe*JxhLh+7+AMRQ%aXp8UkKHmtdI)3(db{`;rA@c#qCLjL~% literal 0 HcmV?d00001 diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 4ea83108a42e..eb5297ef9637 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -7708,6 +7708,7 @@ dependencies = [ "zk_evm 0.141.0", "zk_evm 0.150.5", "zksync_contracts", + "zksync_mini_merkle_tree", "zksync_system_constants", "zksync_types", "zksync_utils", diff --git a/zk_toolbox/crates/config/src/contracts.rs b/zk_toolbox/crates/config/src/contracts.rs index 8296aa188527..a8fd23d8b3ec 100644 --- a/zk_toolbox/crates/config/src/contracts.rs +++ b/zk_toolbox/crates/config/src/contracts.rs @@ -85,6 +85,7 @@ impl ContractsConfig { ) -> anyhow::Result<()> { self.bridges.shared.l2_address = Some(initialize_bridges_output.l2_shared_bridge_proxy); self.bridges.erc20.l2_address = Some(initialize_bridges_output.l2_shared_bridge_proxy); + self.l2.legacy_shared_bridge_addr = Some(initialize_bridges_output.l2_shared_bridge_proxy); Ok(()) } @@ -159,4 +160,5 @@ pub struct L2Contracts { pub default_l2_upgrader: Address, pub consensus_registry: Option

, pub multicall3: Option
, + pub legacy_shared_bridge_addr: Option
, } From 48fd0e645e1dcc702fb97443ab30ef212324df18 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Thu, 3 Oct 2024 12:26:44 +0300 Subject: [PATCH 02/23] fix test --- core/lib/types/src/commitment/tests/post_gateway_test.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/lib/types/src/commitment/tests/post_gateway_test.json b/core/lib/types/src/commitment/tests/post_gateway_test.json index a421bd41f95f..9de441b65946 100644 --- a/core/lib/types/src/commitment/tests/post_gateway_test.json +++ b/core/lib/types/src/commitment/tests/post_gateway_test.json @@ -9,7 +9,7 @@ "PostBoojum": { "common": { "l2_l1_logs_merkle_root": "0x38eaeef3afe69b6f6b2fa22c92da8137f1e405a1e1861b7de7cfa30c7d7462dd", - "protocol_version": "Version25" + "protocol_version": "Version26" }, "system_logs_linear_hash": "0xe8460ce1ed47b77cfee3cadf803aa089c144c506ea2bdd358a6a38ff2c7bc8e3", "state_diffs_compressed": [ @@ -64,7 +64,7 @@ "zkporter_is_available": false, "bootloader_code_hash": "0x010008c753336bc8d1ddca235602b9f31d346412b2d463cd342899f7bfb73baf", "default_aa_code_hash": "0x0100055d760f11a3d737e7fd1816e600a4cd874a9f17f7a225d1f1c537c51a1e", - "protocol_version": "Version25" + "protocol_version": "Version26" }, "pass_through_data": { "shared_states": [ @@ -311,7 +311,7 @@ "rollup_root_hash": "0x0332d2acc43785a44b2b84fc010372c8f3e4ff4d0ca5f312de142ffe74189500", "bootloader_code_hash": "0x010008c753336bc8d1ddca235602b9f31d346412b2d463cd342899f7bfb73baf", "default_aa_code_hash": "0x0100055d760f11a3d737e7fd1816e600a4cd874a9f17f7a225d1f1c537c51a1e", - "protocol_version": "Version25" + "protocol_version": "Version26" }, "system_logs": [ { From aff2e98d7a6badcd216ec20d3458f6e6b5857a6a Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Mon, 7 Oct 2024 14:58:58 +0300 Subject: [PATCH 03/23] nits --- Cargo.lock | 1 + core/lib/constants/src/lib.rs | 1 + core/lib/constants/src/message_root.rs | 5 + .../vm_latest/bootloader_state/utils.rs | 11 +- .../vm_latest/types/internals/pubdata.rs | 64 +++--- core/lib/types/src/commitment/mod.rs | 58 +++-- .../tests/post_boojum_1_4_1_test.json | 32 +-- .../tests/post_boojum_1_4_2_test.json | 32 +-- .../tests/post_boojum_1_5_0_test.json | 200 ++++++++++++------ .../commitment/tests/post_gateway_test.json | 200 ++++++++++++------ core/lib/types/src/l2_to_l1_log.rs | 7 +- core/node/commitment_generator/Cargo.toml | 1 + core/node/commitment_generator/src/lib.rs | 39 ++-- core/node/commitment_generator/src/utils.rs | 17 +- .../src/request_processor.rs | 7 +- 15 files changed, 406 insertions(+), 269 deletions(-) create mode 100644 core/lib/constants/src/message_root.rs diff --git a/Cargo.lock b/Cargo.lock index a92778a3afe7..b1ead7e44bd1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9633,6 +9633,7 @@ dependencies = [ "zksync_multivm", "zksync_node_genesis", "zksync_node_test_utils", + "zksync_system_constants", "zksync_types", "zksync_utils", "zksync_web3_decl", diff --git a/core/lib/constants/src/lib.rs b/core/lib/constants/src/lib.rs index 6aab79ad71f3..30ae6a7b582a 100644 --- a/core/lib/constants/src/lib.rs +++ b/core/lib/constants/src/lib.rs @@ -3,6 +3,7 @@ pub mod contracts; pub mod crypto; pub mod ethereum; pub mod fees; +pub mod message_root; pub mod system_context; pub mod system_logs; pub mod trusted_slots; diff --git a/core/lib/constants/src/message_root.rs b/core/lib/constants/src/message_root.rs new file mode 100644 index 000000000000..a8f4a034fb99 --- /dev/null +++ b/core/lib/constants/src/message_root.rs @@ -0,0 +1,5 @@ +// Position of `FullTree::_height` in `MessageRoot`'s storage layout. +pub const AGG_TREE_HEIGHT_KEY: usize = 3; + +// Position of `FullTree::nodes` in `MessageRoot`'s storage layout. +pub const AGG_TREE_NODES_KEY: usize = 5; diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs index 9f2ad19b089b..498071220568 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs @@ -136,10 +136,13 @@ pub(crate) fn get_encoded_pubdata( pubdata_params: PubdataParams, l2_version: bool, ) -> Vec { - let pubdata_bytes: Vec = if pubdata_params.pubdata_type == L1BatchCommitmentMode::Rollup { - RollupPubdataBuilder.build_pubdata(pubdata_information, l2_version) - } else { - ValidiumPubdataBuilder.build_pubdata(pubdata_information, l2_version) + let pubdata_bytes: Vec = match pubdata_params.pubdata_type { + L1BatchCommitmentMode::Rollup => { + RollupPubdataBuilder.build_pubdata(pubdata_information, l2_version) + } + L1BatchCommitmentMode::Validium => { + ValidiumPubdataBuilder.build_pubdata(pubdata_information, l2_version) + } }; if l2_version { diff --git a/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs index a6252ca62fa5..b39e280dc33e 100644 --- a/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs +++ b/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs @@ -1,3 +1,4 @@ +use ethabi::ParamType; use zksync_mini_merkle_tree::MiniMerkleTree; use zksync_types::{ ethabi::{self, Token}, @@ -92,10 +93,10 @@ impl PubdataBuilder for RollupPubdataBuilder { } = input; if l2_version { - let chained_log_hash = build_chained_log_hash(user_logs.clone()); - let log_root_hash = build_logs_root(user_logs.clone(), l2_to_l1_logs_tree_size); - let chained_msg_hash = build_chained_message_hash(l2_to_l1_messages.clone()); - let chained_bytecodes_hash = build_chained_bytecode_hash(published_bytecodes.clone()); + let chained_log_hash = build_chained_log_hash(&user_logs); + let log_root_hash = build_logs_root(&user_logs, l2_to_l1_logs_tree_size); + let chained_msg_hash = build_chained_message_hash(&l2_to_l1_messages); + let chained_bytecodes_hash = build_chained_bytecode_hash(&published_bytecodes); l2_da_header.push(Token::FixedBytes(chained_log_hash)); l2_da_header.push(Token::FixedBytes(log_root_hash)); @@ -103,7 +104,7 @@ impl PubdataBuilder for RollupPubdataBuilder { l2_da_header.push(Token::FixedBytes(chained_bytecodes_hash)); } - l1_messenger_pubdata.extend(encode_user_logs(user_logs)); + l1_messenger_pubdata.extend(encode_user_logs(&user_logs)); // Encoding L2->L1 messages // Format: `[(numberOfMessages as u32) || (messages[1].len() as u32) || messages[1] || ... || (messages[n].len() as u32) || messages[n]]` @@ -131,11 +132,20 @@ impl PubdataBuilder for RollupPubdataBuilder { } // Selector of `IL2DAValidator::validatePubdata`. - let func_selector = vec![0x89, 0xf9, 0xa0, 0x72]; + let func_selector = ethabi::short_signature( + "validatePubdata", + &[ + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::Bytes, + ], + ); l2_da_header.push(ethabi::Token::Bytes(l1_messenger_pubdata)); - l1_messenger_pubdata = [func_selector, ethabi::encode(&l2_da_header)] + l1_messenger_pubdata = [func_selector.to_vec(), ethabi::encode(&l2_da_header)] .concat() .to_vec(); } @@ -161,25 +171,34 @@ impl PubdataBuilder for ValidiumPubdataBuilder { } = input; if l2_version { - let chained_log_hash = build_chained_log_hash(user_logs.clone()); - let log_root_hash = build_logs_root(user_logs.clone(), l2_to_l1_logs_tree_size); - let chained_msg_hash = build_chained_message_hash(l2_to_l1_messages.clone()); - let chained_bytecodes_hash = build_chained_bytecode_hash(published_bytecodes.clone()); + let chained_log_hash = build_chained_log_hash(&user_logs); + let log_root_hash = build_logs_root(&user_logs, l2_to_l1_logs_tree_size); + let chained_msg_hash = build_chained_message_hash(&l2_to_l1_messages); + let chained_bytecodes_hash = build_chained_bytecode_hash(&published_bytecodes); l2_da_header.push(Token::FixedBytes(chained_log_hash)); l2_da_header.push(Token::FixedBytes(log_root_hash)); l2_da_header.push(Token::FixedBytes(chained_msg_hash)); l2_da_header.push(Token::FixedBytes(chained_bytecodes_hash)); } - l1_messenger_pubdata.extend(encode_user_logs(user_logs)); + l1_messenger_pubdata.extend(encode_user_logs(&user_logs)); if l2_version { // Selector of `IL2DAValidator::validatePubdata`. - let func_selector = vec![0x89, 0xf9, 0xa0, 0x72]; + let func_selector = ethabi::short_signature( + "validatePubdata", + &[ + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::Bytes, + ], + ); l2_da_header.push(ethabi::Token::Bytes(l1_messenger_pubdata)); - [func_selector, ethabi::encode(&l2_da_header)] + [func_selector.to_vec(), ethabi::encode(&l2_da_header)] .concat() .to_vec() } else { @@ -193,7 +212,7 @@ impl PubdataBuilder for ValidiumPubdataBuilder { } } -fn build_chained_log_hash(user_logs: Vec) -> Vec { +fn build_chained_log_hash(user_logs: &[L1MessengerL2ToL1Log]) -> Vec { let mut chained_log_hash = vec![0u8; 32]; for log in user_logs { @@ -206,10 +225,7 @@ fn build_chained_log_hash(user_logs: Vec) -> Vec { chained_log_hash } -fn build_logs_root( - user_logs: Vec, - l2_to_l1_logs_tree_size: usize, -) -> Vec { +fn build_logs_root(user_logs: &[L1MessengerL2ToL1Log], l2_to_l1_logs_tree_size: usize) -> Vec { let logs = user_logs.iter().map(|log| { let encoded = log.packed_encoding(); let mut slice = [0u8; 88]; @@ -222,11 +238,11 @@ fn build_logs_root( .to_vec() } -fn build_chained_message_hash(l2_to_l1_messages: Vec>) -> Vec { +fn build_chained_message_hash(l2_to_l1_messages: &[Vec]) -> Vec { let mut chained_msg_hash = vec![0u8; 32]; for msg in l2_to_l1_messages { - let hash = keccak256(&msg); + let hash = keccak256(msg); chained_msg_hash = keccak256(&[chained_msg_hash, hash.to_vec()].concat()).to_vec(); } @@ -234,11 +250,11 @@ fn build_chained_message_hash(l2_to_l1_messages: Vec>) -> Vec { chained_msg_hash } -fn build_chained_bytecode_hash(published_bytecodes: Vec>) -> Vec { +fn build_chained_bytecode_hash(published_bytecodes: &[Vec]) -> Vec { let mut chained_bytecode_hash = vec![0u8; 32]; for bytecode in published_bytecodes { - let hash = hash_bytecode(&bytecode).to_fixed_bytes(); + let hash = hash_bytecode(bytecode).to_fixed_bytes(); chained_bytecode_hash = keccak256(&[chained_bytecode_hash, hash.to_vec()].concat()).to_vec(); @@ -247,7 +263,7 @@ fn build_chained_bytecode_hash(published_bytecodes: Vec>) -> Vec { chained_bytecode_hash } -fn encode_user_logs(user_logs: Vec) -> Vec { +fn encode_user_logs(user_logs: &[L1MessengerL2ToL1Log]) -> Vec { // Encoding user L2->L1 logs. // Format: `[(numberOfL2ToL1Logs as u32) || l2tol1logs[1] || ... || l2tol1logs[n]]` let mut result = vec![]; diff --git a/core/lib/types/src/commitment/mod.rs b/core/lib/types/src/commitment/mod.rs index 544d21ba7d26..6803e46e1af2 100644 --- a/core/lib/types/src/commitment/mod.rs +++ b/core/lib/types/src/commitment/mod.rs @@ -276,6 +276,13 @@ pub struct L1BatchAuxiliaryCommonOutput { protocol_version: ProtocolVersionId, } +#[derive(Debug, Default, Clone, Copy, Eq, PartialEq)] +#[cfg_attr(test, derive(Serialize, Deserialize))] +pub struct BlobHash { + pub commitment: H256, + pub linear_hash: H256, +} + /// Block Output produced by Virtual Machine #[derive(Debug, Clone, Eq, PartialEq)] #[cfg_attr(test, derive(Serialize, Deserialize))] @@ -294,8 +301,7 @@ pub enum L1BatchAuxiliaryOutput { state_diffs_compressed: Vec, state_diffs_hash: H256, aux_commitments: AuxCommitments, - blob_linear_hashes: Vec, - blob_commitments: Vec, + blob_hashes: Vec, aggregated_root: H256, local_root: H256, }, @@ -346,8 +352,7 @@ impl L1BatchAuxiliaryOutput { system_logs, state_diffs, aux_commitments, - blob_commitments, - blob_linear_hashes, + blob_hashes, aggregated_root, } => { let l2_l1_logs_compressed = serialize_commitments(&common_input.l2_to_l1_logs); @@ -397,6 +402,8 @@ impl L1BatchAuxiliaryOutput { &common_input.protocol_version, &system_logs, ); + let blob_linear_hashes: Vec<_> = + blob_hashes.iter().map(|b| b.linear_hash).collect(); assert_eq!( blob_linear_hashes, blob_linear_hashes_from_logs, "Blob linear hashes mismatch" @@ -416,20 +423,13 @@ impl L1BatchAuxiliaryOutput { ); } - assert_eq!( - blob_linear_hashes.len(), - blob_commitments.len(), - "Blob linear hashes and commitments have different lengths" - ); - Self::PostBoojum { common: common_output, system_logs_linear_hash, state_diffs_compressed, state_diffs_hash, aux_commitments, - blob_linear_hashes, - blob_commitments, + blob_hashes, local_root, aggregated_root, } @@ -437,14 +437,14 @@ impl L1BatchAuxiliaryOutput { } } - pub fn get_local_root(&self) -> H256 { + pub fn local_root(&self) -> H256 { match self { Self::PreBoojum { common, .. } => common.l2_l1_logs_merkle_root, Self::PostBoojum { local_root, .. } => *local_root, } } - pub fn get_aggregated_root(&self) -> H256 { + pub fn aggregated_root(&self) -> H256 { match self { Self::PreBoojum { .. } => H256::zero(), Self::PostBoojum { @@ -453,7 +453,7 @@ impl L1BatchAuxiliaryOutput { } } - pub fn get_state_diff_hash(&self) -> H256 { + pub fn state_diff_hash(&self) -> H256 { match self { Self::PreBoojum { .. } => H256::zero(), Self::PostBoojum { @@ -482,8 +482,7 @@ impl L1BatchAuxiliaryOutput { system_logs_linear_hash, state_diffs_hash, aux_commitments, - blob_linear_hashes, - blob_commitments, + blob_hashes, .. } => { result.extend(system_logs_linear_hash.as_bytes()); @@ -495,9 +494,9 @@ impl L1BatchAuxiliaryOutput { ); result.extend(aux_commitments.events_queue_commitment.as_bytes()); - for i in 0..blob_commitments.len() { - result.extend(blob_linear_hashes[i].as_bytes()); - result.extend(blob_commitments[i].as_bytes()); + for b in blob_hashes { + result.extend(b.linear_hash.as_bytes()); + result.extend(b.commitment.as_bytes()); } } } @@ -690,9 +689,9 @@ impl L1BatchCommitment { aux_commitments: self.aux_commitments(), compressed_initial_writes, compressed_repeated_writes, - local_root: self.auxiliary_output.get_local_root(), - aggregation_root: self.auxiliary_output.get_aggregated_root(), - state_diff_hash: self.auxiliary_output.get_state_diff_hash(), + local_root: self.auxiliary_output.local_root(), + aggregation_root: self.auxiliary_output.aggregated_root(), + state_diff_hash: self.auxiliary_output.state_diff_hash(), } } } @@ -728,8 +727,7 @@ pub enum CommitmentInput { system_logs: Vec, state_diffs: Vec, aux_commitments: AuxCommitments, - blob_commitments: Vec, - blob_linear_hashes: Vec, + blob_hashes: Vec, aggregated_root: H256, }, } @@ -771,15 +769,9 @@ impl CommitmentInput { events_queue_commitment: H256::zero(), bootloader_initial_content_commitment: H256::zero(), }, - blob_commitments: { + blob_hashes: { let num_blobs = num_blobs_required(&protocol_version); - - vec![H256::zero(); num_blobs] - }, - blob_linear_hashes: { - let num_blobs = num_blobs_required(&protocol_version); - - vec![H256::zero(); num_blobs] + vec![Default::default(); num_blobs] }, aggregated_root: H256::zero(), } diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json b/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json index 87f7c9e51ea2..57b2f0845dc7 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json @@ -190,13 +190,15 @@ "events_queue_commitment": "0x6193a5098eb140796387bdf40700a3855eeb010474b5478f30bf917172c67883", "bootloader_initial_content_commitment": "0xf031b4491c37f20516c4ebf428f4765156409f67089e64772f4106fd2d9f3351" }, - "blob_commitments": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ], - "blob_linear_hashes": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" + "blob_hashes": [ + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } ], "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000" } @@ -253,13 +255,15 @@ "events_queue_commitment": "0x6193a5098eb140796387bdf40700a3855eeb010474b5478f30bf917172c67883", "bootloader_initial_content_commitment": "0xf031b4491c37f20516c4ebf428f4765156409f67089e64772f4106fd2d9f3351" }, - "blob_linear_hashes": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ], - "blob_commitments": [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" + "blob_hashes": [ + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } ], "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000", "local_root": "0xe52d57bd64cabf6c588b30365512da2bf10912c106e7a06483b236d05ac4037e" diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json b/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json index 4ae5b361b7cb..698c592bba4c 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json @@ -206,13 +206,15 @@ "events_queue_commitment": "0x6193a5098eb140796387bdf40700a3855eeb010474b5478f30bf917172c67883", "bootloader_initial_content_commitment": "0xf031b4491c37f20516c4ebf428f4765156409f67089e64772f4106fd2d9f3351" }, - "blob_commitments": [ - "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x0000000000000000000000000000000000000000000000000000000000000002" - ], - "blob_linear_hashes": [ - "0x0000000000000000000000000000000000000000000000000000000000000003", - "0x0000000000000000000000000000000000000000000000000000000000000004" + "blob_hashes": [ + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000001", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000003" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000002", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000004" + } ], "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000" } @@ -269,13 +271,15 @@ "events_queue_commitment": "0x6193a5098eb140796387bdf40700a3855eeb010474b5478f30bf917172c67883", "bootloader_initial_content_commitment": "0xf031b4491c37f20516c4ebf428f4765156409f67089e64772f4106fd2d9f3351" }, - "blob_linear_hashes": [ - "0x0000000000000000000000000000000000000000000000000000000000000003", - "0x0000000000000000000000000000000000000000000000000000000000000004" - ], - "blob_commitments": [ - "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x0000000000000000000000000000000000000000000000000000000000000002" + "blob_hashes": [ + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000001", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000003" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000002", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000004" + } ], "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000", "local_root": "0x0b6e1ad4643cc2bee06b5e173184ec822d80826e5720f5715172898350433299" diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json b/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json index 78f7afb372d2..1979a02aa189 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json @@ -238,41 +238,71 @@ "events_queue_commitment": "0x6193a5098eb140796387bdf40700a3855eeb010474b5478f30bf917172c67883", "bootloader_initial_content_commitment": "0xf031b4491c37f20516c4ebf428f4765156409f67089e64772f4106fd2d9f3351" }, - "blob_commitments": [ - "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x0000000000000000000000000000000000000000000000000000000000000002", - "0x0000000000000000000000000000000000000000000000000000000000000003", - "0x0000000000000000000000000000000000000000000000000000000000000004", - "0x0000000000000000000000000000000000000000000000000000000000000005", - "0x0000000000000000000000000000000000000000000000000000000000000006", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ], - "blob_linear_hashes": [ - "0x0000000000000000000000000000000000000000000000000000000000000003", - "0x0000000000000000000000000000000000000000000000000000000000000004", - "0x0000000000000000000000000000000000000000000000000000000000000005", - "0x0000000000000000000000000000000000000000000000000000000000000006", - "0x0000000000000000000000000000000000000000000000000000000000000007", - "0x0000000000000000000000000000000000000000000000000000000000000008", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" + "blob_hashes": [ + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000001", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000003" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000002", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000004" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000003", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000005" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000004", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000006" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000005", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000007" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000006", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000008" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } ], "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000" } @@ -329,41 +359,71 @@ "events_queue_commitment": "0x6193a5098eb140796387bdf40700a3855eeb010474b5478f30bf917172c67883", "bootloader_initial_content_commitment": "0xf031b4491c37f20516c4ebf428f4765156409f67089e64772f4106fd2d9f3351" }, - "blob_linear_hashes": [ - "0x0000000000000000000000000000000000000000000000000000000000000003", - "0x0000000000000000000000000000000000000000000000000000000000000004", - "0x0000000000000000000000000000000000000000000000000000000000000005", - "0x0000000000000000000000000000000000000000000000000000000000000006", - "0x0000000000000000000000000000000000000000000000000000000000000007", - "0x0000000000000000000000000000000000000000000000000000000000000008", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ], - "blob_commitments": [ - "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x0000000000000000000000000000000000000000000000000000000000000002", - "0x0000000000000000000000000000000000000000000000000000000000000003", - "0x0000000000000000000000000000000000000000000000000000000000000004", - "0x0000000000000000000000000000000000000000000000000000000000000005", - "0x0000000000000000000000000000000000000000000000000000000000000006", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" + "blob_hashes": [ + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000001", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000003" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000002", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000004" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000003", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000005" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000004", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000006" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000005", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000007" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000006", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000008" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } ], "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000", "local_root": "0x30ba728b1aac22b122de4f32589dd2711da264412cb90e35bf7b1f735dd357ff" diff --git a/core/lib/types/src/commitment/tests/post_gateway_test.json b/core/lib/types/src/commitment/tests/post_gateway_test.json index 9de441b65946..9a197116f7f2 100644 --- a/core/lib/types/src/commitment/tests/post_gateway_test.json +++ b/core/lib/types/src/commitment/tests/post_gateway_test.json @@ -20,41 +20,71 @@ "events_queue_commitment": "0xec82208c87a937d88768a0067b2a80f0525eca8288dad2cf96cf8bbe6a1aa565", "bootloader_initial_content_commitment": "0x97df88dcecbcd29b49773c042cdee7a44c57a741e64913fff5aa1b3484232f28" }, - "blob_linear_hashes": [ - "0xff4feb4bef9401731ab9db3626c2e015baa6880d7b1c4382d03b30da3a0fd75e", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ], - "blob_commitments": [ - "0xf840cf3f6b7dc92729b2b9ef3b399e7b896d553b746362fe81c4eb911013570d", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" + "blob_hashes": [ + { + "commitment": "0xf840cf3f6b7dc92729b2b9ef3b399e7b896d553b746362fe81c4eb911013570d", + "linear_hash": "0xff4feb4bef9401731ab9db3626c2e015baa6880d7b1c4382d03b30da3a0fd75e" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } ], "aggregated_root": "0x0924928c1377a6cf24c39c2d46f8eb9df23e811b26dc3527e548396fd4e173b1", "local_root": "0xd4790efa9052ea67dcb473de870e3522e2fc340374e6293ad4646fde312c8c76" @@ -1875,41 +1905,71 @@ "events_queue_commitment": "0xec82208c87a937d88768a0067b2a80f0525eca8288dad2cf96cf8bbe6a1aa565", "bootloader_initial_content_commitment": "0x97df88dcecbcd29b49773c042cdee7a44c57a741e64913fff5aa1b3484232f28" }, - "blob_commitments": [ - "0xf840cf3f6b7dc92729b2b9ef3b399e7b896d553b746362fe81c4eb911013570d", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ], - "blob_linear_hashes": [ - "0xff4feb4bef9401731ab9db3626c2e015baa6880d7b1c4382d03b30da3a0fd75e", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" + "blob_hashes": [ + { + "commitment": "0xf840cf3f6b7dc92729b2b9ef3b399e7b896d553b746362fe81c4eb911013570d", + "linear_hash": "0xff4feb4bef9401731ab9db3626c2e015baa6880d7b1c4382d03b30da3a0fd75e" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } ], "aggregated_root": "0x0924928c1377a6cf24c39c2d46f8eb9df23e811b26dc3527e548396fd4e173b1" } diff --git a/core/lib/types/src/l2_to_l1_log.rs b/core/lib/types/src/l2_to_l1_log.rs index 05b27c421ef0..957cfa9a1a6a 100644 --- a/core/lib/types/src/l2_to_l1_log.rs +++ b/core/lib/types/src/l2_to_l1_log.rs @@ -84,9 +84,10 @@ pub fn parse_system_logs_for_blob_hashes_pre_gateway( protocol_version: &ProtocolVersionId, system_logs: &[SystemL2ToL1Log], ) -> Vec { - if !protocol_version.is_pre_gateway() { - panic!("Cannot parse blob linear hashes from system logs for post gateway"); - } + assert!( + protocol_version.is_pre_gateway(), + "Cannot parse blob linear hashes from system logs for post gateway" + ); let num_required_blobs = num_blobs_required(protocol_version) as u32; let num_created_blobs = num_blobs_created(protocol_version) as u32; diff --git a/core/node/commitment_generator/Cargo.toml b/core/node/commitment_generator/Cargo.toml index 5ec8410124fc..1f4645414cbd 100644 --- a/core/node/commitment_generator/Cargo.toml +++ b/core/node/commitment_generator/Cargo.toml @@ -20,6 +20,7 @@ zksync_utils.workspace = true zksync_eth_client.workspace = true zksync_contracts.workspace = true zksync_multivm.workspace = true +zksync_system_constants.workspace = true circuit_sequencer_api_1_4_0.workspace = true circuit_sequencer_api_1_4_1.workspace = true circuit_sequencer_api_1_5_0.workspace = true diff --git a/core/node/commitment_generator/src/lib.rs b/core/node/commitment_generator/src/lib.rs index f16714e4ebf5..0ba7f128f111 100644 --- a/core/node/commitment_generator/src/lib.rs +++ b/core/node/commitment_generator/src/lib.rs @@ -9,7 +9,7 @@ use zksync_l1_contract_interface::i_executor::commit::kzg::pubdata_to_blob_commi use zksync_types::{ blob::num_blobs_required, commitment::{ - AuxCommitments, CommitmentCommonInput, CommitmentInput, L1BatchAuxiliaryOutput, + AuxCommitments, BlobHash, CommitmentCommonInput, CommitmentInput, L1BatchAuxiliaryOutput, L1BatchCommitment, L1BatchCommitmentArtifacts, L1BatchCommitmentMode, }, writes::{InitialStorageWrite, RepeatedStorageWrite, StateDiffRecord}, @@ -265,7 +265,7 @@ impl CommitmentGenerator { } state_diffs.sort_unstable_by_key(|rec| (rec.address, rec.key)); - let (blob_commitments, blob_linear_hashes) = if protocol_version.is_post_1_4_2() { + let blob_hashes = if protocol_version.is_post_1_4_2() { let pubdata_input = header.pubdata_input.with_context(|| { format!("`pubdata_input` is missing for L1 batch #{l1_batch_number}") })?; @@ -279,12 +279,16 @@ impl CommitmentGenerator { pubdata_input, ); - (commitments, linear_hashes) + commitments + .into_iter() + .zip(linear_hashes) + .map(|(commitment, linear_hash)| BlobHash { + commitment, + linear_hash, + }) + .collect::>() } else { - ( - vec![H256::zero(); num_blobs_required(&protocol_version)], - vec![H256::zero(); num_blobs_required(&protocol_version)], - ) + vec![Default::default(); num_blobs_required(&protocol_version)] }; let mut connection = self @@ -298,8 +302,7 @@ impl CommitmentGenerator { system_logs: header.system_logs, state_diffs, aux_commitments, - blob_commitments, - blob_linear_hashes, + blob_hashes, aggregated_root, } }; @@ -379,13 +382,8 @@ impl CommitmentGenerator { (L1BatchCommitmentMode::Rollup, _) => { // Do nothing } - ( - L1BatchCommitmentMode::Validium, - CommitmentInput::PostBoojum { - blob_commitments, .. - }, - ) => { - blob_commitments.fill(H256::zero()); + (L1BatchCommitmentMode::Validium, CommitmentInput::PostBoojum { blob_hashes, .. }) => { + blob_hashes.fill(Default::default()); } (L1BatchCommitmentMode::Validium, _) => { /* Do nothing */ } } @@ -395,14 +393,9 @@ impl CommitmentGenerator { match (self.commitment_mode, &mut commitment.auxiliary_output) { ( L1BatchCommitmentMode::Validium, - L1BatchAuxiliaryOutput::PostBoojum { - blob_linear_hashes, - blob_commitments, - .. - }, + L1BatchAuxiliaryOutput::PostBoojum { blob_hashes, .. }, ) => { - blob_linear_hashes.fill(H256::zero()); - blob_commitments.fill(H256::zero()); + blob_hashes.fill(Default::default()); } _ => { /* Do nothing */ } } diff --git a/core/node/commitment_generator/src/utils.rs b/core/node/commitment_generator/src/utils.rs index 9ed6682733c3..d405a1256a29 100644 --- a/core/node/commitment_generator/src/utils.rs +++ b/core/node/commitment_generator/src/utils.rs @@ -19,6 +19,7 @@ use zk_evm_1_5_0::{ use zksync_dal::{Connection, Core, CoreDal}; use zksync_l1_contract_interface::i_executor::commit::kzg::ZK_SYNC_BYTES_PER_BLOB; use zksync_multivm::{interface::VmEvent, utils::get_used_bootloader_memory_bytes}; +use zksync_system_constants::message_root::{AGG_TREE_HEIGHT_KEY, AGG_TREE_NODES_KEY}; use zksync_types::{ vm::VmVersion, web3::keccak256, @@ -249,9 +250,11 @@ pub(crate) fn pubdata_to_blob_linear_hashes( // Now, we need to calculate the linear hashes of the blobs. // Firstly, let's pad the pubdata to the size of the blob. if pubdata_input.len() % ZK_SYNC_BYTES_PER_BLOB != 0 { - let padding = - vec![0u8; ZK_SYNC_BYTES_PER_BLOB - pubdata_input.len() % ZK_SYNC_BYTES_PER_BLOB]; - pubdata_input.extend(padding); + pubdata_input.resize( + pubdata_input.len() + + (ZK_SYNC_BYTES_PER_BLOB - pubdata_input.len() % ZK_SYNC_BYTES_PER_BLOB), + 0, + ); } let mut result = vec![H256::zero(); blobs_required]; @@ -270,12 +273,6 @@ pub(crate) async fn read_aggregation_root( connection: &mut Connection<'_, Core>, l1_batch_number: L1BatchNumber, ) -> anyhow::Result { - // Position of `FullTree::_height` in `MessageRoot`'s storage layout. - const AGG_TREE_HEIGHT_KEY: usize = 3; - - // Position of `FullTree::nodes` in `MessageRoot`'s storage layout. - const AGG_TREE_NODES_KEY: usize = 5; - let (_, last_l2_block) = connection .blocks_dal() .get_l2_block_range_of_l1_batch(l1_batch_number) @@ -284,7 +281,7 @@ pub(crate) async fn read_aggregation_root( let agg_tree_height_slot = StorageKey::new( AccountTreeId::new(L2_MESSAGE_ROOT_ADDRESS), - u256_to_h256(AGG_TREE_HEIGHT_KEY.into()), + H256::from_low_u64_be(AGG_TREE_HEIGHT_KEY as u64), ); let agg_tree_height = connection diff --git a/core/node/proof_data_handler/src/request_processor.rs b/core/node/proof_data_handler/src/request_processor.rs index 1c4a1833766c..89304724a7c2 100644 --- a/core/node/proof_data_handler/src/request_processor.rs +++ b/core/node/proof_data_handler/src/request_processor.rs @@ -244,11 +244,10 @@ impl RequestProcessor { || bootloader_heap_initial_content != bootloader_heap_initial_content_from_prover { - let server_values = format!("events_queue_state = {events_queue_state}, bootloader_heap_initial_content = {bootloader_heap_initial_content}"); - let prover_values = format!("events_queue_state = {events_queue_state_from_prover}, bootloader_heap_initial_content = {bootloader_heap_initial_content_from_prover}"); panic!( - "Auxilary output doesn't match, server values: {} prover values: {}", - server_values, prover_values + "Auxilary output doesn't match\n\ + server values: events_queue_state = {events_queue_state}, bootloader_heap_initial_content = {bootloader_heap_initial_content}\n\ + prover values: events_queue_state = {events_queue_state_from_prover}, bootloader_heap_initial_content = {bootloader_heap_initial_content_from_prover}", ); } From cd015b6caedac6ffb880e9b41f605237f2cb0111 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Mon, 7 Oct 2024 15:08:26 +0300 Subject: [PATCH 04/23] move bridge address validation to SK persistance --- core/node/consensus/src/testonly.rs | 8 ++- .../layers/state_keeper/output_handler.rs | 41 +------------ core/node/node_sync/src/tests.rs | 4 +- core/node/state_keeper/src/io/persistence.rs | 58 ++++++++++++++++--- core/node/state_keeper/src/io/tests/mod.rs | 4 +- 5 files changed, 65 insertions(+), 50 deletions(-) diff --git a/core/node/consensus/src/testonly.rs b/core/node/consensus/src/testonly.rs index 1996928b26e0..41224f5a8f2b 100644 --- a/core/node/consensus/src/testonly.rs +++ b/core/node/consensus/src/testonly.rs @@ -571,7 +571,9 @@ impl StateKeeperRunner { self.pool.0.clone(), Some(ethabi::Address::repeat_byte(11)), 5, - ); + ) + .await + .unwrap(); let io = ExternalIO::new( self.pool.0.clone(), @@ -678,7 +680,9 @@ impl StateKeeperRunner { self.pool.0.clone(), Some(ethabi::Address::repeat_byte(11)), 5, - ); + ) + .await + .unwrap(); let tree_writes_persistence = TreeWritesPersistence::new(self.pool.0.clone()); let io = ExternalIO::new( diff --git a/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs b/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs index 7a0de6193643..1a07591c1cd9 100644 --- a/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs +++ b/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs @@ -1,12 +1,10 @@ use anyhow::Context as _; -use zksync_dal::{Core, CoreDal}; -use zksync_db_connection::connection_pool::ConnectionPool; use zksync_node_framework_derive::FromContext; use zksync_state_keeper::{ io::seal_logic::l2_block_seal_subtasks::L2BlockSealProcess, L2BlockSealerTask, OutputHandler, StateKeeperPersistence, TreeWritesPersistence, }; -use zksync_types::{Address, ProtocolVersionId}; +use zksync_types::Address; use crate::{ implementations::resources::{ @@ -89,38 +87,6 @@ impl OutputHandlerLayer { self.protective_reads_persistence_enabled = protective_reads_persistence_enabled; self } - - async fn validate_l2_legacy_shared_bridge_addr( - &self, - pool: &ConnectionPool, - ) -> Result<(), WiringError> { - let mut connection = pool.connection().await.context("Get DB connection")?; - - if let Some(l2_block) = connection - .blocks_dal() - .get_earliest_l2_block_number() - .await - .context("failed to load earliest l2 block number")? - { - let header = connection - .blocks_dal() - .get_l2_block_header(l2_block) - .await - .context("failed to load L2 block header")? - .context("missing L2 block header")?; - let protocol_version = header - .protocol_version - .unwrap_or_else(ProtocolVersionId::last_potentially_undefined); - - if protocol_version.is_pre_gateway() && self.l2_legacy_shared_bridge_addr.is_none() { - return Err(WiringError::Configuration( - "Missing `l2_legacy_shared_bridge_addr` for chain that was initialized before gateway upgrade".to_string() - )); - } - } - - Ok(()) - } } #[async_trait::async_trait] @@ -140,14 +106,13 @@ impl WiringLayer for OutputHandlerLayer { .get_custom(L2BlockSealProcess::subtasks_len()) .await .context("Get master pool")?; - self.validate_l2_legacy_shared_bridge_addr(&persistence_pool) - .await?; let (mut persistence, l2_block_sealer) = StateKeeperPersistence::new( persistence_pool.clone(), self.l2_legacy_shared_bridge_addr, self.l2_block_seal_queue_capacity, - ); + ) + .await?; if self.pre_insert_txs { persistence = persistence.with_tx_insertion(); } diff --git a/core/node/node_sync/src/tests.rs b/core/node/node_sync/src/tests.rs index 3322dbf0f9b7..6c873b03128f 100644 --- a/core/node/node_sync/src/tests.rs +++ b/core/node/node_sync/src/tests.rs @@ -107,7 +107,9 @@ impl StateKeeperHandles { let sync_state = SyncState::default(); let (persistence, l2_block_sealer) = - StateKeeperPersistence::new(pool.clone(), Some(Address::repeat_byte(1)), 5); + StateKeeperPersistence::new(pool.clone(), Some(Address::repeat_byte(1)), 5) + .await + .unwrap(); let tree_writes_persistence = TreeWritesPersistence::new(pool.clone()); let output_handler = OutputHandler::new(Box::new(persistence.with_tx_insertion())) .with_handler(Box::new(tree_writes_persistence)) diff --git a/core/node/state_keeper/src/io/persistence.rs b/core/node/state_keeper/src/io/persistence.rs index dc854c9e58f1..28dd0ba7cc2d 100644 --- a/core/node/state_keeper/src/io/persistence.rs +++ b/core/node/state_keeper/src/io/persistence.rs @@ -7,7 +7,7 @@ use async_trait::async_trait; use tokio::sync::{mpsc, oneshot}; use zksync_dal::{ConnectionPool, Core, CoreDal}; use zksync_shared_metrics::{BlockStage, APP_METRICS}; -use zksync_types::{writes::TreeWrite, Address}; +use zksync_types::{writes::TreeWrite, Address, ProtocolVersionId}; use zksync_utils::u256_to_h256; use crate::{ @@ -41,13 +41,47 @@ pub struct StateKeeperPersistence { impl StateKeeperPersistence { const SHUTDOWN_MSG: &'static str = "L2 block sealer unexpectedly shut down"; + async fn validate_l2_legacy_shared_bridge_addr( + pool: &ConnectionPool, + l2_legacy_shared_bridge_addr: Option
, + ) -> anyhow::Result<()> { + let mut connection = pool.connection().await.context("Get DB connection")?; + + if let Some(l2_block) = connection + .blocks_dal() + .get_earliest_l2_block_number() + .await + .context("failed to load earliest l2 block number")? + { + let header = connection + .blocks_dal() + .get_l2_block_header(l2_block) + .await + .context("failed to load L2 block header")? + .context("missing L2 block header")?; + let protocol_version = header + .protocol_version + .unwrap_or_else(ProtocolVersionId::last_potentially_undefined); + + if protocol_version.is_pre_gateway() && l2_legacy_shared_bridge_addr.is_none() { + anyhow::bail!( + "Missing `l2_legacy_shared_bridge_addr` for chain that was initialized before gateway upgrade".to_string() + ); + } + } + + Ok(()) + } + /// Creates a sealer that will use the provided Postgres connection and will have the specified /// `command_capacity` for unprocessed sealing commands. - pub fn new( + pub async fn new( pool: ConnectionPool, l2_legacy_shared_bridge_addr: Option
, mut command_capacity: usize, - ) -> (Self, L2BlockSealerTask) { + ) -> anyhow::Result<(Self, L2BlockSealerTask)> { + Self::validate_l2_legacy_shared_bridge_addr(&pool, l2_legacy_shared_bridge_addr).await?; + let is_sync = command_capacity == 0; command_capacity = command_capacity.max(1); @@ -67,7 +101,7 @@ impl StateKeeperPersistence { latest_completion_receiver: None, is_sync, }; - (this, sealer) + Ok((this, sealer)) } pub fn with_tx_insertion(mut self) -> Self { @@ -396,7 +430,9 @@ mod tests { pool.clone(), Some(Address::default()), l2_block_sealer_capacity, - ); + ) + .await + .unwrap(); let mut output_handler = OutputHandler::new(Box::new(persistence)) .with_handler(Box::new(TreeWritesPersistence::new(pool.clone()))); tokio::spawn(l2_block_sealer.run()); @@ -530,7 +566,9 @@ mod tests { drop(storage); let (mut persistence, l2_block_sealer) = - StateKeeperPersistence::new(pool.clone(), Some(Address::default()), 1); + StateKeeperPersistence::new(pool.clone(), Some(Address::default()), 1) + .await + .unwrap(); persistence = persistence.with_tx_insertion().without_protective_reads(); let mut output_handler = OutputHandler::new(Box::new(persistence)); tokio::spawn(l2_block_sealer.run()); @@ -569,7 +607,9 @@ mod tests { async fn l2_block_sealer_handle_blocking() { let pool = ConnectionPool::constrained_test_pool(1).await; let (mut persistence, mut sealer) = - StateKeeperPersistence::new(pool, Some(Address::default()), 1); + StateKeeperPersistence::new(pool, Some(Address::default()), 1) + .await + .unwrap(); // The first command should be successfully submitted immediately. let mut updates_manager = create_updates_manager(); @@ -620,7 +660,9 @@ mod tests { async fn l2_block_sealer_handle_parallel_processing() { let pool = ConnectionPool::constrained_test_pool(1).await; let (mut persistence, mut sealer) = - StateKeeperPersistence::new(pool, Some(Address::default()), 5); + StateKeeperPersistence::new(pool, Some(Address::default()), 5) + .await + .unwrap(); // 5 L2 block sealing commands can be submitted without blocking. let mut updates_manager = create_updates_manager(); diff --git a/core/node/state_keeper/src/io/tests/mod.rs b/core/node/state_keeper/src/io/tests/mod.rs index 0f1f5dd4f518..4e2f8aa8af3f 100644 --- a/core/node/state_keeper/src/io/tests/mod.rs +++ b/core/node/state_keeper/src/io/tests/mod.rs @@ -465,7 +465,9 @@ async fn l2_block_processing_after_snapshot_recovery(commitment_mode: L1BatchCom ); let (mut persistence, l2_block_sealer) = - StateKeeperPersistence::new(connection_pool.clone(), Some(Address::default()), 0); + StateKeeperPersistence::new(connection_pool.clone(), Some(Address::default()), 0) + .await + .unwrap(); tokio::spawn(l2_block_sealer.run()); persistence.handle_l2_block(&updates).await.unwrap(); From 068d654d99fd180c08eeb2630d9892b3acdcc69e Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Mon, 7 Oct 2024 15:14:48 +0300 Subject: [PATCH 05/23] fix en --- core/bin/external_node/src/node_builder.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/bin/external_node/src/node_builder.rs b/core/bin/external_node/src/node_builder.rs index b17cd8651500..69bf2e294fa9 100644 --- a/core/bin/external_node/src/node_builder.rs +++ b/core/bin/external_node/src/node_builder.rs @@ -55,6 +55,7 @@ use zksync_node_framework::{ service::{ZkStackService, ZkStackServiceBuilder}, }; use zksync_state::RocksdbStorageOptions; +use zksync_types::L2_NATIVE_TOKEN_VAULT_ADDRESS; use crate::{config::ExternalNodeConfig, metrics::framework::ExternalNodeMetricsLayer, Component}; @@ -192,8 +193,22 @@ impl ExternalNodeBuilder { // compression. const OPTIONAL_BYTECODE_COMPRESSION: bool = true; + let l2_shared_bridge_addr = self + .config + .remote + .l2_shared_bridge_addr + .context("Missing `l2_shared_bridge_addr`")?; + let l2_legacy_shared_bridge_addr = if l2_shared_bridge_addr == L2_NATIVE_TOKEN_VAULT_ADDRESS + { + // System has migrated to `L2_NATIVE_TOKEN_VAULT_ADDRESS`, use legacy shared bridge address from main node. + self.config.remote.l2_legacy_shared_bridge_addr + } else { + // System hasn't migrated on `L2_NATIVE_TOKEN_VAULT_ADDRESS`, we can safely use `l2_shared_bridge_addr`. + l2_shared_bridge_addr + }; + let persistence_layer = OutputHandlerLayer::new( - self.config.remote.l2_legacy_shared_bridge_addr, + l2_legacy_shared_bridge_addr, self.config.optional.l2_block_seal_queue_capacity, ) .with_pre_insert_txs(true) // EN requires txs to be pre-inserted. From 847c3da5a6a756a98552dc69c92af5552e56b351 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Mon, 7 Oct 2024 15:22:56 +0300 Subject: [PATCH 06/23] fix --- core/bin/external_node/src/node_builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/bin/external_node/src/node_builder.rs b/core/bin/external_node/src/node_builder.rs index 69bf2e294fa9..a30da7b54920 100644 --- a/core/bin/external_node/src/node_builder.rs +++ b/core/bin/external_node/src/node_builder.rs @@ -204,7 +204,7 @@ impl ExternalNodeBuilder { self.config.remote.l2_legacy_shared_bridge_addr } else { // System hasn't migrated on `L2_NATIVE_TOKEN_VAULT_ADDRESS`, we can safely use `l2_shared_bridge_addr`. - l2_shared_bridge_addr + Some(l2_shared_bridge_addr) }; let persistence_layer = OutputHandlerLayer::new( From f9e4c90a20b7d493f8521bbfa3ad5224902a0db7 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Tue, 8 Oct 2024 16:41:29 +0300 Subject: [PATCH 07/23] rework pubdata approach --- Cargo.lock | 3 +- .../system-constants-generator/src/utils.rs | 32 +- core/lib/multivm/Cargo.toml | 1 - core/lib/multivm/src/utils/events.rs | 56 +-- core/lib/multivm/src/versions/testonly.rs | 13 +- core/lib/multivm/src/versions/tests.rs | 29 +- core/lib/multivm/src/versions/vm_1_3_2/vm.rs | 10 +- .../vm_1_4_1/tracers/pubdata_tracer.rs | 3 +- .../vm_1_4_1/types/internals/pubdata.rs | 2 +- core/lib/multivm/src/versions/vm_1_4_1/vm.rs | 10 +- .../vm_1_4_2/tracers/pubdata_tracer.rs | 3 +- .../vm_1_4_2/types/internals/pubdata.rs | 2 +- core/lib/multivm/src/versions/vm_1_4_2/vm.rs | 10 +- .../tracers/pubdata_tracer.rs | 3 +- .../types/internals/pubdata.rs | 2 +- .../src/versions/vm_boojum_integration/vm.rs | 10 +- .../multivm/src/versions/vm_fast/pubdata.rs | 2 +- core/lib/multivm/src/versions/vm_fast/vm.rs | 4 +- .../vm_latest/bootloader_state/state.rs | 59 ++- .../vm_latest/bootloader_state/utils.rs | 116 +++--- .../vm_latest/implementation/execution.rs | 1 - .../src/versions/vm_latest/tests/block_tip.rs | 4 +- .../vm_latest/tests/tester/vm_tester.rs | 32 +- .../vm_latest/tracers/pubdata_tracer.rs | 20 +- .../versions/vm_latest/types/internals/mod.rs | 2 - .../vm_latest/types/internals/pubdata.rs | 339 ------------------ .../vm_latest/types/internals/vm_state.rs | 10 +- core/lib/multivm/src/versions/vm_latest/vm.rs | 17 +- core/lib/multivm/src/versions/vm_m5/vm.rs | 10 +- core/lib/multivm/src/versions/vm_m6/vm.rs | 10 +- .../src/versions/vm_refunds_enhancement/vm.rs | 10 +- .../src/versions/vm_virtual_blocks/vm.rs | 10 +- core/lib/multivm/src/vm_instance.rs | 70 +++- core/lib/prover_interface/src/inputs.rs | 5 +- core/lib/tee_verifier/src/lib.rs | 10 +- core/lib/vm_executor/src/batch/factory.rs | 36 +- core/lib/vm_executor/src/oneshot/block.rs | 8 +- core/lib/vm_executor/src/oneshot/mod.rs | 2 + core/lib/vm_executor/src/storage.rs | 8 +- core/lib/vm_interface/Cargo.toml | 2 + core/lib/vm_interface/src/executor.rs | 3 +- core/lib/vm_interface/src/lib.rs | 1 + core/lib/vm_interface/src/pubdata/mod.rs | 122 +++++++ core/lib/vm_interface/src/pubdata/rollup.rs | 136 +++++++ core/lib/vm_interface/src/pubdata/tests.rs | 121 +++++++ core/lib/vm_interface/src/pubdata/utils.rs | 70 ++++ core/lib/vm_interface/src/pubdata/validium.rs | 103 ++++++ core/lib/vm_interface/src/types/inputs/mod.rs | 5 +- .../src/types/inputs/system_env.rs | 4 +- core/lib/vm_interface/src/utils/dump.rs | 37 +- core/lib/vm_interface/src/utils/shadow.rs | 26 +- core/lib/vm_interface/src/vm.rs | 13 +- core/node/node_sync/src/external_io.rs | 4 +- core/node/proof_data_handler/src/tests.rs | 2 +- .../state_keeper/src/executor/tests/tester.rs | 30 +- core/node/state_keeper/src/io/common/mod.rs | 4 +- core/node/state_keeper/src/io/common/tests.rs | 8 +- core/node/state_keeper/src/io/mempool.rs | 41 +-- core/node/state_keeper/src/io/mod.rs | 3 +- core/node/state_keeper/src/io/persistence.rs | 3 +- core/node/state_keeper/src/io/tests/mod.rs | 4 +- core/node/state_keeper/src/keeper.rs | 25 +- core/node/state_keeper/src/testonly/mod.rs | 7 +- .../src/testonly/test_batch_executor.rs | 6 +- core/node/state_keeper/src/tests/mod.rs | 5 +- core/node/state_keeper/src/updates/mod.rs | 8 +- .../tee_verifier_input_producer/src/lib.rs | 3 +- core/node/vm_runner/src/process.rs | 1 + core/node/vm_runner/src/storage.rs | 9 +- .../vm_runner/src/tests/output_handler.rs | 1 - core/tests/vm-benchmark/src/vm.rs | 14 +- prover/Cargo.lock | 3 +- 72 files changed, 1097 insertions(+), 701 deletions(-) delete mode 100644 core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs create mode 100644 core/lib/vm_interface/src/pubdata/mod.rs create mode 100644 core/lib/vm_interface/src/pubdata/rollup.rs create mode 100644 core/lib/vm_interface/src/pubdata/tests.rs create mode 100644 core/lib/vm_interface/src/pubdata/utils.rs create mode 100644 core/lib/vm_interface/src/pubdata/validium.rs diff --git a/Cargo.lock b/Cargo.lock index b1ead7e44bd1..16c2d9033cc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10484,7 +10484,6 @@ dependencies = [ "zk_evm 0.150.5", "zksync_contracts", "zksync_eth_signer", - "zksync_mini_merkle_tree", "zksync_system_constants", "zksync_test_account", "zksync_types", @@ -11342,8 +11341,10 @@ dependencies = [ "thiserror", "tracing", "zksync_contracts", + "zksync_mini_merkle_tree", "zksync_system_constants", "zksync_types", + "zksync_utils", ] [[package]] diff --git a/core/bin/system-constants-generator/src/utils.rs b/core/bin/system-constants-generator/src/utils.rs index 084c8037e2c6..fd2a64222374 100644 --- a/core/bin/system-constants-generator/src/utils.rs +++ b/core/bin/system-constants-generator/src/utils.rs @@ -7,6 +7,7 @@ use zksync_contracts::{ }; use zksync_multivm::{ interface::{ + pubdata::pubdata_params_to_builder, storage::{InMemoryStorage, StorageView, WriteStorage}, tracer::VmExecutionStopReason, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory, @@ -21,11 +22,12 @@ use zksync_multivm::{ zk_evm_latest::aux_structures::Timestamp, }; use zksync_types::{ - block::L2BlockHasher, ethabi::Token, fee::Fee, fee_model::BatchFeeInput, l1::L1Tx, l2::L2Tx, - utils::storage_key_for_eth_balance, AccountTreeId, Address, Execute, K256PrivateKey, - L1BatchNumber, L1TxCommonData, L2BlockNumber, L2ChainId, Nonce, ProtocolVersionId, StorageKey, - Transaction, BOOTLOADER_ADDRESS, SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_GAS_PRICE_POSITION, - SYSTEM_CONTEXT_TX_ORIGIN_POSITION, U256, ZKPORTER_IS_AVAILABLE, + block::L2BlockHasher, commitment::PubdataParams, ethabi::Token, fee::Fee, + fee_model::BatchFeeInput, l1::L1Tx, l2::L2Tx, utils::storage_key_for_eth_balance, + AccountTreeId, Address, Execute, K256PrivateKey, L1BatchNumber, L1TxCommonData, L2BlockNumber, + L2ChainId, Nonce, ProtocolVersionId, StorageKey, Transaction, BOOTLOADER_ADDRESS, + SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_GAS_PRICE_POSITION, SYSTEM_CONTEXT_TX_ORIGIN_POSITION, + U256, ZKPORTER_IS_AVAILABLE, }; use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, u256_to_h256}; @@ -231,7 +233,6 @@ pub(super) fn execute_internal_transfer_test() -> u32 { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::default(), - pubdata_params: Default::default(), }; let eth_token_sys_contract = load_sys_contract("L2BaseToken"); @@ -262,7 +263,14 @@ pub(super) fn execute_internal_transfer_test() -> u32 { output: tracer_result.clone(), } .into_tracer_pointer(); - let mut vm: Vm<_, HistoryEnabled> = Vm::new(l1_batch, system_env, storage_view.to_rc_ptr()); + + let pubdata_builder = pubdata_params_to_builder(PubdataParams::default()); + let mut vm: Vm<_, HistoryEnabled> = Vm::new( + l1_batch, + system_env, + storage_view.to_rc_ptr(), + Some(pubdata_builder), + ); let result = vm.inspect(&mut tracer.into(), VmExecutionMode::Bootloader); assert!(!result.result.is_failed(), "The internal call has reverted"); @@ -314,11 +322,15 @@ pub(super) fn execute_user_txs_in_test_gas_vm( execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::default(), - pubdata_params: Default::default(), }; + let pubdata_builder = pubdata_params_to_builder(PubdataParams::default()); - let mut vm: Vm<_, HistoryEnabled> = - Vm::new(l1_batch, system_env, Rc::new(RefCell::new(storage_view))); + let mut vm: Vm<_, HistoryEnabled> = Vm::new( + l1_batch, + system_env, + Rc::new(RefCell::new(storage_view)), + Some(pubdata_builder), + ); let mut total_gas_refunded = 0; for tx in txs { diff --git a/core/lib/multivm/Cargo.toml b/core/lib/multivm/Cargo.toml index 3bb8fd9b11f9..2c2cd4f044b9 100644 --- a/core/lib/multivm/Cargo.toml +++ b/core/lib/multivm/Cargo.toml @@ -28,7 +28,6 @@ zksync_types.workspace = true zksync_contracts.workspace = true zksync_utils.workspace = true zksync_system_constants.workspace = true -zksync_mini_merkle_tree.workspace = true zksync_vm_interface.workspace = true anyhow.workspace = true diff --git a/core/lib/multivm/src/utils/events.rs b/core/lib/multivm/src/utils/events.rs index 9720cb779142..d84651989e75 100644 --- a/core/lib/multivm/src/utils/events.rs +++ b/core/lib/multivm/src/utils/events.rs @@ -1,59 +1,10 @@ use zksync_system_constants::L1_MESSENGER_ADDRESS; use zksync_types::{ ethabi::{self, Token}, - l2_to_l1_log::L2ToL1Log, - Address, H256, U256, + H256, U256, }; -use zksync_utils::{u256_to_bytes_be, u256_to_h256}; -use crate::interface::VmEvent; - -/// Corresponds to the following solidity event: -/// ```solidity -/// struct L2ToL1Log { -/// uint8 l2ShardId; -/// bool isService; -/// uint16 txNumberInBlock; -/// address sender; -/// bytes32 key; -/// bytes32 value; -/// } -/// ``` -#[derive(Debug, Default, Clone, PartialEq)] -pub(crate) struct L1MessengerL2ToL1Log { - pub l2_shard_id: u8, - pub is_service: bool, - pub tx_number_in_block: u16, - pub sender: Address, - pub key: U256, - pub value: U256, -} - -impl L1MessengerL2ToL1Log { - pub fn packed_encoding(&self) -> Vec { - let mut res: Vec = vec![]; - res.push(self.l2_shard_id); - res.push(self.is_service as u8); - res.extend_from_slice(&self.tx_number_in_block.to_be_bytes()); - res.extend_from_slice(self.sender.as_bytes()); - res.extend(u256_to_bytes_be(&self.key)); - res.extend(u256_to_bytes_be(&self.value)); - res - } -} - -impl From for L2ToL1Log { - fn from(log: L1MessengerL2ToL1Log) -> Self { - L2ToL1Log { - shard_id: log.l2_shard_id, - is_service: log.is_service, - tx_number_in_block: log.tx_number_in_block, - sender: log.sender, - key: u256_to_h256(log.key), - value: u256_to_h256(log.value), - } - } -} +use crate::interface::{pubdata::L1MessengerL2ToL1Log, VmEvent}; #[derive(Debug, PartialEq)] pub(crate) struct L1MessengerBytecodePublicationRequest { @@ -142,7 +93,8 @@ mod tests { use zksync_system_constants::{ BOOTLOADER_ADDRESS, KNOWN_CODES_STORAGE_ADDRESS, L2_BASE_TOKEN_ADDRESS, }; - use zksync_types::L1BatchNumber; + use zksync_types::{Address, L1BatchNumber}; + use zksync_utils::u256_to_h256; use super::*; diff --git a/core/lib/multivm/src/versions/testonly.rs b/core/lib/multivm/src/versions/testonly.rs index 6d3ee5571775..c498959e27b0 100644 --- a/core/lib/multivm/src/versions/testonly.rs +++ b/core/lib/multivm/src/versions/testonly.rs @@ -1,3 +1,5 @@ +use std::rc::Rc; + use zksync_contracts::BaseSystemContracts; use zksync_test_account::Account; use zksync_types::{ @@ -8,10 +10,18 @@ use zksync_types::{ use zksync_utils::{bytecode::hash_bytecode, u256_to_h256}; use crate::{ - interface::{storage::InMemoryStorage, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode}, + interface::{ + pubdata::{rollup::RollupPubdataBuilder, PubdataBuilder}, + storage::InMemoryStorage, + L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, + }, vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT, }; +pub(super) fn default_pubdata_builder() -> Rc { + Rc::new(RollupPubdataBuilder::new(Address::zero())) +} + pub(super) fn default_system_env() -> SystemEnv { SystemEnv { zk_porter_available: false, @@ -21,7 +31,6 @@ pub(super) fn default_system_env() -> SystemEnv { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::from(270), - pubdata_params: Default::default(), } } diff --git a/core/lib/multivm/src/versions/tests.rs b/core/lib/multivm/src/versions/tests.rs index c2a04c155fec..1c438eb5a1cf 100644 --- a/core/lib/multivm/src/versions/tests.rs +++ b/core/lib/multivm/src/versions/tests.rs @@ -22,7 +22,8 @@ use crate::{ }, utils::get_max_gas_per_pubdata_byte, versions::testonly::{ - default_l1_batch, default_system_env, make_account_rich, ContractToDeploy, + default_l1_batch, default_pubdata_builder, default_system_env, make_account_rich, + ContractToDeploy, }, vm_fast, vm_latest::{self, HistoryEnabled}, @@ -206,12 +207,13 @@ where { let system_env = default_system_env(); let l1_batch_env = default_l1_batch(L1BatchNumber(1)); + let pubdata_builder = default_pubdata_builder(); let mut storage = InMemoryStorage::with_system_contracts(hash_bytecode); let mut harness = Harness::new(&l1_batch_env); harness.setup_storage(&mut storage); let storage = StorageView::new(storage).to_rc_ptr(); - let mut vm = Vm::new(l1_batch_env, system_env, storage); + let mut vm = Vm::new(l1_batch_env, system_env, storage, Some(pubdata_builder)); harness.execute_on_vm(&mut vm); (vm, harness) } @@ -230,6 +232,7 @@ fn sanity_check_harness_on_new_vm() { fn sanity_check_shadow_vm() { let system_env = default_system_env(); let l1_batch_env = default_l1_batch(L1BatchNumber(1)); + let pubdata_builder = default_pubdata_builder(); let mut storage = InMemoryStorage::with_system_contracts(hash_bytecode); let mut harness = Harness::new(&l1_batch_env); harness.setup_storage(&mut storage); @@ -242,6 +245,7 @@ fn sanity_check_shadow_vm() { system_env, main_storage, shadow_storage, + Some(pubdata_builder), ); harness.execute_on_vm(&mut vm); } @@ -261,16 +265,17 @@ fn shadow_vm_basics() { harness.setup_storage(&mut storage); let storage = StorageView::new(storage).to_rc_ptr(); - let vm = dump - .clone() - .play_back_custom(|l1_batch_env, system_env, dump_storage| { - ShadowVm::<_, ReferenceVm, ReferenceVm<_>>::with_custom_shadow( - l1_batch_env, - system_env, - storage, - dump_storage, - ) - }); + let vm = + dump.clone() + .play_back_custom(|l1_batch_env, system_env, dump_storage, pubdata_builder| { + ShadowVm::<_, ReferenceVm, ReferenceVm<_>>::with_custom_shadow( + l1_batch_env, + system_env, + storage, + dump_storage, + pubdata_builder, + ) + }); let new_dump = vm.dump_state(); pretty_assertions::assert_eq!(new_dump, dump); } diff --git a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs index 5692f103da3d..afbe55780da9 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs @@ -1,7 +1,8 @@ -use std::collections::HashSet; +use std::{collections::HashSet, rc::Rc}; use zksync_types::Transaction; use zksync_utils::{bytecode::hash_bytecode, h256_to_u256}; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ glue::{history_mode::HistoryMode, GlueInto}, @@ -187,7 +188,12 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr, + _pubdata_builder: Option>, + ) -> Self { let oracle_tools = crate::vm_1_3_2::OracleTools::new(storage.clone()); let block_properties = crate::vm_1_3_2::BlockProperties { default_aa_code_hash: h256_to_u256( diff --git a/core/lib/multivm/src/versions/vm_1_4_1/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_1_4_1/tracers/pubdata_tracer.rs index 238804bc7fca..6f927c5c99a8 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/tracers/pubdata_tracer.rs @@ -10,6 +10,7 @@ use zksync_utils::{h256_to_u256, u256_to_bytes_be, u256_to_h256}; use crate::{ interface::{ + pubdata::L1MessengerL2ToL1Log, storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, L1BatchEnv, VmEvent, VmExecutionMode, @@ -17,7 +18,7 @@ use crate::{ tracers::dynamic::vm_1_4_1::DynTracer, utils::events::{ extract_bytecode_publication_requests_from_l1_messenger, - extract_l2tol1logs_from_l1_messenger, L1MessengerL2ToL1Log, + extract_l2tol1logs_from_l1_messenger, }, vm_1_4_1::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/types/internals/pubdata.rs b/core/lib/multivm/src/versions/vm_1_4_1/types/internals/pubdata.rs index d07732ae4350..c1ca93152a03 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/types/internals/pubdata.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/types/internals/pubdata.rs @@ -1,6 +1,6 @@ use zksync_types::writes::{compress_state_diffs, StateDiffRecord}; -use crate::utils::events::L1MessengerL2ToL1Log; +use crate::interface::pubdata::L1MessengerL2ToL1Log; /// Struct based on which the pubdata blob is formed #[derive(Debug, Clone, Default)] diff --git a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs index 68c8e92a03a1..75f3c64052c3 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs @@ -1,8 +1,11 @@ +use std::rc::Rc; + use circuit_sequencer_api_1_4_1::sort_storage_access::sort_storage_access_queries; use zksync_types::{ l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, Transaction, }; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ glue::GlueInto, @@ -148,7 +151,12 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr, + _pubdata_builder: Option>, + ) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_1_4_2/tracers/pubdata_tracer.rs index ffe65b5e050b..6c4f737f9e94 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/tracers/pubdata_tracer.rs @@ -10,6 +10,7 @@ use zksync_utils::{h256_to_u256, u256_to_bytes_be, u256_to_h256}; use crate::{ interface::{ + pubdata::L1MessengerL2ToL1Log, storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, L1BatchEnv, VmEvent, VmExecutionMode, @@ -17,7 +18,7 @@ use crate::{ tracers::dynamic::vm_1_4_1::DynTracer, utils::events::{ extract_bytecode_publication_requests_from_l1_messenger, - extract_l2tol1logs_from_l1_messenger, L1MessengerL2ToL1Log, + extract_l2tol1logs_from_l1_messenger, }, vm_1_4_2::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/types/internals/pubdata.rs b/core/lib/multivm/src/versions/vm_1_4_2/types/internals/pubdata.rs index d07732ae4350..c1ca93152a03 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/types/internals/pubdata.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/types/internals/pubdata.rs @@ -1,6 +1,6 @@ use zksync_types::writes::{compress_state_diffs, StateDiffRecord}; -use crate::utils::events::L1MessengerL2ToL1Log; +use crate::interface::pubdata::L1MessengerL2ToL1Log; /// Struct based on which the pubdata blob is formed #[derive(Debug, Clone, Default)] diff --git a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs index d6e1fbc68a8f..4f5d6caa6977 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs @@ -1,10 +1,11 @@ -use std::mem; +use std::{mem, rc::Rc}; use circuit_sequencer_api_1_4_2::sort_storage_access::sort_storage_access_queries; use zksync_types::{ l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, Transaction, }; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ glue::GlueInto, @@ -155,7 +156,12 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr, + _pubdata_builder: Option>, + ) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/pubdata_tracer.rs index 326a57896124..2f7d141cb0a7 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/tracers/pubdata_tracer.rs @@ -10,6 +10,7 @@ use zksync_utils::{h256_to_u256, u256_to_bytes_be, u256_to_h256}; use crate::{ interface::{ + pubdata::L1MessengerL2ToL1Log, storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, L1BatchEnv, VmEvent, VmExecutionMode, @@ -17,7 +18,7 @@ use crate::{ tracers::dynamic::vm_1_4_0::DynTracer, utils::events::{ extract_bytecode_publication_requests_from_l1_messenger, - extract_l2tol1logs_from_l1_messenger, L1MessengerL2ToL1Log, + extract_l2tol1logs_from_l1_messenger, }, vm_boojum_integration::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/types/internals/pubdata.rs b/core/lib/multivm/src/versions/vm_boojum_integration/types/internals/pubdata.rs index 9df9009831f4..152ccad2fbcb 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/types/internals/pubdata.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/types/internals/pubdata.rs @@ -1,6 +1,6 @@ use zksync_types::writes::{compress_state_diffs, StateDiffRecord}; -use crate::utils::events::L1MessengerL2ToL1Log; +use crate::interface::pubdata::L1MessengerL2ToL1Log; /// Struct based on which the pubdata blob is formed #[derive(Debug, Clone, Default)] diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs index 17ce8365a0aa..b3b75352dfb3 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs @@ -1,8 +1,11 @@ +use std::rc::Rc; + use circuit_sequencer_api_1_4_0::sort_storage_access::sort_storage_access_queries; use zksync_types::{ l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, Transaction, }; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ glue::GlueInto, @@ -149,7 +152,12 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr, + _pubdata_builder: Option>, + ) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, diff --git a/core/lib/multivm/src/versions/vm_fast/pubdata.rs b/core/lib/multivm/src/versions/vm_fast/pubdata.rs index d07732ae4350..c1ca93152a03 100644 --- a/core/lib/multivm/src/versions/vm_fast/pubdata.rs +++ b/core/lib/multivm/src/versions/vm_fast/pubdata.rs @@ -1,6 +1,6 @@ use zksync_types::writes::{compress_state_diffs, StateDiffRecord}; -use crate::utils::events::L1MessengerL2ToL1Log; +use crate::interface::pubdata::L1MessengerL2ToL1Log; /// Struct based on which the pubdata blob is formed #[derive(Debug, Clone, Default)] diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index 36698de105c1..a11c305f4ce7 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, fmt, mem}; +use std::{collections::HashMap, fmt, mem, rc::Rc}; use zk_evm_1_5_0::zkevm_opcode_defs::system_params::INITIAL_FRAME_FORMAL_EH_LOCATION; use zksync_contracts::SystemContractCode; @@ -19,6 +19,7 @@ use zksync_vm2::{ interface::{CallframeInterface, HeapId, StateInterface, Tracer}, ExecutionEnd, FatPointer, Program, Settings, VirtualMachine, }; +use zksync_vm_interface::pubdata::PubdataBuilder; use super::{ bootloader_state::{BootloaderState, BootloaderStateSnapshot}, @@ -501,6 +502,7 @@ where batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr>, + _pubdata_builder: Option>, ) -> Self { let storage = ImmutableStorageView::new(storage); Self::custom(batch_env, system_env, storage) diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs index b2cb50c653e4..863ed6cd40b0 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs @@ -1,14 +1,15 @@ -use std::cmp::Ordering; +use std::{cmp::Ordering, rc::Rc}; use once_cell::sync::OnceCell; -use zksync_types::{commitment::PubdataParams, L2ChainId, U256}; +use zksync_types::{L2ChainId, ProtocolVersionId, U256}; +use zksync_vm_interface::pubdata::PubdataBuilder; -use super::{ - tx::BootloaderTx, - utils::{apply_pubdata_to_memory, get_encoded_pubdata}, -}; +use super::{tx::BootloaderTx, utils::apply_pubdata_to_memory}; use crate::{ - interface::{BootloaderMemory, CompressedBytecodeInfo, L2BlockEnv, TxExecutionMode}, + interface::{ + pubdata::PubdataInput, BootloaderMemory, CompressedBytecodeInfo, L2BlockEnv, + TxExecutionMode, + }, vm_latest::{ bootloader_state::{ l2_block::BootloaderL2Block, @@ -16,9 +17,8 @@ use crate::{ utils::{apply_l2_block, apply_tx_to_memory}, }, constants::TX_DESCRIPTION_OFFSET, - types::internals::{PubdataInput, TransactionData}, + types::internals::TransactionData, utils::l2_blocks::assert_next_block, - MultiVMSubversion, }, }; @@ -49,10 +49,10 @@ pub struct BootloaderState { free_tx_offset: usize, /// Information about the the pubdata that will be needed to supply to the L1Messenger pubdata_information: OnceCell, - /// Params related to how the pubdata should be processed by the bootloader in the batch - pubdata_params: PubdataParams, - /// VM subversion - subversion: MultiVMSubversion, + /// Protocol version. + protocol_version: ProtocolVersionId, + /// Pubdata builder which is used to convert pubdata input to bytes. + pubdata_builder: Rc, } impl BootloaderState { @@ -60,8 +60,8 @@ impl BootloaderState { execution_mode: TxExecutionMode, initial_memory: BootloaderMemory, first_l2_block: L2BlockEnv, - pubdata_params: PubdataParams, - subversion: MultiVMSubversion, + protocol_version: ProtocolVersionId, + pubdata_builder: Rc, ) -> Self { let l2_block = BootloaderL2Block::new(first_l2_block, 0); Self { @@ -72,8 +72,8 @@ impl BootloaderState { execution_mode, free_tx_offset: 0, pubdata_information: Default::default(), - pubdata_params, - subversion, + protocol_version, + pubdata_builder, } } @@ -154,22 +154,15 @@ impl BootloaderState { .expect("Pubdata information is not set") } - pub(crate) fn get_encoded_pubdata(&self) -> Vec { + pub(crate) fn settlement_layer_pubdata(&self) -> Vec { let pubdata_information = self .pubdata_information .get() .expect("Pubdata information is not set") .clone(); - match self.subversion { - MultiVMSubversion::SmallBootloaderMemory - | MultiVMSubversion::IncreasedBootloaderMemory => { - pubdata_information.build_pubdata_pre_gateway(false) - } - MultiVMSubversion::Gateway => { - get_encoded_pubdata(pubdata_information, self.pubdata_params, false) - } - } + self.pubdata_builder + .settlement_layer_pubdata(pubdata_information, self.protocol_version) } fn last_mut_l2_block(&mut self) -> &mut BootloaderL2Block { @@ -211,9 +204,9 @@ impl BootloaderState { apply_pubdata_to_memory( &mut initial_memory, + self.pubdata_builder.clone(), pubdata_information, - self.pubdata_params, - self.subversion, + self.protocol_version, ); initial_memory } @@ -328,11 +321,11 @@ impl BootloaderState { } } - pub(crate) fn get_pubdata_params(&self) -> PubdataParams { - self.pubdata_params + pub(crate) fn pubdata_builder(&self) -> Rc { + self.pubdata_builder.clone() } - pub(crate) fn get_vm_subversion(&self) -> MultiVMSubversion { - self.subversion + pub(crate) fn protocol_version(&self) -> ProtocolVersionId { + self.protocol_version } } diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs index 498071220568..1e43dee1ceae 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs @@ -1,12 +1,14 @@ -use zksync_types::{ - commitment::{L1BatchCommitmentMode, PubdataParams}, - ethabi, U256, -}; +use std::rc::Rc; + +use zksync_types::{ethabi, ProtocolVersionId, U256}; use zksync_utils::{bytes_to_be_words, h256_to_u256}; use super::tx::BootloaderTx; use crate::{ - interface::{BootloaderMemory, CompressedBytecodeInfo, TxExecutionMode}, + interface::{ + pubdata::{PubdataBuilder, PubdataInput}, + BootloaderMemory, CompressedBytecodeInfo, TxExecutionMode, + }, utils::bytecode, vm_latest::{ bootloader_state::l2_block::BootloaderL2Block, @@ -17,11 +19,6 @@ use crate::{ TX_DESCRIPTION_OFFSET, TX_OPERATOR_L2_BLOCK_INFO_OFFSET, TX_OPERATOR_SLOTS_PER_L2_BLOCK_INFO, TX_OVERHEAD_OFFSET, TX_TRUSTED_GAS_LIMIT_OFFSET, }, - types::internals::{ - pubdata::{PubdataBuilder, RollupPubdataBuilder, ValidiumPubdataBuilder}, - PubdataInput, - }, - MultiVMSubversion, }, }; @@ -131,73 +128,46 @@ fn apply_l2_block_inner( ]) } -pub(crate) fn get_encoded_pubdata( - pubdata_information: PubdataInput, - pubdata_params: PubdataParams, - l2_version: bool, -) -> Vec { - let pubdata_bytes: Vec = match pubdata_params.pubdata_type { - L1BatchCommitmentMode::Rollup => { - RollupPubdataBuilder.build_pubdata(pubdata_information, l2_version) - } - L1BatchCommitmentMode::Validium => { - ValidiumPubdataBuilder.build_pubdata(pubdata_information, l2_version) - } - }; - - if l2_version { - ethabi::encode(&[ - ethabi::Token::Address(pubdata_params.l2_da_validator_address), - ethabi::Token::Bytes(pubdata_bytes), - ]) - .to_vec() - } else { - pubdata_bytes - } -} - pub(crate) fn apply_pubdata_to_memory( memory: &mut BootloaderMemory, + pubdata_builder: Rc, pubdata_information: PubdataInput, - pubdata_params: PubdataParams, - subversion: MultiVMSubversion, + protocol_version: ProtocolVersionId, ) { - let (l1_messenger_pubdata_start_slot, pubdata) = match subversion { - MultiVMSubversion::SmallBootloaderMemory | MultiVMSubversion::IncreasedBootloaderMemory => { - // Skipping two slots as they will be filled by the bootloader itself: - // - One slot is for the selector of the call to the L1Messenger. - // - The other slot is for the 0x20 offset for the calldata. - let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 2; - - // Need to skip first word as it represents array offset - // while bootloader expects only [len || data] - let pubdata = ethabi::encode(&[ethabi::Token::Bytes( - pubdata_information.build_pubdata_pre_gateway(true), - )])[32..] - .to_vec(); - - assert!( - pubdata.len() / 32 <= OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS - 2, - "The encoded pubdata is too big" - ); - - (l1_messenger_pubdata_start_slot, pubdata) - } - MultiVMSubversion::Gateway => { - // Skipping the first slot as it will be filled by the bootloader itself: - // It is for the selector of the call to the L1Messenger. - let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 1; - - let pubdata = get_encoded_pubdata(pubdata_information, pubdata_params, true); - - assert!( - // Note that unlike the previous version, the difference is `1`, since now it also includes the offset - pubdata.len() / 32 < OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS, - "The encoded pubdata is too big" - ); - - (l1_messenger_pubdata_start_slot, pubdata) - } + let (l1_messenger_pubdata_start_slot, pubdata) = if protocol_version.is_pre_gateway() { + // Skipping two slots as they will be filled by the bootloader itself: + // - One slot is for the selector of the call to the L1Messenger. + // - The other slot is for the 0x20 offset for the calldata. + let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 2; + + // Need to skip first word as it represents array offset + // while bootloader expects only [len || data] + let pubdata = ethabi::encode(&[ethabi::Token::Bytes( + pubdata_builder.l1_messenger_operator_input(pubdata_information, protocol_version), + )])[32..] + .to_vec(); + + assert!( + pubdata.len() / 32 <= OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS - 2, + "The encoded pubdata is too big" + ); + + (l1_messenger_pubdata_start_slot, pubdata) + } else { + // Skipping the first slot as it will be filled by the bootloader itself: + // It is for the selector of the call to the L1Messenger. + let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 1; + + let pubdata = + pubdata_builder.bootloader_memory_input(pubdata_information, protocol_version); + + assert!( + // Note that unlike the previous version, the difference is `1`, since now it also includes the offset + pubdata.len() / 32 < OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS, + "The encoded pubdata is too big" + ); + + (l1_messenger_pubdata_start_slot, pubdata) }; pubdata diff --git a/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs b/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs index 2f23bfb89f0b..b8242fa7ca85 100644 --- a/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs +++ b/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs @@ -64,7 +64,6 @@ impl Vm { self.batch_env.clone(), execution_mode, self.subversion, - self.system_env.version, )) }), self.subversion, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs b/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs index 8ce00229332e..9909ca24937f 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs @@ -9,8 +9,7 @@ use zksync_system_constants::{ }; use zksync_types::{ commitment::SerializeCommitment, fee_model::BatchFeeInput, get_code_key, - l2_to_l1_log::L2ToL1Log, writes::StateDiffRecord, Address, Execute, ProtocolVersionId, H256, - U256, + l2_to_l1_log::L2ToL1Log, writes::StateDiffRecord, Address, Execute, H256, U256, }; use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u256_to_h256}; @@ -194,7 +193,6 @@ fn execute_test(test_data: L1MessengerTestData) -> TestStatistics { VmExecutionMode::Batch, test_data.state_diffs.clone(), crate::vm_latest::MultiVMSubversion::latest(), - ProtocolVersionId::latest(), ); let result = vm.vm.inspect_inner( diff --git a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs index 91a2a9256411..8c776fdbfd33 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs @@ -1,9 +1,8 @@ -use std::marker::PhantomData; +use std::{marker::PhantomData, rc::Rc}; use zksync_contracts::BaseSystemContracts; use zksync_types::{ block::L2BlockHasher, - commitment::PubdataParams, fee_model::BatchFeeInput, get_code_key, get_is_account_key, helpers::unix_timestamp_ms, @@ -11,6 +10,7 @@ use zksync_types::{ Address, L1BatchNumber, L2BlockNumber, L2ChainId, Nonce, ProtocolVersionId, U256, }; use zksync_utils::{bytecode::hash_bytecode, u256_to_h256}; +use zksync_vm_interface::pubdata::{rollup::RollupPubdataBuilder, PubdataBuilder}; use crate::{ interface::{ @@ -97,7 +97,12 @@ impl VmTester { }; } - let vm = Vm::new(l1_batch, self.vm.system_env.clone(), self.storage.clone()); + let vm = Vm::new( + l1_batch, + self.vm.system_env.clone(), + self.storage.clone(), + Some(self.vm.bootloader_state.pubdata_builder()), + ); if self.test_contract.is_some() { self.deploy_test_contract(); @@ -116,6 +121,7 @@ pub(crate) struct VmTesterBuilder { deployer: Option, rich_accounts: Vec, custom_contracts: Vec, + pubdata_builder: Option>, _phantom: PhantomData, } @@ -128,6 +134,7 @@ impl Clone for VmTesterBuilder { deployer: self.deployer.clone(), rich_accounts: self.rich_accounts.clone(), custom_contracts: self.custom_contracts.clone(), + pubdata_builder: self.pubdata_builder.clone(), _phantom: PhantomData, } } @@ -147,11 +154,11 @@ impl VmTesterBuilder { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::from(270), - pubdata_params: Default::default(), }, deployer: None, rich_accounts: vec![], custom_contracts: vec![], + pubdata_builder: None, _phantom: PhantomData, } } @@ -218,8 +225,11 @@ impl VmTesterBuilder { self } - pub(crate) fn with_custom_pubdata_params(mut self, pubdata_params: PubdataParams) -> Self { - self.system_env.pubdata_params = pubdata_params; + pub(crate) fn with_custom_pubdata_builder( + mut self, + pubdata_builder: Rc, + ) -> Self { + self.pubdata_builder = Some(pubdata_builder); self } @@ -239,7 +249,15 @@ impl VmTesterBuilder { } let fee_account = l1_batch_env.fee_account; - let vm = Vm::new(l1_batch_env, self.system_env, storage_ptr.clone()); + let pubdata_builder = self + .pubdata_builder + .unwrap_or_else(|| Rc::new(RollupPubdataBuilder::new(Address::zero()))); + let vm = Vm::new( + l1_batch_env, + self.system_env, + storage_ptr.clone(), + Some(pubdata_builder), + ); VmTester { vm, diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs index 9e620f96af2b..6d8de43bad44 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs @@ -5,14 +5,12 @@ use zk_evm_1_5_0::{ aux_structures::Timestamp, tracing::{BeforeExecutionData, VmLocalStateData}, }; -use zksync_types::{ - l2_to_l1_log::l2_to_l1_logs_tree_size, writes::StateDiffRecord, AccountTreeId, - ProtocolVersionId, StorageKey, L1_MESSENGER_ADDRESS, -}; +use zksync_types::{writes::StateDiffRecord, AccountTreeId, StorageKey, L1_MESSENGER_ADDRESS}; use zksync_utils::{h256_to_u256, u256_to_bytes_be, u256_to_h256}; use crate::{ interface::{ + pubdata::{L1MessengerL2ToL1Log, PubdataInput}, storage::{StoragePtr, WriteStorage}, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, L1BatchEnv, VmEvent, VmExecutionMode, @@ -20,14 +18,14 @@ use crate::{ tracers::dynamic::vm_1_5_0::DynTracer, utils::events::{ extract_bytecode_publication_requests_from_l1_messenger, - extract_l2tol1logs_from_l1_messenger, L1MessengerL2ToL1Log, + extract_l2tol1logs_from_l1_messenger, }, vm_latest::{ bootloader_state::{utils::apply_pubdata_to_memory, BootloaderState}, constants::BOOTLOADER_HEAP_PAGE, old_vm::{history_recorder::HistoryMode, memory::SimpleMemory}, tracers::{traits::VmTracer, utils::VmHook}, - types::internals::{PubdataInput, ZkSyncVmState}, + types::internals::ZkSyncVmState, utils::logs::collect_events_and_l1_system_logs_after_timestamp, vm::MultiVMSubversion, StorageOracle, @@ -44,7 +42,6 @@ pub(crate) struct PubdataTracer { // to the L1Messenger. enforced_state_diffs: Option>, subversion: MultiVMSubversion, - protocol_version: ProtocolVersionId, _phantom_data: PhantomData, } @@ -53,7 +50,6 @@ impl PubdataTracer { l1_batch_env: L1BatchEnv, execution_mode: VmExecutionMode, subversion: MultiVMSubversion, - protocol_version: ProtocolVersionId, ) -> Self { Self { l1_batch_env, @@ -61,7 +57,6 @@ impl PubdataTracer { execution_mode, enforced_state_diffs: None, subversion, - protocol_version, _phantom_data: Default::default(), } } @@ -74,7 +69,6 @@ impl PubdataTracer { execution_mode: VmExecutionMode, forced_state_diffs: Vec, subversion: MultiVMSubversion, - protocol_version: ProtocolVersionId, ) -> Self { Self { l1_batch_env, @@ -82,7 +76,6 @@ impl PubdataTracer { execution_mode, enforced_state_diffs: Some(forced_state_diffs), subversion, - protocol_version, _phantom_data: Default::default(), } } @@ -192,7 +185,6 @@ impl PubdataTracer { l2_to_l1_messages: self.get_total_l1_messenger_messages(state), published_bytecodes: self.get_total_published_bytecodes(state), state_diffs: self.get_state_diffs(&state.storage), - l2_to_l1_logs_tree_size: l2_to_l1_logs_tree_size(self.protocol_version), } } } @@ -238,9 +230,9 @@ impl VmTracer for PubdataTracer { apply_pubdata_to_memory( &mut memory_to_apply, + bootloader_state.pubdata_builder(), pubdata_input, - bootloader_state.get_pubdata_params(), - bootloader_state.get_vm_subversion(), + bootloader_state.protocol_version(), ); state.memory.populate_page( BOOTLOADER_HEAP_PAGE as usize, diff --git a/core/lib/multivm/src/versions/vm_latest/types/internals/mod.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/mod.rs index 0b9f704e8dbf..601b7b8bd014 100644 --- a/core/lib/multivm/src/versions/vm_latest/types/internals/mod.rs +++ b/core/lib/multivm/src/versions/vm_latest/types/internals/mod.rs @@ -1,9 +1,7 @@ -pub(crate) use pubdata::PubdataInput; pub(crate) use snapshot::VmSnapshot; pub(crate) use transaction_data::TransactionData; pub(crate) use vm_state::new_vm_state; pub use vm_state::ZkSyncVmState; -pub(crate) mod pubdata; mod snapshot; mod transaction_data; mod vm_state; diff --git a/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs deleted file mode 100644 index b39e280dc33e..000000000000 --- a/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs +++ /dev/null @@ -1,339 +0,0 @@ -use ethabi::ParamType; -use zksync_mini_merkle_tree::MiniMerkleTree; -use zksync_types::{ - ethabi::{self, Token}, - web3::keccak256, - writes::{compress_state_diffs, StateDiffRecord}, -}; -use zksync_utils::bytecode::hash_bytecode; - -use crate::utils::events::L1MessengerL2ToL1Log; - -/// Struct based on which the pubdata blob is formed -#[derive(Debug, Clone, Default)] -pub(crate) struct PubdataInput { - pub(crate) user_logs: Vec, - pub(crate) l2_to_l1_messages: Vec>, - pub(crate) published_bytecodes: Vec>, - pub(crate) state_diffs: Vec, - pub(crate) l2_to_l1_logs_tree_size: usize, -} - -impl PubdataInput { - pub(crate) fn build_pubdata_pre_gateway(self, with_uncompressed_state_diffs: bool) -> Vec { - let mut l1_messenger_pubdata = vec![]; - - let PubdataInput { - user_logs, - l2_to_l1_messages, - published_bytecodes, - state_diffs, - .. - } = self; - - // Encoding user L2->L1 logs. - // Format: `[(numberOfL2ToL1Logs as u32) || l2tol1logs[1] || ... || l2tol1logs[n]]` - l1_messenger_pubdata.extend((user_logs.len() as u32).to_be_bytes()); - for l2tol1log in user_logs { - l1_messenger_pubdata.extend(l2tol1log.packed_encoding()); - } - - // Encoding L2->L1 messages - // Format: `[(numberOfMessages as u32) || (messages[1].len() as u32) || messages[1] || ... || (messages[n].len() as u32) || messages[n]]` - l1_messenger_pubdata.extend((l2_to_l1_messages.len() as u32).to_be_bytes()); - for message in l2_to_l1_messages { - l1_messenger_pubdata.extend((message.len() as u32).to_be_bytes()); - l1_messenger_pubdata.extend(message); - } - - // Encoding bytecodes - // Format: `[(numberOfBytecodes as u32) || (bytecodes[1].len() as u32) || bytecodes[1] || ... || (bytecodes[n].len() as u32) || bytecodes[n]]` - l1_messenger_pubdata.extend((published_bytecodes.len() as u32).to_be_bytes()); - for bytecode in published_bytecodes { - l1_messenger_pubdata.extend((bytecode.len() as u32).to_be_bytes()); - l1_messenger_pubdata.extend(bytecode); - } - - // Encoding state diffs - // Format: `[size of compressed state diffs u32 || compressed state diffs || (# state diffs: intial + repeated) as u32 || sorted state diffs by ]` - let state_diffs_compressed = compress_state_diffs(state_diffs.clone()); - l1_messenger_pubdata.extend(state_diffs_compressed); - - if with_uncompressed_state_diffs { - l1_messenger_pubdata.extend((state_diffs.len() as u32).to_be_bytes()); - for state_diff in state_diffs { - l1_messenger_pubdata.extend(state_diff.encode_padded()); - } - } - - l1_messenger_pubdata - } -} - -pub trait PubdataBuilder { - // when `l2_version` is true it will return the data to be sent to the L1_MESSENGER - // otherwise it returns the array of bytes to be sent to settlement layer inside the operator input. - fn build_pubdata(&self, input: PubdataInput, l2_version: bool) -> Vec; -} - -#[derive(Debug)] -pub struct RollupPubdataBuilder; - -impl PubdataBuilder for RollupPubdataBuilder { - fn build_pubdata(&self, input: PubdataInput, l2_version: bool) -> Vec { - let mut l1_messenger_pubdata = vec![]; - let mut l2_da_header = vec![]; - - let PubdataInput { - user_logs, - l2_to_l1_messages, - published_bytecodes, - state_diffs, - l2_to_l1_logs_tree_size, - } = input; - - if l2_version { - let chained_log_hash = build_chained_log_hash(&user_logs); - let log_root_hash = build_logs_root(&user_logs, l2_to_l1_logs_tree_size); - let chained_msg_hash = build_chained_message_hash(&l2_to_l1_messages); - let chained_bytecodes_hash = build_chained_bytecode_hash(&published_bytecodes); - - l2_da_header.push(Token::FixedBytes(chained_log_hash)); - l2_da_header.push(Token::FixedBytes(log_root_hash)); - l2_da_header.push(Token::FixedBytes(chained_msg_hash)); - l2_da_header.push(Token::FixedBytes(chained_bytecodes_hash)); - } - - l1_messenger_pubdata.extend(encode_user_logs(&user_logs)); - - // Encoding L2->L1 messages - // Format: `[(numberOfMessages as u32) || (messages[1].len() as u32) || messages[1] || ... || (messages[n].len() as u32) || messages[n]]` - l1_messenger_pubdata.extend((l2_to_l1_messages.len() as u32).to_be_bytes()); - for message in l2_to_l1_messages { - l1_messenger_pubdata.extend((message.len() as u32).to_be_bytes()); - l1_messenger_pubdata.extend(message); - } - // Encoding bytecodes - // Format: `[(numberOfBytecodes as u32) || (bytecodes[1].len() as u32) || bytecodes[1] || ... || (bytecodes[n].len() as u32) || bytecodes[n]]` - l1_messenger_pubdata.extend((published_bytecodes.len() as u32).to_be_bytes()); - for bytecode in published_bytecodes { - l1_messenger_pubdata.extend((bytecode.len() as u32).to_be_bytes()); - l1_messenger_pubdata.extend(bytecode); - } - // Encoding state diffs - // Format: `[size of compressed state diffs u32 || compressed state diffs || (# state diffs: intial + repeated) as u32 || sorted state diffs by ]` - let state_diffs_compressed = compress_state_diffs(state_diffs.clone()); - l1_messenger_pubdata.extend(state_diffs_compressed); - - if l2_version { - l1_messenger_pubdata.extend((state_diffs.len() as u32).to_be_bytes()); - for state_diff in state_diffs { - l1_messenger_pubdata.extend(state_diff.encode_padded()); - } - - // Selector of `IL2DAValidator::validatePubdata`. - let func_selector = ethabi::short_signature( - "validatePubdata", - &[ - ParamType::FixedBytes(32), - ParamType::FixedBytes(32), - ParamType::FixedBytes(32), - ParamType::FixedBytes(32), - ParamType::Bytes, - ], - ); - - l2_da_header.push(ethabi::Token::Bytes(l1_messenger_pubdata)); - - l1_messenger_pubdata = [func_selector.to_vec(), ethabi::encode(&l2_da_header)] - .concat() - .to_vec(); - } - - l1_messenger_pubdata - } -} - -#[derive(Debug)] -pub struct ValidiumPubdataBuilder; - -impl PubdataBuilder for ValidiumPubdataBuilder { - fn build_pubdata(&self, input: PubdataInput, l2_version: bool) -> Vec { - let mut l1_messenger_pubdata = vec![]; - let mut l2_da_header = vec![]; - - let PubdataInput { - user_logs, - l2_to_l1_messages, - published_bytecodes, - state_diffs, - l2_to_l1_logs_tree_size, - } = input; - - if l2_version { - let chained_log_hash = build_chained_log_hash(&user_logs); - let log_root_hash = build_logs_root(&user_logs, l2_to_l1_logs_tree_size); - let chained_msg_hash = build_chained_message_hash(&l2_to_l1_messages); - let chained_bytecodes_hash = build_chained_bytecode_hash(&published_bytecodes); - l2_da_header.push(Token::FixedBytes(chained_log_hash)); - l2_da_header.push(Token::FixedBytes(log_root_hash)); - l2_da_header.push(Token::FixedBytes(chained_msg_hash)); - l2_da_header.push(Token::FixedBytes(chained_bytecodes_hash)); - } - - l1_messenger_pubdata.extend(encode_user_logs(&user_logs)); - - if l2_version { - // Selector of `IL2DAValidator::validatePubdata`. - let func_selector = ethabi::short_signature( - "validatePubdata", - &[ - ParamType::FixedBytes(32), - ParamType::FixedBytes(32), - ParamType::FixedBytes(32), - ParamType::FixedBytes(32), - ParamType::Bytes, - ], - ); - - l2_da_header.push(ethabi::Token::Bytes(l1_messenger_pubdata)); - - [func_selector.to_vec(), ethabi::encode(&l2_da_header)] - .concat() - .to_vec() - } else { - let state_diffs_packed = state_diffs - .into_iter() - .flat_map(|diff| diff.encode_padded()) - .collect::>(); - - keccak256(&state_diffs_packed).to_vec() - } - } -} - -fn build_chained_log_hash(user_logs: &[L1MessengerL2ToL1Log]) -> Vec { - let mut chained_log_hash = vec![0u8; 32]; - - for log in user_logs { - let log_bytes = log.packed_encoding(); - let hash = keccak256(&log_bytes); - - chained_log_hash = keccak256(&[chained_log_hash, hash.to_vec()].concat()).to_vec(); - } - - chained_log_hash -} - -fn build_logs_root(user_logs: &[L1MessengerL2ToL1Log], l2_to_l1_logs_tree_size: usize) -> Vec { - let logs = user_logs.iter().map(|log| { - let encoded = log.packed_encoding(); - let mut slice = [0u8; 88]; - slice.copy_from_slice(&encoded); - slice - }); - MiniMerkleTree::new(logs, Some(l2_to_l1_logs_tree_size)) - .merkle_root() - .as_bytes() - .to_vec() -} - -fn build_chained_message_hash(l2_to_l1_messages: &[Vec]) -> Vec { - let mut chained_msg_hash = vec![0u8; 32]; - - for msg in l2_to_l1_messages { - let hash = keccak256(msg); - - chained_msg_hash = keccak256(&[chained_msg_hash, hash.to_vec()].concat()).to_vec(); - } - - chained_msg_hash -} - -fn build_chained_bytecode_hash(published_bytecodes: &[Vec]) -> Vec { - let mut chained_bytecode_hash = vec![0u8; 32]; - - for bytecode in published_bytecodes { - let hash = hash_bytecode(bytecode).to_fixed_bytes(); - - chained_bytecode_hash = - keccak256(&[chained_bytecode_hash, hash.to_vec()].concat()).to_vec(); - } - - chained_bytecode_hash -} - -fn encode_user_logs(user_logs: &[L1MessengerL2ToL1Log]) -> Vec { - // Encoding user L2->L1 logs. - // Format: `[(numberOfL2ToL1Logs as u32) || l2tol1logs[1] || ... || l2tol1logs[n]]` - let mut result = vec![]; - result.extend((user_logs.len() as u32).to_be_bytes()); - for l2tol1log in user_logs { - result.extend(l2tol1log.packed_encoding()); - } - result -} - -#[cfg(test)] -mod tests { - use zksync_system_constants::{ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS}; - use zksync_types::{l2_to_l1_log::l2_to_l1_logs_tree_size, ProtocolVersionId}; - use zksync_utils::u256_to_h256; - - use super::*; - - #[test] - fn test_basic_pubdata_building() { - // Just using some constant addresses for tests - let addr1 = BOOTLOADER_ADDRESS; - let addr2 = ACCOUNT_CODE_STORAGE_ADDRESS; - - let user_logs = vec![L1MessengerL2ToL1Log { - l2_shard_id: 0, - is_service: false, - tx_number_in_block: 0, - sender: addr1, - key: 1.into(), - value: 128.into(), - }]; - - let l2_to_l1_messages = vec![hex::decode("deadbeef").unwrap()]; - - let published_bytecodes = vec![hex::decode("aaaabbbb").unwrap()]; - - // For covering more cases, we have two state diffs: - // One with enumeration index present (and so it is a repeated write) and the one without it. - let state_diffs = vec![ - StateDiffRecord { - address: addr2, - key: 155.into(), - derived_key: u256_to_h256(125.into()).0, - enumeration_index: 12, - initial_value: 11.into(), - final_value: 12.into(), - }, - StateDiffRecord { - address: addr2, - key: 156.into(), - derived_key: u256_to_h256(126.into()).0, - enumeration_index: 0, - initial_value: 0.into(), - final_value: 14.into(), - }, - ]; - - let input = PubdataInput { - user_logs, - l2_to_l1_messages, - published_bytecodes, - state_diffs, - l2_to_l1_logs_tree_size: l2_to_l1_logs_tree_size(ProtocolVersionId::latest()), - }; - - let pubdata = - ethabi::encode(&[ethabi::Token::Bytes(input.build_pubdata_pre_gateway(true))])[32..] - .to_vec(); - - assert_eq!(hex::encode(pubdata), "00000000000000000000000000000000000000000000000000000000000002c700000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000004aaaabbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901000000020000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009b000000000000000000000000000000000000000000000000000000000000007d000000000000000c000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000007e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); - } -} diff --git a/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs index b6e5e127c857..8aa11aad3cd2 100644 --- a/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs +++ b/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs @@ -1,3 +1,5 @@ +use std::rc::Rc; + use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; use zk_evm_1_5_0::{ aux_structures::{MemoryPage, PubdataCost, Timestamp}, @@ -13,6 +15,7 @@ use zk_evm_1_5_0::{ use zksync_system_constants::BOOTLOADER_ADDRESS; use zksync_types::{block::L2BlockHasher, Address, L2BlockNumber}; use zksync_utils::h256_to_u256; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ interface::{ @@ -33,7 +36,6 @@ use crate::{ oracles::storage::StorageOracle, types::l1_batch::bootloader_initial_memory, utils::l2_blocks::{assert_next_block, load_last_l2_block}, - MultiVMSubversion, }, }; @@ -65,7 +67,7 @@ pub(crate) fn new_vm_state( storage: StoragePtr, system_env: &SystemEnv, l1_batch_env: &L1BatchEnv, - subversion: MultiVMSubversion, + pubdata_builder: Rc, ) -> (ZkSyncVmState, BootloaderState) { let last_l2_block = if let Some(last_l2_block) = load_last_l2_block(&storage) { last_l2_block @@ -183,8 +185,8 @@ pub(crate) fn new_vm_state( system_env.execution_mode, bootloader_initial_memory, first_l2_block, - system_env.pubdata_params, - subversion, + system_env.version, + pubdata_builder, ); (vm, bootloader_state) diff --git a/core/lib/multivm/src/versions/vm_latest/vm.rs b/core/lib/multivm/src/versions/vm_latest/vm.rs index e43dcf31d802..c6371732f814 100644 --- a/core/lib/multivm/src/versions/vm_latest/vm.rs +++ b/core/lib/multivm/src/versions/vm_latest/vm.rs @@ -1,3 +1,5 @@ +use std::rc::Rc; + use circuit_sequencer_api_1_5_0::sort_storage_access::sort_storage_access_queries; use zksync_types::{ l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, @@ -5,6 +7,7 @@ use zksync_types::{ Transaction, H256, }; use zksync_utils::u256_to_h256; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ glue::GlueInto, @@ -176,7 +179,7 @@ impl VmInterface for Vm { block_tip_execution_result: result, final_execution_state: execution_state, final_bootloader_memory: Some(bootloader_memory), - pubdata_input: Some(self.bootloader_state.get_encoded_pubdata()), + pubdata_input: Some(self.bootloader_state.settlement_layer_pubdata()), state_diffs: Some( self.bootloader_state .get_pubdata_information() @@ -188,12 +191,18 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr, + pubdata_builder: Option>, + ) -> Self { let vm_version: VmVersion = system_env.version.into(); Self::new_with_subversion( batch_env, system_env, storage, + pubdata_builder, vm_version.try_into().expect("Incorrect 1.5.0 VmVersion"), ) } @@ -204,10 +213,12 @@ impl Vm { batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr, + pubdata_builder: Option>, subversion: MultiVMSubversion, ) -> Self { + let pubdata_builder = pubdata_builder.expect("pubdata_builder is required"); let (state, bootloader_state) = - new_vm_state(storage.clone(), &system_env, &batch_env, subversion); + new_vm_state(storage.clone(), &system_env, &batch_env, pubdata_builder); Self { bootloader_state, state, diff --git a/core/lib/multivm/src/versions/vm_m5/vm.rs b/core/lib/multivm/src/versions/vm_m5/vm.rs index 40f66659f29f..47b917004088 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm.rs @@ -1,5 +1,8 @@ +use std::rc::Rc; + use zksync_types::{vm::VmVersion, Transaction}; use zksync_utils::h256_to_u256; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ glue::{history_mode::HistoryMode, GlueInto}, @@ -129,7 +132,12 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr, + _pubdata_builder: Option>, + ) -> Self { let vm_version: VmVersion = system_env.version.into(); let vm_sub_version = match vm_version { VmVersion::M5WithoutRefunds => MultiVMSubversion::V1, diff --git a/core/lib/multivm/src/versions/vm_m6/vm.rs b/core/lib/multivm/src/versions/vm_m6/vm.rs index 627687a5524a..8920cdd88bf1 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm.rs @@ -1,7 +1,8 @@ -use std::collections::HashSet; +use std::{collections::HashSet, rc::Rc}; use zksync_types::{vm::VmVersion, Transaction}; use zksync_utils::{bytecode::hash_bytecode, h256_to_u256}; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ glue::{history_mode::HistoryMode, GlueInto}, @@ -213,7 +214,12 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr, + _pubdata_builder: Option>, + ) -> Self { let vm_version: VmVersion = system_env.version.into(); let vm_sub_version = match vm_version { VmVersion::M6Initial => MultiVMSubversion::V1, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs index 735bd29c3b09..1da38c73e7d9 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs @@ -1,5 +1,8 @@ +use std::rc::Rc; + use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; use zksync_types::{l2_to_l1_log::UserL2ToL1Log, Transaction}; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ glue::GlueInto, @@ -137,7 +140,12 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr, + _pubdata_builder: Option>, + ) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs index 2a9d6eed6c7d..4f187553afdd 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs @@ -1,5 +1,8 @@ +use std::rc::Rc; + use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; use zksync_types::{l2_to_l1_log::UserL2ToL1Log, Transaction}; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ glue::GlueInto, @@ -137,7 +140,12 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr, + _pubdata_builder: Option>, + ) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs index bfb121a740e6..6dded13a9793 100644 --- a/core/lib/multivm/src/vm_instance.rs +++ b/core/lib/multivm/src/vm_instance.rs @@ -1,7 +1,8 @@ -use std::mem; +use std::{mem, rc::Rc}; use zksync_types::{vm::VmVersion, Transaction}; use zksync_vm2::interface::Tracer; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ glue::history_mode::HistoryMode, @@ -102,10 +103,17 @@ impl VmFactory> for LegacyVmInsta batch_env: L1BatchEnv, system_env: SystemEnv, storage_view: StoragePtr>, + pubdata_builder: Option>, ) -> Self { let protocol_version = system_env.version; let vm_version: VmVersion = protocol_version.into(); - Self::new_with_specific_version(batch_env, system_env, storage_view, vm_version) + Self::new_with_specific_version( + batch_env, + system_env, + storage_view, + vm_version, + pubdata_builder, + ) } } @@ -129,6 +137,7 @@ impl LegacyVmInstance { system_env: SystemEnv, storage_view: StoragePtr>, vm_version: VmVersion, + pubdata_builder: Option>, ) -> Self { match vm_version { VmVersion::M5WithoutRefunds => { @@ -168,29 +177,57 @@ impl LegacyVmInstance { Self::VmM6(vm) } VmVersion::Vm1_3_2 => { - let vm = crate::vm_1_3_2::Vm::new(l1_batch_env, system_env, storage_view); + let vm = crate::vm_1_3_2::Vm::new( + l1_batch_env, + system_env, + storage_view, + pubdata_builder, + ); Self::Vm1_3_2(vm) } VmVersion::VmVirtualBlocks => { - let vm = crate::vm_virtual_blocks::Vm::new(l1_batch_env, system_env, storage_view); + let vm = crate::vm_virtual_blocks::Vm::new( + l1_batch_env, + system_env, + storage_view, + pubdata_builder, + ); Self::VmVirtualBlocks(vm) } VmVersion::VmVirtualBlocksRefundsEnhancement => { - let vm = - crate::vm_refunds_enhancement::Vm::new(l1_batch_env, system_env, storage_view); + let vm = crate::vm_refunds_enhancement::Vm::new( + l1_batch_env, + system_env, + storage_view, + pubdata_builder, + ); Self::VmVirtualBlocksRefundsEnhancement(vm) } VmVersion::VmBoojumIntegration => { - let vm = - crate::vm_boojum_integration::Vm::new(l1_batch_env, system_env, storage_view); + let vm = crate::vm_boojum_integration::Vm::new( + l1_batch_env, + system_env, + storage_view, + pubdata_builder, + ); Self::VmBoojumIntegration(vm) } VmVersion::Vm1_4_1 => { - let vm = crate::vm_1_4_1::Vm::new(l1_batch_env, system_env, storage_view); + let vm = crate::vm_1_4_1::Vm::new( + l1_batch_env, + system_env, + storage_view, + pubdata_builder, + ); Self::Vm1_4_1(vm) } VmVersion::Vm1_4_2 => { - let vm = crate::vm_1_4_2::Vm::new(l1_batch_env, system_env, storage_view); + let vm = crate::vm_1_4_2::Vm::new( + l1_batch_env, + system_env, + storage_view, + pubdata_builder, + ); Self::Vm1_4_2(vm) } VmVersion::Vm1_5_0SmallBootloaderMemory => { @@ -198,6 +235,7 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, + pubdata_builder, crate::vm_latest::MultiVMSubversion::SmallBootloaderMemory, ); Self::Vm1_5_0(vm) @@ -207,6 +245,7 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, + pubdata_builder, crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory, ); Self::Vm1_5_0(vm) @@ -216,6 +255,7 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, + pubdata_builder, crate::vm_latest::MultiVMSubversion::Gateway, ); Self::Vm1_5_0(vm) @@ -323,11 +363,13 @@ impl FastVmInstance { l1_batch_env: L1BatchEnv, system_env: SystemEnv, storage_view: StoragePtr>, + pubdata_builder: Option>, ) -> Self { Self::Fast(crate::vm_fast::Vm::new( l1_batch_env, system_env, storage_view, + pubdata_builder, )) } @@ -336,7 +378,13 @@ impl FastVmInstance { l1_batch_env: L1BatchEnv, system_env: SystemEnv, storage_view: StoragePtr>, + pubdata_builder: Option>, ) -> Self { - Self::Shadowed(ShadowedFastVm::new(l1_batch_env, system_env, storage_view)) + Self::Shadowed(ShadowedFastVm::new( + l1_batch_env, + system_env, + storage_view, + pubdata_builder, + )) } } diff --git a/core/lib/prover_interface/src/inputs.rs b/core/lib/prover_interface/src/inputs.rs index 22a20223c8b4..fc661ea27cec 100644 --- a/core/lib/prover_interface/src/inputs.rs +++ b/core/lib/prover_interface/src/inputs.rs @@ -5,7 +5,7 @@ use serde_with::{serde_as, Bytes}; use zksync_multivm::interface::{L1BatchEnv, SystemEnv}; use zksync_object_store::{serialize_using_bincode, Bucket, StoredObject}; use zksync_types::{ - basic_fri_types::Eip4844Blobs, block::L2BlockExecutionData, + basic_fri_types::Eip4844Blobs, block::L2BlockExecutionData, commitment::PubdataParams, witness_block_state::WitnessStorageState, L1BatchNumber, ProtocolVersionId, H256, U256, }; @@ -196,6 +196,7 @@ pub struct V1TeeVerifierInput { pub l1_batch_env: L1BatchEnv, pub system_env: SystemEnv, pub used_contracts: Vec<(H256, Vec)>, + pub pubdata_params: PubdataParams, } impl V1TeeVerifierInput { @@ -205,6 +206,7 @@ impl V1TeeVerifierInput { l1_batch_env: L1BatchEnv, system_env: SystemEnv, used_contracts: Vec<(H256, Vec)>, + pubdata_params: PubdataParams, ) -> Self { V1TeeVerifierInput { witness_input_merkle_paths, @@ -212,6 +214,7 @@ impl V1TeeVerifierInput { l1_batch_env, system_env, used_contracts, + pubdata_params, } } } diff --git a/core/lib/tee_verifier/src/lib.rs b/core/lib/tee_verifier/src/lib.rs index 595480687e9c..79ade47a1a0c 100644 --- a/core/lib/tee_verifier/src/lib.rs +++ b/core/lib/tee_verifier/src/lib.rs @@ -13,6 +13,7 @@ use zksync_merkle_tree::{ }; use zksync_multivm::{ interface::{ + pubdata::pubdata_params_to_builder, storage::{InMemoryStorage, ReadStorage, StorageView}, FinishedL1Batch, L2BlockEnv, VmFactory, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, @@ -70,7 +71,12 @@ impl Verify for V1TeeVerifierInput { let storage_view = Rc::new(RefCell::new(StorageView::new(&raw_storage))); let batch_number = self.l1_batch_env.number; - let vm = LegacyVmInstance::new(self.l1_batch_env, self.system_env, storage_view); + let vm = LegacyVmInstance::new( + self.l1_batch_env, + self.system_env, + storage_view, + Some(pubdata_params_to_builder(self.pubdata_params)), + ); let vm_out = execute_vm(self.l2_blocks_execution_data, vm)?; @@ -311,9 +317,9 @@ mod tests { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: 0, chain_id: Default::default(), - pubdata_params: Default::default(), }, vec![(H256([1; 32]), vec![0, 1, 2, 3, 4])], + Default::default(), ); let tvi = TeeVerifierInput::new(tvi); let serialized = ::serialize(&tvi) diff --git a/core/lib/vm_executor/src/batch/factory.rs b/core/lib/vm_executor/src/batch/factory.rs index 146f0bb4e5c8..5256dd6077e0 100644 --- a/core/lib/vm_executor/src/batch/factory.rs +++ b/core/lib/vm_executor/src/batch/factory.rs @@ -6,6 +6,7 @@ use tokio::sync::mpsc; use zksync_multivm::{ interface::{ executor::{BatchExecutor, BatchExecutorFactory}, + pubdata::{pubdata_params_to_builder, PubdataBuilder}, storage::{ReadStorage, StoragePtr, StorageView, StorageViewStats}, utils::DivergenceHandler, BatchTransactionExecutionResult, BytecodeCompressionError, CompressedBytecodeInfo, @@ -17,7 +18,7 @@ use zksync_multivm::{ vm_latest::HistoryEnabled, FastVmInstance, LegacyVmInstance, MultiVMTracer, }; -use zksync_types::{vm::FastVmMode, Transaction}; +use zksync_types::{commitment::PubdataParams, vm::FastVmMode, Transaction}; use super::{ executor::{Command, MainBatchExecutor}, @@ -115,6 +116,7 @@ impl BatchExecutorFactory storage: S, l1_batch_params: L1BatchEnv, system_env: SystemEnv, + pubdata_params: PubdataParams, ) -> Box> { // Since we process `BatchExecutor` commands one-by-one (the next command is never enqueued // until a previous command is processed), capacity 1 is enough for the commands channel. @@ -129,8 +131,14 @@ impl BatchExecutorFactory _tracer: PhantomData::, }; - let handle = - tokio::task::spawn_blocking(move || executor.run(storage, l1_batch_params, system_env)); + let handle = tokio::task::spawn_blocking(move || { + executor.run( + storage, + l1_batch_params, + system_env, + Some(pubdata_params_to_builder(pubdata_params)), + ) + }); Box::new(MainBatchExecutor::new(handle, commands_sender)) } } @@ -157,19 +165,27 @@ impl BatchVm { l1_batch_env: L1BatchEnv, system_env: SystemEnv, storage_ptr: StoragePtr>, + pubdata_builder: Option>, mode: FastVmMode, ) -> Self { match mode { - FastVmMode::Old => { - Self::Legacy(LegacyVmInstance::new(l1_batch_env, system_env, storage_ptr)) - } - FastVmMode::New => { - Self::Fast(FastVmInstance::fast(l1_batch_env, system_env, storage_ptr)) - } + FastVmMode::Old => Self::Legacy(LegacyVmInstance::new( + l1_batch_env, + system_env, + storage_ptr, + pubdata_builder, + )), + FastVmMode::New => Self::Fast(FastVmInstance::fast( + l1_batch_env, + system_env, + storage_ptr, + pubdata_builder, + )), FastVmMode::Shadow => Self::Fast(FastVmInstance::shadowed( l1_batch_env, system_env, storage_ptr, + pubdata_builder, )), } } @@ -255,6 +271,7 @@ impl CommandReceiver { storage: S, l1_batch_params: L1BatchEnv, system_env: SystemEnv, + pubdata_builder: Option>, ) -> anyhow::Result> { tracing::info!("Starting executing L1 batch #{}", &l1_batch_params.number); @@ -263,6 +280,7 @@ impl CommandReceiver { l1_batch_params, system_env, storage_view.clone(), + pubdata_builder, self.fast_vm_mode, ); let mut batch_finished = false; diff --git a/core/lib/vm_executor/src/oneshot/block.rs b/core/lib/vm_executor/src/oneshot/block.rs index cab64289e5ee..1b5d02f41fb5 100644 --- a/core/lib/vm_executor/src/oneshot/block.rs +++ b/core/lib/vm_executor/src/oneshot/block.rs @@ -182,7 +182,7 @@ impl OneshotEnvParameters { ) .await?; - let (system, l1_batch) = self.prepare_env( + let (system, l1_batch, pubdata_params) = self.prepare_env( execution_mode, resolved_block_info, next_block, @@ -192,6 +192,7 @@ impl OneshotEnvParameters { Ok(OneshotEnv { system, l1_batch, + pubdata_params, current_block, }) } @@ -203,7 +204,7 @@ impl OneshotEnvParameters { next_block: L2BlockEnv, fee_input: BatchFeeInput, enforced_base_fee: Option, - ) -> (SystemEnv, L1BatchEnv) { + ) -> (SystemEnv, L1BatchEnv, PubdataParams) { let &Self { operator_account, validation_computational_gas_limit, @@ -222,7 +223,6 @@ impl OneshotEnvParameters { execution_mode, default_validation_computational_gas_limit: validation_computational_gas_limit, chain_id, - pubdata_params: resolved_block_info.pubdata_params, }; let l1_batch_env = L1BatchEnv { previous_batch_hash: None, @@ -233,7 +233,7 @@ impl OneshotEnvParameters { enforced_base_fee, first_l2_block: next_block, }; - (system_env, l1_batch_env) + (system_env, l1_batch_env, resolved_block_info.pubdata_params) } } diff --git a/core/lib/vm_executor/src/oneshot/mod.rs b/core/lib/vm_executor/src/oneshot/mod.rs index cb75f396b5d5..e13bacbe5f96 100644 --- a/core/lib/vm_executor/src/oneshot/mod.rs +++ b/core/lib/vm_executor/src/oneshot/mod.rs @@ -17,6 +17,7 @@ use once_cell::sync::OnceCell; use zksync_multivm::{ interface::{ executor::{OneshotExecutor, TransactionValidator}, + pubdata::pubdata_params_to_builder, storage::{ReadStorage, StoragePtr, StorageView, WriteStorage}, tracer::{ValidationError, ValidationParams}, ExecutionResult, OneshotEnv, OneshotTracingParams, OneshotTransactionExecutionResult, @@ -217,6 +218,7 @@ impl VmSandbox { env.system, storage_view.clone(), protocol_version.into_api_vm_version(), + Some(pubdata_params_to_builder(env.pubdata_params)), )); Self { diff --git a/core/lib/vm_executor/src/storage.rs b/core/lib/vm_executor/src/storage.rs index 19514bd5fa8b..ec574d7e5439 100644 --- a/core/lib/vm_executor/src/storage.rs +++ b/core/lib/vm_executor/src/storage.rs @@ -55,7 +55,7 @@ pub fn l1_batch_params( virtual_blocks: u32, chain_id: L2ChainId, pubdata_params: PubdataParams, -) -> (SystemEnv, L1BatchEnv) { +) -> (SystemEnv, L1BatchEnv, PubdataParams) { ( SystemEnv { zk_porter_available: ZKPORTER_IS_AVAILABLE, @@ -65,7 +65,6 @@ pub fn l1_batch_params( execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: validation_computational_gas_limit, chain_id, - pubdata_params, }, L1BatchEnv { previous_batch_hash: Some(previous_batch_hash), @@ -81,6 +80,7 @@ pub fn l1_batch_params( max_virtual_blocks_to_create: virtual_blocks, }, }, + pubdata_params, ) } @@ -266,7 +266,7 @@ impl L1BatchParamsProvider { first_l2_block_in_batch: &FirstL2BlockInBatch, validation_computational_gas_limit: u32, chain_id: L2ChainId, - ) -> anyhow::Result<(SystemEnv, L1BatchEnv)> { + ) -> anyhow::Result<(SystemEnv, L1BatchEnv, PubdataParams)> { anyhow::ensure!( first_l2_block_in_batch.l1_batch_number > L1BatchNumber(0), "Loading params for genesis L1 batch not supported" @@ -346,7 +346,7 @@ impl L1BatchParamsProvider { number: L1BatchNumber, validation_computational_gas_limit: u32, chain_id: L2ChainId, - ) -> anyhow::Result> { + ) -> anyhow::Result> { let first_l2_block = self .load_first_l2_block_in_batch(storage, number) .await diff --git a/core/lib/vm_interface/Cargo.toml b/core/lib/vm_interface/Cargo.toml index 8bff19ddc475..e771bb131e58 100644 --- a/core/lib/vm_interface/Cargo.toml +++ b/core/lib/vm_interface/Cargo.toml @@ -14,6 +14,8 @@ categories.workspace = true zksync_contracts.workspace = true zksync_system_constants.workspace = true zksync_types.workspace = true +zksync_utils.workspace = true +zksync_mini_merkle_tree.workspace = true anyhow.workspace = true async-trait.workspace = true diff --git a/core/lib/vm_interface/src/executor.rs b/core/lib/vm_interface/src/executor.rs index 119f975fecd5..60522ba338a2 100644 --- a/core/lib/vm_interface/src/executor.rs +++ b/core/lib/vm_interface/src/executor.rs @@ -3,7 +3,7 @@ use std::fmt; use async_trait::async_trait; -use zksync_types::{l2::L2Tx, Transaction}; +use zksync_types::{commitment::PubdataParams, l2::L2Tx, Transaction}; use crate::{ storage::{ReadStorage, StorageView}, @@ -20,6 +20,7 @@ pub trait BatchExecutorFactory: 'static + Send + fmt::Debug { storage: S, l1_batch_params: L1BatchEnv, system_env: SystemEnv, + pubdata_params: PubdataParams, ) -> Box>; } diff --git a/core/lib/vm_interface/src/lib.rs b/core/lib/vm_interface/src/lib.rs index 645e3e7c856e..008c9abb75d9 100644 --- a/core/lib/vm_interface/src/lib.rs +++ b/core/lib/vm_interface/src/lib.rs @@ -41,6 +41,7 @@ pub use crate::{ }; pub mod executor; +pub mod pubdata; pub mod storage; mod types; pub mod utils; diff --git a/core/lib/vm_interface/src/pubdata/mod.rs b/core/lib/vm_interface/src/pubdata/mod.rs new file mode 100644 index 000000000000..5e05acd93307 --- /dev/null +++ b/core/lib/vm_interface/src/pubdata/mod.rs @@ -0,0 +1,122 @@ +use std::rc::Rc; + +use zksync_types::{ + commitment::{L1BatchCommitmentMode, PubdataParams}, + ethabi, + l2_to_l1_log::L2ToL1Log, + writes::StateDiffRecord, + Address, ProtocolVersionId, U256, +}; +use zksync_utils::{u256_to_bytes_be, u256_to_h256}; + +use crate::pubdata::{rollup::RollupPubdataBuilder, validium::ValidiumPubdataBuilder}; + +pub mod rollup; +pub mod utils; +pub mod validium; + +#[cfg(test)] +mod tests; + +/// Corresponds to the following solidity event: +/// ```solidity +/// struct L2ToL1Log { +/// uint8 l2ShardId; +/// bool isService; +/// uint16 txNumberInBlock; +/// address sender; +/// bytes32 key; +/// bytes32 value; +/// } +/// ``` +#[derive(Debug, Default, Clone, PartialEq)] +pub struct L1MessengerL2ToL1Log { + pub l2_shard_id: u8, + pub is_service: bool, + pub tx_number_in_block: u16, + pub sender: Address, + pub key: U256, + pub value: U256, +} + +impl L1MessengerL2ToL1Log { + pub fn packed_encoding(&self) -> Vec { + let mut res: Vec = vec![]; + res.push(self.l2_shard_id); + res.push(self.is_service as u8); + res.extend_from_slice(&self.tx_number_in_block.to_be_bytes()); + res.extend_from_slice(self.sender.as_bytes()); + res.extend(u256_to_bytes_be(&self.key)); + res.extend(u256_to_bytes_be(&self.value)); + res + } +} + +impl From for L2ToL1Log { + fn from(log: L1MessengerL2ToL1Log) -> Self { + L2ToL1Log { + shard_id: log.l2_shard_id, + is_service: log.is_service, + tx_number_in_block: log.tx_number_in_block, + sender: log.sender, + key: u256_to_h256(log.key), + value: u256_to_h256(log.value), + } + } +} + +/// Struct based on which the pubdata blob is formed +#[derive(Debug, Clone, Default)] +pub struct PubdataInput { + pub user_logs: Vec, + pub l2_to_l1_messages: Vec>, + pub published_bytecodes: Vec>, + pub state_diffs: Vec, +} + +/// Trait that encapsulates pubdata building logic. It is implemented for rollup and validium cases. +/// If chains needs custom pubdata format then another implementation should be added. +pub trait PubdataBuilder: std::fmt::Debug { + fn pubdata_params(&self) -> Option { + None + } + + fn l2_da_validator(&self) -> Address; + + fn l1_messenger_operator_input( + &self, + input: PubdataInput, + protocol_version: ProtocolVersionId, + ) -> Vec; + + fn settlement_layer_pubdata( + &self, + input: PubdataInput, + protocol_version: ProtocolVersionId, + ) -> Vec; + + fn bootloader_memory_input( + &self, + input: PubdataInput, + protocol_version: ProtocolVersionId, + ) -> Vec { + let l2_da_validator_address = self.l2_da_validator(); + let operator_input = self.l1_messenger_operator_input(input, protocol_version); + + ethabi::encode(&[ + ethabi::Token::Address(l2_da_validator_address), + ethabi::Token::Bytes(operator_input), + ]) + } +} + +pub fn pubdata_params_to_builder(params: PubdataParams) -> Rc { + match params.pubdata_type { + L1BatchCommitmentMode::Rollup => { + Rc::new(RollupPubdataBuilder::new(params.l2_da_validator_address)) + } + L1BatchCommitmentMode::Validium => { + Rc::new(ValidiumPubdataBuilder::new(params.l2_da_validator_address)) + } + } +} diff --git a/core/lib/vm_interface/src/pubdata/rollup.rs b/core/lib/vm_interface/src/pubdata/rollup.rs new file mode 100644 index 000000000000..b7328f1668f1 --- /dev/null +++ b/core/lib/vm_interface/src/pubdata/rollup.rs @@ -0,0 +1,136 @@ +use zksync_types::{ + commitment::{L1BatchCommitmentMode, PubdataParams}, + ethabi, + ethabi::{ParamType, Token}, + l2_to_l1_log::l2_to_l1_logs_tree_size, + writes::compress_state_diffs, + Address, ProtocolVersionId, +}; + +use super::{PubdataBuilder, PubdataInput}; +use crate::pubdata::utils::{ + build_chained_bytecode_hash, build_chained_log_hash, build_chained_message_hash, + build_logs_root, encode_user_logs, +}; + +#[derive(Debug, Clone, Copy)] +pub struct RollupPubdataBuilder { + pub l2_da_validator: Address, +} + +impl RollupPubdataBuilder { + pub fn new(l2_da_validator: Address) -> Self { + Self { l2_da_validator } + } +} + +impl PubdataBuilder for RollupPubdataBuilder { + fn pubdata_params(&self) -> Option { + Some(PubdataParams { + l2_da_validator_address: self.l2_da_validator, + pubdata_type: L1BatchCommitmentMode::Rollup, + }) + } + + fn l2_da_validator(&self) -> Address { + self.l2_da_validator + } + + fn l1_messenger_operator_input( + &self, + input: PubdataInput, + protocol_version: ProtocolVersionId, + ) -> Vec { + if protocol_version.is_pre_gateway() { + let mut operator_input = vec![]; + extend_from_pubdata_input(&mut operator_input, &input); + + // Extend with uncompressed state diffs. + operator_input.extend((input.state_diffs.len() as u32).to_be_bytes()); + for state_diff in &input.state_diffs { + operator_input.extend(state_diff.encode_padded()); + } + + operator_input + } else { + let mut pubdata = vec![]; + extend_from_pubdata_input(&mut pubdata, &input); + + // Extend with uncompressed state diffs. + pubdata.extend((input.state_diffs.len() as u32).to_be_bytes()); + for state_diff in &input.state_diffs { + pubdata.extend(state_diff.encode_padded()); + } + + let chained_log_hash = build_chained_log_hash(&input.user_logs); + let log_root_hash = + build_logs_root(&input.user_logs, l2_to_l1_logs_tree_size(protocol_version)); + let chained_msg_hash = build_chained_message_hash(&input.l2_to_l1_messages); + let chained_bytecodes_hash = build_chained_bytecode_hash(&input.published_bytecodes); + + let l2_da_header = vec![ + Token::FixedBytes(chained_log_hash), + Token::FixedBytes(log_root_hash), + Token::FixedBytes(chained_msg_hash), + Token::FixedBytes(chained_bytecodes_hash), + Token::Bytes(pubdata), + ]; + + // Selector of `IL2DAValidator::validatePubdata`. + let func_selector = ethabi::short_signature( + "validatePubdata", + &[ + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::Bytes, + ], + ); + + [func_selector.to_vec(), ethabi::encode(&l2_da_header)].concat() + } + } + + fn settlement_layer_pubdata( + &self, + input: PubdataInput, + _protocol_version: ProtocolVersionId, + ) -> Vec { + let mut pubdata = vec![]; + extend_from_pubdata_input(&mut pubdata, &input); + + pubdata + } +} + +fn extend_from_pubdata_input(buffer: &mut Vec, pubdata_input: &PubdataInput) { + let PubdataInput { + user_logs, + l2_to_l1_messages, + published_bytecodes, + state_diffs, + } = pubdata_input; + + // Adding user L2->L1 logs. + buffer.extend(encode_user_logs(user_logs)); + + // Encoding L2->L1 messages + // Format: `[(numberOfMessages as u32) || (messages[1].len() as u32) || messages[1] || ... || (messages[n].len() as u32) || messages[n]]` + buffer.extend((l2_to_l1_messages.len() as u32).to_be_bytes()); + for message in l2_to_l1_messages { + buffer.extend((message.len() as u32).to_be_bytes()); + buffer.extend(message); + } + // Encoding bytecodes + // Format: `[(numberOfBytecodes as u32) || (bytecodes[1].len() as u32) || bytecodes[1] || ... || (bytecodes[n].len() as u32) || bytecodes[n]]` + buffer.extend((published_bytecodes.len() as u32).to_be_bytes()); + for bytecode in published_bytecodes { + buffer.extend((bytecode.len() as u32).to_be_bytes()); + buffer.extend(bytecode); + } + // Encoding state diffs + // Format: `[size of compressed state diffs u32 || compressed state diffs || (# state diffs: intial + repeated) as u32 || sorted state diffs by ]` + let state_diffs_compressed = compress_state_diffs(state_diffs.clone()); + buffer.extend(state_diffs_compressed); +} diff --git a/core/lib/vm_interface/src/pubdata/tests.rs b/core/lib/vm_interface/src/pubdata/tests.rs new file mode 100644 index 000000000000..8877116085cd --- /dev/null +++ b/core/lib/vm_interface/src/pubdata/tests.rs @@ -0,0 +1,121 @@ +use zksync_system_constants::{ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS}; +use zksync_types::{writes::StateDiffRecord, Address, ProtocolVersionId}; +use zksync_utils::u256_to_h256; + +use super::{L1MessengerL2ToL1Log, PubdataBuilder, PubdataInput}; +use crate::pubdata::{rollup::RollupPubdataBuilder, validium::ValidiumPubdataBuilder}; + +fn mock_input() -> PubdataInput { + // Just using some constant addresses for tests + let addr1 = BOOTLOADER_ADDRESS; + let addr2 = ACCOUNT_CODE_STORAGE_ADDRESS; + + let user_logs = vec![L1MessengerL2ToL1Log { + l2_shard_id: 0, + is_service: false, + tx_number_in_block: 0, + sender: addr1, + key: 1.into(), + value: 128.into(), + }]; + + let l2_to_l1_messages = vec![hex::decode("deadbeef").unwrap()]; + + let published_bytecodes = vec![hex::decode("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb").unwrap()]; + + // For covering more cases, we have two state diffs: + // One with enumeration index present (and so it is a repeated write) and the one without it. + let state_diffs = vec![ + StateDiffRecord { + address: addr2, + key: 155.into(), + derived_key: u256_to_h256(125.into()).0, + enumeration_index: 12, + initial_value: 11.into(), + final_value: 12.into(), + }, + StateDiffRecord { + address: addr2, + key: 156.into(), + derived_key: u256_to_h256(126.into()).0, + enumeration_index: 0, + initial_value: 0.into(), + final_value: 14.into(), + }, + ]; + + PubdataInput { + user_logs, + l2_to_l1_messages, + published_bytecodes, + state_diffs, + } +} + +#[test] +fn test_rollup_pubdata_building() { + let input = mock_input(); + + let rollup_pubdata_builder = RollupPubdataBuilder::new(Address::zero()); + + let actual = rollup_pubdata_builder + .l1_messenger_operator_input(input.clone(), ProtocolVersionId::Version24); + let expected = "00000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000060bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901000000020000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009b000000000000000000000000000000000000000000000000000000000000007d000000000000000c000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000007e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + assert_eq!( + &hex::encode(actual), + expected, + "mismatch for `l1_messenger_operator_input` (pre gateway)" + ); + + let actual = rollup_pubdata_builder + .settlement_layer_pubdata(input.clone(), ProtocolVersionId::Version24); + let expected = "00000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000060bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901"; + assert_eq!( + &hex::encode(actual), + expected, + "mismatch for `settlement_layer_pubdata` (pre gateway)" + ); + + let actual = rollup_pubdata_builder + .l1_messenger_operator_input(input.clone(), ProtocolVersionId::Version26); + let expected = "89f9a07233e608561d90f7c4e7bcea24d718e425a6bd6c8eefb48a334366143694c75fae278944d856d68e33bbd32937cb3a1ea35cbf7d6eeeb1150f500dd0d64d0efe420d6dafe5897eab2fc27b2e47af303397ed285ace146d836d042717b0a3dc4b28a603a33b28ce1d5c52c593a46a15a99f1afa1c1d92715284288958fd54a93de700000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000032300000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000060bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901000000020000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009b000000000000000000000000000000000000000000000000000000000000007d000000000000000c000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000007e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + assert_eq!( + &hex::encode(actual), + expected, + "mismatch for `l1_messenger_operator_input` (post gateway)" + ); + + let actual = rollup_pubdata_builder + .settlement_layer_pubdata(input.clone(), ProtocolVersionId::Version26); + let expected = "00000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000060bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901"; + assert_eq!( + &hex::encode(actual), + expected, + "mismatch for `settlement_layer_pubdata` (post gateway)" + ); +} + +#[test] +fn test_validium_pubdata_building() { + let input = mock_input(); + + let validium_pubdata_builder = ValidiumPubdataBuilder::new(Address::zero()); + + let actual = validium_pubdata_builder + .l1_messenger_operator_input(input.clone(), ProtocolVersionId::Version26); + let expected = "89f9a07233e608561d90f7c4e7bcea24d718e425a6bd6c8eefb48a334366143694c75fae278944d856d68e33bbd32937cb3a1ea35cbf7d6eeeb1150f500dd0d64d0efe420d6dafe5897eab2fc27b2e47af303397ed285ace146d836d042717b0a3dc4b28a603a33b28ce1d5c52c593a46a15a99f1afa1c1d92715284288958fd54a93de700000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000005c000000010000000000000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000"; + assert_eq!( + &hex::encode(actual), + expected, + "mismatch for `l1_messenger_operator_input`" + ); + + let actual = validium_pubdata_builder + .settlement_layer_pubdata(input.clone(), ProtocolVersionId::Version26); + let expected = "fa96e2436e6fb4d668f5a06681a7c53fcb199b2747ee624ee52a13e85aac5f1e"; + assert_eq!( + &hex::encode(actual), + expected, + "mismatch for `settlement_layer_pubdata`" + ); +} diff --git a/core/lib/vm_interface/src/pubdata/utils.rs b/core/lib/vm_interface/src/pubdata/utils.rs new file mode 100644 index 000000000000..8ed34962c3af --- /dev/null +++ b/core/lib/vm_interface/src/pubdata/utils.rs @@ -0,0 +1,70 @@ +use zksync_mini_merkle_tree::MiniMerkleTree; +use zksync_types::web3::keccak256; +use zksync_utils::bytecode::hash_bytecode; + +use crate::pubdata::L1MessengerL2ToL1Log; + +pub(crate) fn build_chained_log_hash(user_logs: &[L1MessengerL2ToL1Log]) -> Vec { + let mut chained_log_hash = vec![0u8; 32]; + + for log in user_logs { + let log_bytes = log.packed_encoding(); + let hash = keccak256(&log_bytes); + + chained_log_hash = keccak256(&[chained_log_hash, hash.to_vec()].concat()).to_vec(); + } + + chained_log_hash +} + +pub(crate) fn build_logs_root( + user_logs: &[L1MessengerL2ToL1Log], + l2_to_l1_logs_tree_size: usize, +) -> Vec { + let logs = user_logs.iter().map(|log| { + let encoded = log.packed_encoding(); + let mut slice = [0u8; 88]; + slice.copy_from_slice(&encoded); + slice + }); + MiniMerkleTree::new(logs, Some(l2_to_l1_logs_tree_size)) + .merkle_root() + .as_bytes() + .to_vec() +} + +pub(crate) fn build_chained_message_hash(l2_to_l1_messages: &[Vec]) -> Vec { + let mut chained_msg_hash = vec![0u8; 32]; + + for msg in l2_to_l1_messages { + let hash = keccak256(msg); + + chained_msg_hash = keccak256(&[chained_msg_hash, hash.to_vec()].concat()).to_vec(); + } + + chained_msg_hash +} + +pub(crate) fn build_chained_bytecode_hash(published_bytecodes: &[Vec]) -> Vec { + let mut chained_bytecode_hash = vec![0u8; 32]; + + for bytecode in published_bytecodes { + let hash = hash_bytecode(bytecode).to_fixed_bytes(); + + chained_bytecode_hash = + keccak256(&[chained_bytecode_hash, hash.to_vec()].concat()).to_vec(); + } + + chained_bytecode_hash +} + +pub(crate) fn encode_user_logs(user_logs: &[L1MessengerL2ToL1Log]) -> Vec { + // Encoding user L2->L1 logs. + // Format: `[(numberOfL2ToL1Logs as u32) || l2tol1logs[1] || ... || l2tol1logs[n]]` + let mut result = vec![]; + result.extend((user_logs.len() as u32).to_be_bytes()); + for l2tol1log in user_logs { + result.extend(l2tol1log.packed_encoding()); + } + result +} diff --git a/core/lib/vm_interface/src/pubdata/validium.rs b/core/lib/vm_interface/src/pubdata/validium.rs new file mode 100644 index 000000000000..f0d8c9d0eb95 --- /dev/null +++ b/core/lib/vm_interface/src/pubdata/validium.rs @@ -0,0 +1,103 @@ +use zksync_types::{ + commitment::{L1BatchCommitmentMode, PubdataParams}, + ethabi, + ethabi::{ParamType, Token}, + l2_to_l1_log::l2_to_l1_logs_tree_size, + web3::keccak256, + Address, ProtocolVersionId, +}; + +use crate::pubdata::{ + utils::{ + build_chained_bytecode_hash, build_chained_log_hash, build_chained_message_hash, + build_logs_root, encode_user_logs, + }, + PubdataBuilder, PubdataInput, +}; + +#[derive(Debug, Clone, Copy)] +pub struct ValidiumPubdataBuilder { + pub l2_da_validator: Address, +} + +impl ValidiumPubdataBuilder { + pub fn new(l2_da_validator: Address) -> Self { + Self { l2_da_validator } + } +} + +impl PubdataBuilder for ValidiumPubdataBuilder { + fn pubdata_params(&self) -> Option { + Some(PubdataParams { + l2_da_validator_address: self.l2_da_validator, + pubdata_type: L1BatchCommitmentMode::Validium, + }) + } + + fn l2_da_validator(&self) -> Address { + self.l2_da_validator + } + + fn l1_messenger_operator_input( + &self, + input: PubdataInput, + protocol_version: ProtocolVersionId, + ) -> Vec { + assert!( + !protocol_version.is_pre_gateway(), + "ValidiumPubdataBuilder must not be called for pre gateway" + ); + + let mut pubdata = vec![]; + pubdata.extend(encode_user_logs(&input.user_logs)); + + let chained_log_hash = build_chained_log_hash(&input.user_logs); + let log_root_hash = + build_logs_root(&input.user_logs, l2_to_l1_logs_tree_size(protocol_version)); + let chained_msg_hash = build_chained_message_hash(&input.l2_to_l1_messages); + let chained_bytecodes_hash = build_chained_bytecode_hash(&input.published_bytecodes); + + let l2_da_header = vec![ + Token::FixedBytes(chained_log_hash), + Token::FixedBytes(log_root_hash), + Token::FixedBytes(chained_msg_hash), + Token::FixedBytes(chained_bytecodes_hash), + Token::Bytes(pubdata), + ]; + + // Selector of `IL2DAValidator::validatePubdata`. + let func_selector = ethabi::short_signature( + "validatePubdata", + &[ + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::FixedBytes(32), + ParamType::Bytes, + ], + ); + + [func_selector.to_vec(), ethabi::encode(&l2_da_header)] + .concat() + .to_vec() + } + + fn settlement_layer_pubdata( + &self, + input: PubdataInput, + protocol_version: ProtocolVersionId, + ) -> Vec { + assert!( + !protocol_version.is_pre_gateway(), + "ValidiumPubdataBuilder must not be called for pre gateway" + ); + + let state_diffs_packed = input + .state_diffs + .into_iter() + .flat_map(|diff| diff.encode_padded()) + .collect::>(); + + keccak256(&state_diffs_packed).to_vec() + } +} diff --git a/core/lib/vm_interface/src/types/inputs/mod.rs b/core/lib/vm_interface/src/types/inputs/mod.rs index 24f58ae72f16..78e653a7f26a 100644 --- a/core/lib/vm_interface/src/types/inputs/mod.rs +++ b/core/lib/vm_interface/src/types/inputs/mod.rs @@ -1,5 +1,6 @@ use zksync_types::{ - l2::L2Tx, ExecuteTransactionCommon, Nonce, PackedEthSignature, Transaction, U256, + commitment::PubdataParams, l2::L2Tx, ExecuteTransactionCommon, Nonce, PackedEthSignature, + Transaction, U256, }; pub use self::{ @@ -21,6 +22,8 @@ pub struct OneshotEnv { pub system: SystemEnv, /// Part of the environment specific to an L1 batch. pub l1_batch: L1BatchEnv, + /// Pubdata building parameters. + pub pubdata_params: PubdataParams, /// Part of the environment representing the current L2 block. Can be used to override storage slots /// in the system context contract, which are set from `L1BatchEnv.first_l2_block` by default. pub current_block: Option, diff --git a/core/lib/vm_interface/src/types/inputs/system_env.rs b/core/lib/vm_interface/src/types/inputs/system_env.rs index 67d555f9bc0f..5a0496752d54 100644 --- a/core/lib/vm_interface/src/types/inputs/system_env.rs +++ b/core/lib/vm_interface/src/types/inputs/system_env.rs @@ -2,7 +2,7 @@ use std::fmt::Debug; use serde::{Deserialize, Serialize}; use zksync_contracts::BaseSystemContracts; -use zksync_types::{commitment::PubdataParams, L2ChainId, ProtocolVersionId}; +use zksync_types::{L2ChainId, ProtocolVersionId}; /// Params related to the execution process, not batch it self #[derive(Clone, PartialEq, Serialize, Deserialize)] @@ -15,7 +15,6 @@ pub struct SystemEnv { pub execution_mode: TxExecutionMode, pub default_validation_computational_gas_limit: u32, pub chain_id: L2ChainId, - pub pubdata_params: PubdataParams, } impl Debug for SystemEnv { @@ -34,7 +33,6 @@ impl Debug for SystemEnv { ) .field("execution_mode", &self.execution_mode) .field("chain_id", &self.chain_id) - .field("pubdata_params", &self.pubdata_params) .finish() } } diff --git a/core/lib/vm_interface/src/utils/dump.rs b/core/lib/vm_interface/src/utils/dump.rs index 5dc2351dcf7a..034793b0907d 100644 --- a/core/lib/vm_interface/src/utils/dump.rs +++ b/core/lib/vm_interface/src/utils/dump.rs @@ -1,9 +1,13 @@ -use std::collections::HashMap; +use std::{collections::HashMap, rc::Rc}; use serde::{Deserialize, Serialize}; -use zksync_types::{block::L2BlockExecutionData, L1BatchNumber, L2BlockNumber, Transaction, H256}; +use zksync_types::{ + block::L2BlockExecutionData, commitment::PubdataParams, L1BatchNumber, L2BlockNumber, + Transaction, H256, +}; use crate::{ + pubdata::{pubdata_params_to_builder, PubdataBuilder}, storage::{ReadStorage, StoragePtr, StorageSnapshot, StorageView}, BytecodeCompressionResult, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, @@ -54,6 +58,7 @@ pub struct VmDump { pub system_env: SystemEnv, pub l2_blocks: Vec, pub storage: StorageSnapshot, + pub pubdata_params: Option, } impl VmDump { @@ -73,10 +78,20 @@ impl VmDump { #[doc(hidden)] // too low-level pub fn play_back_custom( self, - create_vm: impl FnOnce(L1BatchEnv, SystemEnv, StoragePtr>) -> Vm, + create_vm: impl FnOnce( + L1BatchEnv, + SystemEnv, + StoragePtr>, + Option>, + ) -> Vm, ) -> Vm { let storage = StorageView::new(self.storage).to_rc_ptr(); - let mut vm = create_vm(self.l1_batch_env, self.system_env, storage); + let mut vm = create_vm( + self.l1_batch_env, + self.system_env, + storage, + self.pubdata_params.map(pubdata_params_to_builder), + ); for (i, l2_block) in self.l2_blocks.into_iter().enumerate() { if i > 0 { @@ -118,6 +133,7 @@ pub(super) struct DumpingVm { system_env: SystemEnv, l2_blocks: Vec, l2_blocks_snapshot: Option, + pubdata_builder: Option>, } impl DumpingVm { @@ -135,6 +151,10 @@ impl DumpingVm { system_env: self.system_env.clone(), l2_blocks: self.l2_blocks.clone(), storage: create_storage_snapshot(&self.storage, self.inner.used_contract_hashes()), + pubdata_params: self + .pubdata_builder + .clone() + .map(|p| p.pubdata_params().expect("pubdata builder is not dumpable")), } } } @@ -231,8 +251,14 @@ where l1_batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr>, + pubdata_builder: Option>, ) -> Self { - let inner = Vm::new(l1_batch_env.clone(), system_env.clone(), storage.clone()); + let inner = Vm::new( + l1_batch_env.clone(), + system_env.clone(), + storage.clone(), + pubdata_builder.clone(), + ); let first_block = L2BlockExecutionData { number: L2BlockNumber(l1_batch_env.first_l2_block.number), timestamp: l1_batch_env.first_l2_block.timestamp, @@ -247,6 +273,7 @@ where l2_blocks_snapshot: None, storage, inner, + pubdata_builder, } } } diff --git a/core/lib/vm_interface/src/utils/shadow.rs b/core/lib/vm_interface/src/utils/shadow.rs index 2819e54e9a7b..6ebc4edbe218 100644 --- a/core/lib/vm_interface/src/utils/shadow.rs +++ b/core/lib/vm_interface/src/utils/shadow.rs @@ -2,6 +2,7 @@ use std::{ cell::RefCell, collections::{BTreeMap, BTreeSet}, fmt, + rc::Rc, sync::Arc, }; @@ -9,6 +10,7 @@ use zksync_types::{StorageKey, StorageLog, StorageLogWithPreviousValue, Transact use super::dump::{DumpingVm, VmDump}; use crate::{ + pubdata::PubdataBuilder, storage::{ReadStorage, StoragePtr, StorageView}, BytecodeCompressionResult, CurrentExecutionState, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, @@ -119,12 +121,23 @@ where system_env: SystemEnv, storage: StoragePtr>, shadow_storage: StoragePtr, + pubdata_builder: Option>, ) -> Self where Shadow: VmFactory, { - let main = DumpingVm::new(batch_env.clone(), system_env.clone(), storage.clone()); - let shadow = Shadow::new(batch_env.clone(), system_env.clone(), shadow_storage); + let main = DumpingVm::new( + batch_env.clone(), + system_env.clone(), + storage, + pubdata_builder.clone(), + ); + let shadow = Shadow::new( + batch_env.clone(), + system_env.clone(), + shadow_storage, + pubdata_builder, + ); let shadow = VmWithReporting { vm: shadow, divergence_handler: DivergenceHandler::default(), @@ -146,8 +159,15 @@ where batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr>, + pubdata_builder: Option>, ) -> Self { - Self::with_custom_shadow(batch_env, system_env, storage.clone(), storage) + Self::with_custom_shadow( + batch_env, + system_env, + storage.clone(), + storage, + pubdata_builder, + ) } } diff --git a/core/lib/vm_interface/src/vm.rs b/core/lib/vm_interface/src/vm.rs index 90ae76be8057..52d7264edc88 100644 --- a/core/lib/vm_interface/src/vm.rs +++ b/core/lib/vm_interface/src/vm.rs @@ -11,11 +11,13 @@ //! Generally speaking, in most cases, the tracer dispatcher is a wrapper around `Vec>`, //! where `VmTracer` is a trait implemented for a specific VM version. +use std::rc::Rc; + use zksync_types::{Transaction, H256}; use crate::{ - storage::StoragePtr, BytecodeCompressionResult, FinishedL1Batch, L1BatchEnv, L2BlockEnv, - SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmMemoryMetrics, + pubdata::PubdataBuilder, storage::StoragePtr, BytecodeCompressionResult, FinishedL1Batch, + L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmMemoryMetrics, }; pub trait VmInterface { @@ -78,7 +80,12 @@ impl VmInterfaceExt for T {} /// Encapsulates creating VM instance based on the provided environment. pub trait VmFactory: VmInterface { /// Creates a new VM instance. - fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self; + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr, + pubdata_builder: Option>, + ) -> Self; } /// Methods of VM requiring history manipulations. diff --git a/core/node/node_sync/src/external_io.rs b/core/node/node_sync/src/external_io.rs index 6075ff048bfd..82c22a6f2692 100644 --- a/core/node/node_sync/src/external_io.rs +++ b/core/node/node_sync/src/external_io.rs @@ -185,7 +185,7 @@ impl StateKeeperIO for ExternalIO { pending_l2_block_header.set_protocol_version(protocol_version); } - let (system_env, l1_batch_env) = self + let (system_env, l1_batch_env, pubdata_params) = self .l1_batch_params_provider .load_l1_batch_params( &mut storage, @@ -200,7 +200,7 @@ impl StateKeeperIO for ExternalIO { cursor.l1_batch ) })?; - let data = load_pending_batch(&mut storage, system_env, l1_batch_env) + let data = load_pending_batch(&mut storage, system_env, l1_batch_env, pubdata_params) .await .with_context(|| { format!( diff --git a/core/node/proof_data_handler/src/tests.rs b/core/node/proof_data_handler/src/tests.rs index 4319fce6216d..fb6712da4c94 100644 --- a/core/node/proof_data_handler/src/tests.rs +++ b/core/node/proof_data_handler/src/tests.rs @@ -67,9 +67,9 @@ async fn request_tee_proof_inputs() { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: 0, chain_id: Default::default(), - pubdata_params: Default::default(), }, vec![(H256([1; 32]), vec![0, 1, 2, 3, 4])], + Default::default(), ); let tvi = TeeVerifierInput::V1(tvi); diff --git a/core/node/state_keeper/src/executor/tests/tester.rs b/core/node/state_keeper/src/executor/tests/tester.rs index 7a1871dbfea9..4c65953e9fcb 100644 --- a/core/node/state_keeper/src/executor/tests/tester.rs +++ b/core/node/state_keeper/src/executor/tests/tester.rs @@ -25,6 +25,7 @@ use zksync_state::{OwnedStorage, ReadStorageFactory, RocksdbStorageOptions}; use zksync_test_account::{Account, DeployContractsTx, TxType}; use zksync_types::{ block::L2BlockHasher, + commitment::PubdataParams, ethabi::Token, protocol_version::ProtocolSemanticVersion, snapshots::{SnapshotRecoveryStatus, SnapshotStorageLog}, @@ -104,10 +105,9 @@ impl Tester { &mut self, storage_type: StorageType, ) -> Box> { - let (l1_batch_env, system_env) = self.default_batch_params(); + let (l1_batch_env, system_env, pubdata_params) = self.default_batch_params(); match storage_type { StorageType::AsyncRocksdbCache => { - let (l1_batch_env, system_env) = self.default_batch_params(); let (state_keeper_storage, task) = AsyncRocksdbCache::new( self.pool(), self.state_keeper_db_path(), @@ -122,6 +122,7 @@ impl Tester { Arc::new(state_keeper_storage), l1_batch_env, system_env, + pubdata_params, ) .await } @@ -133,12 +134,18 @@ impl Tester { )), l1_batch_env, system_env, + pubdata_params, ) .await } StorageType::Postgres => { - self.create_batch_executor_inner(Arc::new(self.pool()), l1_batch_env, system_env) - .await + self.create_batch_executor_inner( + Arc::new(self.pool()), + l1_batch_env, + system_env, + pubdata_params, + ) + .await } } } @@ -148,6 +155,7 @@ impl Tester { storage_factory: Arc, l1_batch_env: L1BatchEnv, system_env: SystemEnv, + pubdata_params: PubdataParams, ) -> Box> { let (_stop_sender, stop_receiver) = watch::channel(false); let storage = storage_factory @@ -158,11 +166,11 @@ impl Tester { if self.config.trace_calls { let mut executor = MainBatchExecutorFactory::::new(false); executor.set_fast_vm_mode(self.config.fast_vm_mode); - executor.init_batch(storage, l1_batch_env, system_env) + executor.init_batch(storage, l1_batch_env, system_env, pubdata_params) } else { let mut executor = MainBatchExecutorFactory::<()>::new(false); executor.set_fast_vm_mode(self.config.fast_vm_mode); - executor.init_batch(storage, l1_batch_env, system_env) + executor.init_batch(storage, l1_batch_env, system_env, pubdata_params) } } @@ -212,7 +220,7 @@ impl Tester { snapshot: &SnapshotRecoveryStatus, ) -> Box> { let current_timestamp = snapshot.l2_block_timestamp + 1; - let (mut l1_batch_env, system_env) = + let (mut l1_batch_env, system_env, pubdata_params) = self.batch_params(snapshot.l1_batch_number + 1, current_timestamp); l1_batch_env.previous_batch_hash = Some(snapshot.l1_batch_root_hash); l1_batch_env.first_l2_block = L2BlockEnv { @@ -222,11 +230,11 @@ impl Tester { max_virtual_blocks_to_create: 1, }; - self.create_batch_executor_inner(storage_factory, l1_batch_env, system_env) + self.create_batch_executor_inner(storage_factory, l1_batch_env, system_env, pubdata_params) .await } - pub(super) fn default_batch_params(&self) -> (L1BatchEnv, SystemEnv) { + pub(super) fn default_batch_params(&self) -> (L1BatchEnv, SystemEnv, PubdataParams) { // Not really important for the batch executor - it operates over a single batch. self.batch_params(L1BatchNumber(1), 100) } @@ -236,7 +244,7 @@ impl Tester { &self, l1_batch_number: L1BatchNumber, timestamp: u64, - ) -> (L1BatchEnv, SystemEnv) { + ) -> (L1BatchEnv, SystemEnv, PubdataParams) { let mut system_params = default_system_env(); if let Some(vm_gas_limit) = self.config.vm_gas_limit { system_params.bootloader_gas_limit = vm_gas_limit; @@ -245,7 +253,7 @@ impl Tester { self.config.validation_computational_gas_limit; let mut batch_params = default_l1_batch_env(l1_batch_number.0, timestamp, self.fee_account); batch_params.previous_batch_hash = Some(H256::zero()); // Not important in this context. - (batch_params, system_params) + (batch_params, system_params, PubdataParams::default()) } /// Performs the genesis in the storage. diff --git a/core/node/state_keeper/src/io/common/mod.rs b/core/node/state_keeper/src/io/common/mod.rs index 6bd881414a20..867ffa7fb371 100644 --- a/core/node/state_keeper/src/io/common/mod.rs +++ b/core/node/state_keeper/src/io/common/mod.rs @@ -3,7 +3,7 @@ use std::time::Duration; use anyhow::Context; use zksync_dal::{Connection, Core, CoreDal}; use zksync_multivm::interface::{L1BatchEnv, SystemEnv}; -use zksync_types::{L1BatchNumber, L2BlockNumber, H256}; +use zksync_types::{commitment::PubdataParams, L1BatchNumber, L2BlockNumber, H256}; use super::PendingBatchData; @@ -85,6 +85,7 @@ pub async fn load_pending_batch( storage: &mut Connection<'_, Core>, system_env: SystemEnv, l1_batch_env: L1BatchEnv, + pubdata_params: PubdataParams, ) -> anyhow::Result { let pending_l2_blocks = storage .transactions_dal() @@ -104,6 +105,7 @@ pub async fn load_pending_batch( Ok(PendingBatchData { l1_batch_env, system_env, + pubdata_params, pending_l2_blocks, }) } diff --git a/core/node/state_keeper/src/io/common/tests.rs b/core/node/state_keeper/src/io/common/tests.rs index b2a24acb4956..ec9f906b1cd7 100644 --- a/core/node/state_keeper/src/io/common/tests.rs +++ b/core/node/state_keeper/src/io/common/tests.rs @@ -318,7 +318,7 @@ async fn loading_pending_batch_with_genesis() { .await; let provider = L1BatchParamsProvider::new(&mut storage).await.unwrap(); - let (system_env, l1_batch_env) = provider + let (system_env, l1_batch_env, pubdata_params) = provider .load_l1_batch_env( &mut storage, L1BatchNumber(1), @@ -331,7 +331,7 @@ async fn loading_pending_batch_with_genesis() { assert_eq!(l1_batch_env.first_l2_block.number, 1); - let pending_batch = load_pending_batch(&mut storage, system_env, l1_batch_env) + let pending_batch = load_pending_batch(&mut storage, system_env, l1_batch_env, pubdata_params) .await .unwrap(); @@ -396,7 +396,7 @@ async fn loading_pending_batch_after_snapshot_recovery() { .await; let provider = L1BatchParamsProvider::new(&mut storage).await.unwrap(); - let (system_env, l1_batch_env) = provider + let (system_env, l1_batch_env, pubdata_params) = provider .load_l1_batch_env( &mut storage, snapshot_recovery.l1_batch_number + 1, @@ -406,7 +406,7 @@ async fn loading_pending_batch_after_snapshot_recovery() { .await .unwrap() .expect("no L1 batch"); - let pending_batch = load_pending_batch(&mut storage, system_env, l1_batch_env) + let pending_batch = load_pending_batch(&mut storage, system_env, l1_batch_env, pubdata_params) .await .unwrap(); diff --git a/core/node/state_keeper/src/io/mempool.rs b/core/node/state_keeper/src/io/mempool.rs index 1114000e8d13..4c673ba111c0 100644 --- a/core/node/state_keeper/src/io/mempool.rs +++ b/core/node/state_keeper/src/io/mempool.rs @@ -101,7 +101,7 @@ impl StateKeeperIO for MempoolIO { L2BlockSealProcess::clear_pending_l2_block(&mut storage, cursor.next_l2_block - 1).await?; - let Some((system_env, l1_batch_env)) = self + let Some((system_env, l1_batch_env, pubdata_params)) = self .l1_batch_params_provider .load_l1_batch_env( &mut storage, @@ -113,38 +113,29 @@ impl StateKeeperIO for MempoolIO { else { return Ok((cursor, None)); }; - let pending_batch_data = load_pending_batch(&mut storage, system_env, l1_batch_env) - .await - .with_context(|| { - format!( - "failed loading data for re-execution for pending L1 batch #{}", - cursor.l1_batch - ) - })?; + let pending_batch_data = + load_pending_batch(&mut storage, system_env, l1_batch_env, pubdata_params) + .await + .with_context(|| { + format!( + "failed loading data for re-execution for pending L1 batch #{}", + cursor.l1_batch + ) + })?; - let PendingBatchData { - l1_batch_env, - system_env, - pending_l2_blocks, - } = pending_batch_data; // Initialize the filter for the transactions that come after the pending batch. // We use values from the pending block to match the filter with one used before the restart. - let (base_fee, gas_per_pubdata) = - derive_base_fee_and_gas_per_pubdata(l1_batch_env.fee_input, system_env.version.into()); + let (base_fee, gas_per_pubdata) = derive_base_fee_and_gas_per_pubdata( + pending_batch_data.l1_batch_env.fee_input, + pending_batch_data.system_env.version.into(), + ); self.filter = L2TxFilter { - fee_input: l1_batch_env.fee_input, + fee_input: pending_batch_data.l1_batch_env.fee_input, fee_per_gas: base_fee, gas_per_pubdata: gas_per_pubdata as u32, }; - Ok(( - cursor, - Some(PendingBatchData { - l1_batch_env, - system_env, - pending_l2_blocks, - }), - )) + Ok((cursor, Some(pending_batch_data))) } async fn wait_for_new_batch_params( diff --git a/core/node/state_keeper/src/io/mod.rs b/core/node/state_keeper/src/io/mod.rs index 947d05ec800f..1228b086527f 100644 --- a/core/node/state_keeper/src/io/mod.rs +++ b/core/node/state_keeper/src/io/mod.rs @@ -39,6 +39,7 @@ pub struct PendingBatchData { /// (e.g. timestamp) are the same, so transaction would have the same result after re-execution. pub(crate) l1_batch_env: L1BatchEnv, pub(crate) system_env: SystemEnv, + pub(crate) pubdata_params: PubdataParams, /// List of L2 blocks and corresponding transactions that were executed within batch. pub(crate) pending_l2_blocks: Vec, } @@ -82,7 +83,7 @@ impl L1BatchParams { contracts: BaseSystemContracts, cursor: &IoCursor, previous_batch_hash: H256, - ) -> (SystemEnv, L1BatchEnv) { + ) -> (SystemEnv, L1BatchEnv, PubdataParams) { l1_batch_params( cursor.l1_batch, self.operator_address, diff --git a/core/node/state_keeper/src/io/persistence.rs b/core/node/state_keeper/src/io/persistence.rs index 28dd0ba7cc2d..d48c4831dcf0 100644 --- a/core/node/state_keeper/src/io/persistence.rs +++ b/core/node/state_keeper/src/io/persistence.rs @@ -487,7 +487,8 @@ mod tests { async fn execute_mock_batch(output_handler: &mut OutputHandler) -> H256 { let l1_batch_env = default_l1_batch_env(1, 1, Address::random()); - let mut updates = UpdatesManager::new(&l1_batch_env, &default_system_env()); + let mut updates = + UpdatesManager::new(&l1_batch_env, &default_system_env(), Default::default()); let tx = create_transaction(10, 100); let tx_hash = tx.hash(); diff --git a/core/node/state_keeper/src/io/tests/mod.rs b/core/node/state_keeper/src/io/tests/mod.rs index 4e2f8aa8af3f..942a9ddbe026 100644 --- a/core/node/state_keeper/src/io/tests/mod.rs +++ b/core/node/state_keeper/src/io/tests/mod.rs @@ -446,13 +446,13 @@ async fn l2_block_processing_after_snapshot_recovery(commitment_mode: L1BatchCom .await .unwrap() .expect("no batch params generated"); - let (system_env, l1_batch_env) = l1_batch_params.into_env( + let (system_env, l1_batch_env, pubdata_params) = l1_batch_params.into_env( L2ChainId::default(), BASE_SYSTEM_CONTRACTS.clone(), &cursor, previous_batch_hash, ); - let mut updates = UpdatesManager::new(&l1_batch_env, &system_env); + let mut updates = UpdatesManager::new(&l1_batch_env, &system_env, pubdata_params); let tx_hash = tx.hash(); updates.extend_from_executed_transaction( diff --git a/core/node/state_keeper/src/keeper.rs b/core/node/state_keeper/src/keeper.rs index d36ceec7d70c..408c3e11cb4b 100644 --- a/core/node/state_keeper/src/keeper.rs +++ b/core/node/state_keeper/src/keeper.rs @@ -17,8 +17,9 @@ use zksync_multivm::{ use zksync_shared_metrics::{TxStage, APP_METRICS}; use zksync_state::{OwnedStorage, ReadStorageFactory}; use zksync_types::{ - block::L2BlockExecutionData, l2::TransactionType, protocol_upgrade::ProtocolUpgradeTx, - protocol_version::ProtocolVersionId, utils::display_timestamp, L1BatchNumber, Transaction, + block::L2BlockExecutionData, commitment::PubdataParams, l2::TransactionType, + protocol_upgrade::ProtocolUpgradeTx, protocol_version::ProtocolVersionId, + utils::display_timestamp, L1BatchNumber, Transaction, }; use crate::{ @@ -116,6 +117,7 @@ impl ZkSyncStateKeeper { let PendingBatchData { mut l1_batch_env, mut system_env, + mut pubdata_params, pending_l2_blocks, } = match pending_batch_params { Some(params) => { @@ -132,7 +134,7 @@ impl ZkSyncStateKeeper { } None => { tracing::info!("There is no open pending batch, starting a new empty batch"); - let (system_env, l1_batch_env) = self + let (system_env, l1_batch_env, pubdata_params) = self .wait_for_new_batch_env(&cursor) .await .map_err(|e| e.context("wait_for_new_batch_params()"))?; @@ -140,18 +142,19 @@ impl ZkSyncStateKeeper { l1_batch_env, pending_l2_blocks: Vec::new(), system_env, + pubdata_params, } } }; let protocol_version = system_env.version; - let mut updates_manager = UpdatesManager::new(&l1_batch_env, &system_env); + let mut updates_manager = UpdatesManager::new(&l1_batch_env, &system_env, pubdata_params); let mut protocol_upgrade_tx: Option = self .load_protocol_upgrade_tx(&pending_l2_blocks, protocol_version, l1_batch_env.number) .await?; let mut batch_executor = self - .create_batch_executor(l1_batch_env.clone(), system_env.clone()) + .create_batch_executor(l1_batch_env.clone(), system_env.clone(), pubdata_params) .await?; self.restore_state( &mut *batch_executor, @@ -201,10 +204,11 @@ impl ZkSyncStateKeeper { // Start the new batch. next_cursor.l1_batch += 1; - (system_env, l1_batch_env) = self.wait_for_new_batch_env(&next_cursor).await?; - updates_manager = UpdatesManager::new(&l1_batch_env, &system_env); + (system_env, l1_batch_env, pubdata_params) = + self.wait_for_new_batch_env(&next_cursor).await?; + updates_manager = UpdatesManager::new(&l1_batch_env, &system_env, pubdata_params); batch_executor = self - .create_batch_executor(l1_batch_env.clone(), system_env.clone()) + .create_batch_executor(l1_batch_env.clone(), system_env.clone(), pubdata_params) .await?; let version_changed = system_env.version != sealed_batch_protocol_version; @@ -221,6 +225,7 @@ impl ZkSyncStateKeeper { &mut self, l1_batch_env: L1BatchEnv, system_env: SystemEnv, + pubdata_params: PubdataParams, ) -> Result>, Error> { let storage = self .storage_factory @@ -230,7 +235,7 @@ impl ZkSyncStateKeeper { .ok_or(Error::Canceled)?; Ok(self .batch_executor - .init_batch(storage, l1_batch_env, system_env)) + .init_batch(storage, l1_batch_env, system_env, pubdata_params)) } /// This function is meant to be called only once during the state-keeper initialization. @@ -327,7 +332,7 @@ impl ZkSyncStateKeeper { async fn wait_for_new_batch_env( &mut self, cursor: &IoCursor, - ) -> Result<(SystemEnv, L1BatchEnv), Error> { + ) -> Result<(SystemEnv, L1BatchEnv, PubdataParams), Error> { // `io.wait_for_new_batch_params(..)` is not cancel-safe; once we get new batch params, we must hold onto them // until we get the rest of parameters from I/O or receive a stop signal. let params = self.wait_for_new_batch_params(cursor).await?; diff --git a/core/node/state_keeper/src/testonly/mod.rs b/core/node/state_keeper/src/testonly/mod.rs index edcf3ccc4f5c..b01d759379ba 100644 --- a/core/node/state_keeper/src/testonly/mod.rs +++ b/core/node/state_keeper/src/testonly/mod.rs @@ -14,9 +14,9 @@ use zksync_multivm::interface::{ use zksync_state::OwnedStorage; use zksync_test_account::Account; use zksync_types::{ - fee::Fee, utils::storage_key_for_standard_token_balance, AccountTreeId, Address, Execute, - L1BatchNumber, L2BlockNumber, PriorityOpId, StorageLog, Transaction, L2_BASE_TOKEN_ADDRESS, - SYSTEM_CONTEXT_MINIMAL_BASE_FEE, U256, + commitment::PubdataParams, fee::Fee, utils::storage_key_for_standard_token_balance, + AccountTreeId, Address, Execute, L1BatchNumber, L2BlockNumber, PriorityOpId, StorageLog, + Transaction, L2_BASE_TOKEN_ADDRESS, SYSTEM_CONTEXT_MINIMAL_BASE_FEE, U256, }; use zksync_utils::u256_to_h256; @@ -49,6 +49,7 @@ impl BatchExecutorFactory for MockBatchExecutor { _storage: OwnedStorage, _l1_batch_env: L1BatchEnv, _system_env: SystemEnv, + _pubdata_params: PubdataParams, ) -> Box> { Box::new(Self) } diff --git a/core/node/state_keeper/src/testonly/test_batch_executor.rs b/core/node/state_keeper/src/testonly/test_batch_executor.rs index 4a58e9e0a952..433208e794a2 100644 --- a/core/node/state_keeper/src/testonly/test_batch_executor.rs +++ b/core/node/state_keeper/src/testonly/test_batch_executor.rs @@ -27,8 +27,9 @@ use zksync_multivm::{ use zksync_node_test_utils::create_l2_transaction; use zksync_state::{interface::StorageView, OwnedStorage, ReadStorageFactory}; use zksync_types::{ - fee_model::BatchFeeInput, l2_to_l1_log::UserL2ToL1Log, protocol_upgrade::ProtocolUpgradeTx, - Address, L1BatchNumber, L2BlockNumber, L2ChainId, ProtocolVersionId, Transaction, H256, + commitment::PubdataParams, fee_model::BatchFeeInput, l2_to_l1_log::UserL2ToL1Log, + protocol_upgrade::ProtocolUpgradeTx, Address, L1BatchNumber, L2BlockNumber, L2ChainId, + ProtocolVersionId, Transaction, H256, }; use crate::{ @@ -421,6 +422,7 @@ impl BatchExecutorFactory for TestBatchExecutorBuilder { _storage: OwnedStorage, _l1_batch_env: L1BatchEnv, _system_env: SystemEnv, + _pubdata_params: PubdataParams, ) -> Box> { let executor = TestBatchExecutor::new(self.txs.pop_front().unwrap(), self.rollback_set.clone()); diff --git a/core/node/state_keeper/src/tests/mod.rs b/core/node/state_keeper/src/tests/mod.rs index 552e6ec37996..39d3e7c3c60a 100644 --- a/core/node/state_keeper/src/tests/mod.rs +++ b/core/node/state_keeper/src/tests/mod.rs @@ -58,8 +58,8 @@ pub(crate) fn pending_batch_data(pending_l2_blocks: Vec) - execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::from(270), - pubdata_params: Default::default(), }, + pubdata_params: Default::default(), pending_l2_blocks, } } @@ -73,7 +73,6 @@ pub(super) fn default_system_env() -> SystemEnv { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::from(270), - pubdata_params: Default::default(), } } @@ -104,7 +103,7 @@ pub(super) fn default_l1_batch_env( pub(super) fn create_updates_manager() -> UpdatesManager { let l1_batch_env = default_l1_batch_env(1, 1, Address::default()); - UpdatesManager::new(&l1_batch_env, &default_system_env()) + UpdatesManager::new(&l1_batch_env, &default_system_env(), Default::default()) } pub(super) fn create_transaction(fee_per_gas: u64, gas_per_pubdata: u64) -> Transaction { diff --git a/core/node/state_keeper/src/updates/mod.rs b/core/node/state_keeper/src/updates/mod.rs index 9996741a6268..da69225e17f0 100644 --- a/core/node/state_keeper/src/updates/mod.rs +++ b/core/node/state_keeper/src/updates/mod.rs @@ -43,7 +43,11 @@ pub struct UpdatesManager { } impl UpdatesManager { - pub fn new(l1_batch_env: &L1BatchEnv, system_env: &SystemEnv) -> Self { + pub fn new( + l1_batch_env: &L1BatchEnv, + system_env: &SystemEnv, + pubdata_params: PubdataParams, + ) -> Self { let protocol_version = system_env.version; Self { batch_timestamp: l1_batch_env.timestamp, @@ -62,7 +66,7 @@ impl UpdatesManager { ), storage_writes_deduplicator: StorageWritesDeduplicator::new(), storage_view_cache: None, - pubdata_params: system_env.pubdata_params, + pubdata_params, } } diff --git a/core/node/tee_verifier_input_producer/src/lib.rs b/core/node/tee_verifier_input_producer/src/lib.rs index 8a99aa07ae51..f80bf0d002ed 100644 --- a/core/node/tee_verifier_input_producer/src/lib.rs +++ b/core/node/tee_verifier_input_producer/src/lib.rs @@ -86,7 +86,7 @@ impl TeeVerifierInputProducer { // This means we don't want to reject any execution, therefore we're using MAX as an allow all. let validation_computational_gas_limit = u32::MAX; - let (system_env, l1_batch_env) = l1_batch_params_provider + let (system_env, l1_batch_env, pubdata_params) = l1_batch_params_provider .load_l1_batch_env( &mut connection, l1_batch_number, @@ -128,6 +128,7 @@ impl TeeVerifierInputProducer { l1_batch_env, system_env, used_contracts, + pubdata_params, ); // TODO (SEC-263): remove these 2 lines after successful testnet runs diff --git a/core/node/vm_runner/src/process.rs b/core/node/vm_runner/src/process.rs index 4f7ac1f97284..dbd218c8dc5f 100644 --- a/core/node/vm_runner/src/process.rs +++ b/core/node/vm_runner/src/process.rs @@ -82,6 +82,7 @@ impl VmRunner { storage, batch_data.l1_batch_env.clone(), batch_data.system_env.clone(), + batch_data.pubdata_params, ); let mut output_handler = self .output_handler_factory diff --git a/core/node/vm_runner/src/storage.rs b/core/node/vm_runner/src/storage.rs index 2285455ba244..9ab4ed87b9f1 100644 --- a/core/node/vm_runner/src/storage.rs +++ b/core/node/vm_runner/src/storage.rs @@ -13,7 +13,9 @@ use zksync_state::{ AsyncCatchupTask, BatchDiff, OwnedStorage, RocksdbCell, RocksdbStorage, RocksdbStorageBuilder, RocksdbWithMemory, }; -use zksync_types::{block::L2BlockExecutionData, L1BatchNumber, L2ChainId}; +use zksync_types::{ + block::L2BlockExecutionData, commitment::PubdataParams, L1BatchNumber, L2ChainId, +}; use zksync_vm_executor::storage::L1BatchParamsProvider; use zksync_vm_interface::{L1BatchEnv, SystemEnv}; @@ -106,6 +108,8 @@ pub struct BatchExecuteData { pub l1_batch_env: L1BatchEnv, /// Execution process parameters. pub system_env: SystemEnv, + /// Pubdata building parameters. + pub pubdata_params: PubdataParams, /// List of L2 blocks and corresponding transactions that were executed within batch. pub l2_blocks: Vec, } @@ -394,7 +398,7 @@ pub(crate) async fn load_batch_execute_data( l1_batch_params_provider: &L1BatchParamsProvider, chain_id: L2ChainId, ) -> anyhow::Result> { - let Some((system_env, l1_batch_env)) = l1_batch_params_provider + let Some((system_env, l1_batch_env, pubdata_params)) = l1_batch_params_provider .load_l1_batch_env( conn, l1_batch_number, @@ -415,6 +419,7 @@ pub(crate) async fn load_batch_execute_data( Ok(Some(BatchExecuteData { l1_batch_env, system_env, + pubdata_params, l2_blocks, })) } diff --git a/core/node/vm_runner/src/tests/output_handler.rs b/core/node/vm_runner/src/tests/output_handler.rs index 131089d0f796..1bf30effdbe5 100644 --- a/core/node/vm_runner/src/tests/output_handler.rs +++ b/core/node/vm_runner/src/tests/output_handler.rs @@ -71,7 +71,6 @@ impl OutputHandlerTester { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: 0, chain_id: Default::default(), - pubdata_params: Default::default(), }; let mut output_handler = self diff --git a/core/tests/vm-benchmark/src/vm.rs b/core/tests/vm-benchmark/src/vm.rs index 410c0e071b49..ee9b5d1c5e70 100644 --- a/core/tests/vm-benchmark/src/vm.rs +++ b/core/tests/vm-benchmark/src/vm.rs @@ -4,6 +4,7 @@ use once_cell::sync::Lazy; use zksync_contracts::BaseSystemContracts; use zksync_multivm::{ interface::{ + pubdata::{pubdata_params_to_builder, PubdataBuilder}, storage::{InMemoryStorage, StorageView}, ExecutionResult, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceExt, @@ -14,9 +15,9 @@ use zksync_multivm::{ zk_evm_latest::ethereum_types::{Address, U256}, }; use zksync_types::{ - block::L2BlockHasher, fee_model::BatchFeeInput, helpers::unix_timestamp_ms, - utils::storage_key_for_eth_balance, L1BatchNumber, L2BlockNumber, L2ChainId, ProtocolVersionId, - Transaction, + block::L2BlockHasher, commitment::PubdataParams, fee_model::BatchFeeInput, + helpers::unix_timestamp_ms, utils::storage_key_for_eth_balance, L1BatchNumber, L2BlockNumber, + L2ChainId, ProtocolVersionId, Transaction, }; use zksync_utils::bytecode::hash_bytecode; @@ -71,6 +72,7 @@ pub trait BenchmarkingVmFactory { batch_env: L1BatchEnv, system_env: SystemEnv, storage: &'static InMemoryStorage, + pubdata_builder: Rc, ) -> Self::Instance; } @@ -87,6 +89,7 @@ impl BenchmarkingVmFactory for Fast { batch_env: L1BatchEnv, system_env: SystemEnv, storage: &'static InMemoryStorage, + _pubdata_builder: Rc, ) -> Self::Instance { vm_fast::Vm::custom(batch_env, system_env, storage) } @@ -105,9 +108,10 @@ impl BenchmarkingVmFactory for Legacy { batch_env: L1BatchEnv, system_env: SystemEnv, storage: &'static InMemoryStorage, + pubdata_builder: Rc, ) -> Self::Instance { let storage = StorageView::new(storage).to_rc_ptr(); - vm_latest::Vm::new(batch_env, system_env, storage) + vm_latest::Vm::new(batch_env, system_env, storage, Some(pubdata_builder)) } } @@ -143,9 +147,9 @@ impl Default for BenchmarkingVm { execution_mode: TxExecutionMode::VerifyExecute, default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::from(270), - pubdata_params: Default::default(), }, &STORAGE, + pubdata_params_to_builder(PubdataParams::default()), )) } } diff --git a/prover/Cargo.lock b/prover/Cargo.lock index eb5297ef9637..fcd4798c8b49 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -7708,7 +7708,6 @@ dependencies = [ "zk_evm 0.141.0", "zk_evm 0.150.5", "zksync_contracts", - "zksync_mini_merkle_tree", "zksync_system_constants", "zksync_types", "zksync_utils", @@ -8153,8 +8152,10 @@ dependencies = [ "thiserror", "tracing", "zksync_contracts", + "zksync_mini_merkle_tree", "zksync_system_constants", "zksync_types", + "zksync_utils", ] [[package]] From 379b5c3b0358f633d14d403960e92d68cebd9b39 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Tue, 8 Oct 2024 16:44:09 +0300 Subject: [PATCH 08/23] unify naming --- core/lib/types/src/commitment/mod.rs | 20 +++++++++---------- .../tests/post_boojum_1_4_1_test.json | 4 ++-- .../tests/post_boojum_1_4_2_test.json | 4 ++-- .../tests/post_boojum_1_5_0_test.json | 4 ++-- .../commitment/tests/post_gateway_test.json | 4 ++-- core/node/commitment_generator/src/lib.rs | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/core/lib/types/src/commitment/mod.rs b/core/lib/types/src/commitment/mod.rs index 6803e46e1af2..d9d18d5a3a5b 100644 --- a/core/lib/types/src/commitment/mod.rs +++ b/core/lib/types/src/commitment/mod.rs @@ -302,7 +302,7 @@ pub enum L1BatchAuxiliaryOutput { state_diffs_hash: H256, aux_commitments: AuxCommitments, blob_hashes: Vec, - aggregated_root: H256, + aggregation_root: H256, local_root: H256, }, } @@ -353,7 +353,7 @@ impl L1BatchAuxiliaryOutput { state_diffs, aux_commitments, blob_hashes, - aggregated_root, + aggregation_root, } => { let l2_l1_logs_compressed = serialize_commitments(&common_input.l2_to_l1_logs); let merkle_tree_leaves = l2_l1_logs_compressed @@ -367,7 +367,7 @@ impl L1BatchAuxiliaryOutput { let l2_l1_logs_merkle_root = if common_input.protocol_version.is_pre_gateway() { local_root } else { - KeccakHasher.compress(&local_root, &aggregated_root) + KeccakHasher.compress(&local_root, &aggregation_root) }; let common_output = L1BatchAuxiliaryCommonOutput { @@ -431,7 +431,7 @@ impl L1BatchAuxiliaryOutput { aux_commitments, blob_hashes, local_root, - aggregated_root, + aggregation_root, } } } @@ -444,12 +444,12 @@ impl L1BatchAuxiliaryOutput { } } - pub fn aggregated_root(&self) -> H256 { + pub fn aggregation_root(&self) -> H256 { match self { Self::PreBoojum { .. } => H256::zero(), Self::PostBoojum { - aggregated_root, .. - } => *aggregated_root, + aggregation_root, .. + } => *aggregation_root, } } @@ -690,7 +690,7 @@ impl L1BatchCommitment { compressed_initial_writes, compressed_repeated_writes, local_root: self.auxiliary_output.local_root(), - aggregation_root: self.auxiliary_output.aggregated_root(), + aggregation_root: self.auxiliary_output.aggregation_root(), state_diff_hash: self.auxiliary_output.state_diff_hash(), } } @@ -728,7 +728,7 @@ pub enum CommitmentInput { state_diffs: Vec, aux_commitments: AuxCommitments, blob_hashes: Vec, - aggregated_root: H256, + aggregation_root: H256, }, } @@ -773,7 +773,7 @@ impl CommitmentInput { let num_blobs = num_blobs_required(&protocol_version); vec![Default::default(); num_blobs] }, - aggregated_root: H256::zero(), + aggregation_root: H256::zero(), } } } diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json b/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json index 57b2f0845dc7..c854a6e77d8f 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_4_1_test.json @@ -200,7 +200,7 @@ "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" } ], - "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000" + "aggregation_root": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, "pass_through_data": { @@ -265,7 +265,7 @@ "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" } ], - "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000", + "aggregation_root": "0x0000000000000000000000000000000000000000000000000000000000000000", "local_root": "0xe52d57bd64cabf6c588b30365512da2bf10912c106e7a06483b236d05ac4037e" } }, diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json b/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json index 698c592bba4c..96aa8ab842ce 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_4_2_test.json @@ -216,7 +216,7 @@ "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000004" } ], - "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000" + "aggregation_root": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, "pass_through_data": { @@ -281,7 +281,7 @@ "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000004" } ], - "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000", + "aggregation_root": "0x0000000000000000000000000000000000000000000000000000000000000000", "local_root": "0x0b6e1ad4643cc2bee06b5e173184ec822d80826e5720f5715172898350433299" } }, diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json b/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json index 1979a02aa189..ed61ea67cefc 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test.json @@ -304,7 +304,7 @@ "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" } ], - "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000" + "aggregation_root": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, "pass_through_data": { @@ -425,7 +425,7 @@ "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" } ], - "aggregated_root": "0x0000000000000000000000000000000000000000000000000000000000000000", + "aggregation_root": "0x0000000000000000000000000000000000000000000000000000000000000000", "local_root": "0x30ba728b1aac22b122de4f32589dd2711da264412cb90e35bf7b1f735dd357ff" } }, diff --git a/core/lib/types/src/commitment/tests/post_gateway_test.json b/core/lib/types/src/commitment/tests/post_gateway_test.json index 9a197116f7f2..71f09d99ba4f 100644 --- a/core/lib/types/src/commitment/tests/post_gateway_test.json +++ b/core/lib/types/src/commitment/tests/post_gateway_test.json @@ -86,7 +86,7 @@ "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" } ], - "aggregated_root": "0x0924928c1377a6cf24c39c2d46f8eb9df23e811b26dc3527e548396fd4e173b1", + "aggregation_root": "0x0924928c1377a6cf24c39c2d46f8eb9df23e811b26dc3527e548396fd4e173b1", "local_root": "0xd4790efa9052ea67dcb473de870e3522e2fc340374e6293ad4646fde312c8c76" } }, @@ -1971,7 +1971,7 @@ "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" } ], - "aggregated_root": "0x0924928c1377a6cf24c39c2d46f8eb9df23e811b26dc3527e548396fd4e173b1" + "aggregation_root": "0x0924928c1377a6cf24c39c2d46f8eb9df23e811b26dc3527e548396fd4e173b1" } } } diff --git a/core/node/commitment_generator/src/lib.rs b/core/node/commitment_generator/src/lib.rs index 0ba7f128f111..743c9d2197c3 100644 --- a/core/node/commitment_generator/src/lib.rs +++ b/core/node/commitment_generator/src/lib.rs @@ -295,7 +295,7 @@ impl CommitmentGenerator { .connection_pool .connection_tagged("commitment_generator") .await?; - let aggregated_root = read_aggregation_root(&mut connection, l1_batch_number).await?; + let aggregation_root = read_aggregation_root(&mut connection, l1_batch_number).await?; CommitmentInput::PostBoojum { common, @@ -303,7 +303,7 @@ impl CommitmentGenerator { state_diffs, aux_commitments, blob_hashes, - aggregated_root, + aggregation_root, } }; From b00be9d87c05ddad8a8bb40a09d11cbf56cc0be5 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Tue, 8 Oct 2024 17:30:28 +0300 Subject: [PATCH 09/23] fix commitment --- core/node/commitment_generator/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/node/commitment_generator/src/lib.rs b/core/node/commitment_generator/src/lib.rs index 743c9d2197c3..f1b1116e7860 100644 --- a/core/node/commitment_generator/src/lib.rs +++ b/core/node/commitment_generator/src/lib.rs @@ -383,7 +383,9 @@ impl CommitmentGenerator { // Do nothing } (L1BatchCommitmentMode::Validium, CommitmentInput::PostBoojum { blob_hashes, .. }) => { - blob_hashes.fill(Default::default()); + blob_hashes + .iter_mut() + .for_each(|b| *b.commitment = H256::zero()); } (L1BatchCommitmentMode::Validium, _) => { /* Do nothing */ } } From ecd8e244993cc399ef687c7e897bf2e2e9a580fd Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Tue, 8 Oct 2024 17:50:56 +0300 Subject: [PATCH 10/23] fix --- core/node/commitment_generator/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/node/commitment_generator/src/lib.rs b/core/node/commitment_generator/src/lib.rs index f1b1116e7860..a5e302e5e099 100644 --- a/core/node/commitment_generator/src/lib.rs +++ b/core/node/commitment_generator/src/lib.rs @@ -385,7 +385,7 @@ impl CommitmentGenerator { (L1BatchCommitmentMode::Validium, CommitmentInput::PostBoojum { blob_hashes, .. }) => { blob_hashes .iter_mut() - .for_each(|b| *b.commitment = H256::zero()); + .for_each(|b| b.commitment = H256::zero()); } (L1BatchCommitmentMode::Validium, _) => { /* Do nothing */ } } From b0d6af71b6ce27c52fb0f46de533ac65ec5c99b4 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Wed, 9 Oct 2024 13:14:57 +0300 Subject: [PATCH 11/23] update evm commitment test json --- .../post_boojum_1_5_0_test_with_evm.json | 182 +++++++++++++----- 1 file changed, 130 insertions(+), 52 deletions(-) diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test_with_evm.json b/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test_with_evm.json index 4e8c0e0814a0..f465ab4d7952 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test_with_evm.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test_with_evm.json @@ -239,23 +239,71 @@ "events_queue_commitment": "0x6193a5098eb140796387bdf40700a3855eeb010474b5478f30bf917172c67883", "bootloader_initial_content_commitment": "0xf031b4491c37f20516c4ebf428f4765156409f67089e64772f4106fd2d9f3351" }, - "blob_commitments": [ - "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x0000000000000000000000000000000000000000000000000000000000000002", - "0x0000000000000000000000000000000000000000000000000000000000000003", - "0x0000000000000000000000000000000000000000000000000000000000000004", - "0x0000000000000000000000000000000000000000000000000000000000000005", - "0x0000000000000000000000000000000000000000000000000000000000000006", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" + "blob_hashes": [ + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000001", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000003" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000002", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000004" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000003", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000005" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000004", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000006" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000005", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000007" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000006", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000008" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } ] } }, @@ -312,41 +360,71 @@ "events_queue_commitment": "0x6193a5098eb140796387bdf40700a3855eeb010474b5478f30bf917172c67883", "bootloader_initial_content_commitment": "0xf031b4491c37f20516c4ebf428f4765156409f67089e64772f4106fd2d9f3351" }, - "blob_linear_hashes": [ - "0x0000000000000000000000000000000000000000000000000000000000000003", - "0x0000000000000000000000000000000000000000000000000000000000000004", - "0x0000000000000000000000000000000000000000000000000000000000000005", - "0x0000000000000000000000000000000000000000000000000000000000000006", - "0x0000000000000000000000000000000000000000000000000000000000000007", - "0x0000000000000000000000000000000000000000000000000000000000000008", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" - ], - "blob_commitments": [ - "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x0000000000000000000000000000000000000000000000000000000000000002", - "0x0000000000000000000000000000000000000000000000000000000000000003", - "0x0000000000000000000000000000000000000000000000000000000000000004", - "0x0000000000000000000000000000000000000000000000000000000000000005", - "0x0000000000000000000000000000000000000000000000000000000000000006", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000000" + "blob_hashes": [ + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000001", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000003" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000002", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000004" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000003", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000005" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000004", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000006" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000005", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000007" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000006", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000008" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + { + "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", + "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } ] } }, From 8106288f52952611327f3c3c4eb5dcad037be06c Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Wed, 9 Oct 2024 14:03:59 +0300 Subject: [PATCH 12/23] another test json fix --- .../commitment/tests/post_boojum_1_5_0_test_with_evm.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test_with_evm.json b/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test_with_evm.json index f465ab4d7952..a41aa33c04a1 100644 --- a/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test_with_evm.json +++ b/core/lib/types/src/commitment/tests/post_boojum_1_5_0_test_with_evm.json @@ -304,7 +304,8 @@ "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" } - ] + ], + "aggregation_root": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, "pass_through_data": { @@ -425,7 +426,9 @@ "commitment": "0x0000000000000000000000000000000000000000000000000000000000000000", "linear_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" } - ] + ], + "aggregation_root": "0x0000000000000000000000000000000000000000000000000000000000000000", + "local_root": "0x30ba728b1aac22b122de4f32589dd2711da264412cb90e35bf7b1f735dd357ff" } }, "hashes": { From d8c6f4c37703ff00e5ac24b99a2a1677cbfac1ae Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Mon, 14 Oct 2024 18:23:33 +0300 Subject: [PATCH 13/23] fix after merge --- core/lib/vm_executor/src/batch/factory.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/core/lib/vm_executor/src/batch/factory.rs b/core/lib/vm_executor/src/batch/factory.rs index 9713663283e2..f7bbfc98310e 100644 --- a/core/lib/vm_executor/src/batch/factory.rs +++ b/core/lib/vm_executor/src/batch/factory.rs @@ -170,7 +170,12 @@ impl BatchVm { mode: FastVmMode, ) -> Self { if !is_supported_by_fast_vm(system_env.version) { - return Self::Legacy(LegacyVmInstance::new(l1_batch_env, system_env, storage_ptr)); + return Self::Legacy(LegacyVmInstance::new( + l1_batch_env, + system_env, + storage_ptr, + pubdata_builder, + )); } match mode { @@ -470,7 +475,9 @@ impl CommandReceiver { #[cfg(test)] mod tests { use assert_matches::assert_matches; - use zksync_multivm::interface::{storage::InMemoryStorage, TxExecutionMode}; + use zksync_multivm::interface::{ + pubdata::rollup::RollupPubdataBuilder, storage::InMemoryStorage, TxExecutionMode, + }; use zksync_types::ProtocolVersionId; use super::*; @@ -489,6 +496,7 @@ mod tests { l1_batch_env.clone(), system_env.clone(), storage.clone(), + Some(Rc::new(RollupPubdataBuilder::new(Default::default()))), mode, ); assert_matches!(vm, BatchVm::Legacy(_)); @@ -499,6 +507,7 @@ mod tests { l1_batch_env.clone(), system_env.clone(), storage.clone(), + Some(Rc::new(RollupPubdataBuilder::new(Default::default()))), FastVmMode::Old, ); assert_matches!(vm, BatchVm::Legacy(_)); @@ -506,10 +515,17 @@ mod tests { l1_batch_env.clone(), system_env.clone(), storage.clone(), + Some(Rc::new(RollupPubdataBuilder::new(Default::default()))), FastVmMode::New, ); assert_matches!(vm, BatchVm::Fast(FastVmInstance::Fast(_))); - let vm = BatchVm::<_, ()>::new(l1_batch_env, system_env, storage, FastVmMode::Shadow); + let vm = BatchVm::<_, ()>::new( + l1_batch_env, + system_env, + storage, + Some(Rc::new(RollupPubdataBuilder::new(Default::default()))), + FastVmMode::Shadow, + ); assert_matches!(vm, BatchVm::Fast(FastVmInstance::Shadowed(_))); } } From 01b89ee72de87c3339a1c3bc646579f29f25b0eb Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Fri, 18 Oct 2024 11:45:54 +0300 Subject: [PATCH 14/23] put pubdata_builder to finish_batch --- .../system-constants-generator/src/utils.rs | 39 +++------ core/lib/dal/src/consensus/conv.rs | 4 +- core/lib/multivm/src/versions/tests.rs | 40 ++++----- core/lib/multivm/src/versions/vm_1_3_2/vm.rs | 24 +++--- core/lib/multivm/src/versions/vm_1_4_1/vm.rs | 23 ++--- core/lib/multivm/src/versions/vm_1_4_2/vm.rs | 19 ++--- .../src/versions/vm_boojum_integration/vm.rs | 19 ++--- .../src/versions/vm_fast/tests/block_tip.rs | 24 ++++-- .../src/versions/vm_fast/tests/bootloader.rs | 6 +- .../vm_fast/tests/bytecode_publishing.rs | 6 +- .../src/versions/vm_fast/tests/call_tracer.rs | 6 +- .../src/versions/vm_fast/tests/circuits.rs | 4 +- .../src/versions/vm_fast/tests/code_oracle.rs | 10 +-- .../src/versions/vm_fast/tests/default_aa.rs | 6 +- .../vm_fast/tests/get_used_contracts.rs | 6 +- .../vm_fast/tests/is_write_initial.rs | 4 +- .../versions/vm_fast/tests/l1_tx_execution.rs | 14 ++-- .../src/versions/vm_fast/tests/l2_blocks.rs | 18 ++-- .../versions/vm_fast/tests/nonce_holder.rs | 6 +- .../src/versions/vm_fast/tests/precompiles.rs | 8 +- .../versions/vm_fast/tests/prestate_tracer.rs | 10 +-- .../src/versions/vm_fast/tests/refunds.rs | 14 ++-- .../versions/vm_fast/tests/require_eip712.rs | 8 +- .../src/versions/vm_fast/tests/sekp256r1.rs | 6 +- .../vm_fast/tests/simple_execution.rs | 12 +-- .../src/versions/vm_fast/tests/storage.rs | 9 +- .../tests/tester/transaction_test_info.rs | 8 +- .../vm_fast/tests/tester/vm_tester.rs | 6 +- .../src/versions/vm_fast/tests/transfer.rs | 12 +-- .../src/versions/vm_fast/tests/upgrade.rs | 20 ++--- core/lib/multivm/src/versions/vm_fast/vm.rs | 71 +++++++++------- .../vm_latest/bootloader_state/state.rs | 23 +++-- .../vm_latest/bootloader_state/utils.rs | 16 +++- .../vm_latest/implementation/execution.rs | 1 + .../src/versions/vm_latest/tests/block_tip.rs | 8 +- .../versions/vm_latest/tests/bootloader.rs | 6 +- .../vm_latest/tests/bytecode_publishing.rs | 6 +- .../versions/vm_latest/tests/call_tracer.rs | 6 +- .../src/versions/vm_latest/tests/circuits.rs | 4 +- .../versions/vm_latest/tests/code_oracle.rs | 10 +-- .../versions/vm_latest/tests/default_aa.rs | 6 +- .../vm_latest/tests/get_used_contracts.rs | 6 +- .../vm_latest/tests/is_write_initial.rs | 4 +- .../vm_latest/tests/l1_tx_execution.rs | 14 ++-- .../src/versions/vm_latest/tests/l2_blocks.rs | 18 ++-- .../versions/vm_latest/tests/nonce_holder.rs | 6 +- .../versions/vm_latest/tests/precompiles.rs | 8 +- .../vm_latest/tests/prestate_tracer.rs | 10 +-- .../src/versions/vm_latest/tests/refunds.rs | 14 ++-- .../vm_latest/tests/require_eip712.rs | 8 +- .../src/versions/vm_latest/tests/rollbacks.rs | 9 +- .../src/versions/vm_latest/tests/sekp256r1.rs | 6 +- .../vm_latest/tests/simple_execution.rs | 12 +-- .../src/versions/vm_latest/tests/storage.rs | 5 +- .../tests/tester/transaction_test_info.rs | 6 +- .../vm_latest/tests/tester/vm_tester.rs | 34 ++------ .../src/versions/vm_latest/tests/transfer.rs | 12 +-- .../src/versions/vm_latest/tests/upgrade.rs | 20 ++--- .../vm_latest/tracers/pubdata_tracer.rs | 11 ++- .../vm_latest/types/internals/vm_state.rs | 5 -- core/lib/multivm/src/versions/vm_latest/vm.rs | 44 ++++++---- core/lib/multivm/src/versions/vm_m5/vm.rs | 26 +++--- core/lib/multivm/src/versions/vm_m6/vm.rs | 25 +++--- .../src/versions/vm_refunds_enhancement/vm.rs | 21 +++-- .../src/versions/vm_virtual_blocks/vm.rs | 19 ++--- core/lib/multivm/src/vm_instance.rs | 84 +++++-------------- core/lib/tee_verifier/src/lib.rs | 13 ++- core/lib/vm_executor/src/batch/factory.rs | 53 ++++-------- core/lib/vm_executor/src/oneshot/mod.rs | 7 +- core/lib/vm_executor/src/storage.rs | 11 ++- core/lib/vm_interface/src/lib.rs | 4 +- core/lib/vm_interface/src/pubdata/mod.rs | 15 ---- .../src/types/inputs/execution_mode.rs | 19 +++++ core/lib/vm_interface/src/types/inputs/mod.rs | 2 +- core/lib/vm_interface/src/utils/dump.rs | 44 +++------- core/lib/vm_interface/src/utils/shadow.rs | 58 +++++-------- core/lib/vm_interface/src/vm.rs | 15 ++-- core/node/state_keeper/src/io/mod.rs | 7 +- core/tests/vm-benchmark/src/vm.rs | 22 ++--- 79 files changed, 577 insertions(+), 668 deletions(-) diff --git a/core/bin/system-constants-generator/src/utils.rs b/core/bin/system-constants-generator/src/utils.rs index 77ee49586eec..1c4e2691c681 100644 --- a/core/bin/system-constants-generator/src/utils.rs +++ b/core/bin/system-constants-generator/src/utils.rs @@ -5,13 +5,12 @@ use zksync_contracts::{ load_sys_contract, read_bootloader_code, read_bytecode_from_path, read_sys_contract_bytecode, read_zbin_bytecode, BaseSystemContracts, ContractLanguage, SystemContractCode, }; +use zksync_multivm::interface::InspectExecutionMode; use zksync_multivm::{ interface::{ - pubdata::pubdata_params_to_builder, storage::{InMemoryStorage, StorageView, WriteStorage}, tracer::VmExecutionStopReason, - L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory, - VmInterface, VmInterfaceExt, + L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmFactory, VmInterface, VmInterfaceExt, }, tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ @@ -22,12 +21,11 @@ use zksync_multivm::{ zk_evm_latest::aux_structures::Timestamp, }; use zksync_types::{ - block::L2BlockHasher, commitment::PubdataParams, ethabi::Token, fee::Fee, - fee_model::BatchFeeInput, l1::L1Tx, l2::L2Tx, utils::storage_key_for_eth_balance, - AccountTreeId, Address, Execute, K256PrivateKey, L1BatchNumber, L1TxCommonData, L2BlockNumber, - L2ChainId, Nonce, ProtocolVersionId, StorageKey, Transaction, BOOTLOADER_ADDRESS, - SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_GAS_PRICE_POSITION, SYSTEM_CONTEXT_TX_ORIGIN_POSITION, - U256, ZKPORTER_IS_AVAILABLE, + block::L2BlockHasher, ethabi::Token, fee::Fee, fee_model::BatchFeeInput, l1::L1Tx, l2::L2Tx, + utils::storage_key_for_eth_balance, AccountTreeId, Address, Execute, K256PrivateKey, + L1BatchNumber, L1TxCommonData, L2BlockNumber, L2ChainId, Nonce, ProtocolVersionId, StorageKey, + Transaction, BOOTLOADER_ADDRESS, SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_GAS_PRICE_POSITION, + SYSTEM_CONTEXT_TX_ORIGIN_POSITION, U256, ZKPORTER_IS_AVAILABLE, }; use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, u256_to_h256}; @@ -274,14 +272,8 @@ pub(super) fn execute_internal_transfer_test() -> u32 { } .into_tracer_pointer(); - let pubdata_builder = pubdata_params_to_builder(PubdataParams::default()); - let mut vm: Vm<_, HistoryEnabled> = Vm::new( - l1_batch, - system_env, - storage_view.to_rc_ptr(), - Some(pubdata_builder), - ); - let result = vm.inspect(&mut tracer.into(), VmExecutionMode::Bootloader); + let mut vm: Vm<_, HistoryEnabled> = Vm::new(l1_batch, system_env, storage_view.to_rc_ptr()); + let result = vm.inspect(&mut tracer.into(), InspectExecutionMode::Bootloader); assert!(!result.result.is_failed(), "The internal call has reverted"); tracer_result.take() @@ -333,19 +325,14 @@ pub(super) fn execute_user_txs_in_test_gas_vm( default_validation_computational_gas_limit: BATCH_COMPUTATIONAL_GAS_LIMIT, chain_id: L2ChainId::default(), }; - let pubdata_builder = pubdata_params_to_builder(PubdataParams::default()); - let mut vm: Vm<_, HistoryEnabled> = Vm::new( - l1_batch, - system_env, - Rc::new(RefCell::new(storage_view)), - Some(pubdata_builder), - ); + let mut vm: Vm<_, HistoryEnabled> = + Vm::new(l1_batch, system_env, Rc::new(RefCell::new(storage_view))); let mut total_gas_refunded = 0; for tx in txs { vm.push_transaction(tx); - let tx_execution_result = vm.execute(VmExecutionMode::OneTx); + let tx_execution_result = vm.execute(InspectExecutionMode::OneTx); total_gas_refunded += tx_execution_result.refunds.gas_refunded; if !accept_failure { @@ -357,7 +344,7 @@ pub(super) fn execute_user_txs_in_test_gas_vm( } } - let result = vm.execute(VmExecutionMode::Bootloader); + let result = vm.execute(InspectExecutionMode::Bootloader); let metrics = result.get_execution_metrics(None); VmSpentResourcesResult { diff --git a/core/lib/dal/src/consensus/conv.rs b/core/lib/dal/src/consensus/conv.rs index 8815abf591cc..2b8488dd0c2a 100644 --- a/core/lib/dal/src/consensus/conv.rs +++ b/core/lib/dal/src/consensus/conv.rs @@ -141,10 +141,10 @@ impl ProtoFmt for Payload { Some(PubdataParams { l2_da_validator_address: required(&pubdata_params.l2_da_validator_address) .and_then(|a| parse_h160(a)) - .context("operator_address")?, + .context("l2_da_validator_address")?, pubdata_type: required(&pubdata_params.pubdata_type) .and_then(|x| Ok(proto::L1BatchCommitDataGeneratorMode::try_from(*x)?)) - .context("l1_batch_commit_data_generator_mode")? + .context("pubdata_type")? .parse(), }) } else { diff --git a/core/lib/multivm/src/versions/tests.rs b/core/lib/multivm/src/versions/tests.rs index 1c438eb5a1cf..ed46aa74bb2e 100644 --- a/core/lib/multivm/src/versions/tests.rs +++ b/core/lib/multivm/src/versions/tests.rs @@ -3,6 +3,7 @@ use assert_matches::assert_matches; use ethabi::Contract; +use std::rc::Rc; use zksync_contracts::{ get_loadnext_contract, load_contract, read_bytecode, test_contracts::LoadnextContractExecutionParams, @@ -13,6 +14,7 @@ use zksync_types::{ ProtocolVersionId, StorageKey, H256, U256, }; use zksync_utils::bytecode::hash_bytecode; +use zksync_vm_interface::pubdata::rollup::RollupPubdataBuilder; use crate::{ interface::{ @@ -197,7 +199,7 @@ impl Harness { assert!(!exec_result.result.is_failed(), "{:#?}", exec_result); self.new_block(vm, &[deploy_tx.tx.hash(), load_test_tx.hash()]); - vm.finish_batch(); + vm.finish_batch(Some(default_pubdata_builder())); } } @@ -207,13 +209,12 @@ where { let system_env = default_system_env(); let l1_batch_env = default_l1_batch(L1BatchNumber(1)); - let pubdata_builder = default_pubdata_builder(); let mut storage = InMemoryStorage::with_system_contracts(hash_bytecode); let mut harness = Harness::new(&l1_batch_env); harness.setup_storage(&mut storage); let storage = StorageView::new(storage).to_rc_ptr(); - let mut vm = Vm::new(l1_batch_env, system_env, storage, Some(pubdata_builder)); + let mut vm = Vm::new(l1_batch_env, system_env, storage); harness.execute_on_vm(&mut vm); (vm, harness) } @@ -232,7 +233,6 @@ fn sanity_check_harness_on_new_vm() { fn sanity_check_shadow_vm() { let system_env = default_system_env(); let l1_batch_env = default_l1_batch(L1BatchNumber(1)); - let pubdata_builder = default_pubdata_builder(); let mut storage = InMemoryStorage::with_system_contracts(hash_bytecode); let mut harness = Harness::new(&l1_batch_env); harness.setup_storage(&mut storage); @@ -245,7 +245,6 @@ fn sanity_check_shadow_vm() { system_env, main_storage, shadow_storage, - Some(pubdata_builder), ); harness.execute_on_vm(&mut vm); } @@ -253,11 +252,15 @@ fn sanity_check_shadow_vm() { #[test] fn shadow_vm_basics() { let (vm, harness) = sanity_check_vm::(); - let mut dump = vm.dump_state(); + let pubdata_builder = default_pubdata_builder(); + let mut dump = vm.dump_state(Some(pubdata_builder.clone())); Harness::assert_dump(&mut dump); // Test standard playback functionality. - let replayed_dump = dump.clone().play_back::>().dump_state(); + let replayed_dump = dump + .clone() + .play_back::>() + .dump_state(Some(pubdata_builder.clone())); pretty_assertions::assert_eq!(replayed_dump, dump); // Check that the VM executes identically when reading from the original storage and one restored from the dump. @@ -265,17 +268,16 @@ fn shadow_vm_basics() { harness.setup_storage(&mut storage); let storage = StorageView::new(storage).to_rc_ptr(); - let vm = - dump.clone() - .play_back_custom(|l1_batch_env, system_env, dump_storage, pubdata_builder| { - ShadowVm::<_, ReferenceVm, ReferenceVm<_>>::with_custom_shadow( - l1_batch_env, - system_env, - storage, - dump_storage, - pubdata_builder, - ) - }); - let new_dump = vm.dump_state(); + let vm = dump + .clone() + .play_back_custom(|l1_batch_env, system_env, dump_storage| { + ShadowVm::<_, ReferenceVm, ReferenceVm<_>>::with_custom_shadow( + l1_batch_env, + system_env, + storage, + dump_storage, + ) + }); + let new_dump = vm.dump_state(Some(pubdata_builder)); pretty_assertions::assert_eq!(new_dump, dump); } diff --git a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs index c1b3fb549cfe..7b3a30f396bd 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs @@ -3,14 +3,15 @@ use std::{collections::HashSet, rc::Rc}; use zksync_types::Transaction; use zksync_utils::{bytecode::hash_bytecode, h256_to_u256}; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; use crate::{ glue::{history_mode::HistoryMode, GlueInto}, interface::{ storage::{StoragePtr, WriteStorage}, BytecodeCompressionError, BytecodeCompressionResult, FinishedL1Batch, L1BatchEnv, - L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmExecutionResultAndLogs, - VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, + L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, + VmInterfaceHistoryEnabled, VmMemoryMetrics, }, tracers::old::TracerDispatcher, utils::bytecode, @@ -57,7 +58,7 @@ impl VmInterface for Vm { fn inspect( &mut self, tracer: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { if let Some(storage_invocations) = tracer.storage_invocations { self.vm @@ -66,7 +67,7 @@ impl VmInterface for Vm { } match execution_mode { - VmExecutionMode::OneTx => { + InspectExecutionMode::OneTx => { match self.system_env.execution_mode { TxExecutionMode::VerifyExecute => { let enable_call_tracer = tracer @@ -89,8 +90,7 @@ impl VmInterface for Vm { .glue_into(), } } - VmExecutionMode::Batch => self.finish_batch().block_tip_execution_result, - VmExecutionMode::Bootloader => self.vm.execute_block_tip().glue_into(), + InspectExecutionMode::Bootloader => self.vm.execute_block_tip().glue_into(), } } @@ -180,7 +180,10 @@ impl VmInterface for Vm { } } - fn finish_batch(&mut self) -> FinishedL1Batch { + fn finish_batch( + &mut self, + _pubdata_builder: Option>, + ) -> FinishedL1Batch { self.vm .execute_till_block_end( crate::vm_1_3_2::vm_with_bootloader::BootloaderJobType::BlockPostprocessing, @@ -190,12 +193,7 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr, - _pubdata_builder: Option>, - ) -> Self { + fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let oracle_tools = crate::vm_1_3_2::OracleTools::new(storage.clone()); let block_properties = crate::vm_1_3_2::BlockProperties { default_aa_code_hash: h256_to_u256( diff --git a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs index deb70466e3f4..1fea9e1a5a23 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs @@ -6,6 +6,7 @@ use zksync_types::{ Transaction, }; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; use crate::{ glue::GlueInto, @@ -93,9 +94,9 @@ impl VmInterface for Vm { fn inspect( &mut self, tracer: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { - self.inspect_inner(tracer, execution_mode, None) + self.inspect_inner(tracer, execution_mode.into(), None) } fn start_new_l2_block(&mut self, l2_block_env: L2BlockEnv) { @@ -126,8 +127,15 @@ impl VmInterface for Vm { } } - fn finish_batch(&mut self) -> FinishedL1Batch { - let result = self.inspect(&mut TracerDispatcher::default(), VmExecutionMode::Batch); + fn finish_batch( + &mut self, + _pubdata_builder: Option>, + ) -> FinishedL1Batch { + let result = self.inspect_inner( + &mut TracerDispatcher::default(), + VmExecutionMode::Batch, + None, + ); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); FinishedL1Batch { @@ -146,12 +154,7 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr, - _pubdata_builder: Option>, - ) -> Self { + fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs index 116b4b753d22..b2a6183fe7f1 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs @@ -6,6 +6,7 @@ use zksync_types::{ Transaction, }; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; use crate::{ glue::GlueInto, @@ -93,9 +94,9 @@ impl VmInterface for Vm { fn inspect( &mut self, tracer: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { - self.inspect_inner(mem::take(tracer), execution_mode, None) + self.inspect_inner(mem::take(tracer), execution_mode.into(), None) } fn start_new_l2_block(&mut self, l2_block_env: L2BlockEnv) { @@ -126,8 +127,11 @@ impl VmInterface for Vm { } } - fn finish_batch(&mut self) -> FinishedL1Batch { - let result = self.inspect(&mut TracerDispatcher::default(), VmExecutionMode::Batch); + fn finish_batch( + &mut self, + _pubdata_builder: Option>, + ) -> FinishedL1Batch { + let result = self.inspect_inner(TracerDispatcher::default(), VmExecutionMode::Batch, None); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); FinishedL1Batch { @@ -151,12 +155,7 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr, - _pubdata_builder: Option>, - ) -> Self { + fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs index 0a340a34e9fe..6f85ddf5f8c1 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs @@ -6,6 +6,7 @@ use zksync_types::{ Transaction, }; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; use crate::{ glue::GlueInto, @@ -93,9 +94,9 @@ impl VmInterface for Vm { fn inspect( &mut self, tracer: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { - self.inspect_inner(tracer, execution_mode) + self.inspect_inner(tracer, execution_mode.into()) } fn start_new_l2_block(&mut self, l2_block_env: L2BlockEnv) { @@ -127,8 +128,11 @@ impl VmInterface for Vm { } } - fn finish_batch(&mut self) -> FinishedL1Batch { - let result = self.inspect(&mut TracerDispatcher::default(), VmExecutionMode::Batch); + fn finish_batch( + &mut self, + _pubdata_builder: Option>, + ) -> FinishedL1Batch { + let result = self.inspect_inner(&mut TracerDispatcher::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); FinishedL1Batch { @@ -147,12 +151,7 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr, - _pubdata_builder: Option>, - ) -> Self { + fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, diff --git a/core/lib/multivm/src/versions/vm_fast/tests/block_tip.rs b/core/lib/multivm/src/versions/vm_fast/tests/block_tip.rs index dd407c616682..befcfa22ec46 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/block_tip.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/block_tip.rs @@ -17,7 +17,7 @@ use super::{ utils::{get_complex_upgrade_abi, read_complex_upgrade}, }; use crate::{ - interface::{L1BatchEnv, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, L1BatchEnv, TxExecutionMode, VmInterface, VmInterfaceExt}, versions::testonly::default_l1_batch, vm_latest::constants::{ BOOTLOADER_BATCH_TIP_CIRCUIT_STATISTICS_OVERHEAD, @@ -158,7 +158,7 @@ fn execute_test(test_data: L1MessengerTestData) -> TestStatistics { vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction {i} wasn't successful for input: {test_data:#?}" @@ -170,18 +170,28 @@ fn execute_test(test_data: L1MessengerTestData) -> TestStatistics { vm.vm.enforce_state_diffs(test_data.state_diffs.clone()); let gas_before = vm.vm.gas_remaining(); - let result = vm.vm.execute(VmExecutionMode::Batch); + let result = vm.vm.finish_batch(None); assert!( - !result.result.is_failed(), + !result.block_tip_execution_result.result.is_failed(), "Batch wasn't successful for input: {test_data:?}" ); let gas_after = vm.vm.gas_remaining(); - assert_eq!((gas_before - gas_after) as u64, result.statistics.gas_used); + assert_eq!( + (gas_before - gas_after) as u64, + result.block_tip_execution_result.statistics.gas_used + ); TestStatistics { max_used_gas: gas_before - gas_after, - circuit_statistics: result.statistics.circuit_statistic.total() as u64, - execution_metrics_size: result.get_execution_metrics(None).size() as u64, + circuit_statistics: result + .block_tip_execution_result + .statistics + .circuit_statistic + .total() as u64, + execution_metrics_size: result + .block_tip_execution_result + .get_execution_metrics(None) + .size() as u64, } } diff --git a/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs b/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs index 48e1b10de442..4e7cb97d473f 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs @@ -3,7 +3,7 @@ use zksync_types::U256; use zksync_vm2::interface::HeapId; use crate::{ - interface::{ExecutionResult, Halt, TxExecutionMode, VmExecutionMode, VmInterfaceExt}, + interface::{ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, VmInterfaceExt}, versions::vm_fast::tests::{ tester::VmTesterBuilder, utils::{get_bootloader, verify_required_memory, BASE_SYSTEM_CONTRACTS}, @@ -21,7 +21,7 @@ fn test_dummy_bootloader() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let result = vm.vm.execute(VmExecutionMode::Batch); + let result = vm.vm.execute(InspectExecutionMode::Batch); assert!(!result.result.is_failed()); let correct_first_cell = U256::from_str_radix("123123123", 16).unwrap(); @@ -41,7 +41,7 @@ fn test_bootloader_out_of_gas() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let res = vm.vm.execute(VmExecutionMode::Batch); + let res = vm.vm.execute(InspectExecutionMode::Batch); assert_matches!( res.result, diff --git a/core/lib/multivm/src/versions/vm_fast/tests/bytecode_publishing.rs b/core/lib/multivm/src/versions/vm_fast/tests/bytecode_publishing.rs index 3070140c00b3..5efef2b63b95 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/bytecode_publishing.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/bytecode_publishing.rs @@ -1,5 +1,5 @@ use crate::{ - interface::{TxExecutionMode, VmEvent, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmEvent, VmInterface, VmInterfaceExt}, utils::bytecode, vm_fast::tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, @@ -24,10 +24,10 @@ fn test_bytecode_publishing() { let DeployContractsTx { tx, .. } = account.get_deploy_tx(&counter, None, TxType::L2); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.execute(VmExecutionMode::Batch); + vm.vm.execute(InspectExecutionMode::Batch); let state = vm.vm.get_current_execution_state(); let long_messages = VmEvent::extract_long_l2_to_l1_messages(&state.events); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/call_tracer.rs b/core/lib/multivm/src/versions/vm_fast/tests/call_tracer.rs index c97b38b6afc4..0f7b59f91c14 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/call_tracer.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/call_tracer.rs @@ -4,7 +4,7 @@ use once_cell::sync::OnceCell; use zksync_types::{Address, Execute}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{TxExecutionMode, InspectExecutionMode, VmInterface}, tracers::CallTracer, vm_latest::{ constants::BATCH_COMPUTATIONAL_GAS_LIMIT, @@ -45,7 +45,7 @@ fn test_max_depth() { let result = Arc::new(OnceCell::new()); let call_tracer = CallTracer::new(result.clone()).into_tracer_pointer(); vm.vm.push_transaction(tx); - let res = vm.vm.inspect(call_tracer.into(), VmExecutionMode::OneTx); + let res = vm.vm.inspect(call_tracer.into(), InspectExecutionMode::OneTx); assert!(result.get().is_some()); assert!(res.result.is_failed()); } @@ -80,7 +80,7 @@ fn test_basic_behavior() { let result = Arc::new(OnceCell::new()); let call_tracer = CallTracer::new(result.clone()).into_tracer_pointer(); vm.vm.push_transaction(tx); - let res = vm.vm.inspect(call_tracer.into(), VmExecutionMode::OneTx); + let res = vm.vm.inspect(call_tracer.into(), InspectExecutionMode::OneTx); let call_tracer_result = result.get().unwrap(); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/circuits.rs b/core/lib/multivm/src/versions/vm_fast/tests/circuits.rs index f40e5336eb3d..8e2c62bd62eb 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/circuits.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/circuits.rs @@ -2,7 +2,7 @@ use zksync_types::{Address, Execute, U256}; use super::tester::VmTesterBuilder; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT, }; @@ -29,7 +29,7 @@ fn test_circuits() { None, ); vm.vm.push_transaction(tx); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!res.result.is_failed(), "{res:#?}"); let s = res.statistics.circuit_statistic; diff --git a/core/lib/multivm/src/versions/vm_fast/tests/code_oracle.rs b/core/lib/multivm/src/versions/vm_fast/tests/code_oracle.rs index 34342d7f3b87..b2734533887f 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/code_oracle.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/code_oracle.rs @@ -5,7 +5,7 @@ use zksync_types::{ use zksync_utils::{bytecode::hash_bytecode, h256_to_u256, u256_to_h256}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, versions::testonly::ContractToDeploy, vm_fast::{ tests::{ @@ -72,7 +72,7 @@ fn test_code_oracle() { ); vm.vm.push_transaction(tx1); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction wasn't successful: {result:#?}" @@ -95,7 +95,7 @@ fn test_code_oracle() { None, ); vm.vm.push_transaction(tx2); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction wasn't successful: {result:#?}" @@ -165,7 +165,7 @@ fn test_code_oracle_big_bytecode() { ); vm.vm.push_transaction(tx1); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction wasn't successful: {result:#?}" @@ -232,7 +232,7 @@ fn refunds_in_code_oracle() { ); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction wasn't successful: {result:#?}" diff --git a/core/lib/multivm/src/versions/vm_fast/tests/default_aa.rs b/core/lib/multivm/src/versions/vm_fast/tests/default_aa.rs index c2ce02d39fe1..6ffd8939c8f7 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/default_aa.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/default_aa.rs @@ -7,7 +7,7 @@ use zksync_types::{ use zksync_utils::u256_to_h256; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, vm_fast::tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, utils::{get_balance, read_test_contract, verify_required_storage}, @@ -35,10 +35,10 @@ fn test_default_aa_interaction() { let maximal_fee = tx.gas_limit() * get_batch_base_fee(&vm.vm.batch_env); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.execute(VmExecutionMode::Batch); + vm.vm.execute(InspectExecutionMode::Batch); vm.vm.get_current_execution_state(); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs index 0447304f69f4..780084605109 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs @@ -11,7 +11,7 @@ use zksync_utils::{bytecode::hash_bytecode, h256_to_u256}; use crate::{ interface::{ - storage::ReadStorage, ExecutionResult, TxExecutionMode, VmExecutionMode, + storage::ReadStorage, ExecutionResult, InspectExecutionMode, TxExecutionMode, VmExecutionResultAndLogs, VmInterface, VmInterfaceExt, }, versions::testonly::ContractToDeploy, @@ -39,7 +39,7 @@ fn test_get_used_contracts() { let mut account = Account::random(); let tx = account.get_deploy_tx(&contract_code, None, TxType::L1 { serial_id: 0 }); vm.vm.push_transaction(tx.tx.clone()); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed()); assert!(vm @@ -76,7 +76,7 @@ fn test_get_used_contracts() { vm.vm.push_transaction(tx2.clone()); - let res2 = vm.vm.execute(VmExecutionMode::OneTx); + let res2 = vm.vm.execute(InspectExecutionMode::OneTx); assert!(res2.result.is_failed()); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/is_write_initial.rs b/core/lib/multivm/src/versions/vm_fast/tests/is_write_initial.rs index df8d992f02fe..536c21e6784c 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/is_write_initial.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/is_write_initial.rs @@ -2,7 +2,7 @@ use zksync_types::get_nonce_key; use crate::{ interface::{ - storage::ReadStorage, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt, + storage::ReadStorage, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, }, vm_fast::tests::{ tester::{Account, TxType, VmTesterBuilder}, @@ -35,7 +35,7 @@ fn test_is_write_initial_behaviour() { let tx = account.get_deploy_tx(&contract_code, None, TxType::L2).tx; vm.vm.push_transaction(tx); - vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); // Check that `is_write_initial` still returns true for the nonce key. assert!(vm diff --git a/core/lib/multivm/src/versions/vm_fast/tests/l1_tx_execution.rs b/core/lib/multivm/src/versions/vm_fast/tests/l1_tx_execution.rs index 5897ec5f2662..55dba62dfbb5 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/l1_tx_execution.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/l1_tx_execution.rs @@ -9,7 +9,7 @@ use zksync_types::{ use zksync_utils::{h256_to_u256, u256_to_h256}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, utils::StorageWritesDeduplicator, vm_fast::{ tests::{ @@ -66,7 +66,7 @@ fn test_l1_tx_execution() { vm.vm.push_transaction(deploy_tx.tx.clone()); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); // The code hash of the deployed contract should be marked as republished. let known_codes_key = get_known_code_key(&deploy_tx.bytecode_hash); @@ -99,7 +99,7 @@ fn test_l1_tx_execution() { TxType::L1 { serial_id: 0 }, ); vm.vm.push_transaction(tx); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); let storage_logs = res.logs.storage_logs; let res = StorageWritesDeduplicator::apply_on_empty_state(&storage_logs); @@ -114,7 +114,7 @@ fn test_l1_tx_execution() { TxType::L1 { serial_id: 0 }, ); vm.vm.push_transaction(tx.clone()); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); let storage_logs = res.logs.storage_logs; let res = StorageWritesDeduplicator::apply_on_empty_state(&storage_logs); // We changed one slot inside contract. @@ -125,7 +125,7 @@ fn test_l1_tx_execution() { assert_eq!(res.repeated_storage_writes, 0); vm.vm.push_transaction(tx); - let storage_logs = vm.vm.execute(VmExecutionMode::OneTx).logs.storage_logs; + let storage_logs = vm.vm.execute(InspectExecutionMode::OneTx).logs.storage_logs; let res = StorageWritesDeduplicator::apply_on_empty_state(&storage_logs); // We do the same storage write, it will be deduplicated, so still 4 initial write and 0 repeated. // But now the base pubdata spent has changed too. @@ -140,7 +140,7 @@ fn test_l1_tx_execution() { TxType::L1 { serial_id: 1 }, ); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); // Method is not payable tx should fail assert!(result.result.is_failed(), "The transaction should fail"); @@ -192,7 +192,7 @@ fn test_l1_tx_execution_high_gas_limit() { vm.vm.push_transaction(tx); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); assert!(res.result.is_failed(), "The transaction should've failed"); } diff --git a/core/lib/multivm/src/versions/vm_fast/tests/l2_blocks.rs b/core/lib/multivm/src/versions/vm_fast/tests/l2_blocks.rs index fde94d9da6cd..369ac2b0b7b5 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/l2_blocks.rs @@ -15,8 +15,8 @@ use zksync_utils::{h256_to_u256, u256_to_h256}; use crate::{ interface::{ - storage::ReadStorage, ExecutionResult, Halt, L2BlockEnv, TxExecutionMode, VmExecutionMode, - VmInterface, VmInterfaceExt, + storage::ReadStorage, ExecutionResult, Halt, InspectExecutionMode, L2BlockEnv, + TxExecutionMode, VmInterface, VmInterfaceExt, }, versions::testonly::default_l1_batch, vm_fast::{tests::tester::VmTesterBuilder, vm::Vm}, @@ -67,7 +67,7 @@ fn test_l2_block_initialization_timestamp() { let l1_tx = get_l1_noop(); vm.vm.push_transaction(l1_tx); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); assert_eq!( res.result, @@ -101,7 +101,7 @@ fn test_l2_block_initialization_number_non_zero() { set_manual_l2_block_info(&mut vm.vm, 0, first_l2_block); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); assert_eq!( res.result, @@ -129,7 +129,7 @@ fn test_same_l2_block( let l1_tx = get_l1_noop(); vm.vm.push_transaction(l1_tx.clone()); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!res.result.is_failed()); let mut current_l2_block = vm.vm.batch_env.first_l2_block; @@ -148,7 +148,7 @@ fn test_same_l2_block( vm.vm.push_transaction(l1_tx); set_manual_l2_block_info(&mut vm.vm, 1, current_l2_block); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); if let Some(err) = expected_error { assert_eq!(result.result, ExecutionResult::Halt { reason: err }); @@ -205,7 +205,7 @@ fn test_new_l2_block( // Firstly we execute the first transaction vm.vm.push_transaction(l1_tx.clone()); - vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); let mut second_l2_block = vm.vm.batch_env.first_l2_block; second_l2_block.number += 1; @@ -226,7 +226,7 @@ fn test_new_l2_block( vm.vm.push_transaction(l1_tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); if let Some(err) = expected_error { assert_eq!(result.result, ExecutionResult::Halt { reason: err }); } else { @@ -352,7 +352,7 @@ fn test_first_in_batch( vm.vm.push_transaction(l1_tx); set_manual_l2_block_info(&mut vm.vm, 0, proposed_block); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); if let Some(err) = expected_error { assert_eq!(result.result, ExecutionResult::Halt { reason: err }); } else { diff --git a/core/lib/multivm/src/versions/vm_fast/tests/nonce_holder.rs b/core/lib/multivm/src/versions/vm_fast/tests/nonce_holder.rs index 6d1e0f016e9e..12c69cbed457 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/nonce_holder.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/nonce_holder.rs @@ -2,8 +2,8 @@ use zksync_types::{Execute, ExecuteTransactionCommon, Nonce}; use crate::{ interface::{ - ExecutionResult, Halt, TxExecutionMode, TxRevertReason, VmExecutionMode, VmInterfaceExt, - VmRevertReason, + ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, TxRevertReason, + VmInterfaceExt, VmRevertReason, }, versions::testonly::ContractToDeploy, vm_fast::tests::{ @@ -73,7 +73,7 @@ fn test_nonce_holder() { }; tx_data.signature = vec![test_mode.into()]; vm.vm.push_transaction_inner(transaction, 0, true); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); if let Some(msg) = error_message { let expected_error = diff --git a/core/lib/multivm/src/versions/vm_fast/tests/precompiles.rs b/core/lib/multivm/src/versions/vm_fast/tests/precompiles.rs index b3ca15962172..1ff4cf4d08f3 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/precompiles.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/precompiles.rs @@ -3,7 +3,7 @@ use zksync_types::{Address, Execute}; use super::{tester::VmTesterBuilder, utils::read_precompiles_contract}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, versions::testonly::ContractToDeploy, vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT, }; @@ -38,7 +38,7 @@ fn test_keccak() { ); vm.vm.push_transaction(tx); - let exec_result = vm.vm.execute(VmExecutionMode::OneTx); + let exec_result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!exec_result.result.is_failed(), "{exec_result:#?}"); let keccak_count = exec_result.statistics.circuit_statistic.keccak256 @@ -76,7 +76,7 @@ fn test_sha256() { ); vm.vm.push_transaction(tx); - let exec_result = vm.vm.execute(VmExecutionMode::OneTx); + let exec_result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!exec_result.result.is_failed(), "{exec_result:#?}"); let sha_count = exec_result.statistics.circuit_statistic.sha256 @@ -107,7 +107,7 @@ fn test_ecrecover() { ); vm.vm.push_transaction(tx); - let exec_result = vm.vm.execute(VmExecutionMode::OneTx); + let exec_result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!exec_result.result.is_failed(), "{exec_result:#?}"); let ecrecover_count = exec_result.statistics.circuit_statistic.ecrecover diff --git a/core/lib/multivm/src/versions/vm_fast/tests/prestate_tracer.rs b/core/lib/multivm/src/versions/vm_fast/tests/prestate_tracer.rs index 63620c7d9ff8..7c45c955e224 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/prestate_tracer.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/prestate_tracer.rs @@ -5,7 +5,7 @@ use zksync_test_account::TxType; use zksync_types::{utils::deployed_address_create, Execute, U256}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{TxExecutionMode, InspectExecutionMode, VmInterface}, tracers::PrestateTracer, vm_latest::{ constants::BATCH_COMPUTATIONAL_GAS_LIMIT, @@ -40,7 +40,7 @@ fn test_prestate_tracer() { let prestate_tracer_result = Arc::new(OnceCell::default()); let prestate_tracer = PrestateTracer::new(false, prestate_tracer_result.clone()); let tracer_ptr = prestate_tracer.into_tracer_pointer(); - vm.vm.inspect(tracer_ptr.into(), VmExecutionMode::Batch); + vm.vm.inspect(tracer_ptr.into(), InspectExecutionMode::Batch); let prestate_result = Arc::try_unwrap(prestate_tracer_result) .unwrap() @@ -68,7 +68,7 @@ fn test_prestate_tracer_diff_mode() { .tx; let nonce = tx.nonce().unwrap().0.into(); vm.vm.push_transaction(tx); - vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); let deployed_address = deployed_address_create(vm.deployer.as_ref().unwrap().address, nonce); vm.test_contract = Some(deployed_address); @@ -81,7 +81,7 @@ fn test_prestate_tracer_diff_mode() { .tx; let nonce2 = tx2.nonce().unwrap().0.into(); vm.vm.push_transaction(tx2); - vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); let deployed_address2 = deployed_address_create(vm.deployer.as_ref().unwrap().address, nonce2); let account = &mut vm.rich_accounts[0]; @@ -110,7 +110,7 @@ fn test_prestate_tracer_diff_mode() { let prestate_tracer = PrestateTracer::new(true, prestate_tracer_result.clone()); let tracer_ptr = prestate_tracer.into_tracer_pointer(); vm.vm - .inspect(tracer_ptr.into(), VmExecutionMode::Bootloader); + .inspect(tracer_ptr.into(), InspectExecutionMode::Bootloader); let prestate_result = Arc::try_unwrap(prestate_tracer_result) .unwrap() diff --git a/core/lib/multivm/src/versions/vm_fast/tests/refunds.rs b/core/lib/multivm/src/versions/vm_fast/tests/refunds.rs index 1856995149aa..1e691af1e5d8 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/refunds.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/refunds.rs @@ -2,7 +2,7 @@ use ethabi::Token; use zksync_types::{Address, Execute, U256}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, versions::testonly::ContractToDeploy, vm_fast::tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, @@ -31,7 +31,7 @@ fn test_predetermined_refunded_gas() { address: _, } = account.get_deploy_tx(&counter, None, TxType::L2); vm.vm.push_transaction(tx.clone()); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed()); @@ -44,7 +44,7 @@ fn test_predetermined_refunded_gas() { ); assert!(result.refunds.gas_refunded > 0, "The final refund is 0"); - let result_without_predefined_refunds = vm.vm.execute(VmExecutionMode::Batch); + let result_without_predefined_refunds = vm.vm.execute(InspectExecutionMode::Batch); let mut current_state_without_predefined_refunds = vm.vm.get_current_execution_state(); assert!(!result_without_predefined_refunds.result.is_failed(),); @@ -62,7 +62,7 @@ fn test_predetermined_refunded_gas() { vm.vm .push_transaction_inner(tx.clone(), result.refunds.gas_refunded, true); - let result_with_predefined_refunds = vm.vm.execute(VmExecutionMode::Batch); + let result_with_predefined_refunds = vm.vm.execute(InspectExecutionMode::Batch); let mut current_state_with_predefined_refunds = vm.vm.get_current_execution_state(); assert!(!result_with_predefined_refunds.result.is_failed()); @@ -112,7 +112,7 @@ fn test_predetermined_refunded_gas() { let changed_operator_suggested_refund = result.refunds.gas_refunded + 1000; vm.vm .push_transaction_inner(tx, changed_operator_suggested_refund, true); - let result = vm.vm.execute(VmExecutionMode::Batch); + let result = vm.vm.execute(InspectExecutionMode::Batch); let mut current_state_with_changed_predefined_refunds = vm.vm.get_current_execution_state(); assert!(!result.result.is_failed()); @@ -191,7 +191,7 @@ fn negative_pubdata_for_transaction() { None, ); vm.vm.push_transaction(expensive_tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction wasn't successful: {result:#?}" @@ -208,7 +208,7 @@ fn negative_pubdata_for_transaction() { None, ); vm.vm.push_transaction(clean_up_tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction wasn't successful: {result:#?}" diff --git a/core/lib/multivm/src/versions/vm_fast/tests/require_eip712.rs b/core/lib/multivm/src/versions/vm_fast/tests/require_eip712.rs index b4448683cf71..96ee38b05504 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/require_eip712.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/require_eip712.rs @@ -10,7 +10,7 @@ use zksync_utils::h256_to_u256; use crate::{ interface::{ - storage::ReadStorage, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt, + storage::ReadStorage, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, }, versions::testonly::ContractToDeploy, vm_fast::tests::{ @@ -81,7 +81,7 @@ fn test_require_eip712() { ); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed()); let private_account_balance = vm.get_eth_balance(private_account.address); @@ -114,7 +114,7 @@ fn test_require_eip712() { let transaction: Transaction = l2_tx.into(); vm.vm.push_transaction(transaction); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed()); assert_eq!( @@ -162,7 +162,7 @@ fn test_require_eip712() { let transaction: Transaction = l2_tx.into(); vm.vm.push_transaction(transaction); - vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); assert_eq!( vm.get_eth_balance(beneficiary.address), diff --git a/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs b/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs index 55ca372c4a9f..f4bc95fe2a31 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs @@ -4,7 +4,9 @@ use zksync_types::{web3::keccak256, Execute, H256, U256}; use zksync_utils::h256_to_u256; use crate::{ - interface::{ExecutionResult, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{ + ExecutionResult, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, + }, vm_fast::tests::tester::VmTesterBuilder, }; @@ -58,7 +60,7 @@ fn test_sekp256r1() { vm.vm.push_transaction(tx); - let execution_result = vm.vm.execute(VmExecutionMode::Batch); + let execution_result = vm.vm.execute(InspectExecutionMode::Batch); let ExecutionResult::Success { output } = execution_result.result else { panic!("batch failed") diff --git a/core/lib/multivm/src/versions/vm_fast/tests/simple_execution.rs b/core/lib/multivm/src/versions/vm_fast/tests/simple_execution.rs index 8c916a541e21..aea766752eb7 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/simple_execution.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/simple_execution.rs @@ -1,7 +1,7 @@ use assert_matches::assert_matches; use crate::{ - interface::{ExecutionResult, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{ExecutionResult, InspectExecutionMode, VmInterface, VmInterfaceExt}, vm_fast::tests::tester::{TxType, VmTesterBuilder}, }; @@ -26,7 +26,7 @@ fn estimate_fee() { vm_tester.vm.push_transaction(tx); - let result = vm_tester.vm.execute(VmExecutionMode::OneTx); + let result = vm_tester.vm.execute(InspectExecutionMode::OneTx); assert_matches!(result.result, ExecutionResult::Success { .. }); } @@ -69,12 +69,12 @@ fn simple_execute() { vm.push_transaction(tx1); vm.push_transaction(tx2); vm.push_transaction(tx3); - let tx = vm.execute(VmExecutionMode::OneTx); + let tx = vm.execute(InspectExecutionMode::OneTx); assert_matches!(tx.result, ExecutionResult::Success { .. }); - let tx = vm.execute(VmExecutionMode::OneTx); + let tx = vm.execute(InspectExecutionMode::OneTx); assert_matches!(tx.result, ExecutionResult::Revert { .. }); - let tx = vm.execute(VmExecutionMode::OneTx); + let tx = vm.execute(InspectExecutionMode::OneTx); assert_matches!(tx.result, ExecutionResult::Success { .. }); - let block_tip = vm.execute(VmExecutionMode::Batch); + let block_tip = vm.execute(InspectExecutionMode::Batch); assert_matches!(block_tip.result, ExecutionResult::Success { .. }); } diff --git a/core/lib/multivm/src/versions/vm_fast/tests/storage.rs b/core/lib/multivm/src/versions/vm_fast/tests/storage.rs index 2cfadb640e72..da4557708ea6 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/storage.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/storage.rs @@ -4,7 +4,8 @@ use zksync_types::{Address, Execute, U256}; use crate::{ interface::{ - TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, + InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, + VmInterfaceHistoryEnabled, }, versions::testonly::ContractToDeploy, vm_fast::tests::tester::VmTesterBuilder, @@ -51,20 +52,20 @@ fn test_storage(first_tx_calldata: Vec, second_tx_calldata: Vec) -> u32 vm.vm.make_snapshot(); vm.vm.push_transaction(tx1); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "First tx failed"); vm.vm.pop_snapshot_no_rollback(); // We rollback once because transient storage and rollbacks are a tricky combination. vm.vm.make_snapshot(); vm.vm.push_transaction(tx2.clone()); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Second tx failed"); vm.vm.rollback_to_the_latest_snapshot(); vm.vm.make_snapshot(); vm.vm.push_transaction(tx2); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Second tx failed on second run"); result.statistics.pubdata_published diff --git a/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs b/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs index 6b1395f66340..918ff6e4182b 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs @@ -4,8 +4,8 @@ use zksync_vm2::interface::{Event, StateInterface}; use super::VmTester; use crate::{ interface::{ - storage::ReadStorage, CurrentExecutionState, ExecutionResult, Halt, TxRevertReason, - VmExecutionMode, VmExecutionResultAndLogs, VmInterface, VmInterfaceExt, + storage::ReadStorage, CurrentExecutionState, ExecutionResult, Halt, InspectExecutionMode, + TxRevertReason, VmExecutionResultAndLogs, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, VmRevertReason, }, vm_fast::Vm, @@ -209,7 +209,7 @@ impl VmTester<()> { for tx_test_info in txs { self.execute_tx_and_verify(tx_test_info.clone()); } - self.vm.execute(VmExecutionMode::Batch); + self.vm.execute(InspectExecutionMode::Batch); let mut state = self.vm.get_current_execution_state(); state.used_contract_hashes.sort(); state @@ -222,7 +222,7 @@ impl VmTester<()> { self.vm.make_snapshot(); let inner_state_before = self.vm.dump_state(); self.vm.push_transaction(tx_test_info.tx.clone()); - let result = self.vm.execute(VmExecutionMode::OneTx); + let result = self.vm.execute(InspectExecutionMode::OneTx); tx_test_info.verify_result(&result); if tx_test_info.should_rollback() { self.vm.rollback_to_the_latest_snapshot(); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_fast/tests/tester/vm_tester.rs index 9549b32c4f1a..b9e0a4949f31 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/tester/vm_tester.rs @@ -12,7 +12,8 @@ use zksync_vm2::{interface::Tracer, WorldDiff}; use crate::{ interface::{ storage::{InMemoryStorage, StoragePtr}, - L1BatchEnv, L2Block, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmInterface, + InspectExecutionMode, L1BatchEnv, L2Block, L2BlockEnv, SystemEnv, TxExecutionMode, + VmInterface, }, versions::{ testonly::{default_l1_batch, default_system_env, make_account_rich, ContractToDeploy}, @@ -42,7 +43,8 @@ impl VmTester { .tx; let nonce = tx.nonce().unwrap().0.into(); self.vm.push_transaction(tx); - self.vm.inspect(&mut Tr::default(), VmExecutionMode::OneTx); + self.vm + .inspect(&mut Tr::default(), InspectExecutionMode::OneTx); let deployed_address = deployed_address_create(self.deployer.as_ref().unwrap().address, nonce); self.test_contract = Some(deployed_address); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/transfer.rs b/core/lib/multivm/src/versions/vm_fast/tests/transfer.rs index ef510546f11c..4b394a186cf4 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/transfer.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/transfer.rs @@ -5,7 +5,7 @@ use zksync_types::{utils::storage_key_for_eth_balance, AccountTreeId, Address, E use zksync_utils::u256_to_h256; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, versions::testonly::ContractToDeploy, vm_fast::tests::{ tester::{get_empty_storage, VmTesterBuilder}, @@ -80,13 +80,13 @@ fn test_send_or_transfer(test_option: TestOptions) { ); vm.vm.push_transaction(tx); - let tx_result = vm.vm.execute(VmExecutionMode::OneTx); + let tx_result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !tx_result.result.is_failed(), "Transaction wasn't successful" ); - let batch_result = vm.vm.execute(VmExecutionMode::Batch); + let batch_result = vm.vm.execute(InspectExecutionMode::Batch); assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); let new_recipient_balance = get_balance( @@ -177,7 +177,7 @@ fn test_reentrancy_protection_send_or_transfer(test_option: TestOptions) { ); vm.vm.push_transaction(tx1); - let tx1_result = vm.vm.execute(VmExecutionMode::OneTx); + let tx1_result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !tx1_result.result.is_failed(), "Transaction 1 wasn't successful" @@ -194,13 +194,13 @@ fn test_reentrancy_protection_send_or_transfer(test_option: TestOptions) { ); vm.vm.push_transaction(tx2); - let tx2_result = vm.vm.execute(VmExecutionMode::OneTx); + let tx2_result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( tx2_result.result.is_failed(), "Transaction 2 should have failed, but it succeeded" ); - let batch_result = vm.vm.execute(VmExecutionMode::Batch); + let batch_result = vm.vm.execute(InspectExecutionMode::Batch); assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); } diff --git a/core/lib/multivm/src/versions/vm_fast/tests/upgrade.rs b/core/lib/multivm/src/versions/vm_fast/tests/upgrade.rs index ba4863f7c457..9660ba2815af 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/upgrade.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/upgrade.rs @@ -12,7 +12,7 @@ use zksync_utils::{bytecode::hash_bytecode, u256_to_h256}; use crate::{ interface::{ - ExecutionResult, Halt, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt, + ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, }, vm_fast::tests::{ @@ -81,9 +81,9 @@ fn test_protocol_upgrade_is_first() { vm.vm.push_transaction(normal_l1_transaction.clone()); vm.vm.push_transaction(another_protocol_upgrade_transaction); - vm.vm.execute(VmExecutionMode::OneTx); - vm.vm.execute(VmExecutionMode::OneTx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert_eq!( result.result, ExecutionResult::Halt { @@ -97,8 +97,8 @@ fn test_protocol_upgrade_is_first() { vm.vm.push_transaction(normal_l1_transaction.clone()); vm.vm.push_transaction(protocol_upgrade_transaction.clone()); - vm.vm.execute(VmExecutionMode::OneTx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert_eq!( result.result, ExecutionResult::Halt { @@ -111,8 +111,8 @@ fn test_protocol_upgrade_is_first() { vm.vm.push_transaction(protocol_upgrade_transaction); vm.vm.push_transaction(normal_l1_transaction); - vm.vm.execute(VmExecutionMode::OneTx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed()); } @@ -152,7 +152,7 @@ fn test_force_deploy_upgrade() { vm.vm.push_transaction(transaction); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "The force upgrade was not successful" @@ -208,7 +208,7 @@ fn test_complex_upgrader() { ); vm.vm.push_transaction(transaction); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "The force upgrade was not successful" diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index 417a4ab0610c..147245e436e5 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -22,6 +22,7 @@ use zksync_vm2::{ ExecutionEnd, FatPointer, Program, Settings, StorageSlot, VirtualMachine, }; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; use super::{ bootloader_state::{BootloaderState, BootloaderStateSnapshot}, @@ -104,7 +105,7 @@ pub struct Vm { enforced_state_diffs: Option>, } -impl Vm { +impl Vm { pub fn custom(batch_env: L1BatchEnv, system_env: SystemEnv, storage: S) -> Self { assert!( is_supported_by_fast_vm(system_env.version), @@ -534,34 +535,10 @@ impl Vm { pubdata_costs: world_diff.pubdata_costs().to_vec(), } } -} -impl VmFactory> for Vm, Tr> -where - S: ReadStorage, - Tr: Tracer + Default + 'static, -{ - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr>, - _pubdata_builder: Option>, - ) -> Self { - let storage = ImmutableStorageView::new(storage); - Self::custom(batch_env, system_env, storage) - } -} - -impl VmInterface for Vm { - type TracerDispatcher = Tr; - - fn push_transaction(&mut self, tx: zksync_types::Transaction) { - self.push_transaction_inner(tx, 0, true); - } - - fn inspect( + fn inspect_inner( &mut self, - tracer: &mut Self::TracerDispatcher, + tracer: &mut Tr, execution_mode: VmExecutionMode, ) -> VmExecutionResultAndLogs { let mut track_refunds = false; @@ -651,6 +628,37 @@ impl VmInterface for Vm { new_known_factory_deps: None, } } +} + +impl VmFactory> for Vm, Tr> +where + S: ReadStorage, + Tr: Tracer + Default + 'static, +{ + fn new( + batch_env: L1BatchEnv, + system_env: SystemEnv, + storage: StoragePtr>, + ) -> Self { + let storage = ImmutableStorageView::new(storage); + Self::custom(batch_env, system_env, storage) + } +} + +impl VmInterface for Vm { + type TracerDispatcher = Tr; + + fn push_transaction(&mut self, tx: zksync_types::Transaction) { + self.push_transaction_inner(tx, 0, true); + } + + fn inspect( + &mut self, + tracer: &mut Self::TracerDispatcher, + execution_mode: InspectExecutionMode, + ) -> VmExecutionResultAndLogs { + self.inspect_inner(tracer, execution_mode.into()) + } fn inspect_transaction_with_bytecode_compression( &mut self, @@ -659,7 +667,7 @@ impl VmInterface for Vm { with_compression: bool, ) -> (BytecodeCompressionResult<'_>, VmExecutionResultAndLogs) { self.push_transaction_inner(tx, 0, with_compression); - let result = self.inspect(tracer, VmExecutionMode::OneTx); + let result = self.inspect(tracer, InspectExecutionMode::OneTx); let compression_result = if self.has_unpublished_bytecodes() { Err(BytecodeCompressionError::BytecodeCompressionFailed) @@ -676,8 +684,11 @@ impl VmInterface for Vm { self.bootloader_state.start_new_l2_block(l2_block_env) } - fn finish_batch(&mut self) -> FinishedL1Batch { - let result = self.inspect(&mut Tr::default(), VmExecutionMode::Batch); + fn finish_batch( + &mut self, + _pubdata_builder: Option>, + ) -> FinishedL1Batch { + let result = self.inspect_inner(&mut Tr::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); FinishedL1Batch { diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs index 863ed6cd40b0..cf06497f3eab 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs @@ -51,8 +51,6 @@ pub struct BootloaderState { pubdata_information: OnceCell, /// Protocol version. protocol_version: ProtocolVersionId, - /// Pubdata builder which is used to convert pubdata input to bytes. - pubdata_builder: Rc, } impl BootloaderState { @@ -61,7 +59,6 @@ impl BootloaderState { initial_memory: BootloaderMemory, first_l2_block: L2BlockEnv, protocol_version: ProtocolVersionId, - pubdata_builder: Rc, ) -> Self { let l2_block = BootloaderL2Block::new(first_l2_block, 0); Self { @@ -73,7 +70,6 @@ impl BootloaderState { free_tx_offset: 0, pubdata_information: Default::default(), protocol_version, - pubdata_builder, } } @@ -154,15 +150,17 @@ impl BootloaderState { .expect("Pubdata information is not set") } - pub(crate) fn settlement_layer_pubdata(&self) -> Vec { + pub(crate) fn settlement_layer_pubdata( + &self, + pubdata_builder: Rc, + ) -> Vec { let pubdata_information = self .pubdata_information .get() .expect("Pubdata information is not set") .clone(); - self.pubdata_builder - .settlement_layer_pubdata(pubdata_information, self.protocol_version) + pubdata_builder.settlement_layer_pubdata(pubdata_information, self.protocol_version) } fn last_mut_l2_block(&mut self) -> &mut BootloaderL2Block { @@ -170,7 +168,10 @@ impl BootloaderState { } /// Apply all bootloader transaction to the initial memory - pub(crate) fn bootloader_memory(&self) -> BootloaderMemory { + pub(crate) fn bootloader_memory( + &self, + pubdata_builder: Rc, + ) -> BootloaderMemory { let mut initial_memory = self.initial_memory.clone(); let mut offset = 0; let mut compressed_bytecodes_offset = 0; @@ -204,7 +205,7 @@ impl BootloaderState { apply_pubdata_to_memory( &mut initial_memory, - self.pubdata_builder.clone(), + pubdata_builder, pubdata_information, self.protocol_version, ); @@ -321,10 +322,6 @@ impl BootloaderState { } } - pub(crate) fn pubdata_builder(&self) -> Rc { - self.pubdata_builder.clone() - } - pub(crate) fn protocol_version(&self) -> ProtocolVersionId { self.protocol_version } diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs index 1e6a92c8419c..4c15eab27325 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs @@ -128,6 +128,20 @@ fn apply_l2_block_inner( ]) } +fn bootloader_memory_input( + pubdata_builder: Rc, + input: PubdataInput, + protocol_version: ProtocolVersionId, +) -> Vec { + let l2_da_validator_address = pubdata_builder.l2_da_validator(); + let operator_input = pubdata_builder.l1_messenger_operator_input(input, protocol_version); + + ethabi::encode(&[ + ethabi::Token::Address(l2_da_validator_address), + ethabi::Token::Bytes(operator_input), + ]) +} + pub(crate) fn apply_pubdata_to_memory( memory: &mut BootloaderMemory, pubdata_builder: Rc, @@ -159,7 +173,7 @@ pub(crate) fn apply_pubdata_to_memory( let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 1; let pubdata = - pubdata_builder.bootloader_memory_input(pubdata_information, protocol_version); + bootloader_memory_input(pubdata_builder, pubdata_information, protocol_version); assert!( // Note that unlike the previous version, the difference is `1`, since now it also includes the offset diff --git a/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs b/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs index e70f05f85ef2..d9331720ce28 100644 --- a/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs +++ b/core/lib/multivm/src/versions/vm_latest/implementation/execution.rs @@ -69,6 +69,7 @@ impl Vm { self.batch_env.clone(), execution_mode, self.subversion, + None, )) }), self.subversion, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs b/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs index 9909ca24937f..016334a6acbb 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs @@ -15,7 +15,7 @@ use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u25 use super::utils::{get_complex_upgrade_abi, read_complex_upgrade}; use crate::{ - interface::{L1BatchEnv, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, L1BatchEnv, TxExecutionMode, VmInterface, VmInterfaceExt}, vm_latest::{ constants::{ BOOTLOADER_BATCH_TIP_CIRCUIT_STATISTICS_OVERHEAD, @@ -174,7 +174,7 @@ fn execute_test(test_data: L1MessengerTestData) -> TestStatistics { vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction {i} wasn't successful for input: {:#?}", @@ -190,14 +190,14 @@ fn execute_test(test_data: L1MessengerTestData) -> TestStatistics { // We ensure that indeed the provided state diffs are used let pubdata_tracer = PubdataTracer::::new_with_forced_state_diffs( vm.vm.batch_env.clone(), - VmExecutionMode::Batch, + InspectExecutionMode::Batch, test_data.state_diffs.clone(), crate::vm_latest::MultiVMSubversion::latest(), ); let result = vm.vm.inspect_inner( &mut TracerDispatcher::default(), - VmExecutionMode::Batch, + InspectExecutionMode::Batch, Some(pubdata_tracer), ); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs b/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs index 9d23f658cb82..9a2a72c04124 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs @@ -2,7 +2,7 @@ use assert_matches::assert_matches; use zksync_types::U256; use crate::{ - interface::{ExecutionResult, Halt, TxExecutionMode, VmExecutionMode, VmInterfaceExt}, + interface::{ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, VmInterfaceExt}, vm_latest::{ constants::BOOTLOADER_HEAP_PAGE, tests::{ @@ -24,7 +24,7 @@ fn test_dummy_bootloader() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let result = vm.vm.execute(VmExecutionMode::Batch); + let result = vm.vm.execute(InspectExecutionMode::Batch); assert!(!result.result.is_failed()); let correct_first_cell = U256::from_str_radix("123123123", 16).unwrap(); @@ -46,7 +46,7 @@ fn test_bootloader_out_of_gas() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let res = vm.vm.execute(VmExecutionMode::Batch); + let res = vm.vm.execute(InspectExecutionMode::Batch); assert_matches!( res.result, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/bytecode_publishing.rs b/core/lib/multivm/src/versions/vm_latest/tests/bytecode_publishing.rs index 2ed9948af819..93dc7d47bf17 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/bytecode_publishing.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/bytecode_publishing.rs @@ -1,5 +1,5 @@ use crate::{ - interface::{TxExecutionMode, VmEvent, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmEvent, VmInterface, VmInterfaceExt}, utils::bytecode, vm_latest::{ tests::{ @@ -27,10 +27,10 @@ fn test_bytecode_publishing() { let DeployContractsTx { tx, .. } = account.get_deploy_tx(&counter, None, TxType::L2); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.execute(VmExecutionMode::Batch); + vm.vm.execute(InspectExecutionMode::Batch); let state = vm.vm.get_current_execution_state(); let long_messages = VmEvent::extract_long_l2_to_l1_messages(&state.events); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/call_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tests/call_tracer.rs index e7f26b7faf88..9e6a4856ef46 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/call_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/call_tracer.rs @@ -4,7 +4,7 @@ use once_cell::sync::OnceCell; use zksync_types::{Address, Execute}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface}, tracers::CallTracer, vm_latest::{ constants::BATCH_COMPUTATIONAL_GAS_LIMIT, @@ -47,7 +47,7 @@ fn test_max_depth() { vm.vm.push_transaction(tx); let res = vm .vm - .inspect(&mut call_tracer.into(), VmExecutionMode::OneTx); + .inspect(&mut call_tracer.into(), InspectExecutionMode::OneTx); assert!(result.get().is_some()); assert!(res.result.is_failed()); } @@ -84,7 +84,7 @@ fn test_basic_behavior() { vm.vm.push_transaction(tx); let res = vm .vm - .inspect(&mut call_tracer.into(), VmExecutionMode::OneTx); + .inspect(&mut call_tracer.into(), InspectExecutionMode::OneTx); let call_tracer_result = result.get().unwrap(); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/circuits.rs b/core/lib/multivm/src/versions/vm_latest/tests/circuits.rs index c3c6816cbd8f..a4920d8034b5 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/circuits.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/circuits.rs @@ -1,7 +1,7 @@ use zksync_types::{Address, Execute, U256}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface}, vm_latest::{ constants::BATCH_COMPUTATIONAL_GAS_LIMIT, tests::tester::VmTesterBuilder, HistoryEnabled, }, @@ -32,7 +32,7 @@ fn test_circuits() { vm.vm.push_transaction(tx); let res = vm .vm - .inspect(&mut Default::default(), VmExecutionMode::OneTx); + .inspect(&mut Default::default(), InspectExecutionMode::OneTx); let s = res.statistics.circuit_statistic; // Check `circuit_statistic`. diff --git a/core/lib/multivm/src/versions/vm_latest/tests/code_oracle.rs b/core/lib/multivm/src/versions/vm_latest/tests/code_oracle.rs index b15ef7fde2bf..aa5ecb571b12 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/code_oracle.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/code_oracle.rs @@ -9,7 +9,7 @@ use zksync_types::{ use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u256_to_h256}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, vm_latest::{ tests::{ tester::{get_empty_storage, VmTesterBuilder}, @@ -83,7 +83,7 @@ fn test_code_oracle() { ); vm.vm.push_transaction(tx1); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction wasn't successful: {result:#?}" @@ -106,7 +106,7 @@ fn test_code_oracle() { None, ); vm.vm.push_transaction(tx2); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction wasn't successful: {result:#?}" @@ -183,7 +183,7 @@ fn test_code_oracle_big_bytecode() { ); vm.vm.push_transaction(tx1); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); } @@ -265,7 +265,7 @@ fn refunds_in_code_oracle() { ); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); let log = find_code_oracle_cost_log(precompiles_contract_address, &result.logs.storage_logs); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/default_aa.rs b/core/lib/multivm/src/versions/vm_latest/tests/default_aa.rs index aa3eb5e752ce..cc2a7b0911a1 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/default_aa.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/default_aa.rs @@ -7,7 +7,7 @@ use zksync_types::{ use zksync_utils::u256_to_h256; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, vm_latest::{ tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, @@ -38,10 +38,10 @@ fn test_default_aa_interaction() { let maximal_fee = tx.gas_limit() * get_batch_base_fee(&vm.vm.batch_env); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.execute(VmExecutionMode::Batch); + vm.vm.execute(InspectExecutionMode::Batch); vm.vm.get_current_execution_state(); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_latest/tests/get_used_contracts.rs index d7cadc54b442..2d4cc5ea4985 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/get_used_contracts.rs @@ -21,7 +21,7 @@ use zksync_vm_interface::VmExecutionResultAndLogs; use crate::{ interface::{ - storage::WriteStorage, ExecutionResult, TxExecutionMode, VmExecutionMode, VmInterface, + storage::WriteStorage, ExecutionResult, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, }, vm_latest::{ @@ -49,7 +49,7 @@ fn test_get_used_contracts() { let mut account = Account::random(); let tx = account.get_deploy_tx(&contract_code, None, TxType::L1 { serial_id: 0 }); vm.vm.push_transaction(tx.tx.clone()); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed()); assert!(vm @@ -92,7 +92,7 @@ fn test_get_used_contracts() { vm.vm.push_transaction(tx2.clone()); - let res2 = vm.vm.execute(VmExecutionMode::OneTx); + let res2 = vm.vm.execute(InspectExecutionMode::OneTx); assert!(res2.result.is_failed()); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/is_write_initial.rs b/core/lib/multivm/src/versions/vm_latest/tests/is_write_initial.rs index 8206cfa9be6f..51485a146229 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/is_write_initial.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/is_write_initial.rs @@ -2,7 +2,7 @@ use zksync_types::get_nonce_key; use crate::{ interface::{ - storage::ReadStorage, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt, + storage::ReadStorage, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, }, vm_latest::{ tests::{ @@ -38,7 +38,7 @@ fn test_is_write_initial_behaviour() { let tx = account.get_deploy_tx(&contract_code, None, TxType::L2).tx; vm.vm.push_transaction(tx); - vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); // Check that `is_write_initial` still returns true for the nonce key. assert!(vm diff --git a/core/lib/multivm/src/versions/vm_latest/tests/l1_tx_execution.rs b/core/lib/multivm/src/versions/vm_latest/tests/l1_tx_execution.rs index e0e4e8228f9f..cd5064c63a8c 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/l1_tx_execution.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/l1_tx_execution.rs @@ -10,7 +10,7 @@ use zksync_types::{ use zksync_utils::u256_to_h256; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, utils::StorageWritesDeduplicator, vm_latest::{ tests::{ @@ -68,7 +68,7 @@ fn test_l1_tx_execution() { vm.vm.push_transaction(deploy_tx.tx.clone()); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); // The code hash of the deployed contract should be marked as republished. let known_codes_key = get_known_code_key(&deploy_tx.bytecode_hash); @@ -94,7 +94,7 @@ fn test_l1_tx_execution() { TxType::L1 { serial_id: 0 }, ); vm.vm.push_transaction(tx); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); let storage_logs = res.logs.storage_logs; let res = StorageWritesDeduplicator::apply_on_empty_state(&storage_logs); @@ -109,7 +109,7 @@ fn test_l1_tx_execution() { TxType::L1 { serial_id: 0 }, ); vm.vm.push_transaction(tx.clone()); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); let storage_logs = res.logs.storage_logs; let res = StorageWritesDeduplicator::apply_on_empty_state(&storage_logs); // We changed one slot inside contract. @@ -120,7 +120,7 @@ fn test_l1_tx_execution() { assert_eq!(res.repeated_storage_writes, 0); vm.vm.push_transaction(tx); - let storage_logs = vm.vm.execute(VmExecutionMode::OneTx).logs.storage_logs; + let storage_logs = vm.vm.execute(InspectExecutionMode::OneTx).logs.storage_logs; let res = StorageWritesDeduplicator::apply_on_empty_state(&storage_logs); // We do the same storage write, it will be deduplicated, so still 4 initial write and 0 repeated. // But now the base pubdata spent has changed too. @@ -135,7 +135,7 @@ fn test_l1_tx_execution() { TxType::L1 { serial_id: 1 }, ); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); // Method is not payable tx should fail assert!(result.result.is_failed(), "The transaction should fail"); @@ -189,7 +189,7 @@ fn test_l1_tx_execution_high_gas_limit() { vm.vm.push_transaction(tx); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); assert!(res.result.is_failed(), "The transaction should've failed"); } diff --git a/core/lib/multivm/src/versions/vm_latest/tests/l2_blocks.rs b/core/lib/multivm/src/versions/vm_latest/tests/l2_blocks.rs index 1b5c3db59f72..aa4dc3e426d7 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/l2_blocks.rs @@ -16,8 +16,8 @@ use zksync_utils::{h256_to_u256, u256_to_h256}; use crate::{ interface::{ - storage::WriteStorage, ExecutionResult, Halt, L2BlockEnv, TxExecutionMode, VmExecutionMode, - VmInterface, VmInterfaceExt, + storage::WriteStorage, ExecutionResult, Halt, InspectExecutionMode, L2BlockEnv, + TxExecutionMode, VmInterface, VmInterfaceExt, }, vm_latest::{ constants::{ @@ -67,7 +67,7 @@ fn test_l2_block_initialization_timestamp() { let l1_tx = get_l1_noop(); vm.vm.push_transaction(l1_tx); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); assert_eq!( res.result, @@ -102,7 +102,7 @@ fn test_l2_block_initialization_number_non_zero() { let timestamp = Timestamp(vm.vm.state.local_state.timestamp); set_manual_l2_block_info(&mut vm.vm, 0, first_l2_block, timestamp); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); assert_eq!( res.result, @@ -130,7 +130,7 @@ fn test_same_l2_block( let l1_tx = get_l1_noop(); vm.vm.push_transaction(l1_tx.clone()); - let res = vm.vm.execute(VmExecutionMode::OneTx); + let res = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!res.result.is_failed()); let mut current_l2_block = vm.vm.batch_env.first_l2_block; @@ -150,7 +150,7 @@ fn test_same_l2_block( let timestamp = Timestamp(vm.vm.state.local_state.timestamp); set_manual_l2_block_info(&mut vm.vm, 1, current_l2_block, timestamp); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); if let Some(err) = expected_error { assert_eq!(result.result, ExecutionResult::Halt { reason: err }); @@ -207,7 +207,7 @@ fn test_new_l2_block( // Firstly we execute the first transaction vm.vm.push_transaction(l1_tx.clone()); - vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); let mut second_l2_block = vm.vm.batch_env.first_l2_block; second_l2_block.number += 1; @@ -228,7 +228,7 @@ fn test_new_l2_block( vm.vm.push_transaction(l1_tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); if let Some(err) = expected_error { assert_eq!(result.result, ExecutionResult::Halt { reason: err }); } else { @@ -356,7 +356,7 @@ fn test_first_in_batch( let timestamp = Timestamp(vm.vm.state.local_state.timestamp); set_manual_l2_block_info(&mut vm.vm, 0, proposed_block, timestamp); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); if let Some(err) = expected_error { assert_eq!(result.result, ExecutionResult::Halt { reason: err }); } else { diff --git a/core/lib/multivm/src/versions/vm_latest/tests/nonce_holder.rs b/core/lib/multivm/src/versions/vm_latest/tests/nonce_holder.rs index 397790a7c957..147d0f4649ae 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/nonce_holder.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/nonce_holder.rs @@ -2,8 +2,8 @@ use zksync_types::{Execute, Nonce}; use crate::{ interface::{ - ExecutionResult, Halt, TxExecutionMode, TxRevertReason, VmExecutionMode, VmInterfaceExt, - VmRevertReason, + ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, TxRevertReason, + VmInterfaceExt, VmRevertReason, }, vm_latest::{ tests::{ @@ -75,7 +75,7 @@ fn test_nonce_holder() { let mut transaction_data = TransactionData::new(tx, false); transaction_data.signature = vec![test_mode.into()]; vm.vm.push_raw_transaction(transaction_data, 0, 0, true); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); if let Some(msg) = error_message { let expected_error = diff --git a/core/lib/multivm/src/versions/vm_latest/tests/precompiles.rs b/core/lib/multivm/src/versions/vm_latest/tests/precompiles.rs index 110b14146c7a..ab512950eed9 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/precompiles.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/precompiles.rs @@ -2,7 +2,7 @@ use zk_evm_1_5_0::zk_evm_abstractions::precompiles::PrecompileAddress; use zksync_types::{Address, Execute}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface}, vm_latest::{ constants::BATCH_COMPUTATIONAL_GAS_LIMIT, tests::{tester::VmTesterBuilder, utils::read_precompiles_contract}, @@ -41,7 +41,7 @@ fn test_keccak() { vm.vm.push_transaction(tx); let _ = vm .vm - .inspect(&mut Default::default(), VmExecutionMode::OneTx); + .inspect(&mut Default::default(), InspectExecutionMode::OneTx); let keccak_count = vm .vm @@ -87,7 +87,7 @@ fn test_sha256() { vm.vm.push_transaction(tx); let _ = vm .vm - .inspect(&mut Default::default(), VmExecutionMode::OneTx); + .inspect(&mut Default::default(), InspectExecutionMode::OneTx); let sha_count = vm .vm @@ -126,7 +126,7 @@ fn test_ecrecover() { vm.vm.push_transaction(tx); let _ = vm .vm - .inspect(&mut Default::default(), VmExecutionMode::OneTx); + .inspect(&mut Default::default(), InspectExecutionMode::OneTx); let ecrecover_count = vm .vm diff --git a/core/lib/multivm/src/versions/vm_latest/tests/prestate_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tests/prestate_tracer.rs index 230b1d0ad876..cea0c4c7e35d 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/prestate_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/prestate_tracer.rs @@ -5,7 +5,7 @@ use zksync_test_account::TxType; use zksync_types::{utils::deployed_address_create, Execute, U256}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, tracers::PrestateTracer, vm_latest::{ constants::BATCH_COMPUTATIONAL_GAS_LIMIT, @@ -41,7 +41,7 @@ fn test_prestate_tracer() { let prestate_tracer = PrestateTracer::new(false, prestate_tracer_result.clone()); let tracer_ptr = prestate_tracer.into_tracer_pointer(); vm.vm - .inspect(&mut tracer_ptr.into(), VmExecutionMode::Batch); + .inspect(&mut tracer_ptr.into(), InspectExecutionMode::Batch); let prestate_result = Arc::try_unwrap(prestate_tracer_result) .unwrap() @@ -69,7 +69,7 @@ fn test_prestate_tracer_diff_mode() { .tx; let nonce = tx.nonce().unwrap().0.into(); vm.vm.push_transaction(tx); - vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); let deployed_address = deployed_address_create(vm.deployer.as_ref().unwrap().address, nonce); vm.test_contract = Some(deployed_address); @@ -82,7 +82,7 @@ fn test_prestate_tracer_diff_mode() { .tx; let nonce2 = tx2.nonce().unwrap().0.into(); vm.vm.push_transaction(tx2); - vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); let deployed_address2 = deployed_address_create(vm.deployer.as_ref().unwrap().address, nonce2); let account = &mut vm.rich_accounts[0]; @@ -111,7 +111,7 @@ fn test_prestate_tracer_diff_mode() { let prestate_tracer = PrestateTracer::new(true, prestate_tracer_result.clone()); let tracer_ptr = prestate_tracer.into_tracer_pointer(); vm.vm - .inspect(&mut tracer_ptr.into(), VmExecutionMode::Bootloader); + .inspect(&mut tracer_ptr.into(), InspectExecutionMode::Bootloader); let prestate_result = Arc::try_unwrap(prestate_tracer_result) .unwrap() diff --git a/core/lib/multivm/src/versions/vm_latest/tests/refunds.rs b/core/lib/multivm/src/versions/vm_latest/tests/refunds.rs index c00192aa8f10..7785a3c46cf4 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/refunds.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/refunds.rs @@ -2,7 +2,7 @@ use ethabi::Token; use zksync_types::{Address, Execute, U256}; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, vm_latest::{ tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, @@ -34,7 +34,7 @@ fn test_predetermined_refunded_gas() { address: _, } = account.get_deploy_tx(&counter, None, TxType::L2); vm.vm.push_transaction(tx.clone()); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed()); @@ -47,7 +47,7 @@ fn test_predetermined_refunded_gas() { ); assert!(result.refunds.gas_refunded > 0, "The final refund is 0"); - let result_without_predefined_refunds = vm.vm.execute(VmExecutionMode::Batch); + let result_without_predefined_refunds = vm.vm.execute(InspectExecutionMode::Batch); let mut current_state_without_predefined_refunds = vm.vm.get_current_execution_state(); assert!(!result_without_predefined_refunds.result.is_failed(),); @@ -68,7 +68,7 @@ fn test_predetermined_refunded_gas() { vm.vm .push_raw_transaction(tx.clone(), overhead, result.refunds.gas_refunded, true); - let result_with_predefined_refunds = vm.vm.execute(VmExecutionMode::Batch); + let result_with_predefined_refunds = vm.vm.execute(InspectExecutionMode::Batch); let mut current_state_with_predefined_refunds = vm.vm.get_current_execution_state(); assert!(!result_with_predefined_refunds.result.is_failed()); @@ -118,7 +118,7 @@ fn test_predetermined_refunded_gas() { let changed_operator_suggested_refund = result.refunds.gas_refunded + 1000; vm.vm .push_raw_transaction(tx, overhead, changed_operator_suggested_refund, true); - let result = vm.vm.execute(VmExecutionMode::Batch); + let result = vm.vm.execute(InspectExecutionMode::Batch); let mut current_state_with_changed_predefined_refunds = vm.vm.get_current_execution_state(); assert!(!result.result.is_failed()); @@ -198,7 +198,7 @@ fn negative_pubdata_for_transaction() { None, ); vm.vm.push_transaction(expensive_tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction wasn't successful: {result:#?}" @@ -215,7 +215,7 @@ fn negative_pubdata_for_transaction() { None, ); vm.vm.push_transaction(clean_up_tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "Transaction wasn't successful: {result:#?}" diff --git a/core/lib/multivm/src/versions/vm_latest/tests/require_eip712.rs b/core/lib/multivm/src/versions/vm_latest/tests/require_eip712.rs index 1f38c6f947e3..bc902bbd491e 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/require_eip712.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/require_eip712.rs @@ -8,7 +8,7 @@ use zksync_types::{ }; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, vm_latest::{ tests::{ tester::{Account, VmTester, VmTesterBuilder}, @@ -72,7 +72,7 @@ fn test_require_eip712() { ); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed()); let private_account_balance = vm.get_eth_balance(private_account.address); @@ -105,7 +105,7 @@ fn test_require_eip712() { let transaction: Transaction = l2_tx.into(); vm.vm.push_transaction(transaction); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed()); assert_eq!( @@ -153,7 +153,7 @@ fn test_require_eip712() { let transaction: Transaction = l2_tx.into(); vm.vm.push_transaction(transaction); - vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); assert_eq!( vm.get_eth_balance(beneficiary.address), diff --git a/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs b/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs index 2e854cfc784d..ccc6c27a054b 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs @@ -7,7 +7,7 @@ use crate::{ interface::{ storage::WriteStorage, tracer::{TracerExecutionStatus, TracerExecutionStopReason}, - ExecutionResult, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt, + ExecutionResult, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, }, tracers::dynamic::vm_1_5_0::DynTracer, @@ -232,7 +232,7 @@ fn test_layered_rollback() { TxType::L2, ); vm.vm.push_transaction(deploy_tx); - let deployment_res = vm.vm.execute(VmExecutionMode::OneTx); + let deployment_res = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!deployment_res.result.is_failed(), "transaction failed"); let loadnext_transaction = account.get_loadnext_transaction( @@ -259,7 +259,8 @@ fn test_layered_rollback() { max_recursion_depth: 15, } .into_tracer_pointer(); - vm.vm.inspect(&mut tracer.into(), VmExecutionMode::OneTx); + vm.vm + .inspect(&mut tracer.into(), InspectExecutionMode::OneTx); let nonce_val2 = vm .vm @@ -286,7 +287,7 @@ fn test_layered_rollback() { ); vm.vm.push_transaction(loadnext_transaction); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "transaction must not fail"); } diff --git a/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs b/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs index 93be9506a3b0..dcb868dec0a2 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs @@ -4,7 +4,9 @@ use zksync_types::{web3::keccak256, Execute, H256, U256}; use zksync_utils::h256_to_u256; use crate::{ - interface::{ExecutionResult, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{ + ExecutionResult, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, + }, vm_latest::{tests::tester::VmTesterBuilder, HistoryEnabled}, }; @@ -58,7 +60,7 @@ fn test_sekp256r1() { vm.vm.push_transaction(tx); - let execution_result = vm.vm.execute(VmExecutionMode::Batch); + let execution_result = vm.vm.execute(InspectExecutionMode::Batch); let ExecutionResult::Success { output } = execution_result.result else { panic!("batch failed") diff --git a/core/lib/multivm/src/versions/vm_latest/tests/simple_execution.rs b/core/lib/multivm/src/versions/vm_latest/tests/simple_execution.rs index cd020ee9f966..c5d47cc7694c 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/simple_execution.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/simple_execution.rs @@ -1,7 +1,7 @@ use assert_matches::assert_matches; use crate::{ - interface::{ExecutionResult, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{ExecutionResult, InspectExecutionMode, VmInterface, VmInterfaceExt}, vm_latest::{ tests::tester::{TxType, VmTesterBuilder}, HistoryDisabled, @@ -29,7 +29,7 @@ fn estimate_fee() { vm_tester.vm.push_transaction(tx); - let result = vm_tester.vm.execute(VmExecutionMode::OneTx); + let result = vm_tester.vm.execute(InspectExecutionMode::OneTx); assert_matches!(result.result, ExecutionResult::Success { .. }); } @@ -72,12 +72,12 @@ fn simple_execute() { vm.push_transaction(tx1); vm.push_transaction(tx2); vm.push_transaction(tx3); - let tx = vm.execute(VmExecutionMode::OneTx); + let tx = vm.execute(InspectExecutionMode::OneTx); assert_matches!(tx.result, ExecutionResult::Success { .. }); - let tx = vm.execute(VmExecutionMode::OneTx); + let tx = vm.execute(InspectExecutionMode::OneTx); assert_matches!(tx.result, ExecutionResult::Revert { .. }); - let tx = vm.execute(VmExecutionMode::OneTx); + let tx = vm.execute(InspectExecutionMode::OneTx); assert_matches!(tx.result, ExecutionResult::Success { .. }); - let block_tip = vm.execute(VmExecutionMode::Batch); + let block_tip = vm.execute(InspectExecutionMode::Batch); assert_matches!(block_tip.result, ExecutionResult::Success { .. }); } diff --git a/core/lib/multivm/src/versions/vm_latest/tests/storage.rs b/core/lib/multivm/src/versions/vm_latest/tests/storage.rs index 126d174a6468..10dd095e76c9 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/storage.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/storage.rs @@ -5,7 +5,8 @@ use zksync_types::{fee::Fee, Address, Execute, U256}; use crate::{ interface::{ - TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, + InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, + VmInterfaceHistoryEnabled, }, vm_latest::{tests::tester::VmTesterBuilder, HistoryEnabled}, }; @@ -59,7 +60,7 @@ fn test_storage(txs: Vec) -> u32 { ); vm.vm.push_transaction(tx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); if should_fail { assert!(result.result.is_failed(), "Transaction should fail"); vm.vm.rollback_to_the_latest_snapshot(); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/tester/transaction_test_info.rs b/core/lib/multivm/src/versions/vm_latest/tests/tester/transaction_test_info.rs index e2155c02b7e1..b0928a11d22a 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/tester/transaction_test_info.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/tester/transaction_test_info.rs @@ -2,7 +2,7 @@ use zksync_types::{ExecuteTransactionCommon, Nonce, Transaction, H160}; use crate::{ interface::{ - CurrentExecutionState, ExecutionResult, Halt, TxRevertReason, VmExecutionMode, + CurrentExecutionState, ExecutionResult, Halt, InspectExecutionMode, TxRevertReason, VmExecutionResultAndLogs, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, VmRevertReason, }, @@ -184,7 +184,7 @@ impl VmTester { for tx_test_info in txs { self.execute_tx_and_verify(tx_test_info.clone()); } - self.vm.execute(VmExecutionMode::Batch); + self.vm.execute(InspectExecutionMode::Batch); let mut state = self.vm.get_current_execution_state(); state.used_contract_hashes.sort(); state @@ -197,7 +197,7 @@ impl VmTester { let inner_state_before = self.vm.dump_inner_state(); self.vm.make_snapshot(); self.vm.push_transaction(tx_test_info.tx.clone()); - let result = self.vm.execute(VmExecutionMode::OneTx); + let result = self.vm.execute(InspectExecutionMode::OneTx); tx_test_info.verify_result(&result); if tx_test_info.should_rollback() { self.vm.rollback_to_the_latest_snapshot(); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs index 8c776fdbfd33..7884c4afcc79 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs @@ -15,8 +15,8 @@ use zksync_vm_interface::pubdata::{rollup::RollupPubdataBuilder, PubdataBuilder} use crate::{ interface::{ storage::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}, - L1BatchEnv, L2Block, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory, - VmInterface, VmInterfaceExt, + InspectExecutionMode, L1BatchEnv, L2Block, L2BlockEnv, SystemEnv, TxExecutionMode, + VmFactory, VmInterface, VmInterfaceExt, }, vm_latest::{ constants::BATCH_COMPUTATIONAL_GAS_LIMIT, @@ -54,7 +54,7 @@ impl VmTester { .tx; let nonce = tx.nonce().unwrap().0.into(); self.vm.push_transaction(tx); - self.vm.execute(VmExecutionMode::OneTx); + self.vm.execute(InspectExecutionMode::OneTx); let deployed_address = deployed_address_create(self.deployer.as_ref().unwrap().address, nonce); self.test_contract = Some(deployed_address); @@ -97,12 +97,7 @@ impl VmTester { }; } - let vm = Vm::new( - l1_batch, - self.vm.system_env.clone(), - self.storage.clone(), - Some(self.vm.bootloader_state.pubdata_builder()), - ); + let vm = Vm::new(l1_batch, self.vm.system_env.clone(), self.storage.clone()); if self.test_contract.is_some() { self.deploy_test_contract(); @@ -121,7 +116,6 @@ pub(crate) struct VmTesterBuilder { deployer: Option, rich_accounts: Vec, custom_contracts: Vec, - pubdata_builder: Option>, _phantom: PhantomData, } @@ -134,7 +128,6 @@ impl Clone for VmTesterBuilder { deployer: self.deployer.clone(), rich_accounts: self.rich_accounts.clone(), custom_contracts: self.custom_contracts.clone(), - pubdata_builder: self.pubdata_builder.clone(), _phantom: PhantomData, } } @@ -158,7 +151,6 @@ impl VmTesterBuilder { deployer: None, rich_accounts: vec![], custom_contracts: vec![], - pubdata_builder: None, _phantom: PhantomData, } } @@ -225,14 +217,6 @@ impl VmTesterBuilder { self } - pub(crate) fn with_custom_pubdata_builder( - mut self, - pubdata_builder: Rc, - ) -> Self { - self.pubdata_builder = Some(pubdata_builder); - self - } - pub(crate) fn build(self) -> VmTester { let l1_batch_env = self .l1_batch_env @@ -249,15 +233,7 @@ impl VmTesterBuilder { } let fee_account = l1_batch_env.fee_account; - let pubdata_builder = self - .pubdata_builder - .unwrap_or_else(|| Rc::new(RollupPubdataBuilder::new(Address::zero()))); - let vm = Vm::new( - l1_batch_env, - self.system_env, - storage_ptr.clone(), - Some(pubdata_builder), - ); + let vm = Vm::new(l1_batch_env, self.system_env, storage_ptr.clone()); VmTester { vm, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/transfer.rs b/core/lib/multivm/src/versions/vm_latest/tests/transfer.rs index 2c380623636a..4b22f45be8f8 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/transfer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/transfer.rs @@ -5,7 +5,7 @@ use zksync_types::{utils::storage_key_for_eth_balance, AccountTreeId, Address, E use zksync_utils::u256_to_h256; use crate::{ - interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt}, + interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, vm_latest::{ tests::{ tester::{get_empty_storage, VmTesterBuilder}, @@ -82,13 +82,13 @@ fn test_send_or_transfer(test_option: TestOptions) { ); vm.vm.push_transaction(tx); - let tx_result = vm.vm.execute(VmExecutionMode::OneTx); + let tx_result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !tx_result.result.is_failed(), "Transaction wasn't successful" ); - let batch_result = vm.vm.execute(VmExecutionMode::Batch); + let batch_result = vm.vm.execute(InspectExecutionMode::Batch); assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); let new_recipient_balance = get_balance( @@ -182,7 +182,7 @@ fn test_reentrancy_protection_send_or_transfer(test_option: TestOptions) { ); vm.vm.push_transaction(tx1); - let tx1_result = vm.vm.execute(VmExecutionMode::OneTx); + let tx1_result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !tx1_result.result.is_failed(), "Transaction 1 wasn't successful" @@ -199,13 +199,13 @@ fn test_reentrancy_protection_send_or_transfer(test_option: TestOptions) { ); vm.vm.push_transaction(tx2); - let tx2_result = vm.vm.execute(VmExecutionMode::OneTx); + let tx2_result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( tx2_result.result.is_failed(), "Transaction 2 should have failed, but it succeeded" ); - let batch_result = vm.vm.execute(VmExecutionMode::Batch); + let batch_result = vm.vm.execute(InspectExecutionMode::Batch); assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); } diff --git a/core/lib/multivm/src/versions/vm_latest/tests/upgrade.rs b/core/lib/multivm/src/versions/vm_latest/tests/upgrade.rs index d85a504de40f..bbe8d9b514d0 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/upgrade.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/upgrade.rs @@ -14,7 +14,7 @@ use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u25 use super::utils::{get_complex_upgrade_abi, read_test_contract}; use crate::{ interface::{ - storage::WriteStorage, ExecutionResult, Halt, TxExecutionMode, VmExecutionMode, + storage::WriteStorage, ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, }, vm_latest::{ @@ -84,9 +84,9 @@ fn test_protocol_upgrade_is_first() { vm.vm.push_transaction(normal_l1_transaction.clone()); vm.vm.push_transaction(another_protocol_upgrade_transaction); - vm.vm.execute(VmExecutionMode::OneTx); - vm.vm.execute(VmExecutionMode::OneTx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert_eq!( result.result, ExecutionResult::Halt { @@ -100,8 +100,8 @@ fn test_protocol_upgrade_is_first() { vm.vm.push_transaction(normal_l1_transaction.clone()); vm.vm.push_transaction(protocol_upgrade_transaction.clone()); - vm.vm.execute(VmExecutionMode::OneTx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert_eq!( result.result, ExecutionResult::Halt { @@ -114,8 +114,8 @@ fn test_protocol_upgrade_is_first() { vm.vm.push_transaction(protocol_upgrade_transaction); vm.vm.push_transaction(normal_l1_transaction); - vm.vm.execute(VmExecutionMode::OneTx); - let result = vm.vm.execute(VmExecutionMode::OneTx); + vm.vm.execute(InspectExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed()); } @@ -155,7 +155,7 @@ fn test_force_deploy_upgrade() { vm.vm.push_transaction(transaction); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "The force upgrade was not successful" @@ -223,7 +223,7 @@ fn test_complex_upgrader() { ); vm.vm.push_transaction(transaction); - let result = vm.vm.execute(VmExecutionMode::OneTx); + let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!( !result.result.is_failed(), "The force upgrade was not successful" diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs index 6d8de43bad44..0ebaf57e4c43 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs @@ -1,4 +1,5 @@ use std::marker::PhantomData; +use std::rc::Rc; use circuit_sequencer_api_1_5_0::sort_storage_access::sort_storage_access_queries; use zk_evm_1_5_0::{ @@ -7,6 +8,7 @@ use zk_evm_1_5_0::{ }; use zksync_types::{writes::StateDiffRecord, AccountTreeId, StorageKey, L1_MESSENGER_ADDRESS}; use zksync_utils::{h256_to_u256, u256_to_bytes_be, u256_to_h256}; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ interface::{ @@ -42,6 +44,7 @@ pub(crate) struct PubdataTracer { // to the L1Messenger. enforced_state_diffs: Option>, subversion: MultiVMSubversion, + pubdata_builder: Option>, _phantom_data: PhantomData, } @@ -50,6 +53,7 @@ impl PubdataTracer { l1_batch_env: L1BatchEnv, execution_mode: VmExecutionMode, subversion: MultiVMSubversion, + pubdata_builder: Option>, ) -> Self { Self { l1_batch_env, @@ -57,6 +61,7 @@ impl PubdataTracer { execution_mode, enforced_state_diffs: None, subversion, + pubdata_builder, _phantom_data: Default::default(), } } @@ -69,6 +74,7 @@ impl PubdataTracer { execution_mode: VmExecutionMode, forced_state_diffs: Vec, subversion: MultiVMSubversion, + pubdata_builder: Option>, ) -> Self { Self { l1_batch_env, @@ -76,6 +82,7 @@ impl PubdataTracer { execution_mode, enforced_state_diffs: Some(forced_state_diffs), subversion, + pubdata_builder, _phantom_data: Default::default(), } } @@ -230,7 +237,9 @@ impl VmTracer for PubdataTracer { apply_pubdata_to_memory( &mut memory_to_apply, - bootloader_state.pubdata_builder(), + self.pubdata_builder + .clone() + .expect("`pubdata_builder` is required to finish batch"), pubdata_input, bootloader_state.protocol_version(), ); diff --git a/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs index 397674c914a5..d25f66361f1b 100644 --- a/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs +++ b/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs @@ -1,5 +1,3 @@ -use std::rc::Rc; - use circuit_sequencer_api_1_3_3::INITIAL_MONOTONIC_CYCLE_COUNTER; use zk_evm_1_5_0::{ aux_structures::{MemoryPage, PubdataCost, Timestamp}, @@ -15,7 +13,6 @@ use zk_evm_1_5_0::{ use zksync_system_constants::BOOTLOADER_ADDRESS; use zksync_types::{block::L2BlockHasher, Address, L2BlockNumber}; use zksync_utils::h256_to_u256; -use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ interface::{ @@ -67,7 +64,6 @@ pub(crate) fn new_vm_state( storage: StoragePtr, system_env: &SystemEnv, l1_batch_env: &L1BatchEnv, - pubdata_builder: Rc, ) -> (ZkSyncVmState, BootloaderState) { let last_l2_block = if let Some(last_l2_block) = load_last_l2_block(&storage) { last_l2_block @@ -196,7 +192,6 @@ pub(crate) fn new_vm_state( bootloader_initial_memory, first_l2_block, system_env.version, - pubdata_builder, ); (vm, bootloader_state) diff --git a/core/lib/multivm/src/versions/vm_latest/vm.rs b/core/lib/multivm/src/versions/vm_latest/vm.rs index 6ea52eb45d1d..b63a9adb380a 100644 --- a/core/lib/multivm/src/versions/vm_latest/vm.rs +++ b/core/lib/multivm/src/versions/vm_latest/vm.rs @@ -8,7 +8,9 @@ use zksync_types::{ }; use zksync_utils::{be_words_to_bytes, h256_to_u256, u256_to_h256}; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; +use crate::vm_latest::tracers::PubdataTracer; use crate::{ glue::GlueInto, interface::{ @@ -147,9 +149,9 @@ impl VmInterface for Vm { fn inspect( &mut self, tracer: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { - self.inspect_inner(tracer, execution_mode, None) + self.inspect_inner(tracer, execution_mode.into(), None) } fn start_new_l2_block(&mut self, l2_block_env: L2BlockEnv) { @@ -181,15 +183,32 @@ impl VmInterface for Vm { } } - fn finish_batch(&mut self) -> FinishedL1Batch { - let result = self.inspect(&mut TracerDispatcher::default(), VmExecutionMode::Batch); + fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + let pubdata_builder = pubdata_builder.expect("`pubdata_builder` is required"); + let pubdata_tracer = Some(PubdataTracer::new( + self.batch_env.clone(), + VmExecutionMode::Batch, + self.subversion, + Some(pubdata_builder.clone()), + )); + + let result = self.inspect_inner( + &mut TracerDispatcher::default(), + VmExecutionMode::Batch, + pubdata_tracer, + ); let execution_state = self.get_current_execution_state(); - let bootloader_memory = self.bootloader_state.bootloader_memory(); + let bootloader_memory = self + .bootloader_state + .bootloader_memory(pubdata_builder.clone()); FinishedL1Batch { block_tip_execution_result: result, final_execution_state: execution_state, final_bootloader_memory: Some(bootloader_memory), - pubdata_input: Some(self.bootloader_state.settlement_layer_pubdata()), + pubdata_input: Some( + self.bootloader_state + .settlement_layer_pubdata(pubdata_builder), + ), state_diffs: Some( self.bootloader_state .get_pubdata_information() @@ -201,18 +220,12 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr, - pubdata_builder: Option>, - ) -> Self { + fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let vm_version: VmVersion = system_env.version.into(); Self::new_with_subversion( batch_env, system_env, storage, - pubdata_builder, vm_version.try_into().expect("Incorrect 1.5.0 VmVersion"), ) } @@ -223,12 +236,9 @@ impl Vm { batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr, - pubdata_builder: Option>, subversion: MultiVMSubversion, ) -> Self { - let pubdata_builder = pubdata_builder.expect("pubdata_builder is required"); - let (state, bootloader_state) = - new_vm_state(storage.clone(), &system_env, &batch_env, pubdata_builder); + let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, state, diff --git a/core/lib/multivm/src/versions/vm_m5/vm.rs b/core/lib/multivm/src/versions/vm_m5/vm.rs index 6fb6c22b9db1..384aa5f3cb46 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm.rs @@ -3,13 +3,14 @@ use std::rc::Rc; use zksync_types::{vm::VmVersion, Transaction}; use zksync_utils::h256_to_u256; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; use crate::{ glue::{history_mode::HistoryMode, GlueInto}, interface::{ storage::StoragePtr, BytecodeCompressionResult, FinishedL1Batch, L1BatchEnv, L2BlockEnv, - SystemEnv, TxExecutionMode, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, - VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, + SystemEnv, TxExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, + VmInterfaceHistoryEnabled, VmMemoryMetrics, }, vm_m5::{ storage::Storage, @@ -74,10 +75,10 @@ impl VmInterface for Vm { fn inspect( &mut self, _tracer: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { match execution_mode { - VmExecutionMode::OneTx => match self.system_env.execution_mode { + InspectExecutionMode::OneTx => match self.system_env.execution_mode { TxExecutionMode::VerifyExecute => self.vm.execute_next_tx().glue_into(), TxExecutionMode::EstimateFee | TxExecutionMode::EthCall => self .vm @@ -86,8 +87,7 @@ impl VmInterface for Vm { ) .glue_into(), }, - VmExecutionMode::Batch => self.finish_batch().block_tip_execution_result, - VmExecutionMode::Bootloader => self.vm.execute_block_tip().glue_into(), + InspectExecutionMode::Bootloader => self.vm.execute_block_tip().glue_into(), } } @@ -109,11 +109,14 @@ impl VmInterface for Vm { // Bytecode compression isn't supported ( Ok(vec![].into()), - self.inspect(&mut (), VmExecutionMode::OneTx), + self.inspect(&mut (), InspectExecutionMode::OneTx), ) } - fn finish_batch(&mut self) -> FinishedL1Batch { + fn finish_batch( + &mut self, + _pubdata_builder: Option>, + ) -> FinishedL1Batch { self.vm .execute_till_block_end( crate::vm_m5::vm_with_bootloader::BootloaderJobType::BlockPostprocessing, @@ -123,12 +126,7 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr, - _pubdata_builder: Option>, - ) -> Self { + fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let vm_version: VmVersion = system_env.version.into(); let vm_sub_version = match vm_version { VmVersion::M5WithoutRefunds => MultiVMSubversion::V1, diff --git a/core/lib/multivm/src/versions/vm_m6/vm.rs b/core/lib/multivm/src/versions/vm_m6/vm.rs index 8eda509d0bbd..50fd4fed4a4c 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm.rs @@ -3,14 +3,14 @@ use std::{collections::HashSet, rc::Rc}; use zksync_types::{vm::VmVersion, Transaction}; use zksync_utils::{bytecode::hash_bytecode, h256_to_u256}; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; use crate::{ glue::{history_mode::HistoryMode, GlueInto}, interface::{ storage::StoragePtr, BytecodeCompressionError, BytecodeCompressionResult, FinishedL1Batch, - L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, - VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, - VmMemoryMetrics, + L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionResultAndLogs, VmFactory, + VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics, }, tracers::old::TracerDispatcher, utils::bytecode, @@ -85,7 +85,7 @@ impl VmInterface for Vm { fn inspect( &mut self, tracer: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { if let Some(storage_invocations) = tracer.storage_invocations { self.vm @@ -94,7 +94,7 @@ impl VmInterface for Vm { } match execution_mode { - VmExecutionMode::OneTx => match self.system_env.execution_mode { + InspectExecutionMode::OneTx => match self.system_env.execution_mode { TxExecutionMode::VerifyExecute => { let enable_call_tracer = tracer.call_tracer.is_some(); let result = self.vm.execute_next_tx( @@ -113,8 +113,7 @@ impl VmInterface for Vm { ) .glue_into(), }, - VmExecutionMode::Batch => self.finish_batch().block_tip_execution_result, - VmExecutionMode::Bootloader => self.vm.execute_block_tip().glue_into(), + InspectExecutionMode::Bootloader => self.vm.execute_block_tip().glue_into(), } } @@ -204,7 +203,10 @@ impl VmInterface for Vm { } } - fn finish_batch(&mut self) -> FinishedL1Batch { + fn finish_batch( + &mut self, + _pubdata_builder: Option>, + ) -> FinishedL1Batch { self.vm .execute_till_block_end( crate::vm_m6::vm_with_bootloader::BootloaderJobType::BlockPostprocessing, @@ -214,12 +216,7 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr, - _pubdata_builder: Option>, - ) -> Self { + fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let vm_version: VmVersion = system_env.version.into(); let vm_sub_version = match vm_version { VmVersion::M6Initial => MultiVMSubversion::V1, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs index 8afcd9210263..5fa51008078f 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs @@ -3,6 +3,7 @@ use std::rc::Rc; use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; use zksync_types::{l2_to_l1_log::UserL2ToL1Log, Transaction}; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; use crate::{ glue::GlueInto, @@ -86,9 +87,9 @@ impl VmInterface for Vm { fn inspect( &mut self, dispatcher: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { - self.inspect_inner(dispatcher, execution_mode) + self.inspect_inner(dispatcher, execution_mode.into()) } fn start_new_l2_block(&mut self, l2_block_env: L2BlockEnv) { @@ -103,7 +104,7 @@ impl VmInterface for Vm { with_compression: bool, ) -> (BytecodeCompressionResult<'_>, VmExecutionResultAndLogs) { self.push_transaction_with_compression(tx, with_compression); - let result = self.inspect(dispatcher, VmExecutionMode::OneTx); + let result = self.inspect(dispatcher, InspectExecutionMode::OneTx); if self.has_unpublished_bytecodes() { ( Err(BytecodeCompressionError::BytecodeCompressionFailed), @@ -120,8 +121,11 @@ impl VmInterface for Vm { } } - fn finish_batch(&mut self) -> FinishedL1Batch { - let result = self.inspect(&mut TracerDispatcher::default(), VmExecutionMode::Batch); + fn finish_batch( + &mut self, + _pubdata_builder: Option>, + ) -> FinishedL1Batch { + let result = self.inspect_inner(&mut TracerDispatcher::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); FinishedL1Batch { @@ -135,12 +139,7 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr, - _pubdata_builder: Option>, - ) -> Self { + fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs index 058274124de2..a21e838421be 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs @@ -3,6 +3,7 @@ use std::rc::Rc; use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; use zksync_types::{l2_to_l1_log::UserL2ToL1Log, Transaction}; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; use crate::{ glue::GlueInto, @@ -86,9 +87,9 @@ impl VmInterface for Vm { fn inspect( &mut self, tracer: &mut TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { - self.inspect_inner(tracer, execution_mode) + self.inspect_inner(tracer, execution_mode.into()) } fn start_new_l2_block(&mut self, l2_block_env: L2BlockEnv) { @@ -120,8 +121,11 @@ impl VmInterface for Vm { } } - fn finish_batch(&mut self) -> FinishedL1Batch { - let result = self.inspect(&mut TracerDispatcher::default(), VmExecutionMode::Batch); + fn finish_batch( + &mut self, + _pubdata_builder: Option>, + ) -> FinishedL1Batch { + let result = self.inspect_inner(&mut TracerDispatcher::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); FinishedL1Batch { @@ -135,12 +139,7 @@ impl VmInterface for Vm { } impl VmFactory for Vm { - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr, - _pubdata_builder: Option>, - ) -> Self { + fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { bootloader_state, diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs index d358fde6d02a..215283f05724 100644 --- a/core/lib/multivm/src/vm_instance.rs +++ b/core/lib/multivm/src/vm_instance.rs @@ -3,6 +3,7 @@ use std::{mem, rc::Rc}; use zksync_types::{vm::VmVersion, ProtocolVersionId, Transaction}; use zksync_vm2::interface::Tracer; use zksync_vm_interface::pubdata::PubdataBuilder; +use zksync_vm_interface::InspectExecutionMode; use crate::{ glue::history_mode::HistoryMode, @@ -10,8 +11,8 @@ use crate::{ storage::{ImmutableStorageView, ReadStorage, StoragePtr, StorageView}, utils::ShadowVm, BytecodeCompressionResult, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, - VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, - VmInterfaceHistoryEnabled, VmMemoryMetrics, + VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, + VmMemoryMetrics, }, tracers::TracerDispatcher, vm_latest::HistoryEnabled, @@ -65,7 +66,7 @@ impl VmInterface for LegacyVmInstance { fn inspect( &mut self, dispatcher: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { dispatch_legacy_vm!(self.inspect(&mut mem::take(dispatcher).into(), execution_mode)) } @@ -89,8 +90,8 @@ impl VmInterface for LegacyVmInstance { } /// Return the results of execution of all batch - fn finish_batch(&mut self) -> FinishedL1Batch { - dispatch_legacy_vm!(self.finish_batch()) + fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + dispatch_legacy_vm!(self.finish_batch(pubdata_builder)) } } @@ -99,17 +100,10 @@ impl VmFactory> for LegacyVmInsta batch_env: L1BatchEnv, system_env: SystemEnv, storage_view: StoragePtr>, - pubdata_builder: Option>, ) -> Self { let protocol_version = system_env.version; let vm_version: VmVersion = protocol_version.into(); - Self::new_with_specific_version( - batch_env, - system_env, - storage_view, - vm_version, - pubdata_builder, - ) + Self::new_with_specific_version(batch_env, system_env, storage_view, vm_version) } } @@ -133,7 +127,6 @@ impl LegacyVmInstance { system_env: SystemEnv, storage_view: StoragePtr>, vm_version: VmVersion, - pubdata_builder: Option>, ) -> Self { match vm_version { VmVersion::M5WithoutRefunds => { @@ -173,57 +166,29 @@ impl LegacyVmInstance { Self::VmM6(vm) } VmVersion::Vm1_3_2 => { - let vm = crate::vm_1_3_2::Vm::new( - l1_batch_env, - system_env, - storage_view, - pubdata_builder, - ); + let vm = crate::vm_1_3_2::Vm::new(l1_batch_env, system_env, storage_view); Self::Vm1_3_2(vm) } VmVersion::VmVirtualBlocks => { - let vm = crate::vm_virtual_blocks::Vm::new( - l1_batch_env, - system_env, - storage_view, - pubdata_builder, - ); + let vm = crate::vm_virtual_blocks::Vm::new(l1_batch_env, system_env, storage_view); Self::VmVirtualBlocks(vm) } VmVersion::VmVirtualBlocksRefundsEnhancement => { - let vm = crate::vm_refunds_enhancement::Vm::new( - l1_batch_env, - system_env, - storage_view, - pubdata_builder, - ); + let vm = + crate::vm_refunds_enhancement::Vm::new(l1_batch_env, system_env, storage_view); Self::VmVirtualBlocksRefundsEnhancement(vm) } VmVersion::VmBoojumIntegration => { - let vm = crate::vm_boojum_integration::Vm::new( - l1_batch_env, - system_env, - storage_view, - pubdata_builder, - ); + let vm = + crate::vm_boojum_integration::Vm::new(l1_batch_env, system_env, storage_view); Self::VmBoojumIntegration(vm) } VmVersion::Vm1_4_1 => { - let vm = crate::vm_1_4_1::Vm::new( - l1_batch_env, - system_env, - storage_view, - pubdata_builder, - ); + let vm = crate::vm_1_4_1::Vm::new(l1_batch_env, system_env, storage_view); Self::Vm1_4_1(vm) } VmVersion::Vm1_4_2 => { - let vm = crate::vm_1_4_2::Vm::new( - l1_batch_env, - system_env, - storage_view, - pubdata_builder, - ); + let vm = crate::vm_1_4_2::Vm::new(l1_batch_env, system_env, storage_view); Self::Vm1_4_2(vm) } VmVersion::Vm1_5_0SmallBootloaderMemory => { @@ -231,7 +196,6 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, - pubdata_builder, crate::vm_latest::MultiVMSubversion::SmallBootloaderMemory, ); Self::Vm1_5_0(vm) @@ -241,7 +205,6 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, - pubdata_builder, crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory, ); Self::Vm1_5_0(vm) @@ -251,7 +214,6 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, - pubdata_builder, crate::vm_latest::MultiVMSubversion::Gateway, ); Self::Vm1_5_0(vm) @@ -303,7 +265,7 @@ impl VmInterface for FastVmInsta fn inspect( &mut self, tracer: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { match self { Self::Fast(vm) => vm.inspect(&mut tracer.1, execution_mode), @@ -333,8 +295,8 @@ impl VmInterface for FastVmInsta } } - fn finish_batch(&mut self) -> FinishedL1Batch { - dispatch_fast_vm!(self.finish_batch()) + fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + dispatch_fast_vm!(self.finish_batch(pubdata_builder)) } } @@ -360,13 +322,11 @@ impl FastVmInstance { l1_batch_env: L1BatchEnv, system_env: SystemEnv, storage_view: StoragePtr>, - pubdata_builder: Option>, ) -> Self { Self::Fast(crate::vm_fast::Vm::new( l1_batch_env, system_env, storage_view, - pubdata_builder, )) } @@ -375,14 +335,8 @@ impl FastVmInstance { l1_batch_env: L1BatchEnv, system_env: SystemEnv, storage_view: StoragePtr>, - pubdata_builder: Option>, ) -> Self { - Self::Shadowed(ShadowedFastVm::new( - l1_batch_env, - system_env, - storage_view, - pubdata_builder, - )) + Self::Shadowed(ShadowedFastVm::new(l1_batch_env, system_env, storage_view)) } } diff --git a/core/lib/tee_verifier/src/lib.rs b/core/lib/tee_verifier/src/lib.rs index a893dcea9407..9f618556cf2d 100644 --- a/core/lib/tee_verifier/src/lib.rs +++ b/core/lib/tee_verifier/src/lib.rs @@ -22,6 +22,7 @@ use zksync_multivm::{ use zksync_prover_interface::inputs::{ StorageLogMetadata, V1TeeVerifierInput, WitnessInputMerklePaths, }; +use zksync_types::commitment::PubdataParams; use zksync_types::{ block::L2BlockExecutionData, L1BatchNumber, StorageLog, StorageValue, Transaction, H256, }; @@ -88,13 +89,8 @@ impl Verify for V1TeeVerifierInput { let storage_snapshot = StorageSnapshot::new(storage, factory_deps); let storage_view = StorageView::new(storage_snapshot).to_rc_ptr(); - let vm = LegacyVmInstance::new( - self.l1_batch_env, - self.system_env, - storage_view, - Some(pubdata_params_to_builder(self.pubdata_params)), - ); - let vm_out = execute_vm(self.l2_blocks_execution_data, vm)?; + let vm = LegacyVmInstance::new(self.l1_batch_env, self.system_env, storage_view); + let vm_out = execute_vm(self.l2_blocks_execution_data, vm, self.pubdata_params)?; let block_output_with_proofs = get_bowp(self.merkle_paths)?; @@ -184,6 +180,7 @@ fn get_bowp(witness_input_merkle_paths: WitnessInputMerklePaths) -> Result( l2_blocks_execution_data: Vec, mut vm: LegacyVmInstance, + pubdata_params: PubdataParams, ) -> anyhow::Result { let next_l2_blocks_data = l2_blocks_execution_data.iter().skip(1); @@ -212,7 +209,7 @@ fn execute_vm( tracing::trace!("about to vm.finish_batch()"); - Ok(vm.finish_batch()) + Ok(vm.finish_batch(Some(pubdata_params_to_builder(pubdata_params)))) } /// Map `LogQuery` and `TreeLogEntry` to a `TreeInstruction` diff --git a/core/lib/vm_executor/src/batch/factory.rs b/core/lib/vm_executor/src/batch/factory.rs index f7bbfc98310e..80531ec43c48 100644 --- a/core/lib/vm_executor/src/batch/factory.rs +++ b/core/lib/vm_executor/src/batch/factory.rs @@ -166,36 +166,23 @@ impl BatchVm { l1_batch_env: L1BatchEnv, system_env: SystemEnv, storage_ptr: StoragePtr>, - pubdata_builder: Option>, mode: FastVmMode, ) -> Self { if !is_supported_by_fast_vm(system_env.version) { - return Self::Legacy(LegacyVmInstance::new( - l1_batch_env, - system_env, - storage_ptr, - pubdata_builder, - )); + return Self::Legacy(LegacyVmInstance::new(l1_batch_env, system_env, storage_ptr)); } match mode { - FastVmMode::Old => Self::Legacy(LegacyVmInstance::new( - l1_batch_env, - system_env, - storage_ptr, - pubdata_builder, - )), - FastVmMode::New => Self::Fast(FastVmInstance::fast( - l1_batch_env, - system_env, - storage_ptr, - pubdata_builder, - )), + FastVmMode::Old => { + Self::Legacy(LegacyVmInstance::new(l1_batch_env, system_env, storage_ptr)) + } + FastVmMode::New => { + Self::Fast(FastVmInstance::fast(l1_batch_env, system_env, storage_ptr)) + } FastVmMode::Shadow => Self::Fast(FastVmInstance::shadowed( l1_batch_env, system_env, storage_ptr, - pubdata_builder, )), } } @@ -204,8 +191,8 @@ impl BatchVm { dispatch_batch_vm!(self.start_new_l2_block(l2_block)); } - fn finish_batch(&mut self) -> FinishedL1Batch { - dispatch_batch_vm!(self.finish_batch()) + fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + dispatch_batch_vm!(self.finish_batch(pubdata_builder)) } fn make_snapshot(&mut self) { @@ -290,7 +277,6 @@ impl CommandReceiver { l1_batch_params, system_env, storage_view.clone(), - pubdata_builder, self.fast_vm_mode, ); let mut batch_finished = false; @@ -333,7 +319,7 @@ impl CommandReceiver { } } Command::FinishBatch(resp) => { - let vm_block_result = self.finish_batch(&mut vm)?; + let vm_block_result = self.finish_batch(&mut vm, pubdata_builder)?; if resp.send(vm_block_result).is_err() { break; } @@ -388,10 +374,14 @@ impl CommandReceiver { latency.observe(); } - fn finish_batch(&self, vm: &mut BatchVm) -> anyhow::Result { + fn finish_batch( + &self, + vm: &mut BatchVm, + pubdata_builder: Option>, + ) -> anyhow::Result { // The vm execution was paused right after the last transaction was executed. // There is some post-processing work that the VM needs to do before the block is fully processed. - let result = vm.finish_batch(); + let result = vm.finish_batch(pubdata_builder); anyhow::ensure!( !result.block_tip_execution_result.result.is_failed(), "VM must not fail when finalizing block: {:#?}", @@ -496,7 +486,6 @@ mod tests { l1_batch_env.clone(), system_env.clone(), storage.clone(), - Some(Rc::new(RollupPubdataBuilder::new(Default::default()))), mode, ); assert_matches!(vm, BatchVm::Legacy(_)); @@ -507,7 +496,6 @@ mod tests { l1_batch_env.clone(), system_env.clone(), storage.clone(), - Some(Rc::new(RollupPubdataBuilder::new(Default::default()))), FastVmMode::Old, ); assert_matches!(vm, BatchVm::Legacy(_)); @@ -515,17 +503,10 @@ mod tests { l1_batch_env.clone(), system_env.clone(), storage.clone(), - Some(Rc::new(RollupPubdataBuilder::new(Default::default()))), FastVmMode::New, ); assert_matches!(vm, BatchVm::Fast(FastVmInstance::Fast(_))); - let vm = BatchVm::<_, ()>::new( - l1_batch_env, - system_env, - storage, - Some(Rc::new(RollupPubdataBuilder::new(Default::default()))), - FastVmMode::Shadow, - ); + let vm = BatchVm::<_, ()>::new(l1_batch_env, system_env, storage, FastVmMode::Shadow); assert_matches!(vm, BatchVm::Fast(FastVmInstance::Shadowed(_))); } } diff --git a/core/lib/vm_executor/src/oneshot/mod.rs b/core/lib/vm_executor/src/oneshot/mod.rs index 6d4749de7e50..7b1a5eb5165b 100644 --- a/core/lib/vm_executor/src/oneshot/mod.rs +++ b/core/lib/vm_executor/src/oneshot/mod.rs @@ -14,14 +14,14 @@ use std::{ use anyhow::Context; use async_trait::async_trait; use once_cell::sync::OnceCell; +use zksync_multivm::interface::InspectExecutionMode; use zksync_multivm::{ interface::{ executor::{OneshotExecutor, TransactionValidator}, - pubdata::pubdata_params_to_builder, storage::{ReadStorage, StoragePtr, StorageView, WriteStorage}, tracer::{ValidationError, ValidationParams}, ExecutionResult, OneshotEnv, OneshotTracingParams, OneshotTransactionExecutionResult, - StoredL2BlockEnv, TxExecutionArgs, TxExecutionMode, VmExecutionMode, VmInterface, + StoredL2BlockEnv, TxExecutionArgs, TxExecutionMode, VmInterface, }, tracers::{CallTracer, StorageInvocations, ValidationTracer}, utils::adjust_pubdata_price_for_tx, @@ -170,7 +170,7 @@ where ); let exec_result = executor.apply(|vm, transaction| { vm.push_transaction(transaction); - vm.inspect(&mut tracers.into(), VmExecutionMode::OneTx) + vm.inspect(&mut tracers.into(), InspectExecutionMode::OneTx) }); let validation_result = Arc::make_mut(&mut validation_result) .take() @@ -222,7 +222,6 @@ impl VmSandbox { env.system, storage_view.clone(), protocol_version.into_api_vm_version(), - Some(pubdata_params_to_builder(env.pubdata_params)), )); Self { diff --git a/core/lib/vm_executor/src/storage.rs b/core/lib/vm_executor/src/storage.rs index 62c359a1cebd..e5a2d404233b 100644 --- a/core/lib/vm_executor/src/storage.rs +++ b/core/lib/vm_executor/src/storage.rs @@ -54,8 +54,7 @@ pub fn l1_batch_params( protocol_version: ProtocolVersionId, virtual_blocks: u32, chain_id: L2ChainId, - pubdata_params: PubdataParams, -) -> (SystemEnv, L1BatchEnv, PubdataParams) { +) -> (SystemEnv, L1BatchEnv) { ( SystemEnv { zk_porter_available: ZKPORTER_IS_AVAILABLE, @@ -80,7 +79,6 @@ pub fn l1_batch_params( max_virtual_blocks_to_create: virtual_blocks, }, }, - pubdata_params, ) } @@ -320,7 +318,7 @@ impl L1BatchParamsProvider { .await .context("failed getting base system contracts")?; - Ok(l1_batch_params( + let (system_env, l1_batch_env) = l1_batch_params( first_l2_block_in_batch.l1_batch_number, first_l2_block_in_batch.header.fee_account_address, l1_batch_timestamp, @@ -336,6 +334,11 @@ impl L1BatchParamsProvider { .context("`protocol_version` must be set for L2 block")?, first_l2_block_in_batch.header.virtual_blocks, chain_id, + ); + + Ok(( + system_env, + l1_batch_env, first_l2_block_in_batch.header.pubdata_params, )) } diff --git a/core/lib/vm_interface/src/lib.rs b/core/lib/vm_interface/src/lib.rs index 008c9abb75d9..978a2e5430bb 100644 --- a/core/lib/vm_interface/src/lib.rs +++ b/core/lib/vm_interface/src/lib.rs @@ -24,8 +24,8 @@ pub use crate::{ VmRevertReason, VmRevertReasonParsingError, }, inputs::{ - L1BatchEnv, L2BlockEnv, OneshotEnv, OneshotTracingParams, StoredL2BlockEnv, SystemEnv, - TxExecutionArgs, TxExecutionMode, VmExecutionMode, + InspectExecutionMode, L1BatchEnv, L2BlockEnv, OneshotEnv, OneshotTracingParams, + StoredL2BlockEnv, SystemEnv, TxExecutionArgs, TxExecutionMode, VmExecutionMode, }, outputs::{ BatchTransactionExecutionResult, BootloaderMemory, Call, CallType, CircuitStatistic, diff --git a/core/lib/vm_interface/src/pubdata/mod.rs b/core/lib/vm_interface/src/pubdata/mod.rs index 5e05acd93307..94bcc859d521 100644 --- a/core/lib/vm_interface/src/pubdata/mod.rs +++ b/core/lib/vm_interface/src/pubdata/mod.rs @@ -2,7 +2,6 @@ use std::rc::Rc; use zksync_types::{ commitment::{L1BatchCommitmentMode, PubdataParams}, - ethabi, l2_to_l1_log::L2ToL1Log, writes::StateDiffRecord, Address, ProtocolVersionId, U256, @@ -94,20 +93,6 @@ pub trait PubdataBuilder: std::fmt::Debug { input: PubdataInput, protocol_version: ProtocolVersionId, ) -> Vec; - - fn bootloader_memory_input( - &self, - input: PubdataInput, - protocol_version: ProtocolVersionId, - ) -> Vec { - let l2_da_validator_address = self.l2_da_validator(); - let operator_input = self.l1_messenger_operator_input(input, protocol_version); - - ethabi::encode(&[ - ethabi::Token::Address(l2_da_validator_address), - ethabi::Token::Bytes(operator_input), - ]) - } } pub fn pubdata_params_to_builder(params: PubdataParams) -> Rc { diff --git a/core/lib/vm_interface/src/types/inputs/execution_mode.rs b/core/lib/vm_interface/src/types/inputs/execution_mode.rs index 41492af6edc5..9a93d3e06174 100644 --- a/core/lib/vm_interface/src/types/inputs/execution_mode.rs +++ b/core/lib/vm_interface/src/types/inputs/execution_mode.rs @@ -13,3 +13,22 @@ pub enum VmExecutionMode { /// Stop after executing the entire bootloader. But before you exit the bootloader. Bootloader, } + +/// Subset of `VmExecutionMode` variants that do not require any additional input +/// and can be invoked with `inspect` method. +#[derive(Debug, Copy, Clone)] +pub enum InspectExecutionMode { + /// Stop after executing the next transaction. + OneTx, + /// Stop after executing the entire bootloader. But before you exit the bootloader. + Bootloader, +} + +impl From for VmExecutionMode { + fn from(mode: InspectExecutionMode) -> Self { + match mode { + InspectExecutionMode::Bootloader => VmExecutionMode::Bootloader, + InspectExecutionMode::OneTx => VmExecutionMode::OneTx, + } + } +} diff --git a/core/lib/vm_interface/src/types/inputs/mod.rs b/core/lib/vm_interface/src/types/inputs/mod.rs index 78e653a7f26a..c84d77af4fcb 100644 --- a/core/lib/vm_interface/src/types/inputs/mod.rs +++ b/core/lib/vm_interface/src/types/inputs/mod.rs @@ -4,7 +4,7 @@ use zksync_types::{ }; pub use self::{ - execution_mode::VmExecutionMode, + execution_mode::{InspectExecutionMode, VmExecutionMode}, l1_batch_env::L1BatchEnv, l2_block::{L2BlockEnv, StoredL2BlockEnv}, system_env::{SystemEnv, TxExecutionMode}, diff --git a/core/lib/vm_interface/src/utils/dump.rs b/core/lib/vm_interface/src/utils/dump.rs index c235b5c59dd8..7b4319f3b24d 100644 --- a/core/lib/vm_interface/src/utils/dump.rs +++ b/core/lib/vm_interface/src/utils/dump.rs @@ -9,9 +9,9 @@ use zksync_types::{ use crate::{ pubdata::{pubdata_params_to_builder, PubdataBuilder}, storage::{ReadStorage, StoragePtr, StorageSnapshot, StorageView}, - BytecodeCompressionResult, FinishedL1Batch, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, - VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, - VmTrackingContracts, + BytecodeCompressionResult, FinishedL1Batch, InspectExecutionMode, L1BatchEnv, L2BlockEnv, + SystemEnv, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceExt, + VmInterfaceHistoryEnabled, VmTrackingContracts, }; fn create_storage_snapshot( @@ -78,20 +78,10 @@ impl VmDump { #[doc(hidden)] // too low-level pub fn play_back_custom( self, - create_vm: impl FnOnce( - L1BatchEnv, - SystemEnv, - StoragePtr>, - Option>, - ) -> Vm, + create_vm: impl FnOnce(L1BatchEnv, SystemEnv, StoragePtr>) -> Vm, ) -> Vm { let storage = StorageView::new(self.storage).to_rc_ptr(); - let mut vm = create_vm( - self.l1_batch_env, - self.system_env, - storage, - self.pubdata_params.map(pubdata_params_to_builder), - ); + let mut vm = create_vm(self.l1_batch_env, self.system_env, storage); for (i, l2_block) in self.l2_blocks.into_iter().enumerate() { if i > 0 { @@ -113,7 +103,7 @@ impl VmDump { } } } - vm.finish_batch(); + vm.finish_batch(self.pubdata_params.map(pubdata_params_to_builder)); vm } } @@ -133,7 +123,6 @@ pub(super) struct DumpingVm { system_env: SystemEnv, l2_blocks: Vec, l2_blocks_snapshot: Option, - pubdata_builder: Option>, } impl DumpingVm { @@ -145,15 +134,13 @@ impl DumpingVm { self.last_block_mut().txs.push(tx); } - pub fn dump_state(&self) -> VmDump { + pub fn dump_state(&self, pubdata_builder: Option>) -> VmDump { VmDump { l1_batch_env: self.l1_batch_env.clone(), system_env: self.system_env.clone(), l2_blocks: self.l2_blocks.clone(), storage: create_storage_snapshot(&self.storage, self.inner.used_contract_hashes()), - pubdata_params: self - .pubdata_builder - .clone() + pubdata_params: pubdata_builder .map(|p| p.pubdata_params().expect("pubdata builder is not dumpable")), } } @@ -170,7 +157,7 @@ impl VmInterface for DumpingVm { fn inspect( &mut self, dispatcher: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { self.inner.inspect(dispatcher, execution_mode) } @@ -197,8 +184,8 @@ impl VmInterface for DumpingVm { .inspect_transaction_with_bytecode_compression(tracer, tx, with_compression) } - fn finish_batch(&mut self) -> FinishedL1Batch { - self.inner.finish_batch() + fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + self.inner.finish_batch(pubdata_builder) } } @@ -247,14 +234,8 @@ where l1_batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr>, - pubdata_builder: Option>, ) -> Self { - let inner = Vm::new( - l1_batch_env.clone(), - system_env.clone(), - storage.clone(), - pubdata_builder.clone(), - ); + let inner = Vm::new(l1_batch_env.clone(), system_env.clone(), storage.clone()); let first_block = L2BlockExecutionData { number: L2BlockNumber(l1_batch_env.first_l2_block.number), timestamp: l1_batch_env.first_l2_block.timestamp, @@ -269,7 +250,6 @@ where l2_blocks_snapshot: None, storage, inner, - pubdata_builder, } } } diff --git a/core/lib/vm_interface/src/utils/shadow.rs b/core/lib/vm_interface/src/utils/shadow.rs index 504ddc11fee8..d15f642d771e 100644 --- a/core/lib/vm_interface/src/utils/shadow.rs +++ b/core/lib/vm_interface/src/utils/shadow.rs @@ -12,8 +12,8 @@ use super::dump::{DumpingVm, VmDump}; use crate::{ pubdata::PubdataBuilder, storage::{ReadStorage, StoragePtr, StorageView}, - BytecodeCompressionResult, CurrentExecutionState, FinishedL1Batch, L1BatchEnv, L2BlockEnv, - SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, + BytecodeCompressionResult, CurrentExecutionState, FinishedL1Batch, InspectExecutionMode, + L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmTrackingContracts, }; @@ -91,21 +91,25 @@ where } /// Mutable ref is not necessary, but it automatically drops potential borrows. - fn report(&mut self, err: DivergenceErrors) { - self.report_shared(err); + fn report(&mut self, err: DivergenceErrors, pubdata_builder: Option>) { + self.report_shared(err, pubdata_builder); } /// The caller is responsible for dropping any `shadow` borrows beforehand. - fn report_shared(&self, err: DivergenceErrors) { + fn report_shared( + &self, + err: DivergenceErrors, + pubdata_builder: Option>, + ) { self.shadow .take() .unwrap() - .report(err, self.main.dump_state()); + .report(err, self.main.dump_state(pubdata_builder)); } /// Dumps the current VM state. - pub fn dump_state(&self) -> VmDump { - self.main.dump_state() + pub fn dump_state(&self, pubdata_builder: Option>) -> VmDump { + self.main.dump_state(pubdata_builder) } } @@ -121,23 +125,12 @@ where system_env: SystemEnv, storage: StoragePtr>, shadow_storage: StoragePtr, - pubdata_builder: Option>, ) -> Self where Shadow: VmFactory, { - let main = DumpingVm::new( - batch_env.clone(), - system_env.clone(), - storage, - pubdata_builder.clone(), - ); - let shadow = Shadow::new( - batch_env.clone(), - system_env.clone(), - shadow_storage, - pubdata_builder, - ); + let main = DumpingVm::new(batch_env.clone(), system_env.clone(), storage); + let shadow = Shadow::new(batch_env.clone(), system_env.clone(), shadow_storage); let shadow = VmWithReporting { vm: shadow, divergence_handler: DivergenceHandler::default(), @@ -159,15 +152,8 @@ where batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr>, - pubdata_builder: Option>, ) -> Self { - Self::with_custom_shadow( - batch_env, - system_env, - storage.clone(), - storage, - pubdata_builder, - ) + Self::with_custom_shadow(batch_env, system_env, storage.clone(), storage) } } @@ -193,7 +179,7 @@ where fn inspect( &mut self, (main_tracer, shadow_tracer): &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { let main_result = self.main.inspect(main_tracer, execution_mode); if let Some(shadow) = self.shadow.get_mut() { @@ -203,7 +189,7 @@ where if let Err(err) = errors.into_result() { let ctx = format!("executing VM with mode {execution_mode:?}"); - self.report(err.context(ctx)); + self.report(err.context(ctx), None); } } main_result @@ -247,16 +233,16 @@ where let ctx = format!( "inspecting transaction {tx_repr}, with_compression={with_compression:?}" ); - self.report(err.context(ctx)); + self.report(err.context(ctx), None); } } (main_bytecodes_result, main_tx_result) } - fn finish_batch(&mut self) -> FinishedL1Batch { - let main_batch = self.main.finish_batch(); + fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + let main_batch = self.main.finish_batch(pubdata_builder.clone()); if let Some(shadow) = self.shadow.get_mut() { - let shadow_batch = shadow.vm.finish_batch(); + let shadow_batch = shadow.vm.finish_batch(pubdata_builder.clone()); let mut errors = DivergenceErrors::new(); errors.check_results_match( &main_batch.block_tip_execution_result, @@ -283,7 +269,7 @@ where ); if let Err(err) = errors.into_result() { - self.report(err); + self.report(err, pubdata_builder); } } main_batch diff --git a/core/lib/vm_interface/src/vm.rs b/core/lib/vm_interface/src/vm.rs index 904797ccbd2c..00b066779dbb 100644 --- a/core/lib/vm_interface/src/vm.rs +++ b/core/lib/vm_interface/src/vm.rs @@ -17,7 +17,7 @@ use zksync_types::{Transaction, H256}; use crate::{ pubdata::PubdataBuilder, storage::StoragePtr, BytecodeCompressionResult, FinishedL1Batch, - L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, + InspectExecutionMode, L1BatchEnv, L2BlockEnv, SystemEnv, VmExecutionResultAndLogs, }; pub trait VmInterface { @@ -32,7 +32,7 @@ pub trait VmInterface { fn inspect( &mut self, dispatcher: &mut Self::TracerDispatcher, - execution_mode: VmExecutionMode, + execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs; /// Start a new L2 block. @@ -48,13 +48,13 @@ pub trait VmInterface { /// Execute batch till the end and return the result, with final execution state /// and bootloader memory. - fn finish_batch(&mut self) -> FinishedL1Batch; + fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch; } /// Extension trait for [`VmInterface`] that provides some additional methods. pub trait VmInterfaceExt: VmInterface { /// Executes the next VM step (either next transaction or bootloader or the whole batch). - fn execute(&mut self, execution_mode: VmExecutionMode) -> VmExecutionResultAndLogs { + fn execute(&mut self, execution_mode: InspectExecutionMode) -> VmExecutionResultAndLogs { self.inspect(&mut ::default(), execution_mode) } @@ -77,12 +77,7 @@ impl VmInterfaceExt for T {} /// Encapsulates creating VM instance based on the provided environment. pub trait VmFactory: VmInterface { /// Creates a new VM instance. - fn new( - batch_env: L1BatchEnv, - system_env: SystemEnv, - storage: StoragePtr, - pubdata_builder: Option>, - ) -> Self; + fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self; } /// Methods of VM requiring history manipulations. diff --git a/core/node/state_keeper/src/io/mod.rs b/core/node/state_keeper/src/io/mod.rs index 72517938e479..e2461e72d7b2 100644 --- a/core/node/state_keeper/src/io/mod.rs +++ b/core/node/state_keeper/src/io/mod.rs @@ -84,7 +84,7 @@ impl L1BatchParams { cursor: &IoCursor, previous_batch_hash: H256, ) -> (SystemEnv, L1BatchEnv, PubdataParams) { - l1_batch_params( + let (system_env, l1_batch_env) = l1_batch_params( cursor.l1_batch, self.operator_address, self.first_l2_block.timestamp, @@ -97,8 +97,9 @@ impl L1BatchParams { self.protocol_version, self.first_l2_block.virtual_blocks, chain_id, - self.pubdata_params, - ) + ); + + (system_env, l1_batch_env, self.pubdata_params) } } diff --git a/core/tests/vm-benchmark/src/vm.rs b/core/tests/vm-benchmark/src/vm.rs index d216a3c9d45b..bdc593716ba3 100644 --- a/core/tests/vm-benchmark/src/vm.rs +++ b/core/tests/vm-benchmark/src/vm.rs @@ -2,11 +2,11 @@ use std::{cell::RefCell, rc::Rc}; use once_cell::sync::Lazy; use zksync_contracts::BaseSystemContracts; +use zksync_multivm::interface::InspectExecutionMode; use zksync_multivm::{ interface::{ - pubdata::{pubdata_params_to_builder, PubdataBuilder}, storage::{InMemoryStorage, StorageView}, - ExecutionResult, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, + ExecutionResult, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, }, @@ -15,9 +15,9 @@ use zksync_multivm::{ zk_evm_latest::ethereum_types::{Address, U256}, }; use zksync_types::{ - block::L2BlockHasher, commitment::PubdataParams, fee_model::BatchFeeInput, - helpers::unix_timestamp_ms, utils::storage_key_for_eth_balance, L1BatchNumber, L2BlockNumber, - L2ChainId, ProtocolVersionId, Transaction, + block::L2BlockHasher, fee_model::BatchFeeInput, helpers::unix_timestamp_ms, + utils::storage_key_for_eth_balance, L1BatchNumber, L2BlockNumber, L2ChainId, ProtocolVersionId, + Transaction, }; use zksync_utils::bytecode::hash_bytecode; @@ -72,7 +72,6 @@ pub trait BenchmarkingVmFactory { batch_env: L1BatchEnv, system_env: SystemEnv, storage: &'static InMemoryStorage, - pubdata_builder: Rc, ) -> Self::Instance; /// Counts instructions executed by the VM while processing the transaction. @@ -92,7 +91,6 @@ impl BenchmarkingVmFactory for Fast batch_env: L1BatchEnv, system_env: SystemEnv, storage: &'static InMemoryStorage, - _pubdata_builder: Rc, ) -> Self::Instance { vm_fast::Vm::custom(batch_env, system_env, storage) } @@ -116,7 +114,7 @@ impl BenchmarkingVmFactory for Fast } let mut tracer = InstructionCount(0); - vm.0.inspect(&mut tracer, VmExecutionMode::OneTx); + vm.0.inspect(&mut tracer, InspectExecutionMode::OneTx); tracer.0 } } @@ -134,10 +132,9 @@ impl BenchmarkingVmFactory for Legacy { batch_env: L1BatchEnv, system_env: SystemEnv, storage: &'static InMemoryStorage, - pubdata_builder: Rc, ) -> Self::Instance { let storage = StorageView::new(storage).to_rc_ptr(); - vm_latest::Vm::new(batch_env, system_env, storage, Some(pubdata_builder)) + vm_latest::Vm::new(batch_env, system_env, storage) } fn count_instructions(tx: &Transaction) -> usize { @@ -148,7 +145,7 @@ impl BenchmarkingVmFactory for Legacy { &mut InstructionCounter::new(count.clone()) .into_tracer_pointer() .into(), - VmExecutionMode::OneTx, + InspectExecutionMode::OneTx, ); count.take() } @@ -188,7 +185,6 @@ impl Default for BenchmarkingVm { chain_id: L2ChainId::from(270), }, &STORAGE, - pubdata_params_to_builder(PubdataParams::default()), )) } } @@ -196,7 +192,7 @@ impl Default for BenchmarkingVm { impl BenchmarkingVm { pub fn run_transaction(&mut self, tx: &Transaction) -> VmExecutionResultAndLogs { self.0.push_transaction(tx.clone()); - self.0.execute(VmExecutionMode::OneTx) + self.0.execute(InspectExecutionMode::OneTx) } pub fn run_transaction_full(&mut self, tx: &Transaction) -> VmExecutionResultAndLogs { From 79c4ba288d849f7311134f0ca9b80771e9edda33 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Fri, 18 Oct 2024 12:17:02 +0300 Subject: [PATCH 15/23] move stuff to multivm --- Cargo.lock | 3 +- core/lib/multivm/Cargo.toml | 1 + core/lib/multivm/src/dump.rs | 45 ++++++++++++++++++ core/lib/multivm/src/lib.rs | 2 + core/lib/multivm/src/pubdata_builders/mod.rs | 23 +++++++++ .../src/pubdata_builders}/rollup.rs | 14 +++--- .../src/pubdata_builders}/tests.rs | 34 +++++++------- .../src/pubdata_builders}/utils.rs | 2 +- .../src/pubdata_builders}/validium.rs | 19 ++++---- core/lib/multivm/src/versions/testonly.rs | 6 +-- core/lib/multivm/src/versions/tests.rs | 26 +++++----- .../vm_latest/bootloader_state/state.rs | 6 +-- .../vm_latest/bootloader_state/utils.rs | 4 +- .../vm_latest/tests/tester/vm_tester.rs | 2 +- .../vm_latest/tracers/pubdata_tracer.rs | 9 ++-- core/lib/tee_verifier/src/lib.rs | 2 +- core/lib/vm_executor/src/batch/factory.rs | 3 +- core/lib/vm_interface/Cargo.toml | 2 - core/lib/vm_interface/src/pubdata/mod.rs | 46 +++++++----------- core/lib/vm_interface/src/utils/dump.rs | 47 ++----------------- prover/Cargo.lock | 3 +- 21 files changed, 154 insertions(+), 145 deletions(-) create mode 100644 core/lib/multivm/src/dump.rs create mode 100644 core/lib/multivm/src/pubdata_builders/mod.rs rename core/lib/{vm_interface/src/pubdata => multivm/src/pubdata_builders}/rollup.rs (93%) rename core/lib/{vm_interface/src/pubdata => multivm/src/pubdata_builders}/tests.rs (88%) rename core/lib/{vm_interface/src/pubdata => multivm/src/pubdata_builders}/utils.rs (97%) rename core/lib/{vm_interface/src/pubdata => multivm/src/pubdata_builders}/validium.rs (90%) diff --git a/Cargo.lock b/Cargo.lock index eb85688a2fea..d0002887ea26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10512,6 +10512,7 @@ dependencies = [ "zk_evm 0.150.5", "zksync_contracts", "zksync_eth_signer", + "zksync_mini_merkle_tree", "zksync_system_constants", "zksync_test_account", "zksync_types", @@ -11355,10 +11356,8 @@ dependencies = [ "thiserror", "tracing", "zksync_contracts", - "zksync_mini_merkle_tree", "zksync_system_constants", "zksync_types", - "zksync_utils", ] [[package]] diff --git a/core/lib/multivm/Cargo.toml b/core/lib/multivm/Cargo.toml index e49086a6b8b1..eb770bf9b57e 100644 --- a/core/lib/multivm/Cargo.toml +++ b/core/lib/multivm/Cargo.toml @@ -29,6 +29,7 @@ zksync_contracts.workspace = true zksync_utils.workspace = true zksync_system_constants.workspace = true zksync_vm_interface.workspace = true +zksync_mini_merkle_tree.workspace = true anyhow.workspace = true hex.workspace = true diff --git a/core/lib/multivm/src/dump.rs b/core/lib/multivm/src/dump.rs new file mode 100644 index 000000000000..63bb017a4634 --- /dev/null +++ b/core/lib/multivm/src/dump.rs @@ -0,0 +1,45 @@ +use crate::interface::storage::{StoragePtr, StorageSnapshot, StorageView}; +use crate::interface::utils::VmDump; +use crate::interface::{L1BatchEnv, L2BlockEnv, SystemEnv, VmFactory, VmInterface, VmInterfaceExt}; +use crate::pubdata_builders::pubdata_params_to_builder; + +/// Plays back dump on the specified VM. +pub fn play_back_dump(dump: VmDump) -> Vm +where + Vm: VmFactory>, +{ + play_back_dump_custom(dump, Vm::new) +} + +/// Plays back dump on a VM created using the provided closure. +#[doc(hidden)] // too low-level +pub fn play_back_dump_custom( + dump: VmDump, + create_vm: impl FnOnce(L1BatchEnv, SystemEnv, StoragePtr>) -> Vm, +) -> Vm { + let storage = StorageView::new(dump.storage).to_rc_ptr(); + let mut vm = create_vm(dump.l1_batch_env, dump.system_env, storage); + + for (i, l2_block) in dump.l2_blocks.into_iter().enumerate() { + if i > 0 { + // First block is already set. + vm.start_new_l2_block(L2BlockEnv { + number: l2_block.number.0, + timestamp: l2_block.timestamp, + prev_block_hash: l2_block.prev_block_hash, + max_virtual_blocks_to_create: l2_block.virtual_blocks, + }); + } + + for tx in l2_block.txs { + let tx_hash = tx.hash(); + let (compression_result, _) = + vm.execute_transaction_with_bytecode_compression(tx, true); + if let Err(err) = compression_result { + panic!("Failed compressing bytecodes for transaction {tx_hash:?}: {err}"); + } + } + } + vm.finish_batch(dump.pubdata_params.map(pubdata_params_to_builder)); + vm +} diff --git a/core/lib/multivm/src/lib.rs b/core/lib/multivm/src/lib.rs index 520274c14ae0..d01ad02e1112 100644 --- a/core/lib/multivm/src/lib.rs +++ b/core/lib/multivm/src/lib.rs @@ -19,7 +19,9 @@ pub use crate::{ vm_instance::{is_supported_by_fast_vm, FastVmInstance, LegacyVmInstance}, }; +pub mod dump; mod glue; +pub mod pubdata_builders; pub mod tracers; pub mod utils; mod versions; diff --git a/core/lib/multivm/src/pubdata_builders/mod.rs b/core/lib/multivm/src/pubdata_builders/mod.rs new file mode 100644 index 000000000000..d9fb0c87d273 --- /dev/null +++ b/core/lib/multivm/src/pubdata_builders/mod.rs @@ -0,0 +1,23 @@ +use crate::interface::pubdata::PubdataBuilder; +use std::rc::Rc; +use zksync_types::commitment::{L1BatchCommitmentMode, PubdataParams}; + +pub use rollup::RollupPubdataBuilder; +pub use validium::ValidiumPubdataBuilder; + +mod rollup; +#[cfg(test)] +mod tests; +mod utils; +mod validium; + +pub fn pubdata_params_to_builder(params: PubdataParams) -> Rc { + match params.pubdata_type { + L1BatchCommitmentMode::Rollup => { + Rc::new(RollupPubdataBuilder::new(params.l2_da_validator_address)) + } + L1BatchCommitmentMode::Validium => { + Rc::new(ValidiumPubdataBuilder::new(params.l2_da_validator_address)) + } + } +} diff --git a/core/lib/vm_interface/src/pubdata/rollup.rs b/core/lib/multivm/src/pubdata_builders/rollup.rs similarity index 93% rename from core/lib/vm_interface/src/pubdata/rollup.rs rename to core/lib/multivm/src/pubdata_builders/rollup.rs index b7328f1668f1..3d91585ed7e4 100644 --- a/core/lib/vm_interface/src/pubdata/rollup.rs +++ b/core/lib/multivm/src/pubdata_builders/rollup.rs @@ -1,3 +1,4 @@ +use crate::interface::pubdata::{PubdataBuilder, PubdataInput}; use zksync_types::{ commitment::{L1BatchCommitmentMode, PubdataParams}, ethabi, @@ -7,8 +8,7 @@ use zksync_types::{ Address, ProtocolVersionId, }; -use super::{PubdataBuilder, PubdataInput}; -use crate::pubdata::utils::{ +use super::utils::{ build_chained_bytecode_hash, build_chained_log_hash, build_chained_message_hash, build_logs_root, encode_user_logs, }; @@ -38,12 +38,12 @@ impl PubdataBuilder for RollupPubdataBuilder { fn l1_messenger_operator_input( &self, - input: PubdataInput, + input: &PubdataInput, protocol_version: ProtocolVersionId, ) -> Vec { if protocol_version.is_pre_gateway() { let mut operator_input = vec![]; - extend_from_pubdata_input(&mut operator_input, &input); + extend_from_pubdata_input(&mut operator_input, input); // Extend with uncompressed state diffs. operator_input.extend((input.state_diffs.len() as u32).to_be_bytes()); @@ -54,7 +54,7 @@ impl PubdataBuilder for RollupPubdataBuilder { operator_input } else { let mut pubdata = vec![]; - extend_from_pubdata_input(&mut pubdata, &input); + extend_from_pubdata_input(&mut pubdata, input); // Extend with uncompressed state diffs. pubdata.extend((input.state_diffs.len() as u32).to_be_bytes()); @@ -94,11 +94,11 @@ impl PubdataBuilder for RollupPubdataBuilder { fn settlement_layer_pubdata( &self, - input: PubdataInput, + input: &PubdataInput, _protocol_version: ProtocolVersionId, ) -> Vec { let mut pubdata = vec![]; - extend_from_pubdata_input(&mut pubdata, &input); + extend_from_pubdata_input(&mut pubdata, input); pubdata } diff --git a/core/lib/vm_interface/src/pubdata/tests.rs b/core/lib/multivm/src/pubdata_builders/tests.rs similarity index 88% rename from core/lib/vm_interface/src/pubdata/tests.rs rename to core/lib/multivm/src/pubdata_builders/tests.rs index 6894547793d8..dfcde027f9e1 100644 --- a/core/lib/vm_interface/src/pubdata/tests.rs +++ b/core/lib/multivm/src/pubdata_builders/tests.rs @@ -1,9 +1,11 @@ -use zksync_system_constants::{ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS}; -use zksync_types::{writes::StateDiffRecord, Address, ProtocolVersionId}; +use crate::interface::pubdata::{L1MessengerL2ToL1Log, PubdataBuilder, PubdataInput}; +use zksync_types::{ + writes::StateDiffRecord, Address, ProtocolVersionId, ACCOUNT_CODE_STORAGE_ADDRESS, + BOOTLOADER_ADDRESS, +}; use zksync_utils::u256_to_h256; -use super::{L1MessengerL2ToL1Log, PubdataBuilder, PubdataInput}; -use crate::pubdata::{rollup::RollupPubdataBuilder, validium::ValidiumPubdataBuilder}; +use super::{rollup::RollupPubdataBuilder, validium::ValidiumPubdataBuilder}; fn mock_input() -> PubdataInput { // Just using some constant addresses for tests @@ -58,8 +60,8 @@ fn test_rollup_pubdata_building() { let rollup_pubdata_builder = RollupPubdataBuilder::new(Address::zero()); - let actual = rollup_pubdata_builder - .l1_messenger_operator_input(input.clone(), ProtocolVersionId::Version24); + let actual = + rollup_pubdata_builder.l1_messenger_operator_input(&input, ProtocolVersionId::Version24); let expected = "00000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000060bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901000000020000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009b000000000000000000000000000000000000000000000000000000000000007d000000000000000c000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000007e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; assert_eq!( &hex::encode(actual), @@ -67,8 +69,8 @@ fn test_rollup_pubdata_building() { "mismatch for `l1_messenger_operator_input` (pre gateway)" ); - let actual = rollup_pubdata_builder - .settlement_layer_pubdata(input.clone(), ProtocolVersionId::Version24); + let actual = + rollup_pubdata_builder.settlement_layer_pubdata(&input, ProtocolVersionId::Version24); let expected = "00000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000060bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901"; assert_eq!( &hex::encode(actual), @@ -76,8 +78,8 @@ fn test_rollup_pubdata_building() { "mismatch for `settlement_layer_pubdata` (pre gateway)" ); - let actual = rollup_pubdata_builder - .l1_messenger_operator_input(input.clone(), ProtocolVersionId::Version27); + let actual = + rollup_pubdata_builder.l1_messenger_operator_input(&input, ProtocolVersionId::Version27); let expected = "89f9a07233e608561d90f7c4e7bcea24d718e425a6bd6c8eefb48a334366143694c75fae278944d856d68e33bbd32937cb3a1ea35cbf7d6eeeb1150f500dd0d64d0efe420d6dafe5897eab2fc27b2e47af303397ed285ace146d836d042717b0a3dc4b28a603a33b28ce1d5c52c593a46a15a99f1afa1c1d92715284288958fd54a93de700000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000032300000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000060bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901000000020000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009b000000000000000000000000000000000000000000000000000000000000007d000000000000000c000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000007e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; assert_eq!( &hex::encode(actual), @@ -85,8 +87,8 @@ fn test_rollup_pubdata_building() { "mismatch for `l1_messenger_operator_input` (post gateway)" ); - let actual = rollup_pubdata_builder - .settlement_layer_pubdata(input.clone(), ProtocolVersionId::Version27); + let actual = + rollup_pubdata_builder.settlement_layer_pubdata(&input, ProtocolVersionId::Version27); let expected = "00000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000060bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901"; assert_eq!( &hex::encode(actual), @@ -101,8 +103,8 @@ fn test_validium_pubdata_building() { let validium_pubdata_builder = ValidiumPubdataBuilder::new(Address::zero()); - let actual = validium_pubdata_builder - .l1_messenger_operator_input(input.clone(), ProtocolVersionId::Version27); + let actual = + validium_pubdata_builder.l1_messenger_operator_input(&input, ProtocolVersionId::Version27); let expected = "89f9a07233e608561d90f7c4e7bcea24d718e425a6bd6c8eefb48a334366143694c75fae278944d856d68e33bbd32937cb3a1ea35cbf7d6eeeb1150f500dd0d64d0efe420d6dafe5897eab2fc27b2e47af303397ed285ace146d836d042717b0a3dc4b28a603a33b28ce1d5c52c593a46a15a99f1afa1c1d92715284288958fd54a93de700000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000005c000000010000000000000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000"; assert_eq!( &hex::encode(actual), @@ -110,8 +112,8 @@ fn test_validium_pubdata_building() { "mismatch for `l1_messenger_operator_input`" ); - let actual = validium_pubdata_builder - .settlement_layer_pubdata(input.clone(), ProtocolVersionId::Version27); + let actual = + validium_pubdata_builder.settlement_layer_pubdata(&input, ProtocolVersionId::Version27); let expected = "fa96e2436e6fb4d668f5a06681a7c53fcb199b2747ee624ee52a13e85aac5f1e"; assert_eq!( &hex::encode(actual), diff --git a/core/lib/vm_interface/src/pubdata/utils.rs b/core/lib/multivm/src/pubdata_builders/utils.rs similarity index 97% rename from core/lib/vm_interface/src/pubdata/utils.rs rename to core/lib/multivm/src/pubdata_builders/utils.rs index 8ed34962c3af..57361a674fb7 100644 --- a/core/lib/vm_interface/src/pubdata/utils.rs +++ b/core/lib/multivm/src/pubdata_builders/utils.rs @@ -2,7 +2,7 @@ use zksync_mini_merkle_tree::MiniMerkleTree; use zksync_types::web3::keccak256; use zksync_utils::bytecode::hash_bytecode; -use crate::pubdata::L1MessengerL2ToL1Log; +use crate::interface::pubdata::L1MessengerL2ToL1Log; pub(crate) fn build_chained_log_hash(user_logs: &[L1MessengerL2ToL1Log]) -> Vec { let mut chained_log_hash = vec![0u8; 32]; diff --git a/core/lib/vm_interface/src/pubdata/validium.rs b/core/lib/multivm/src/pubdata_builders/validium.rs similarity index 90% rename from core/lib/vm_interface/src/pubdata/validium.rs rename to core/lib/multivm/src/pubdata_builders/validium.rs index f0d8c9d0eb95..7fb5f2a046a1 100644 --- a/core/lib/vm_interface/src/pubdata/validium.rs +++ b/core/lib/multivm/src/pubdata_builders/validium.rs @@ -1,3 +1,8 @@ +use super::utils::{ + build_chained_bytecode_hash, build_chained_log_hash, build_chained_message_hash, + build_logs_root, encode_user_logs, +}; +use crate::interface::pubdata::{PubdataBuilder, PubdataInput}; use zksync_types::{ commitment::{L1BatchCommitmentMode, PubdataParams}, ethabi, @@ -7,14 +12,6 @@ use zksync_types::{ Address, ProtocolVersionId, }; -use crate::pubdata::{ - utils::{ - build_chained_bytecode_hash, build_chained_log_hash, build_chained_message_hash, - build_logs_root, encode_user_logs, - }, - PubdataBuilder, PubdataInput, -}; - #[derive(Debug, Clone, Copy)] pub struct ValidiumPubdataBuilder { pub l2_da_validator: Address, @@ -40,7 +37,7 @@ impl PubdataBuilder for ValidiumPubdataBuilder { fn l1_messenger_operator_input( &self, - input: PubdataInput, + input: &PubdataInput, protocol_version: ProtocolVersionId, ) -> Vec { assert!( @@ -84,7 +81,7 @@ impl PubdataBuilder for ValidiumPubdataBuilder { fn settlement_layer_pubdata( &self, - input: PubdataInput, + input: &PubdataInput, protocol_version: ProtocolVersionId, ) -> Vec { assert!( @@ -94,7 +91,7 @@ impl PubdataBuilder for ValidiumPubdataBuilder { let state_diffs_packed = input .state_diffs - .into_iter() + .iter() .flat_map(|diff| diff.encode_padded()) .collect::>(); diff --git a/core/lib/multivm/src/versions/testonly.rs b/core/lib/multivm/src/versions/testonly.rs index c498959e27b0..e38fa6e3960b 100644 --- a/core/lib/multivm/src/versions/testonly.rs +++ b/core/lib/multivm/src/versions/testonly.rs @@ -9,11 +9,11 @@ use zksync_types::{ }; use zksync_utils::{bytecode::hash_bytecode, u256_to_h256}; +use crate::pubdata_builders::RollupPubdataBuilder; use crate::{ interface::{ - pubdata::{rollup::RollupPubdataBuilder, PubdataBuilder}, - storage::InMemoryStorage, - L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, + pubdata::PubdataBuilder, storage::InMemoryStorage, L1BatchEnv, L2BlockEnv, SystemEnv, + TxExecutionMode, }, vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT, }; diff --git a/core/lib/multivm/src/versions/tests.rs b/core/lib/multivm/src/versions/tests.rs index ed46aa74bb2e..f2978908d595 100644 --- a/core/lib/multivm/src/versions/tests.rs +++ b/core/lib/multivm/src/versions/tests.rs @@ -14,8 +14,8 @@ use zksync_types::{ ProtocolVersionId, StorageKey, H256, U256, }; use zksync_utils::bytecode::hash_bytecode; -use zksync_vm_interface::pubdata::rollup::RollupPubdataBuilder; +use crate::dump::{play_back_dump, play_back_dump_custom}; use crate::{ interface::{ storage::{InMemoryStorage, ReadStorage, StorageView}, @@ -257,10 +257,8 @@ fn shadow_vm_basics() { Harness::assert_dump(&mut dump); // Test standard playback functionality. - let replayed_dump = dump - .clone() - .play_back::>() - .dump_state(Some(pubdata_builder.clone())); + let replayed_dump = + play_back_dump::>(dump.clone()).dump_state(Some(pubdata_builder.clone())); pretty_assertions::assert_eq!(replayed_dump, dump); // Check that the VM executes identically when reading from the original storage and one restored from the dump. @@ -268,16 +266,14 @@ fn shadow_vm_basics() { harness.setup_storage(&mut storage); let storage = StorageView::new(storage).to_rc_ptr(); - let vm = dump - .clone() - .play_back_custom(|l1_batch_env, system_env, dump_storage| { - ShadowVm::<_, ReferenceVm, ReferenceVm<_>>::with_custom_shadow( - l1_batch_env, - system_env, - storage, - dump_storage, - ) - }); + let vm = play_back_dump_custom(dump.clone(), |l1_batch_env, system_env, dump_storage| { + ShadowVm::<_, ReferenceVm, ReferenceVm<_>>::with_custom_shadow( + l1_batch_env, + system_env, + storage, + dump_storage, + ) + }); let new_dump = vm.dump_state(Some(pubdata_builder)); pretty_assertions::assert_eq!(new_dump, dump); } diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs index cf06497f3eab..99013f98d5d3 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs @@ -157,8 +157,7 @@ impl BootloaderState { let pubdata_information = self .pubdata_information .get() - .expect("Pubdata information is not set") - .clone(); + .expect("Pubdata information is not set"); pubdata_builder.settlement_layer_pubdata(pubdata_information, self.protocol_version) } @@ -199,8 +198,7 @@ impl BootloaderState { let pubdata_information = self .pubdata_information - .clone() - .into_inner() + .get() .expect("Empty pubdata information"); apply_pubdata_to_memory( diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs index 4c15eab27325..3d0bff33f080 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs @@ -130,7 +130,7 @@ fn apply_l2_block_inner( fn bootloader_memory_input( pubdata_builder: Rc, - input: PubdataInput, + input: &PubdataInput, protocol_version: ProtocolVersionId, ) -> Vec { let l2_da_validator_address = pubdata_builder.l2_da_validator(); @@ -145,7 +145,7 @@ fn bootloader_memory_input( pub(crate) fn apply_pubdata_to_memory( memory: &mut BootloaderMemory, pubdata_builder: Rc, - pubdata_information: PubdataInput, + pubdata_information: &PubdataInput, protocol_version: ProtocolVersionId, ) { let (l1_messenger_pubdata_start_slot, pubdata) = if protocol_version.is_pre_gateway() { diff --git a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs index 7884c4afcc79..95c07e20782b 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs @@ -10,7 +10,7 @@ use zksync_types::{ Address, L1BatchNumber, L2BlockNumber, L2ChainId, Nonce, ProtocolVersionId, U256, }; use zksync_utils::{bytecode::hash_bytecode, u256_to_h256}; -use zksync_vm_interface::pubdata::{rollup::RollupPubdataBuilder, PubdataBuilder}; +use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ interface::{ diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs index 0ebaf57e4c43..0440d7fe82ba 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs @@ -229,9 +229,6 @@ impl VmTracer for PubdataTracer { if self.pubdata_info_requested { let pubdata_input = self.build_pubdata_input(state); - // Save the pubdata for the future initial bootloader memory building - bootloader_state.set_pubdata_input(pubdata_input.clone()); - // Apply the pubdata to the current memory let mut memory_to_apply = vec![]; @@ -240,9 +237,13 @@ impl VmTracer for PubdataTracer { self.pubdata_builder .clone() .expect("`pubdata_builder` is required to finish batch"), - pubdata_input, + &pubdata_input, bootloader_state.protocol_version(), ); + + // Save the pubdata for the future initial bootloader memory building + bootloader_state.set_pubdata_input(pubdata_input); + state.memory.populate_page( BOOTLOADER_HEAP_PAGE as usize, memory_to_apply, diff --git a/core/lib/tee_verifier/src/lib.rs b/core/lib/tee_verifier/src/lib.rs index 9f618556cf2d..088ba831eece 100644 --- a/core/lib/tee_verifier/src/lib.rs +++ b/core/lib/tee_verifier/src/lib.rs @@ -9,7 +9,7 @@ use zksync_crypto_primitives::hasher::blake2::Blake2Hasher; use zksync_merkle_tree::{ BlockOutputWithProofs, TreeInstruction, TreeLogEntry, TreeLogEntryWithProof, ValueHash, }; -use zksync_multivm::interface::pubdata::pubdata_params_to_builder; +use zksync_multivm::pubdata_builders::pubdata_params_to_builder; use zksync_multivm::{ interface::{ storage::{ReadStorage, StorageSnapshot, StorageView}, diff --git a/core/lib/vm_executor/src/batch/factory.rs b/core/lib/vm_executor/src/batch/factory.rs index 80531ec43c48..1328e4371f68 100644 --- a/core/lib/vm_executor/src/batch/factory.rs +++ b/core/lib/vm_executor/src/batch/factory.rs @@ -3,10 +3,11 @@ use std::{borrow::Cow, fmt, marker::PhantomData, rc::Rc, sync::Arc, time::Durati use anyhow::Context as _; use once_cell::sync::OnceCell; use tokio::sync::mpsc; +use zksync_multivm::pubdata_builders::pubdata_params_to_builder; use zksync_multivm::{ interface::{ executor::{BatchExecutor, BatchExecutorFactory}, - pubdata::{pubdata_params_to_builder, PubdataBuilder}, + pubdata::PubdataBuilder, storage::{ReadStorage, StoragePtr, StorageView, StorageViewStats}, utils::DivergenceHandler, BatchTransactionExecutionResult, BytecodeCompressionError, CompressedBytecodeInfo, diff --git a/core/lib/vm_interface/Cargo.toml b/core/lib/vm_interface/Cargo.toml index e771bb131e58..8bff19ddc475 100644 --- a/core/lib/vm_interface/Cargo.toml +++ b/core/lib/vm_interface/Cargo.toml @@ -14,8 +14,6 @@ categories.workspace = true zksync_contracts.workspace = true zksync_system_constants.workspace = true zksync_types.workspace = true -zksync_utils.workspace = true -zksync_mini_merkle_tree.workspace = true anyhow.workspace = true async-trait.workspace = true diff --git a/core/lib/vm_interface/src/pubdata/mod.rs b/core/lib/vm_interface/src/pubdata/mod.rs index 94bcc859d521..ba22fdeec983 100644 --- a/core/lib/vm_interface/src/pubdata/mod.rs +++ b/core/lib/vm_interface/src/pubdata/mod.rs @@ -1,21 +1,7 @@ -use std::rc::Rc; - use zksync_types::{ - commitment::{L1BatchCommitmentMode, PubdataParams}, - l2_to_l1_log::L2ToL1Log, - writes::StateDiffRecord, - Address, ProtocolVersionId, U256, + commitment::PubdataParams, l2_to_l1_log::L2ToL1Log, writes::StateDiffRecord, Address, + ProtocolVersionId, H256, U256, }; -use zksync_utils::{u256_to_bytes_be, u256_to_h256}; - -use crate::pubdata::{rollup::RollupPubdataBuilder, validium::ValidiumPubdataBuilder}; - -pub mod rollup; -pub mod utils; -pub mod validium; - -#[cfg(test)] -mod tests; /// Corresponds to the following solidity event: /// ```solidity @@ -40,6 +26,13 @@ pub struct L1MessengerL2ToL1Log { impl L1MessengerL2ToL1Log { pub fn packed_encoding(&self) -> Vec { + /// Converts `U256` value into bytes array + fn u256_to_bytes_be(value: &U256) -> Vec { + let mut bytes = vec![0u8; 32]; + value.to_big_endian(bytes.as_mut_slice()); + bytes + } + let mut res: Vec = vec![]; res.push(self.l2_shard_id); res.push(self.is_service as u8); @@ -53,6 +46,12 @@ impl L1MessengerL2ToL1Log { impl From for L2ToL1Log { fn from(log: L1MessengerL2ToL1Log) -> Self { + fn u256_to_h256(num: U256) -> H256 { + let mut bytes = [0u8; 32]; + num.to_big_endian(&mut bytes); + H256::from_slice(&bytes) + } + L2ToL1Log { shard_id: log.l2_shard_id, is_service: log.is_service, @@ -84,24 +83,13 @@ pub trait PubdataBuilder: std::fmt::Debug { fn l1_messenger_operator_input( &self, - input: PubdataInput, + input: &PubdataInput, protocol_version: ProtocolVersionId, ) -> Vec; fn settlement_layer_pubdata( &self, - input: PubdataInput, + input: &PubdataInput, protocol_version: ProtocolVersionId, ) -> Vec; } - -pub fn pubdata_params_to_builder(params: PubdataParams) -> Rc { - match params.pubdata_type { - L1BatchCommitmentMode::Rollup => { - Rc::new(RollupPubdataBuilder::new(params.l2_da_validator_address)) - } - L1BatchCommitmentMode::Validium => { - Rc::new(ValidiumPubdataBuilder::new(params.l2_da_validator_address)) - } - } -} diff --git a/core/lib/vm_interface/src/utils/dump.rs b/core/lib/vm_interface/src/utils/dump.rs index 7b4319f3b24d..ac97de49bfa7 100644 --- a/core/lib/vm_interface/src/utils/dump.rs +++ b/core/lib/vm_interface/src/utils/dump.rs @@ -7,11 +7,11 @@ use zksync_types::{ }; use crate::{ - pubdata::{pubdata_params_to_builder, PubdataBuilder}, + pubdata::PubdataBuilder, storage::{ReadStorage, StoragePtr, StorageSnapshot, StorageView}, BytecodeCompressionResult, FinishedL1Batch, InspectExecutionMode, L1BatchEnv, L2BlockEnv, - SystemEnv, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceExt, - VmInterfaceHistoryEnabled, VmTrackingContracts, + SystemEnv, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled, + VmTrackingContracts, }; fn create_storage_snapshot( @@ -65,47 +65,6 @@ impl VmDump { pub fn l1_batch_number(&self) -> L1BatchNumber { self.l1_batch_env.number } - - /// Plays back this dump on the specified VM. - pub fn play_back(self) -> Vm - where - Vm: VmFactory>, - { - self.play_back_custom(Vm::new) - } - - /// Plays back this dump on a VM created using the provided closure. - #[doc(hidden)] // too low-level - pub fn play_back_custom( - self, - create_vm: impl FnOnce(L1BatchEnv, SystemEnv, StoragePtr>) -> Vm, - ) -> Vm { - let storage = StorageView::new(self.storage).to_rc_ptr(); - let mut vm = create_vm(self.l1_batch_env, self.system_env, storage); - - for (i, l2_block) in self.l2_blocks.into_iter().enumerate() { - if i > 0 { - // First block is already set. - vm.start_new_l2_block(L2BlockEnv { - number: l2_block.number.0, - timestamp: l2_block.timestamp, - prev_block_hash: l2_block.prev_block_hash, - max_virtual_blocks_to_create: l2_block.virtual_blocks, - }); - } - - for tx in l2_block.txs { - let tx_hash = tx.hash(); - let (compression_result, _) = - vm.execute_transaction_with_bytecode_compression(tx, true); - if let Err(err) = compression_result { - panic!("Failed compressing bytecodes for transaction {tx_hash:?}: {err}"); - } - } - } - vm.finish_batch(self.pubdata_params.map(pubdata_params_to_builder)); - vm - } } #[derive(Debug, Clone, Copy)] diff --git a/prover/Cargo.lock b/prover/Cargo.lock index 7454ca50f7e0..c71f6d5fb368 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -8168,6 +8168,7 @@ dependencies = [ "zk_evm 0.141.0", "zk_evm 0.150.5", "zksync_contracts", + "zksync_mini_merkle_tree", "zksync_system_constants", "zksync_types", "zksync_utils", @@ -8668,10 +8669,8 @@ dependencies = [ "thiserror", "tracing", "zksync_contracts", - "zksync_mini_merkle_tree", "zksync_system_constants", "zksync_types", - "zksync_utils", ] [[package]] From 0984283ed0405a9c7a3e3c6eaf185a525b1567b8 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Fri, 18 Oct 2024 12:40:33 +0300 Subject: [PATCH 16/23] update tests --- .../system-constants-generator/src/utils.rs | 4 ++-- core/lib/multivm/src/dump.rs | 12 +++++++---- core/lib/multivm/src/pubdata_builders/mod.rs | 5 +++-- .../multivm/src/pubdata_builders/rollup.rs | 2 +- .../lib/multivm/src/pubdata_builders/tests.rs | 2 +- .../multivm/src/pubdata_builders/validium.rs | 11 +++++----- core/lib/multivm/src/versions/testonly.rs | 2 +- core/lib/multivm/src/versions/tests.rs | 3 +-- core/lib/multivm/src/versions/vm_1_3_2/vm.rs | 3 +-- core/lib/multivm/src/versions/vm_1_4_1/vm.rs | 3 +-- core/lib/multivm/src/versions/vm_1_4_2/vm.rs | 3 +-- .../src/versions/vm_boojum_integration/vm.rs | 3 +-- .../src/versions/vm_fast/tests/bootloader.rs | 20 +++++++++++-------- .../vm_fast/tests/bytecode_publishing.rs | 3 ++- .../src/versions/vm_fast/tests/default_aa.rs | 3 ++- .../src/versions/vm_fast/tests/refunds.rs | 20 ++++++++++++------- .../src/versions/vm_fast/tests/sekp256r1.rs | 10 +++++----- .../vm_fast/tests/simple_execution.rs | 5 ++++- .../tests/tester/transaction_test_info.rs | 3 ++- .../src/versions/vm_fast/tests/transfer.rs | 16 ++++++++++----- core/lib/multivm/src/versions/vm_fast/vm.rs | 3 +-- .../vm_latest/bootloader_state/state.rs | 9 +++------ .../vm_latest/bootloader_state/utils.rs | 6 ++---- .../src/versions/vm_latest/tests/block_tip.rs | 7 +++++-- .../versions/vm_latest/tests/bootloader.rs | 12 ++++++----- .../vm_latest/tests/bytecode_publishing.rs | 3 ++- .../versions/vm_latest/tests/default_aa.rs | 3 ++- .../vm_latest/tests/prestate_tracer.rs | 2 +- .../src/versions/vm_latest/tests/refunds.rs | 20 ++++++++++++++----- .../src/versions/vm_latest/tests/sekp256r1.rs | 10 ++++++---- .../vm_latest/tests/simple_execution.rs | 5 ++++- .../tests/tester/transaction_test_info.rs | 3 ++- .../vm_latest/tests/tester/vm_tester.rs | 3 +-- .../src/versions/vm_latest/tests/transfer.rs | 15 ++++++++++---- .../vm_latest/tracers/pubdata_tracer.rs | 8 ++++---- core/lib/multivm/src/versions/vm_latest/vm.rs | 10 ++++------ core/lib/multivm/src/versions/vm_m5/vm.rs | 3 +-- core/lib/multivm/src/versions/vm_m6/vm.rs | 3 +-- .../src/versions/vm_refunds_enhancement/vm.rs | 3 +-- .../src/versions/vm_virtual_blocks/vm.rs | 3 +-- core/lib/multivm/src/vm_instance.rs | 3 +-- core/lib/tee_verifier/src/lib.rs | 6 +++--- core/lib/vm_executor/src/batch/factory.rs | 6 ++---- core/lib/vm_executor/src/oneshot/mod.rs | 6 +++--- core/tests/vm-benchmark/src/vm.rs | 3 +-- 45 files changed, 162 insertions(+), 126 deletions(-) diff --git a/core/bin/system-constants-generator/src/utils.rs b/core/bin/system-constants-generator/src/utils.rs index 1c4e2691c681..cc39fa2d6980 100644 --- a/core/bin/system-constants-generator/src/utils.rs +++ b/core/bin/system-constants-generator/src/utils.rs @@ -5,12 +5,12 @@ use zksync_contracts::{ load_sys_contract, read_bootloader_code, read_bytecode_from_path, read_sys_contract_bytecode, read_zbin_bytecode, BaseSystemContracts, ContractLanguage, SystemContractCode, }; -use zksync_multivm::interface::InspectExecutionMode; use zksync_multivm::{ interface::{ storage::{InMemoryStorage, StorageView, WriteStorage}, tracer::VmExecutionStopReason, - L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmFactory, VmInterface, VmInterfaceExt, + InspectExecutionMode, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmFactory, + VmInterface, VmInterfaceExt, }, tracers::dynamic::vm_1_5_0::DynTracer, vm_latest::{ diff --git a/core/lib/multivm/src/dump.rs b/core/lib/multivm/src/dump.rs index 63bb017a4634..c170d1a0a2b7 100644 --- a/core/lib/multivm/src/dump.rs +++ b/core/lib/multivm/src/dump.rs @@ -1,7 +1,11 @@ -use crate::interface::storage::{StoragePtr, StorageSnapshot, StorageView}; -use crate::interface::utils::VmDump; -use crate::interface::{L1BatchEnv, L2BlockEnv, SystemEnv, VmFactory, VmInterface, VmInterfaceExt}; -use crate::pubdata_builders::pubdata_params_to_builder; +use crate::{ + interface::{ + storage::{StoragePtr, StorageSnapshot, StorageView}, + utils::VmDump, + L1BatchEnv, L2BlockEnv, SystemEnv, VmFactory, VmInterface, VmInterfaceExt, + }, + pubdata_builders::pubdata_params_to_builder, +}; /// Plays back dump on the specified VM. pub fn play_back_dump(dump: VmDump) -> Vm diff --git a/core/lib/multivm/src/pubdata_builders/mod.rs b/core/lib/multivm/src/pubdata_builders/mod.rs index d9fb0c87d273..c52c4c70c86a 100644 --- a/core/lib/multivm/src/pubdata_builders/mod.rs +++ b/core/lib/multivm/src/pubdata_builders/mod.rs @@ -1,9 +1,10 @@ -use crate::interface::pubdata::PubdataBuilder; use std::rc::Rc; -use zksync_types::commitment::{L1BatchCommitmentMode, PubdataParams}; pub use rollup::RollupPubdataBuilder; pub use validium::ValidiumPubdataBuilder; +use zksync_types::commitment::{L1BatchCommitmentMode, PubdataParams}; + +use crate::interface::pubdata::PubdataBuilder; mod rollup; #[cfg(test)] diff --git a/core/lib/multivm/src/pubdata_builders/rollup.rs b/core/lib/multivm/src/pubdata_builders/rollup.rs index 3d91585ed7e4..e395bf65ce46 100644 --- a/core/lib/multivm/src/pubdata_builders/rollup.rs +++ b/core/lib/multivm/src/pubdata_builders/rollup.rs @@ -1,4 +1,3 @@ -use crate::interface::pubdata::{PubdataBuilder, PubdataInput}; use zksync_types::{ commitment::{L1BatchCommitmentMode, PubdataParams}, ethabi, @@ -12,6 +11,7 @@ use super::utils::{ build_chained_bytecode_hash, build_chained_log_hash, build_chained_message_hash, build_logs_root, encode_user_logs, }; +use crate::interface::pubdata::{PubdataBuilder, PubdataInput}; #[derive(Debug, Clone, Copy)] pub struct RollupPubdataBuilder { diff --git a/core/lib/multivm/src/pubdata_builders/tests.rs b/core/lib/multivm/src/pubdata_builders/tests.rs index dfcde027f9e1..bc24b8e47346 100644 --- a/core/lib/multivm/src/pubdata_builders/tests.rs +++ b/core/lib/multivm/src/pubdata_builders/tests.rs @@ -1,4 +1,3 @@ -use crate::interface::pubdata::{L1MessengerL2ToL1Log, PubdataBuilder, PubdataInput}; use zksync_types::{ writes::StateDiffRecord, Address, ProtocolVersionId, ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS, @@ -6,6 +5,7 @@ use zksync_types::{ use zksync_utils::u256_to_h256; use super::{rollup::RollupPubdataBuilder, validium::ValidiumPubdataBuilder}; +use crate::interface::pubdata::{L1MessengerL2ToL1Log, PubdataBuilder, PubdataInput}; fn mock_input() -> PubdataInput { // Just using some constant addresses for tests diff --git a/core/lib/multivm/src/pubdata_builders/validium.rs b/core/lib/multivm/src/pubdata_builders/validium.rs index 7fb5f2a046a1..f367d81fd645 100644 --- a/core/lib/multivm/src/pubdata_builders/validium.rs +++ b/core/lib/multivm/src/pubdata_builders/validium.rs @@ -1,8 +1,3 @@ -use super::utils::{ - build_chained_bytecode_hash, build_chained_log_hash, build_chained_message_hash, - build_logs_root, encode_user_logs, -}; -use crate::interface::pubdata::{PubdataBuilder, PubdataInput}; use zksync_types::{ commitment::{L1BatchCommitmentMode, PubdataParams}, ethabi, @@ -12,6 +7,12 @@ use zksync_types::{ Address, ProtocolVersionId, }; +use super::utils::{ + build_chained_bytecode_hash, build_chained_log_hash, build_chained_message_hash, + build_logs_root, encode_user_logs, +}; +use crate::interface::pubdata::{PubdataBuilder, PubdataInput}; + #[derive(Debug, Clone, Copy)] pub struct ValidiumPubdataBuilder { pub l2_da_validator: Address, diff --git a/core/lib/multivm/src/versions/testonly.rs b/core/lib/multivm/src/versions/testonly.rs index e38fa6e3960b..c05cdd9e60af 100644 --- a/core/lib/multivm/src/versions/testonly.rs +++ b/core/lib/multivm/src/versions/testonly.rs @@ -9,12 +9,12 @@ use zksync_types::{ }; use zksync_utils::{bytecode::hash_bytecode, u256_to_h256}; -use crate::pubdata_builders::RollupPubdataBuilder; use crate::{ interface::{ pubdata::PubdataBuilder, storage::InMemoryStorage, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, }, + pubdata_builders::RollupPubdataBuilder, vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT, }; diff --git a/core/lib/multivm/src/versions/tests.rs b/core/lib/multivm/src/versions/tests.rs index f2978908d595..ad4b7da5c727 100644 --- a/core/lib/multivm/src/versions/tests.rs +++ b/core/lib/multivm/src/versions/tests.rs @@ -3,7 +3,6 @@ use assert_matches::assert_matches; use ethabi::Contract; -use std::rc::Rc; use zksync_contracts::{ get_loadnext_contract, load_contract, read_bytecode, test_contracts::LoadnextContractExecutionParams, @@ -15,8 +14,8 @@ use zksync_types::{ }; use zksync_utils::bytecode::hash_bytecode; -use crate::dump::{play_back_dump, play_back_dump_custom}; use crate::{ + dump::{play_back_dump, play_back_dump_custom}, interface::{ storage::{InMemoryStorage, ReadStorage, StorageView}, utils::{ShadowVm, VmDump}, diff --git a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs index 7b3a30f396bd..057aa6df455e 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs @@ -2,8 +2,7 @@ use std::{collections::HashSet, rc::Rc}; use zksync_types::Transaction; use zksync_utils::{bytecode::hash_bytecode, h256_to_u256}; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use crate::{ glue::{history_mode::HistoryMode, GlueInto}, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs index 1fea9e1a5a23..447a7d1dccb2 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs @@ -5,8 +5,7 @@ use zksync_types::{ l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, Transaction, }; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use crate::{ glue::GlueInto, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs index b2a6183fe7f1..b447a361a65b 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs @@ -5,8 +5,7 @@ use zksync_types::{ l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, Transaction, }; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use crate::{ glue::GlueInto, diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs index 6f85ddf5f8c1..9f641c467a5d 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs @@ -5,8 +5,7 @@ use zksync_types::{ l2_to_l1_log::{SystemL2ToL1Log, UserL2ToL1Log}, Transaction, }; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use crate::{ glue::GlueInto, diff --git a/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs b/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs index 4e7cb97d473f..18bac60560eb 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs @@ -1,12 +1,16 @@ use assert_matches::assert_matches; use zksync_types::U256; use zksync_vm2::interface::HeapId; +use zksync_vm_interface::VmInterface; use crate::{ - interface::{ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, VmInterfaceExt}, - versions::vm_fast::tests::{ - tester::VmTesterBuilder, - utils::{get_bootloader, verify_required_memory, BASE_SYSTEM_CONTRACTS}, + interface::{ExecutionResult, Halt, TxExecutionMode}, + versions::{ + testonly::default_pubdata_builder, + vm_fast::tests::{ + tester::VmTesterBuilder, + utils::{get_bootloader, verify_required_memory, BASE_SYSTEM_CONTRACTS}, + }, }, }; @@ -21,8 +25,8 @@ fn test_dummy_bootloader() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let result = vm.vm.execute(InspectExecutionMode::Batch); - assert!(!result.result.is_failed()); + let result = vm.vm.finish_batch(Some(default_pubdata_builder())); + assert!(!result.block_tip_execution_result.result.is_failed()); let correct_first_cell = U256::from_str_radix("123123123", 16).unwrap(); @@ -41,10 +45,10 @@ fn test_bootloader_out_of_gas() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let res = vm.vm.execute(InspectExecutionMode::Batch); + let res = vm.vm.finish_batch(Some(default_pubdata_builder())); assert_matches!( - res.result, + res.block_tip_execution_result.result, ExecutionResult::Halt { reason: Halt::BootloaderOutOfGas } diff --git a/core/lib/multivm/src/versions/vm_fast/tests/bytecode_publishing.rs b/core/lib/multivm/src/versions/vm_fast/tests/bytecode_publishing.rs index 5efef2b63b95..d85069f34204 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/bytecode_publishing.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/bytecode_publishing.rs @@ -1,6 +1,7 @@ use crate::{ interface::{InspectExecutionMode, TxExecutionMode, VmEvent, VmInterface, VmInterfaceExt}, utils::bytecode, + versions::testonly::default_pubdata_builder, vm_fast::tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, utils::read_test_contract, @@ -27,7 +28,7 @@ fn test_bytecode_publishing() { let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.execute(InspectExecutionMode::Batch); + vm.vm.finish_batch(Some(default_pubdata_builder())); let state = vm.vm.get_current_execution_state(); let long_messages = VmEvent::extract_long_l2_to_l1_messages(&state.events); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/default_aa.rs b/core/lib/multivm/src/versions/vm_fast/tests/default_aa.rs index 6ffd8939c8f7..7f62ef50cf3f 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/default_aa.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/default_aa.rs @@ -8,6 +8,7 @@ use zksync_utils::u256_to_h256; use crate::{ interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, + versions::testonly::default_pubdata_builder, vm_fast::tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, utils::{get_balance, read_test_contract, verify_required_storage}, @@ -38,7 +39,7 @@ fn test_default_aa_interaction() { let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.execute(InspectExecutionMode::Batch); + vm.vm.finish_batch(Some(default_pubdata_builder())); vm.vm.get_current_execution_state(); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/refunds.rs b/core/lib/multivm/src/versions/vm_fast/tests/refunds.rs index 1e691af1e5d8..fe7baf7d0231 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/refunds.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/refunds.rs @@ -3,7 +3,7 @@ use zksync_types::{Address, Execute, U256}; use crate::{ interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, - versions::testonly::ContractToDeploy, + versions::testonly::{default_pubdata_builder, ContractToDeploy}, vm_fast::tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, utils::{read_expensive_contract, read_test_contract}, @@ -44,9 +44,12 @@ fn test_predetermined_refunded_gas() { ); assert!(result.refunds.gas_refunded > 0, "The final refund is 0"); - let result_without_predefined_refunds = vm.vm.execute(InspectExecutionMode::Batch); + let result_without_predefined_refunds = vm.vm.finish_batch(Some(default_pubdata_builder())); let mut current_state_without_predefined_refunds = vm.vm.get_current_execution_state(); - assert!(!result_without_predefined_refunds.result.is_failed(),); + assert!(!result_without_predefined_refunds + .block_tip_execution_result + .result + .is_failed()); // Here we want to provide the same refund from the operator and check that it's the correct one. // We execute the whole block without refund tracer, because refund tracer will eventually override the provided refund. @@ -62,10 +65,13 @@ fn test_predetermined_refunded_gas() { vm.vm .push_transaction_inner(tx.clone(), result.refunds.gas_refunded, true); - let result_with_predefined_refunds = vm.vm.execute(InspectExecutionMode::Batch); + let result_with_predefined_refunds = vm.vm.finish_batch(Some(default_pubdata_builder())); let mut current_state_with_predefined_refunds = vm.vm.get_current_execution_state(); - assert!(!result_with_predefined_refunds.result.is_failed()); + assert!(!result_with_predefined_refunds + .block_tip_execution_result + .result + .is_failed()); // We need to sort these lists as those are flattened from HashMaps current_state_with_predefined_refunds @@ -112,10 +118,10 @@ fn test_predetermined_refunded_gas() { let changed_operator_suggested_refund = result.refunds.gas_refunded + 1000; vm.vm .push_transaction_inner(tx, changed_operator_suggested_refund, true); - let result = vm.vm.execute(InspectExecutionMode::Batch); + let result = vm.vm.finish_batch(Some(default_pubdata_builder())); let mut current_state_with_changed_predefined_refunds = vm.vm.get_current_execution_state(); - assert!(!result.result.is_failed()); + assert!(!result.block_tip_execution_result.result.is_failed()); current_state_with_changed_predefined_refunds .used_contract_hashes .sort(); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs b/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs index f4bc95fe2a31..2bfdcbb13ed5 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs @@ -4,9 +4,8 @@ use zksync_types::{web3::keccak256, Execute, H256, U256}; use zksync_utils::h256_to_u256; use crate::{ - interface::{ - ExecutionResult, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, - }, + interface::{ExecutionResult, TxExecutionMode, VmInterface}, + versions::testonly::default_pubdata_builder, vm_fast::tests::tester::VmTesterBuilder, }; @@ -60,9 +59,10 @@ fn test_sekp256r1() { vm.vm.push_transaction(tx); - let execution_result = vm.vm.execute(InspectExecutionMode::Batch); + let execution_result = vm.vm.finish_batch(Some(default_pubdata_builder())); - let ExecutionResult::Success { output } = execution_result.result else { + let ExecutionResult::Success { output } = execution_result.block_tip_execution_result.result + else { panic!("batch failed") }; diff --git a/core/lib/multivm/src/versions/vm_fast/tests/simple_execution.rs b/core/lib/multivm/src/versions/vm_fast/tests/simple_execution.rs index aea766752eb7..13d42f7bd0df 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/simple_execution.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/simple_execution.rs @@ -2,6 +2,7 @@ use assert_matches::assert_matches; use crate::{ interface::{ExecutionResult, InspectExecutionMode, VmInterface, VmInterfaceExt}, + versions::testonly::default_pubdata_builder, vm_fast::tests::tester::{TxType, VmTesterBuilder}, }; @@ -75,6 +76,8 @@ fn simple_execute() { assert_matches!(tx.result, ExecutionResult::Revert { .. }); let tx = vm.execute(InspectExecutionMode::OneTx); assert_matches!(tx.result, ExecutionResult::Success { .. }); - let block_tip = vm.execute(InspectExecutionMode::Batch); + let block_tip = vm + .finish_batch(Some(default_pubdata_builder())) + .block_tip_execution_result; assert_matches!(block_tip.result, ExecutionResult::Success { .. }); } diff --git a/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs b/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs index 918ff6e4182b..e6d81b04e45f 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/tester/transaction_test_info.rs @@ -8,6 +8,7 @@ use crate::{ TxRevertReason, VmExecutionResultAndLogs, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, VmRevertReason, }, + versions::testonly::default_pubdata_builder, vm_fast::Vm, }; @@ -209,7 +210,7 @@ impl VmTester<()> { for tx_test_info in txs { self.execute_tx_and_verify(tx_test_info.clone()); } - self.vm.execute(InspectExecutionMode::Batch); + self.vm.finish_batch(Some(default_pubdata_builder())); let mut state = self.vm.get_current_execution_state(); state.used_contract_hashes.sort(); state diff --git a/core/lib/multivm/src/versions/vm_fast/tests/transfer.rs b/core/lib/multivm/src/versions/vm_fast/tests/transfer.rs index 4b394a186cf4..9a246a3c3b13 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/transfer.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/transfer.rs @@ -6,7 +6,7 @@ use zksync_utils::u256_to_h256; use crate::{ interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, - versions::testonly::ContractToDeploy, + versions::testonly::{default_pubdata_builder, ContractToDeploy}, vm_fast::tests::{ tester::{get_empty_storage, VmTesterBuilder}, utils::get_balance, @@ -86,8 +86,11 @@ fn test_send_or_transfer(test_option: TestOptions) { "Transaction wasn't successful" ); - let batch_result = vm.vm.execute(InspectExecutionMode::Batch); - assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); + let batch_result = vm.vm.finish_batch(Some(default_pubdata_builder())); + assert!( + !batch_result.block_tip_execution_result.result.is_failed(), + "Batch wasn't successful" + ); let new_recipient_balance = get_balance( AccountTreeId::new(L2_BASE_TOKEN_ADDRESS), @@ -200,8 +203,11 @@ fn test_reentrancy_protection_send_or_transfer(test_option: TestOptions) { "Transaction 2 should have failed, but it succeeded" ); - let batch_result = vm.vm.execute(InspectExecutionMode::Batch); - assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); + let batch_result = vm.vm.finish_batch(Some(default_pubdata_builder())); + assert!( + !batch_result.block_tip_execution_result.result.is_failed(), + "Batch wasn't successful" + ); } #[test] diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index 147245e436e5..0c027c88c2a8 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -21,8 +21,7 @@ use zksync_vm2::{ interface::{CallframeInterface, HeapId, StateInterface, Tracer}, ExecutionEnd, FatPointer, Program, Settings, StorageSlot, VirtualMachine, }; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use super::{ bootloader_state::{BootloaderState, BootloaderStateSnapshot}, diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs index 99013f98d5d3..2085bbaba31f 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/state.rs @@ -1,4 +1,4 @@ -use std::{cmp::Ordering, rc::Rc}; +use std::cmp::Ordering; use once_cell::sync::OnceCell; use zksync_types::{L2ChainId, ProtocolVersionId, U256}; @@ -150,10 +150,7 @@ impl BootloaderState { .expect("Pubdata information is not set") } - pub(crate) fn settlement_layer_pubdata( - &self, - pubdata_builder: Rc, - ) -> Vec { + pub(crate) fn settlement_layer_pubdata(&self, pubdata_builder: &dyn PubdataBuilder) -> Vec { let pubdata_information = self .pubdata_information .get() @@ -169,7 +166,7 @@ impl BootloaderState { /// Apply all bootloader transaction to the initial memory pub(crate) fn bootloader_memory( &self, - pubdata_builder: Rc, + pubdata_builder: &dyn PubdataBuilder, ) -> BootloaderMemory { let mut initial_memory = self.initial_memory.clone(); let mut offset = 0; diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs index 3d0bff33f080..c409bda35c1d 100644 --- a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs +++ b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs @@ -1,5 +1,3 @@ -use std::rc::Rc; - use zksync_types::{ethabi, ProtocolVersionId, U256}; use zksync_utils::{bytes_to_be_words, h256_to_u256}; @@ -129,7 +127,7 @@ fn apply_l2_block_inner( } fn bootloader_memory_input( - pubdata_builder: Rc, + pubdata_builder: &dyn PubdataBuilder, input: &PubdataInput, protocol_version: ProtocolVersionId, ) -> Vec { @@ -144,7 +142,7 @@ fn bootloader_memory_input( pub(crate) fn apply_pubdata_to_memory( memory: &mut BootloaderMemory, - pubdata_builder: Rc, + pubdata_builder: &dyn PubdataBuilder, pubdata_information: &PubdataInput, protocol_version: ProtocolVersionId, ) { diff --git a/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs b/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs index 016334a6acbb..b99bd4aadd60 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/block_tip.rs @@ -12,10 +12,12 @@ use zksync_types::{ l2_to_l1_log::L2ToL1Log, writes::StateDiffRecord, Address, Execute, H256, U256, }; use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u256_to_h256}; +use zksync_vm_interface::VmExecutionMode; use super::utils::{get_complex_upgrade_abi, read_complex_upgrade}; use crate::{ interface::{InspectExecutionMode, L1BatchEnv, TxExecutionMode, VmInterface, VmInterfaceExt}, + versions::testonly::default_pubdata_builder, vm_latest::{ constants::{ BOOTLOADER_BATCH_TIP_CIRCUIT_STATISTICS_OVERHEAD, @@ -190,14 +192,15 @@ fn execute_test(test_data: L1MessengerTestData) -> TestStatistics { // We ensure that indeed the provided state diffs are used let pubdata_tracer = PubdataTracer::::new_with_forced_state_diffs( vm.vm.batch_env.clone(), - InspectExecutionMode::Batch, + VmExecutionMode::Batch, test_data.state_diffs.clone(), crate::vm_latest::MultiVMSubversion::latest(), + Some(default_pubdata_builder()), ); let result = vm.vm.inspect_inner( &mut TracerDispatcher::default(), - InspectExecutionMode::Batch, + VmExecutionMode::Batch, Some(pubdata_tracer), ); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs b/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs index 9a2a72c04124..91ed23cc1778 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs @@ -1,8 +1,10 @@ use assert_matches::assert_matches; use zksync_types::U256; +use zksync_vm_interface::VmInterface; use crate::{ - interface::{ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, VmInterfaceExt}, + interface::{ExecutionResult, Halt, TxExecutionMode}, + versions::testonly::default_pubdata_builder, vm_latest::{ constants::BOOTLOADER_HEAP_PAGE, tests::{ @@ -24,8 +26,8 @@ fn test_dummy_bootloader() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let result = vm.vm.execute(InspectExecutionMode::Batch); - assert!(!result.result.is_failed()); + let result = vm.vm.finish_batch(Some(default_pubdata_builder())); + assert!(!result.block_tip_execution_result.result.is_failed()); let correct_first_cell = U256::from_str_radix("123123123", 16).unwrap(); verify_required_memory( @@ -46,10 +48,10 @@ fn test_bootloader_out_of_gas() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let res = vm.vm.execute(InspectExecutionMode::Batch); + let res = vm.vm.finish_batch(Some(default_pubdata_builder())); assert_matches!( - res.result, + res.block_tip_execution_result.result, ExecutionResult::Halt { reason: Halt::BootloaderOutOfGas } diff --git a/core/lib/multivm/src/versions/vm_latest/tests/bytecode_publishing.rs b/core/lib/multivm/src/versions/vm_latest/tests/bytecode_publishing.rs index 93dc7d47bf17..f5e2e29d6133 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/bytecode_publishing.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/bytecode_publishing.rs @@ -1,6 +1,7 @@ use crate::{ interface::{InspectExecutionMode, TxExecutionMode, VmEvent, VmInterface, VmInterfaceExt}, utils::bytecode, + versions::testonly::default_pubdata_builder, vm_latest::{ tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, @@ -30,7 +31,7 @@ fn test_bytecode_publishing() { let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.execute(InspectExecutionMode::Batch); + vm.vm.finish_batch(Some(default_pubdata_builder())); let state = vm.vm.get_current_execution_state(); let long_messages = VmEvent::extract_long_l2_to_l1_messages(&state.events); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/default_aa.rs b/core/lib/multivm/src/versions/vm_latest/tests/default_aa.rs index cc2a7b0911a1..e3d52682270b 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/default_aa.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/default_aa.rs @@ -8,6 +8,7 @@ use zksync_utils::u256_to_h256; use crate::{ interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, + versions::testonly::default_pubdata_builder, vm_latest::{ tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, @@ -41,7 +42,7 @@ fn test_default_aa_interaction() { let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.execute(InspectExecutionMode::Batch); + vm.vm.finish_batch(Some(default_pubdata_builder())); vm.vm.get_current_execution_state(); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/prestate_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tests/prestate_tracer.rs index cea0c4c7e35d..3116022b4d57 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/prestate_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/prestate_tracer.rs @@ -41,7 +41,7 @@ fn test_prestate_tracer() { let prestate_tracer = PrestateTracer::new(false, prestate_tracer_result.clone()); let tracer_ptr = prestate_tracer.into_tracer_pointer(); vm.vm - .inspect(&mut tracer_ptr.into(), InspectExecutionMode::Batch); + .inspect(&mut tracer_ptr.into(), InspectExecutionMode::OneTx); let prestate_result = Arc::try_unwrap(prestate_tracer_result) .unwrap() diff --git a/core/lib/multivm/src/versions/vm_latest/tests/refunds.rs b/core/lib/multivm/src/versions/vm_latest/tests/refunds.rs index 7785a3c46cf4..2c816afd206e 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/refunds.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/refunds.rs @@ -3,6 +3,7 @@ use zksync_types::{Address, Execute, U256}; use crate::{ interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, + versions::testonly::default_pubdata_builder, vm_latest::{ tests::{ tester::{DeployContractsTx, TxType, VmTesterBuilder}, @@ -47,9 +48,12 @@ fn test_predetermined_refunded_gas() { ); assert!(result.refunds.gas_refunded > 0, "The final refund is 0"); - let result_without_predefined_refunds = vm.vm.execute(InspectExecutionMode::Batch); + let result_without_predefined_refunds = vm.vm.finish_batch(Some(default_pubdata_builder())); let mut current_state_without_predefined_refunds = vm.vm.get_current_execution_state(); - assert!(!result_without_predefined_refunds.result.is_failed(),); + assert!(!result_without_predefined_refunds + .block_tip_execution_result + .result + .is_failed()); // Here we want to provide the same refund from the operator and check that it's the correct one. // We execute the whole block without refund tracer, because refund tracer will eventually override the provided refund. @@ -68,10 +72,13 @@ fn test_predetermined_refunded_gas() { vm.vm .push_raw_transaction(tx.clone(), overhead, result.refunds.gas_refunded, true); - let result_with_predefined_refunds = vm.vm.execute(InspectExecutionMode::Batch); + let result_with_predefined_refunds = vm.vm.finish_batch(Some(default_pubdata_builder())); let mut current_state_with_predefined_refunds = vm.vm.get_current_execution_state(); - assert!(!result_with_predefined_refunds.result.is_failed()); + assert!(!result_with_predefined_refunds + .block_tip_execution_result + .result + .is_failed()); // We need to sort these lists as those are flattened from HashMaps current_state_with_predefined_refunds @@ -118,7 +125,10 @@ fn test_predetermined_refunded_gas() { let changed_operator_suggested_refund = result.refunds.gas_refunded + 1000; vm.vm .push_raw_transaction(tx, overhead, changed_operator_suggested_refund, true); - let result = vm.vm.execute(InspectExecutionMode::Batch); + let result = vm + .vm + .finish_batch(Some(default_pubdata_builder())) + .block_tip_execution_result; let mut current_state_with_changed_predefined_refunds = vm.vm.get_current_execution_state(); assert!(!result.result.is_failed()); diff --git a/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs b/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs index dcb868dec0a2..df11619edfb2 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs @@ -4,9 +4,8 @@ use zksync_types::{web3::keccak256, Execute, H256, U256}; use zksync_utils::h256_to_u256; use crate::{ - interface::{ - ExecutionResult, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, - }, + interface::{ExecutionResult, TxExecutionMode, VmInterface}, + versions::testonly::default_pubdata_builder, vm_latest::{tests::tester::VmTesterBuilder, HistoryEnabled}, }; @@ -60,7 +59,10 @@ fn test_sekp256r1() { vm.vm.push_transaction(tx); - let execution_result = vm.vm.execute(InspectExecutionMode::Batch); + let execution_result = vm + .vm + .finish_batch(Some(default_pubdata_builder())) + .block_tip_execution_result; let ExecutionResult::Success { output } = execution_result.result else { panic!("batch failed") diff --git a/core/lib/multivm/src/versions/vm_latest/tests/simple_execution.rs b/core/lib/multivm/src/versions/vm_latest/tests/simple_execution.rs index c5d47cc7694c..f63c18addee9 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/simple_execution.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/simple_execution.rs @@ -2,6 +2,7 @@ use assert_matches::assert_matches; use crate::{ interface::{ExecutionResult, InspectExecutionMode, VmInterface, VmInterfaceExt}, + versions::testonly::default_pubdata_builder, vm_latest::{ tests::tester::{TxType, VmTesterBuilder}, HistoryDisabled, @@ -78,6 +79,8 @@ fn simple_execute() { assert_matches!(tx.result, ExecutionResult::Revert { .. }); let tx = vm.execute(InspectExecutionMode::OneTx); assert_matches!(tx.result, ExecutionResult::Success { .. }); - let block_tip = vm.execute(InspectExecutionMode::Batch); + let block_tip = vm + .finish_batch(Some(default_pubdata_builder())) + .block_tip_execution_result; assert_matches!(block_tip.result, ExecutionResult::Success { .. }); } diff --git a/core/lib/multivm/src/versions/vm_latest/tests/tester/transaction_test_info.rs b/core/lib/multivm/src/versions/vm_latest/tests/tester/transaction_test_info.rs index b0928a11d22a..02efb1d3f4ee 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/tester/transaction_test_info.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/tester/transaction_test_info.rs @@ -6,6 +6,7 @@ use crate::{ VmExecutionResultAndLogs, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, VmRevertReason, }, + versions::testonly::default_pubdata_builder, vm_latest::{tests::tester::vm_tester::VmTester, HistoryEnabled}, }; @@ -184,7 +185,7 @@ impl VmTester { for tx_test_info in txs { self.execute_tx_and_verify(tx_test_info.clone()); } - self.vm.execute(InspectExecutionMode::Batch); + self.vm.finish_batch(Some(default_pubdata_builder())); let mut state = self.vm.get_current_execution_state(); state.used_contract_hashes.sort(); state diff --git a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs index 95c07e20782b..6267cbf3c076 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/tester/vm_tester.rs @@ -1,4 +1,4 @@ -use std::{marker::PhantomData, rc::Rc}; +use std::marker::PhantomData; use zksync_contracts::BaseSystemContracts; use zksync_types::{ @@ -10,7 +10,6 @@ use zksync_types::{ Address, L1BatchNumber, L2BlockNumber, L2ChainId, Nonce, ProtocolVersionId, U256, }; use zksync_utils::{bytecode::hash_bytecode, u256_to_h256}; -use zksync_vm_interface::pubdata::PubdataBuilder; use crate::{ interface::{ diff --git a/core/lib/multivm/src/versions/vm_latest/tests/transfer.rs b/core/lib/multivm/src/versions/vm_latest/tests/transfer.rs index 4b22f45be8f8..e3c352ef6ff3 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/transfer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/transfer.rs @@ -6,6 +6,7 @@ use zksync_utils::u256_to_h256; use crate::{ interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt}, + versions::testonly::default_pubdata_builder, vm_latest::{ tests::{ tester::{get_empty_storage, VmTesterBuilder}, @@ -88,8 +89,11 @@ fn test_send_or_transfer(test_option: TestOptions) { "Transaction wasn't successful" ); - let batch_result = vm.vm.execute(InspectExecutionMode::Batch); - assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); + let batch_result = vm.vm.finish_batch(Some(default_pubdata_builder())); + assert!( + !batch_result.block_tip_execution_result.result.is_failed(), + "Batch wasn't successful" + ); let new_recipient_balance = get_balance( AccountTreeId::new(L2_BASE_TOKEN_ADDRESS), @@ -205,8 +209,11 @@ fn test_reentrancy_protection_send_or_transfer(test_option: TestOptions) { "Transaction 2 should have failed, but it succeeded" ); - let batch_result = vm.vm.execute(InspectExecutionMode::Batch); - assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); + let batch_result = vm.vm.finish_batch(Some(default_pubdata_builder())); + assert!( + !batch_result.block_tip_execution_result.result.is_failed(), + "Batch wasn't successful" + ); } #[test] diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs index 0440d7fe82ba..998e8a13ad25 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs @@ -1,5 +1,4 @@ -use std::marker::PhantomData; -use std::rc::Rc; +use std::{marker::PhantomData, rc::Rc}; use circuit_sequencer_api_1_5_0::sort_storage_access::sort_storage_access_queries; use zk_evm_1_5_0::{ @@ -235,8 +234,9 @@ impl VmTracer for PubdataTracer { apply_pubdata_to_memory( &mut memory_to_apply, self.pubdata_builder - .clone() - .expect("`pubdata_builder` is required to finish batch"), + .as_ref() + .expect("`pubdata_builder` is required to finish batch") + .as_ref(), &pubdata_input, bootloader_state.protocol_version(), ); diff --git a/core/lib/multivm/src/versions/vm_latest/vm.rs b/core/lib/multivm/src/versions/vm_latest/vm.rs index b63a9adb380a..dbc18f5eb0f9 100644 --- a/core/lib/multivm/src/versions/vm_latest/vm.rs +++ b/core/lib/multivm/src/versions/vm_latest/vm.rs @@ -7,10 +7,8 @@ use zksync_types::{ Transaction, H256, }; use zksync_utils::{be_words_to_bytes, h256_to_u256, u256_to_h256}; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; -use crate::vm_latest::tracers::PubdataTracer; use crate::{ glue::GlueInto, interface::{ @@ -24,7 +22,7 @@ use crate::{ vm_latest::{ bootloader_state::BootloaderState, old_vm::{events::merge_events, history_recorder::HistoryEnabled}, - tracers::dispatcher::TracerDispatcher, + tracers::{dispatcher::TracerDispatcher, PubdataTracer}, types::internals::{new_vm_state, VmSnapshot, ZkSyncVmState}, }, HistoryMode, @@ -200,14 +198,14 @@ impl VmInterface for Vm { let execution_state = self.get_current_execution_state(); let bootloader_memory = self .bootloader_state - .bootloader_memory(pubdata_builder.clone()); + .bootloader_memory(pubdata_builder.as_ref()); FinishedL1Batch { block_tip_execution_result: result, final_execution_state: execution_state, final_bootloader_memory: Some(bootloader_memory), pubdata_input: Some( self.bootloader_state - .settlement_layer_pubdata(pubdata_builder), + .settlement_layer_pubdata(pubdata_builder.as_ref()), ), state_diffs: Some( self.bootloader_state diff --git a/core/lib/multivm/src/versions/vm_m5/vm.rs b/core/lib/multivm/src/versions/vm_m5/vm.rs index 384aa5f3cb46..1e9fc52ac72f 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm.rs @@ -2,8 +2,7 @@ use std::rc::Rc; use zksync_types::{vm::VmVersion, Transaction}; use zksync_utils::h256_to_u256; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use crate::{ glue::{history_mode::HistoryMode, GlueInto}, diff --git a/core/lib/multivm/src/versions/vm_m6/vm.rs b/core/lib/multivm/src/versions/vm_m6/vm.rs index 50fd4fed4a4c..e299fdda27a8 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm.rs @@ -2,8 +2,7 @@ use std::{collections::HashSet, rc::Rc}; use zksync_types::{vm::VmVersion, Transaction}; use zksync_utils::{bytecode::hash_bytecode, h256_to_u256}; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use crate::{ glue::{history_mode::HistoryMode, GlueInto}, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs index 5fa51008078f..8627370683b7 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs @@ -2,8 +2,7 @@ use std::rc::Rc; use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; use zksync_types::{l2_to_l1_log::UserL2ToL1Log, Transaction}; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use crate::{ glue::GlueInto, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs index a21e838421be..108e10a1aa4e 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs @@ -2,8 +2,7 @@ use std::rc::Rc; use circuit_sequencer_api_1_3_3::sort_storage_access::sort_storage_access_queries; use zksync_types::{l2_to_l1_log::UserL2ToL1Log, Transaction}; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use crate::{ glue::GlueInto, diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs index 215283f05724..19130a022a5b 100644 --- a/core/lib/multivm/src/vm_instance.rs +++ b/core/lib/multivm/src/vm_instance.rs @@ -2,8 +2,7 @@ use std::{mem, rc::Rc}; use zksync_types::{vm::VmVersion, ProtocolVersionId, Transaction}; use zksync_vm2::interface::Tracer; -use zksync_vm_interface::pubdata::PubdataBuilder; -use zksync_vm_interface::InspectExecutionMode; +use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use crate::{ glue::history_mode::HistoryMode, diff --git a/core/lib/tee_verifier/src/lib.rs b/core/lib/tee_verifier/src/lib.rs index 088ba831eece..e12e9f611dfb 100644 --- a/core/lib/tee_verifier/src/lib.rs +++ b/core/lib/tee_verifier/src/lib.rs @@ -9,22 +9,22 @@ use zksync_crypto_primitives::hasher::blake2::Blake2Hasher; use zksync_merkle_tree::{ BlockOutputWithProofs, TreeInstruction, TreeLogEntry, TreeLogEntryWithProof, ValueHash, }; -use zksync_multivm::pubdata_builders::pubdata_params_to_builder; use zksync_multivm::{ interface::{ storage::{ReadStorage, StorageSnapshot, StorageView}, FinishedL1Batch, L2BlockEnv, VmFactory, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, }, + pubdata_builders::pubdata_params_to_builder, vm_latest::HistoryEnabled, LegacyVmInstance, }; use zksync_prover_interface::inputs::{ StorageLogMetadata, V1TeeVerifierInput, WitnessInputMerklePaths, }; -use zksync_types::commitment::PubdataParams; use zksync_types::{ - block::L2BlockExecutionData, L1BatchNumber, StorageLog, StorageValue, Transaction, H256, + block::L2BlockExecutionData, commitment::PubdataParams, L1BatchNumber, StorageLog, + StorageValue, Transaction, H256, }; use zksync_utils::u256_to_h256; diff --git a/core/lib/vm_executor/src/batch/factory.rs b/core/lib/vm_executor/src/batch/factory.rs index 1328e4371f68..75a35c91a42f 100644 --- a/core/lib/vm_executor/src/batch/factory.rs +++ b/core/lib/vm_executor/src/batch/factory.rs @@ -3,7 +3,6 @@ use std::{borrow::Cow, fmt, marker::PhantomData, rc::Rc, sync::Arc, time::Durati use anyhow::Context as _; use once_cell::sync::OnceCell; use tokio::sync::mpsc; -use zksync_multivm::pubdata_builders::pubdata_params_to_builder; use zksync_multivm::{ interface::{ executor::{BatchExecutor, BatchExecutorFactory}, @@ -15,6 +14,7 @@ use zksync_multivm::{ VmInterface, VmInterfaceHistoryEnabled, }, is_supported_by_fast_vm, + pubdata_builders::pubdata_params_to_builder, tracers::CallTracer, vm_fast, vm_latest::HistoryEnabled, @@ -466,9 +466,7 @@ impl CommandReceiver { #[cfg(test)] mod tests { use assert_matches::assert_matches; - use zksync_multivm::interface::{ - pubdata::rollup::RollupPubdataBuilder, storage::InMemoryStorage, TxExecutionMode, - }; + use zksync_multivm::interface::{storage::InMemoryStorage, TxExecutionMode}; use zksync_types::ProtocolVersionId; use super::*; diff --git a/core/lib/vm_executor/src/oneshot/mod.rs b/core/lib/vm_executor/src/oneshot/mod.rs index 7b1a5eb5165b..5f9e4dd3c6f4 100644 --- a/core/lib/vm_executor/src/oneshot/mod.rs +++ b/core/lib/vm_executor/src/oneshot/mod.rs @@ -14,14 +14,14 @@ use std::{ use anyhow::Context; use async_trait::async_trait; use once_cell::sync::OnceCell; -use zksync_multivm::interface::InspectExecutionMode; use zksync_multivm::{ interface::{ executor::{OneshotExecutor, TransactionValidator}, storage::{ReadStorage, StoragePtr, StorageView, WriteStorage}, tracer::{ValidationError, ValidationParams}, - ExecutionResult, OneshotEnv, OneshotTracingParams, OneshotTransactionExecutionResult, - StoredL2BlockEnv, TxExecutionArgs, TxExecutionMode, VmInterface, + ExecutionResult, InspectExecutionMode, OneshotEnv, OneshotTracingParams, + OneshotTransactionExecutionResult, StoredL2BlockEnv, TxExecutionArgs, TxExecutionMode, + VmInterface, }, tracers::{CallTracer, StorageInvocations, ValidationTracer}, utils::adjust_pubdata_price_for_tx, diff --git a/core/tests/vm-benchmark/src/vm.rs b/core/tests/vm-benchmark/src/vm.rs index bdc593716ba3..324085077d3c 100644 --- a/core/tests/vm-benchmark/src/vm.rs +++ b/core/tests/vm-benchmark/src/vm.rs @@ -2,11 +2,10 @@ use std::{cell::RefCell, rc::Rc}; use once_cell::sync::Lazy; use zksync_contracts::BaseSystemContracts; -use zksync_multivm::interface::InspectExecutionMode; use zksync_multivm::{ interface::{ storage::{InMemoryStorage, StorageView}, - ExecutionResult, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, + ExecutionResult, InspectExecutionMode, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled, }, From 26bb4388d3fdade5129f26c1b3ea851b0795c77c Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Fri, 18 Oct 2024 13:34:08 +0300 Subject: [PATCH 17/23] fix tests --- .../src/versions/vm_fast/tests/bootloader.rs | 20 +- .../src/versions/vm_fast/tests/sekp256r1.rs | 10 +- .../versions/vm_latest/tests/bootloader.rs | 12 +- .../src/versions/vm_latest/tests/sekp256r1.rs | 10 +- yarn.lock | 235 +++--------------- 5 files changed, 59 insertions(+), 228 deletions(-) diff --git a/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs b/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs index 18bac60560eb..0d0b077b811c 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/bootloader.rs @@ -1,16 +1,12 @@ use assert_matches::assert_matches; use zksync_types::U256; use zksync_vm2::interface::HeapId; -use zksync_vm_interface::VmInterface; use crate::{ - interface::{ExecutionResult, Halt, TxExecutionMode}, - versions::{ - testonly::default_pubdata_builder, - vm_fast::tests::{ - tester::VmTesterBuilder, - utils::{get_bootloader, verify_required_memory, BASE_SYSTEM_CONTRACTS}, - }, + interface::{ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, VmInterfaceExt}, + versions::vm_fast::tests::{ + tester::VmTesterBuilder, + utils::{get_bootloader, verify_required_memory, BASE_SYSTEM_CONTRACTS}, }, }; @@ -25,8 +21,8 @@ fn test_dummy_bootloader() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let result = vm.vm.finish_batch(Some(default_pubdata_builder())); - assert!(!result.block_tip_execution_result.result.is_failed()); + let result = vm.vm.execute(InspectExecutionMode::Bootloader); + assert!(!result.result.is_failed()); let correct_first_cell = U256::from_str_radix("123123123", 16).unwrap(); @@ -45,10 +41,10 @@ fn test_bootloader_out_of_gas() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let res = vm.vm.finish_batch(Some(default_pubdata_builder())); + let res = vm.vm.execute(InspectExecutionMode::Bootloader); assert_matches!( - res.block_tip_execution_result.result, + res.result, ExecutionResult::Halt { reason: Halt::BootloaderOutOfGas } diff --git a/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs b/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs index 2bfdcbb13ed5..3fe20cd92f3b 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/sekp256r1.rs @@ -4,8 +4,9 @@ use zksync_types::{web3::keccak256, Execute, H256, U256}; use zksync_utils::h256_to_u256; use crate::{ - interface::{ExecutionResult, TxExecutionMode, VmInterface}, - versions::testonly::default_pubdata_builder, + interface::{ + ExecutionResult, InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt, + }, vm_fast::tests::tester::VmTesterBuilder, }; @@ -59,10 +60,9 @@ fn test_sekp256r1() { vm.vm.push_transaction(tx); - let execution_result = vm.vm.finish_batch(Some(default_pubdata_builder())); + let execution_result = vm.vm.execute(InspectExecutionMode::OneTx); - let ExecutionResult::Success { output } = execution_result.block_tip_execution_result.result - else { + let ExecutionResult::Success { output } = execution_result.result else { panic!("batch failed") }; diff --git a/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs b/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs index 91ed23cc1778..d87a9b85d68b 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/bootloader.rs @@ -1,10 +1,8 @@ use assert_matches::assert_matches; use zksync_types::U256; -use zksync_vm_interface::VmInterface; use crate::{ - interface::{ExecutionResult, Halt, TxExecutionMode}, - versions::testonly::default_pubdata_builder, + interface::{ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, VmInterfaceExt}, vm_latest::{ constants::BOOTLOADER_HEAP_PAGE, tests::{ @@ -26,8 +24,8 @@ fn test_dummy_bootloader() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let result = vm.vm.finish_batch(Some(default_pubdata_builder())); - assert!(!result.block_tip_execution_result.result.is_failed()); + let result = vm.vm.execute(InspectExecutionMode::Bootloader); + assert!(!result.result.is_failed()); let correct_first_cell = U256::from_str_radix("123123123", 16).unwrap(); verify_required_memory( @@ -48,10 +46,10 @@ fn test_bootloader_out_of_gas() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build(); - let res = vm.vm.finish_batch(Some(default_pubdata_builder())); + let res = vm.vm.execute(InspectExecutionMode::Bootloader); assert_matches!( - res.block_tip_execution_result.result, + res.result, ExecutionResult::Halt { reason: Halt::BootloaderOutOfGas } diff --git a/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs b/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs index df11619edfb2..3d609359a9f9 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/sekp256r1.rs @@ -4,8 +4,7 @@ use zksync_types::{web3::keccak256, Execute, H256, U256}; use zksync_utils::h256_to_u256; use crate::{ - interface::{ExecutionResult, TxExecutionMode, VmInterface}, - versions::testonly::default_pubdata_builder, + interface::{ExecutionResult, TxExecutionMode, VmExecutionMode, VmInterface}, vm_latest::{tests::tester::VmTesterBuilder, HistoryEnabled}, }; @@ -59,10 +58,9 @@ fn test_sekp256r1() { vm.vm.push_transaction(tx); - let execution_result = vm - .vm - .finish_batch(Some(default_pubdata_builder())) - .block_tip_execution_result; + let execution_result = + vm.vm + .inspect_inner(&mut Default::default(), VmExecutionMode::Batch, None); let ExecutionResult::Success { output } = execution_result.result else { panic!("batch failed") diff --git a/yarn.lock b/yarn.lock index 255bd901e035..58511dd1b9ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1424,18 +1424,6 @@ resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c" integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg== -"@isaacs/cliui@^8.0.2": - version "8.0.2" - resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" - integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== - dependencies: - string-width "^5.1.2" - string-width-cjs "npm:string-width@^4.2.0" - strip-ansi "^7.0.1" - strip-ansi-cjs "npm:strip-ansi@^6.0.1" - wrap-ansi "^8.1.0" - wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" - "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1727,24 +1715,15 @@ resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-deploy/-/hardhat-zksync-deploy-1.5.0.tgz#40cb454fb187da4bb354f3acb48762a6657fcb36" integrity sha512-7LAgYYwoKWHeR+3CyWEvA3NKBKtt7ktcr7SX6ZPgbEYqHAdXH02vxJZGwNADtMWpyYm8h+fEQkpPIgErD4NhmA== dependencies: - "@matterlabs/hardhat-zksync-solc" "^1.0.5" - chalk "4.1.2" - ts-morph "^19.0.0" - -"@matterlabs/hardhat-zksync-deploy@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-deploy/-/hardhat-zksync-deploy-1.3.0.tgz#5c2b723318ddf6c4d3929ec225401864ff54557a" - integrity sha512-4UHOgOwIBC4JA3W8DE9GHqbAuBhCPAjtM+Oew1aiYYGkIsPUAMYsH35+4I2FzJsYyE6mD6ATmoS/HfZweQHTlQ== - dependencies: - "@matterlabs/hardhat-zksync-solc" "^1.0.4" - chai "^4.3.6" - chalk "4.1.2" + "@matterlabs/hardhat-zksync-solc" "^1.2.0" + chai "^4.3.4" + chalk "^4.1.2" fs-extra "^11.2.0" - glob "^10.3.10" + glob "^10.4.1" lodash "^4.17.21" - sinon "^17.0.1" + sinon "^18.0.0" sinon-chai "^3.7.0" - ts-morph "^21.0.1" + ts-morph "^22.0.0" "@matterlabs/hardhat-zksync-node@^0.0.1-beta.7": version "0.0.1" @@ -1789,7 +1768,7 @@ chalk "4.1.2" dockerode "^3.3.4" -"@matterlabs/hardhat-zksync-solc@^1.0.4", "@matterlabs/hardhat-zksync-solc@^1.0.5", "@matterlabs/hardhat-zksync-solc@^1.1.4": +"@matterlabs/hardhat-zksync-solc@^1.0.5", "@matterlabs/hardhat-zksync-solc@^1.1.4": version "1.1.4" resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-solc/-/hardhat-zksync-solc-1.1.4.tgz#04a2fad6fb6b6944c64ad969080ee65b9af3f617" integrity sha512-4/usbogh9neewR2/v8Dn2OzqVblZMUuT/iH2MyPZgPRZYQlL4SlZtMvokU9UQjZT6iSoaKCbbdWESHDHSzfUjA== @@ -1823,10 +1802,10 @@ sinon-chai "^3.7.0" undici "^6.18.2" -"@matterlabs/hardhat-zksync-verify@^0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-verify/-/hardhat-zksync-verify-0.4.0.tgz#f812c19950022fc36728f3796f6bdae5633e2fcd" - integrity sha512-GPZmAumFl3ZMPKbECX7Qw8CriwZKWd1DlCRhoG/6YYc6mFy4+MXkF1XsHLMs5r34N+GDOfbVZVMeftIlJC96Kg== +"@matterlabs/hardhat-zksync-solc@^1.2.4": + version "1.2.5" + resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-solc/-/hardhat-zksync-solc-1.2.5.tgz#fbeeabc3fea0dd232fa3c8cb31bd93c103eba11a" + integrity sha512-iZyznWl1Hoe/Z46hnUe1s2drBZBjJOS/eN+Ql2lIBX9B6NevBl9DYzkKzH5HEIMCLGnX9sWpRAJqUQJWy9UB6w== dependencies: "@nomiclabs/hardhat-docker" "^2.0.2" chai "^4.3.4" @@ -1871,20 +1850,20 @@ sinon "^18.0.0" sinon-chai "^3.7.0" -"@matterlabs/hardhat-zksync-vyper@^1.0.8": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-vyper/-/hardhat-zksync-vyper-1.0.8.tgz#d5bd496715a1e322b0bf3926b4146b4e18ab64ff" - integrity sha512-XR7rbfDuBG5/LZWYfhQTP9gD+U24hSJHDuZ9U55wgIfiQTOxPoztFwEbQNiC39vjT5MjP/Nv8/IDrlEBkaVCgw== +"@matterlabs/hardhat-zksync-vyper@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-vyper/-/hardhat-zksync-vyper-1.1.0.tgz#b3fb304429e88a84b4abc3fe4e5a83b2f5e907bd" + integrity sha512-zDjHPeIuHRpumXiWZUbhoji4UJe09jTDRn4xnxsuVkLH7qLAm0VDFzCXYNMvEuySZSdhbSbekxJsH9Kunc5ycA== dependencies: - "@nomiclabs/hardhat-docker" "^2.0.0" - chai "^4.3.6" - chalk "4.1.2" + "@nomiclabs/hardhat-docker" "^2.0.2" + chai "^4.3.4" + chalk "^4.1.2" dockerode "^4.0.2" - fs-extra "^11.1.1" - semver "^7.5.4" - sinon "^17.0.1" + fs-extra "^11.2.0" + semver "^7.6.2" + sinon "^18.0.0" sinon-chai "^3.7.0" - undici "^5.14.0" + undici "^6.18.2" "@matterlabs/prettier-config@^1.0.3": version "1.0.3" @@ -2324,11 +2303,6 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.6.tgz#2a880a24eb19b4f8b25adc2a5095f2aa27f39677" integrity sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA== -"@pkgjs/parseargs@^0.11.0": - version "0.11.0" - resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" - integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== - "@pkgr/core@^0.1.0": version "0.1.1" resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" @@ -2659,16 +2633,6 @@ mkdirp "^2.1.6" path-browserify "^1.0.1" -"@ts-morph/common@~0.22.0": - version "0.22.0" - resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.22.0.tgz#8951d451622a26472fbc3a227d6c3a90e687a683" - integrity sha512-HqNBuV/oIlMKdkLshXd1zKBqNQCsuPEsgQOkfFQ/eUKjRlwndXW1AjN9LVkBEIukm00gGXSRmfkl0Wv5VXLnlw== - dependencies: - fast-glob "^3.3.2" - minimatch "^9.0.3" - mkdirp "^3.0.1" - path-browserify "^1.0.1" - "@tsconfig/node10@^1.0.7": version "1.0.11" resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.11.tgz#6ee46400685f130e278128c7b38b7e031ff5b2f2" @@ -3341,11 +3305,6 @@ ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== -ansi-regex@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" - integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== - ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -3365,11 +3324,6 @@ ansi-styles@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== -ansi-styles@^6.1.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" - integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== - antlr4@^4.11.0: version "4.13.1" resolved "https://registry.yarnpkg.com/antlr4/-/antlr4-4.13.1.tgz#1e0a1830a08faeb86217cb2e6c34716004e4253d" @@ -4481,7 +4435,7 @@ cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -4784,11 +4738,6 @@ dotenv@^8.2.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b" integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g== -eastasianwidth@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" - integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== - ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -4855,11 +4804,6 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -emoji-regex@^9.2.2: - version "9.2.2" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" - integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== - encoding-down@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/encoding-down/-/encoding-down-6.3.0.tgz#b1c4eb0e1728c146ecaef8e32963c549e76d082b" @@ -5830,14 +5774,6 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" -foreground-child@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.1.1.tgz#1d173e776d75d2772fed08efe4a0de1ea1b12d0d" - integrity sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg== - dependencies: - cross-spawn "^7.0.0" - signal-exit "^4.0.1" - forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -6126,17 +6062,6 @@ glob@8.1.0, glob@^8.0.3: minimatch "^5.0.1" once "^1.3.0" -glob@^10.3.10: - version "10.3.16" - resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.16.tgz#bf6679d5d51279c8cfae4febe0d051d2a4bf4c6f" - integrity sha512-JDKXl1DiuuHJ6fVS2FXjownaavciiHNUU4mOvV/B793RLh05vZL1rcPnCSaOgv1hDT6RDlY7AB7ZUvFYAtPgAw== - dependencies: - foreground-child "^3.1.0" - jackspeak "^3.1.2" - minimatch "^9.0.1" - minipass "^7.0.4" - path-scurry "^1.11.0" - glob@^5.0.15: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" @@ -7049,15 +6974,6 @@ istanbul-reports@^3.1.3: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" -jackspeak@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.1.2.tgz#eada67ea949c6b71de50f1b09c92a961897b90ab" - integrity sha512-kWmLKn2tRtfYMF/BakihVVRzBKOxz4gJMiL2Rj91WnAB5TPZumSH99R/Yf1qE1u4uRimvCSJfm6hnxohXeEXjQ== - dependencies: - "@isaacs/cliui" "^8.0.2" - optionalDependencies: - "@pkgjs/parseargs" "^0.11.0" - jest-changed-files@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-29.7.0.tgz#1c06d07e77c78e1585d020424dedc10d6e17ac3a" @@ -7961,11 +7877,6 @@ lowercase-keys@^3.0.0: resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-3.0.0.tgz#c5e7d442e37ead247ae9db117a9d0a467c89d4f2" integrity sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ== -lru-cache@^10.2.0: - version "10.2.2" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878" - integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== - lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -8264,13 +8175,6 @@ minimatch@^7.4.3: dependencies: brace-expansion "^2.0.1" -minimatch@^9.0.1, minimatch@^9.0.3: - version "9.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51" - integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw== - dependencies: - brace-expansion "^2.0.1" - minimatch@~3.0.4: version "3.0.8" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.8.tgz#5e6a59bd11e2ab0de1cfb843eb2d82e546c321c1" @@ -8283,11 +8187,6 @@ minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6, minimist@^1.2.8, minimist@~1. resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== -"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.0.4: - version "7.1.1" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.1.tgz#f7f85aff59aa22f110b20e27692465cf3bf89481" - integrity sha512-UZ7eQ+h8ywIRAW1hIEl2AqdwzJucU/Kp59+8kkZeSvafXhZjul247BvIJjEVFVeON6d7lM46XX1HXCduKAS8VA== - mkdirp-classic@^0.5.2: version "0.5.3" resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" @@ -8310,11 +8209,6 @@ mkdirp@^2.1.6: resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.6.tgz#964fbcb12b2d8c5d6fbc62a963ac95a273e2cc19" integrity sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A== -mkdirp@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50" - integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg== - mnemonist@^0.38.0: version "0.38.5" resolved "https://registry.yarnpkg.com/mnemonist/-/mnemonist-0.38.5.tgz#4adc7f4200491237fe0fa689ac0b86539685cade" @@ -8780,16 +8674,6 @@ package-json@^8.1.0: registry-url "^6.0.0" semver "^7.3.7" -package-json@^8.1.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/package-json/-/package-json-8.1.1.tgz#3e9948e43df40d1e8e78a85485f1070bf8f03dc8" - integrity sha512-cbH9IAIJHNj9uXi196JVsRlt7cHKak6u/e6AkL/bkRelZ7rlL3X1YKxsZwa36xipOEKAsdtmaG6aAJoM1fx2zA== - dependencies: - got "^12.1.0" - registry-auth-token "^5.0.1" - registry-url "^6.0.0" - semver "^7.3.7" - parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -8855,14 +8739,6 @@ path-parse@^1.0.6, path-parse@^1.0.7: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== -path-scurry@^1.11.0: - version "1.11.1" - resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2" - integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA== - dependencies: - lru-cache "^10.2.0" - minipass "^5.0.0 || ^6.0.2 || ^7.0.0" - path-to-regexp@^6.2.1: version "6.2.2" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.2.2.tgz#324377a83e5049cbecadc5554d6a63a9a4866b36" @@ -9863,11 +9739,6 @@ signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== -signal-exit@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" - integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== - sinon-chai@^3.7.0: version "3.7.0" resolved "https://registry.yarnpkg.com/sinon-chai/-/sinon-chai-3.7.0.tgz#cfb7dec1c50990ed18c153f1840721cf13139783" @@ -10199,15 +10070,6 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -10216,14 +10078,14 @@ string-width@^2.1.0, string-width@^2.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string-width@^5.0.1, string-width@^5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" - integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== +string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== dependencies: - eastasianwidth "^0.2.0" - emoji-regex "^9.2.2" - strip-ansi "^7.0.1" + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" string.prototype.padend@^3.0.0: version "3.1.6" @@ -10282,13 +10144,6 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" @@ -10303,12 +10158,12 @@ strip-ansi@^5.1.0: dependencies: ansi-regex "^4.1.0" -strip-ansi@^7.0.1: - version "7.1.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" - integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: - ansi-regex "^6.0.1" + ansi-regex "^5.0.1" strip-bom@^3.0.0: version "3.0.0" @@ -10413,6 +10268,7 @@ synckit@^0.8.6: fast-glob "^3.3.2" hardhat "=2.22.2" preprocess "^3.2.0" + zksync-ethers "^5.9.0" table-layout@^1.0.2: version "1.0.2" @@ -10664,14 +10520,6 @@ ts-morph@^19.0.0: "@ts-morph/common" "~0.20.0" code-block-writer "^12.0.0" -ts-morph@^21.0.1: - version "21.0.1" - resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-21.0.1.tgz#712302a0f6e9dbf1aa8d9cf33a4386c4b18c2006" - integrity sha512-dbDtVdEAncKctzrVZ+Nr7kHpHkv+0JDJb2MjjpBaj8bFeCkePU9rHfMklmhuLFnpeq/EJZk2IhStY6NzqgjOkg== - dependencies: - "@ts-morph/common" "~0.22.0" - code-block-writer "^12.0.0" - ts-node@^10.1.0, ts-node@^10.7.0: version "10.9.2" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" @@ -11152,7 +11000,7 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -11161,15 +11009,6 @@ workerpool@6.2.1: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^8.1.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" - integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== - dependencies: - ansi-styles "^6.1.0" - string-width "^5.0.1" - strip-ansi "^7.0.1" - wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" From a56e0efb15adbd1f3cef4a40a6b3aed4763c9065 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Fri, 18 Oct 2024 14:02:24 +0300 Subject: [PATCH 18/23] update protocol version in json commitment test --- core/lib/types/src/commitment/tests/post_gateway_test.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/lib/types/src/commitment/tests/post_gateway_test.json b/core/lib/types/src/commitment/tests/post_gateway_test.json index 71f09d99ba4f..4b598ff59f4f 100644 --- a/core/lib/types/src/commitment/tests/post_gateway_test.json +++ b/core/lib/types/src/commitment/tests/post_gateway_test.json @@ -9,7 +9,7 @@ "PostBoojum": { "common": { "l2_l1_logs_merkle_root": "0x38eaeef3afe69b6f6b2fa22c92da8137f1e405a1e1861b7de7cfa30c7d7462dd", - "protocol_version": "Version26" + "protocol_version": "Version27" }, "system_logs_linear_hash": "0xe8460ce1ed47b77cfee3cadf803aa089c144c506ea2bdd358a6a38ff2c7bc8e3", "state_diffs_compressed": [ @@ -94,7 +94,7 @@ "zkporter_is_available": false, "bootloader_code_hash": "0x010008c753336bc8d1ddca235602b9f31d346412b2d463cd342899f7bfb73baf", "default_aa_code_hash": "0x0100055d760f11a3d737e7fd1816e600a4cd874a9f17f7a225d1f1c537c51a1e", - "protocol_version": "Version26" + "protocol_version": "Version27" }, "pass_through_data": { "shared_states": [ @@ -341,7 +341,7 @@ "rollup_root_hash": "0x0332d2acc43785a44b2b84fc010372c8f3e4ff4d0ca5f312de142ffe74189500", "bootloader_code_hash": "0x010008c753336bc8d1ddca235602b9f31d346412b2d463cd342899f7bfb73baf", "default_aa_code_hash": "0x0100055d760f11a3d737e7fd1816e600a4cd874a9f17f7a225d1f1c537c51a1e", - "protocol_version": "Version26" + "protocol_version": "Version27" }, "system_logs": [ { From 4fbc3bb79d98519b758e432bc7c8669c0c6261f2 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Fri, 18 Oct 2024 14:06:39 +0300 Subject: [PATCH 19/23] remove pubdata_params from oneshot env --- core/lib/vm_executor/src/oneshot/block.rs | 10 +++------- core/lib/vm_interface/src/types/inputs/mod.rs | 5 +---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/core/lib/vm_executor/src/oneshot/block.rs b/core/lib/vm_executor/src/oneshot/block.rs index 5f64600dfe4e..d6118f15b98e 100644 --- a/core/lib/vm_executor/src/oneshot/block.rs +++ b/core/lib/vm_executor/src/oneshot/block.rs @@ -7,7 +7,6 @@ use zksync_multivm::{ use zksync_types::{ api, block::{unpack_block_info, L2BlockHasher}, - commitment::PubdataParams, fee_model::BatchFeeInput, AccountTreeId, L1BatchNumber, L2BlockNumber, ProtocolVersionId, StorageKey, H256, SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_CURRENT_L2_BLOCK_INFO_POSITION, @@ -148,7 +147,6 @@ impl BlockInfo { protocol_version, use_evm_emulator, is_pending: self.is_pending_l2_block(), - pubdata_params: l2_block_header.pubdata_params, }) } } @@ -163,7 +161,6 @@ pub struct ResolvedBlockInfo { protocol_version: ProtocolVersionId, use_evm_emulator: bool, is_pending: bool, - pubdata_params: PubdataParams, } impl ResolvedBlockInfo { @@ -197,7 +194,7 @@ impl OneshotEnvParameters { ) .await?; - let (system, l1_batch, pubdata_params) = self + let (system, l1_batch) = self .prepare_env( execution_mode, resolved_block_info, @@ -210,7 +207,6 @@ impl OneshotEnvParameters { Ok(OneshotEnv { system, l1_batch, - pubdata_params, current_block, }) } @@ -222,7 +218,7 @@ impl OneshotEnvParameters { next_block: L2BlockEnv, fee_input: BatchFeeInput, enforced_base_fee: Option, - ) -> anyhow::Result<(SystemEnv, L1BatchEnv, PubdataParams)> { + ) -> anyhow::Result<(SystemEnv, L1BatchEnv)> { let &Self { operator_account, validation_computational_gas_limit, @@ -252,7 +248,7 @@ impl OneshotEnvParameters { enforced_base_fee, first_l2_block: next_block, }; - Ok((system_env, l1_batch_env, resolved_block_info.pubdata_params)) + Ok((system_env, l1_batch_env)) } } diff --git a/core/lib/vm_interface/src/types/inputs/mod.rs b/core/lib/vm_interface/src/types/inputs/mod.rs index c84d77af4fcb..cb80ba7c1386 100644 --- a/core/lib/vm_interface/src/types/inputs/mod.rs +++ b/core/lib/vm_interface/src/types/inputs/mod.rs @@ -1,6 +1,5 @@ use zksync_types::{ - commitment::PubdataParams, l2::L2Tx, ExecuteTransactionCommon, Nonce, PackedEthSignature, - Transaction, U256, + l2::L2Tx, ExecuteTransactionCommon, Nonce, PackedEthSignature, Transaction, U256, }; pub use self::{ @@ -22,8 +21,6 @@ pub struct OneshotEnv { pub system: SystemEnv, /// Part of the environment specific to an L1 batch. pub l1_batch: L1BatchEnv, - /// Pubdata building parameters. - pub pubdata_params: PubdataParams, /// Part of the environment representing the current L2 block. Can be used to override storage slots /// in the system context contract, which are set from `L1BatchEnv.first_l2_block` by default. pub current_block: Option, From 082564764d1811d8fea0a3bf89ceea7b65e01c58 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Tue, 22 Oct 2024 15:13:27 +0300 Subject: [PATCH 20/23] remove finish_batch from dump playback --- core/lib/multivm/src/dump.rs | 49 ----------------- core/lib/multivm/src/lib.rs | 1 - .../multivm/src/pubdata_builders/rollup.rs | 8 --- .../multivm/src/pubdata_builders/validium.rs | 8 --- .../multivm/src/versions/testonly/shadow.rs | 31 +++++------ core/lib/vm_interface/src/pubdata/mod.rs | 7 +-- core/lib/vm_interface/src/utils/dump.rs | 53 +++++++++++++++---- core/lib/vm_interface/src/utils/shadow.rs | 24 ++++----- 8 files changed, 69 insertions(+), 112 deletions(-) delete mode 100644 core/lib/multivm/src/dump.rs diff --git a/core/lib/multivm/src/dump.rs b/core/lib/multivm/src/dump.rs deleted file mode 100644 index c170d1a0a2b7..000000000000 --- a/core/lib/multivm/src/dump.rs +++ /dev/null @@ -1,49 +0,0 @@ -use crate::{ - interface::{ - storage::{StoragePtr, StorageSnapshot, StorageView}, - utils::VmDump, - L1BatchEnv, L2BlockEnv, SystemEnv, VmFactory, VmInterface, VmInterfaceExt, - }, - pubdata_builders::pubdata_params_to_builder, -}; - -/// Plays back dump on the specified VM. -pub fn play_back_dump(dump: VmDump) -> Vm -where - Vm: VmFactory>, -{ - play_back_dump_custom(dump, Vm::new) -} - -/// Plays back dump on a VM created using the provided closure. -#[doc(hidden)] // too low-level -pub fn play_back_dump_custom( - dump: VmDump, - create_vm: impl FnOnce(L1BatchEnv, SystemEnv, StoragePtr>) -> Vm, -) -> Vm { - let storage = StorageView::new(dump.storage).to_rc_ptr(); - let mut vm = create_vm(dump.l1_batch_env, dump.system_env, storage); - - for (i, l2_block) in dump.l2_blocks.into_iter().enumerate() { - if i > 0 { - // First block is already set. - vm.start_new_l2_block(L2BlockEnv { - number: l2_block.number.0, - timestamp: l2_block.timestamp, - prev_block_hash: l2_block.prev_block_hash, - max_virtual_blocks_to_create: l2_block.virtual_blocks, - }); - } - - for tx in l2_block.txs { - let tx_hash = tx.hash(); - let (compression_result, _) = - vm.execute_transaction_with_bytecode_compression(tx, true); - if let Err(err) = compression_result { - panic!("Failed compressing bytecodes for transaction {tx_hash:?}: {err}"); - } - } - } - vm.finish_batch(dump.pubdata_params.map(pubdata_params_to_builder)); - vm -} diff --git a/core/lib/multivm/src/lib.rs b/core/lib/multivm/src/lib.rs index d01ad02e1112..1cba2c0fb92b 100644 --- a/core/lib/multivm/src/lib.rs +++ b/core/lib/multivm/src/lib.rs @@ -19,7 +19,6 @@ pub use crate::{ vm_instance::{is_supported_by_fast_vm, FastVmInstance, LegacyVmInstance}, }; -pub mod dump; mod glue; pub mod pubdata_builders; pub mod tracers; diff --git a/core/lib/multivm/src/pubdata_builders/rollup.rs b/core/lib/multivm/src/pubdata_builders/rollup.rs index e395bf65ce46..4a818dfe2314 100644 --- a/core/lib/multivm/src/pubdata_builders/rollup.rs +++ b/core/lib/multivm/src/pubdata_builders/rollup.rs @@ -1,5 +1,4 @@ use zksync_types::{ - commitment::{L1BatchCommitmentMode, PubdataParams}, ethabi, ethabi::{ParamType, Token}, l2_to_l1_log::l2_to_l1_logs_tree_size, @@ -25,13 +24,6 @@ impl RollupPubdataBuilder { } impl PubdataBuilder for RollupPubdataBuilder { - fn pubdata_params(&self) -> Option { - Some(PubdataParams { - l2_da_validator_address: self.l2_da_validator, - pubdata_type: L1BatchCommitmentMode::Rollup, - }) - } - fn l2_da_validator(&self) -> Address { self.l2_da_validator } diff --git a/core/lib/multivm/src/pubdata_builders/validium.rs b/core/lib/multivm/src/pubdata_builders/validium.rs index f367d81fd645..a9156e970aad 100644 --- a/core/lib/multivm/src/pubdata_builders/validium.rs +++ b/core/lib/multivm/src/pubdata_builders/validium.rs @@ -1,5 +1,4 @@ use zksync_types::{ - commitment::{L1BatchCommitmentMode, PubdataParams}, ethabi, ethabi::{ParamType, Token}, l2_to_l1_log::l2_to_l1_logs_tree_size, @@ -25,13 +24,6 @@ impl ValidiumPubdataBuilder { } impl PubdataBuilder for ValidiumPubdataBuilder { - fn pubdata_params(&self) -> Option { - Some(PubdataParams { - l2_da_validator_address: self.l2_da_validator, - pubdata_type: L1BatchCommitmentMode::Validium, - }) - } - fn l2_da_validator(&self) -> Address { self.l2_da_validator } diff --git a/core/lib/multivm/src/versions/testonly/shadow.rs b/core/lib/multivm/src/versions/testonly/shadow.rs index a80d21a28eb1..d739c5d3adcc 100644 --- a/core/lib/multivm/src/versions/testonly/shadow.rs +++ b/core/lib/multivm/src/versions/testonly/shadow.rs @@ -15,7 +15,6 @@ use zksync_types::{ use zksync_utils::bytecode::hash_bytecode; use crate::{ - dump::{play_back_dump, play_back_dump_custom}, interface::{ storage::{InMemoryStorage, ReadStorage, StorageView}, utils::{ShadowVm, VmDump}, @@ -23,8 +22,7 @@ use crate::{ }, utils::get_max_gas_per_pubdata_byte, versions::testonly::{ - default_l1_batch, default_pubdata_builder, default_system_env, make_address_rich, - ContractToDeploy, + default_l1_batch, default_system_env, make_address_rich, ContractToDeploy, }, vm_fast, vm_latest, vm_latest::HistoryEnabled, @@ -198,7 +196,6 @@ impl Harness { assert!(!exec_result.result.is_failed(), "{:#?}", exec_result); self.new_block(vm, &[deploy_tx.tx.hash(), load_test_tx.hash()]); - vm.finish_batch(Some(default_pubdata_builder())); } } @@ -251,13 +248,11 @@ fn sanity_check_shadow_vm() { #[test] fn shadow_vm_basics() { let (vm, harness) = sanity_check_vm::(); - let pubdata_builder = default_pubdata_builder(); - let mut dump = vm.dump_state(Some(pubdata_builder.clone())); + let mut dump = vm.dump_state(); Harness::assert_dump(&mut dump); // Test standard playback functionality. - let replayed_dump = - play_back_dump::>(dump.clone()).dump_state(Some(pubdata_builder.clone())); + let replayed_dump = dump.clone().play_back::>().dump_state(); pretty_assertions::assert_eq!(replayed_dump, dump); // Check that the VM executes identically when reading from the original storage and one restored from the dump. @@ -265,14 +260,16 @@ fn shadow_vm_basics() { harness.setup_storage(&mut storage); let storage = StorageView::new(storage).to_rc_ptr(); - let vm = play_back_dump_custom(dump.clone(), |l1_batch_env, system_env, dump_storage| { - ShadowVm::<_, ReferenceVm, ReferenceVm<_>>::with_custom_shadow( - l1_batch_env, - system_env, - storage, - dump_storage, - ) - }); - let new_dump = vm.dump_state(Some(pubdata_builder)); + let vm = dump + .clone() + .play_back_custom(|l1_batch_env, system_env, dump_storage| { + ShadowVm::<_, ReferenceVm, ReferenceVm<_>>::with_custom_shadow( + l1_batch_env, + system_env, + storage, + dump_storage, + ) + }); + let new_dump = vm.dump_state(); pretty_assertions::assert_eq!(new_dump, dump); } diff --git a/core/lib/vm_interface/src/pubdata/mod.rs b/core/lib/vm_interface/src/pubdata/mod.rs index ba22fdeec983..f901687b5fa6 100644 --- a/core/lib/vm_interface/src/pubdata/mod.rs +++ b/core/lib/vm_interface/src/pubdata/mod.rs @@ -1,6 +1,5 @@ use zksync_types::{ - commitment::PubdataParams, l2_to_l1_log::L2ToL1Log, writes::StateDiffRecord, Address, - ProtocolVersionId, H256, U256, + l2_to_l1_log::L2ToL1Log, writes::StateDiffRecord, Address, ProtocolVersionId, H256, U256, }; /// Corresponds to the following solidity event: @@ -75,10 +74,6 @@ pub struct PubdataInput { /// Trait that encapsulates pubdata building logic. It is implemented for rollup and validium cases. /// If chains needs custom pubdata format then another implementation should be added. pub trait PubdataBuilder: std::fmt::Debug { - fn pubdata_params(&self) -> Option { - None - } - fn l2_da_validator(&self) -> Address; fn l1_messenger_operator_input( diff --git a/core/lib/vm_interface/src/utils/dump.rs b/core/lib/vm_interface/src/utils/dump.rs index d84d41b05312..4e60f166b608 100644 --- a/core/lib/vm_interface/src/utils/dump.rs +++ b/core/lib/vm_interface/src/utils/dump.rs @@ -1,17 +1,14 @@ use std::{collections::HashMap, rc::Rc}; use serde::{Deserialize, Serialize}; -use zksync_types::{ - block::L2BlockExecutionData, commitment::PubdataParams, L1BatchNumber, L2BlockNumber, - Transaction, H256, -}; +use zksync_types::{block::L2BlockExecutionData, L1BatchNumber, L2BlockNumber, Transaction, H256}; use crate::{ pubdata::PubdataBuilder, storage::{ReadStorage, StoragePtr, StorageSnapshot, StorageView}, BytecodeCompressionResult, FinishedL1Batch, InspectExecutionMode, L1BatchEnv, L2BlockEnv, PushTransactionResult, SystemEnv, VmExecutionResultAndLogs, VmFactory, VmInterface, - VmInterfaceHistoryEnabled, VmTrackingContracts, + VmInterfaceExt, VmInterfaceHistoryEnabled, VmTrackingContracts, }; fn create_storage_snapshot( @@ -52,19 +49,59 @@ fn create_storage_snapshot( } /// VM dump allowing to re-run the VM on the same inputs. Can be (de)serialized. +/// Note, dump is not capable of finishing batch in terms of VM execution. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct VmDump { pub l1_batch_env: L1BatchEnv, pub system_env: SystemEnv, pub l2_blocks: Vec, pub storage: StorageSnapshot, - pub pubdata_params: Option, } impl VmDump { pub fn l1_batch_number(&self) -> L1BatchNumber { self.l1_batch_env.number } + + /// Plays back this dump on the specified VM. + pub fn play_back(self) -> Vm + where + Vm: VmFactory>, + { + self.play_back_custom(Vm::new) + } + + /// Plays back this dump on a VM created using the provided closure. + #[doc(hidden)] // too low-level + pub fn play_back_custom( + self, + create_vm: impl FnOnce(L1BatchEnv, SystemEnv, StoragePtr>) -> Vm, + ) -> Vm { + let storage = StorageView::new(self.storage).to_rc_ptr(); + let mut vm = create_vm(self.l1_batch_env, self.system_env, storage); + + for (i, l2_block) in self.l2_blocks.into_iter().enumerate() { + if i > 0 { + // First block is already set. + vm.start_new_l2_block(L2BlockEnv { + number: l2_block.number.0, + timestamp: l2_block.timestamp, + prev_block_hash: l2_block.prev_block_hash, + max_virtual_blocks_to_create: l2_block.virtual_blocks, + }); + } + + for tx in l2_block.txs { + let tx_hash = tx.hash(); + let (compression_result, _) = + vm.execute_transaction_with_bytecode_compression(tx, true); + if let Err(err) = compression_result { + panic!("Failed compressing bytecodes for transaction {tx_hash:?}: {err}"); + } + } + } + vm + } } #[derive(Debug, Clone, Copy)] @@ -93,14 +130,12 @@ impl DumpingVm { self.last_block_mut().txs.push(tx); } - pub fn dump_state(&self, pubdata_builder: Option>) -> VmDump { + pub fn dump_state(&self) -> VmDump { VmDump { l1_batch_env: self.l1_batch_env.clone(), system_env: self.system_env.clone(), l2_blocks: self.l2_blocks.clone(), storage: create_storage_snapshot(&self.storage, self.inner.used_contract_hashes()), - pubdata_params: pubdata_builder - .map(|p| p.pubdata_params().expect("pubdata builder is not dumpable")), } } } diff --git a/core/lib/vm_interface/src/utils/shadow.rs b/core/lib/vm_interface/src/utils/shadow.rs index b5f446563a96..c343e61c4022 100644 --- a/core/lib/vm_interface/src/utils/shadow.rs +++ b/core/lib/vm_interface/src/utils/shadow.rs @@ -91,25 +91,21 @@ where } /// Mutable ref is not necessary, but it automatically drops potential borrows. - fn report(&mut self, err: DivergenceErrors, pubdata_builder: Option>) { - self.report_shared(err, pubdata_builder); + fn report(&mut self, err: DivergenceErrors) { + self.report_shared(err); } /// The caller is responsible for dropping any `shadow` borrows beforehand. - fn report_shared( - &self, - err: DivergenceErrors, - pubdata_builder: Option>, - ) { + fn report_shared(&self, err: DivergenceErrors) { self.shadow .take() .unwrap() - .report(err, self.main.dump_state(pubdata_builder)); + .report(err, self.main.dump_state()); } /// Dumps the current VM state. - pub fn dump_state(&self, pubdata_builder: Option>) -> VmDump { - self.main.dump_state(pubdata_builder) + pub fn dump_state(&self) -> VmDump { + self.main.dump_state() } } @@ -189,7 +185,7 @@ where ); if let Err(err) = errors.into_result() { let ctx = format!("pushing transaction {tx_repr}"); - self.report(err.context(ctx), None); + self.report(err.context(ctx)); } } main_result @@ -208,7 +204,7 @@ where if let Err(err) = errors.into_result() { let ctx = format!("executing VM with mode {execution_mode:?}"); - self.report(err.context(ctx), None); + self.report(err.context(ctx)); } } main_result @@ -252,7 +248,7 @@ where let ctx = format!( "inspecting transaction {tx_repr}, with_compression={with_compression:?}" ); - self.report(err.context(ctx), None); + self.report(err.context(ctx)); } } (main_bytecodes_result, main_tx_result) @@ -288,7 +284,7 @@ where ); if let Err(err) = errors.into_result() { - self.report(err, pubdata_builder); + self.report(err); } } main_batch From b22e77c7cd614603ab6426572fc3dfcc1bcab1f7 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Tue, 22 Oct 2024 15:48:19 +0300 Subject: [PATCH 21/23] Address comments --- core/lib/dal/src/models/storage_sync.rs | 2 +- .../versions/testonly/bytecode_publishing.rs | 2 +- .../src/versions/testonly/default_aa.rs | 2 +- .../multivm/src/versions/testonly/refunds.rs | 6 +-- .../src/versions/testonly/simple_execution.rs | 2 +- .../testonly/tester/transaction_test_info.rs | 2 +- .../multivm/src/versions/testonly/transfer.rs | 4 +- core/lib/multivm/src/versions/vm_1_3_2/vm.rs | 5 +- core/lib/multivm/src/versions/vm_1_4_1/vm.rs | 5 +- core/lib/multivm/src/versions/vm_1_4_2/vm.rs | 5 +- .../src/versions/vm_boojum_integration/vm.rs | 5 +- .../multivm/src/versions/vm_fast/tests/mod.rs | 2 +- core/lib/multivm/src/versions/vm_fast/vm.rs | 5 +- core/lib/multivm/src/versions/vm_latest/vm.rs | 3 +- core/lib/multivm/src/versions/vm_m5/vm.rs | 5 +- core/lib/multivm/src/versions/vm_m6/vm.rs | 5 +- .../src/versions/vm_refunds_enhancement/vm.rs | 5 +- .../src/versions/vm_virtual_blocks/vm.rs | 5 +- core/lib/multivm/src/vm_instance.rs | 4 +- core/lib/tee_verifier/src/lib.rs | 2 +- core/lib/vm_executor/src/batch/factory.rs | 8 ++-- core/lib/vm_interface/src/utils/dump.rs | 2 +- core/lib/vm_interface/src/utils/shadow.rs | 2 +- core/lib/vm_interface/src/vm.rs | 2 +- core/node/commitment_generator/src/lib.rs | 12 +++-- core/node/consensus/src/storage/store.rs | 9 +++- core/node/node_sync/src/fetcher.rs | 11 ++++- core/node/state_keeper/src/io/mempool.rs | 46 ++++++++----------- core/node/state_keeper/src/io/persistence.rs | 6 +-- 29 files changed, 78 insertions(+), 96 deletions(-) diff --git a/core/lib/dal/src/models/storage_sync.rs b/core/lib/dal/src/models/storage_sync.rs index f2842d26b9f7..0eb65a606d1f 100644 --- a/core/lib/dal/src/models/storage_sync.rs +++ b/core/lib/dal/src/models/storage_sync.rs @@ -98,7 +98,7 @@ impl TryFrom for SyncBlock { protocol_version: parse_protocol_version(block.protocol_version)?, pubdata_params: PubdataParams { pubdata_type: L1BatchCommitmentMode::from_str(&block.pubdata_type) - .expect("Invalid pubdata type"), + .decode_column("Invalid pubdata type")?, l2_da_validator_address: parse_h160(&block.l2_da_validator_address) .decode_column("l2_da_validator_address")?, }, diff --git a/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs b/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs index 7d55572d1d10..9da005b995d3 100644 --- a/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs +++ b/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs @@ -33,7 +33,7 @@ pub(crate) fn test_bytecode_publishing() { let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.finish_batch(Some(default_pubdata_builder())); + vm.vm.finish_batch(default_pubdata_builder()); let state = vm.vm.get_current_execution_state(); let long_messages = VmEvent::extract_long_l2_to_l1_messages(&state.events); diff --git a/core/lib/multivm/src/versions/testonly/default_aa.rs b/core/lib/multivm/src/versions/testonly/default_aa.rs index d6f56e7f6ae9..c69c00de4508 100644 --- a/core/lib/multivm/src/versions/testonly/default_aa.rs +++ b/core/lib/multivm/src/versions/testonly/default_aa.rs @@ -35,7 +35,7 @@ pub(crate) fn test_default_aa_interaction() { let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.finish_batch(Some(default_pubdata_builder())); + vm.vm.finish_batch(default_pubdata_builder()); vm.vm.get_current_execution_state(); diff --git a/core/lib/multivm/src/versions/testonly/refunds.rs b/core/lib/multivm/src/versions/testonly/refunds.rs index 71b4f57da2f6..874425fc435c 100644 --- a/core/lib/multivm/src/versions/testonly/refunds.rs +++ b/core/lib/multivm/src/versions/testonly/refunds.rs @@ -39,7 +39,7 @@ pub(crate) fn test_predetermined_refunded_gas() { let result_without_predefined_refunds = vm .vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; let mut current_state_without_predefined_refunds = vm.vm.get_current_execution_state(); assert!(!result_without_predefined_refunds.result.is_failed(),); @@ -61,7 +61,7 @@ pub(crate) fn test_predetermined_refunded_gas() { let result_with_predefined_refunds = vm .vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; let mut current_state_with_predefined_refunds = vm.vm.get_current_execution_state(); @@ -115,7 +115,7 @@ pub(crate) fn test_predetermined_refunded_gas() { .push_transaction_with_refund(tx, changed_operator_suggested_refund); let result = vm .vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; let mut current_state_with_changed_predefined_refunds = vm.vm.get_current_execution_state(); diff --git a/core/lib/multivm/src/versions/testonly/simple_execution.rs b/core/lib/multivm/src/versions/testonly/simple_execution.rs index fc421c305ebc..96239fb362d2 100644 --- a/core/lib/multivm/src/versions/testonly/simple_execution.rs +++ b/core/lib/multivm/src/versions/testonly/simple_execution.rs @@ -71,7 +71,7 @@ pub(crate) fn test_simple_execute() { let tx = vm.execute(InspectExecutionMode::OneTx); assert_matches!(tx.result, ExecutionResult::Success { .. }); let block_tip = vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; assert_matches!(block_tip.result, ExecutionResult::Success { .. }); } diff --git a/core/lib/multivm/src/versions/testonly/tester/transaction_test_info.rs b/core/lib/multivm/src/versions/testonly/tester/transaction_test_info.rs index 85a5fcb25e3f..b9373e331c30 100644 --- a/core/lib/multivm/src/versions/testonly/tester/transaction_test_info.rs +++ b/core/lib/multivm/src/versions/testonly/tester/transaction_test_info.rs @@ -184,7 +184,7 @@ impl VmTester { for tx_test_info in txs { self.execute_tx_and_verify(tx_test_info.clone()); } - self.vm.finish_batch(Some(default_pubdata_builder())); + self.vm.finish_batch(default_pubdata_builder()); let mut state = self.vm.get_current_execution_state(); state.used_contract_hashes.sort(); state diff --git a/core/lib/multivm/src/versions/testonly/transfer.rs b/core/lib/multivm/src/versions/testonly/transfer.rs index e94e6004e83c..3572adba147c 100644 --- a/core/lib/multivm/src/versions/testonly/transfer.rs +++ b/core/lib/multivm/src/versions/testonly/transfer.rs @@ -82,7 +82,7 @@ fn test_send_or_transfer(test_option: TestOptions) { let batch_result = vm .vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); @@ -191,7 +191,7 @@ fn test_reentrancy_protection_send_or_transfer(test_option: TestOp let batch_result = vm .vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); } diff --git a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs index 395254ff6e58..d9768652c2f3 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs @@ -183,10 +183,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { self.vm .execute_till_block_end( crate::vm_1_3_2::vm_with_bootloader::BootloaderJobType::BlockPostprocessing, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs index 04ee59e79720..af483feedd7e 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs @@ -131,10 +131,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner( &mut TracerDispatcher::default(), VmExecutionMode::Batch, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs index 2e0dcc5b03fc..e7c8e7acdd95 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs @@ -131,10 +131,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner(TracerDispatcher::default(), VmExecutionMode::Batch, None); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs index 539308fc3126..43c9900486db 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs @@ -132,10 +132,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner(&mut TracerDispatcher::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/mod.rs b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs index 7f215bf5748b..bb766b7a98dc 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/mod.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs @@ -105,7 +105,7 @@ impl TestedVm for Vm> { pubdata_builder: Rc, ) -> VmExecutionResultAndLogs { self.enforce_state_diffs(diffs); - self.finish_batch(Some(pubdata_builder)) + self.finish_batch(pubdata_builder) .block_tip_execution_result } diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index c0e9d276b6f0..9e8676f09926 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -689,10 +689,7 @@ impl VmInterface for Vm { self.bootloader_state.start_new_l2_block(l2_block_env) } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner(&mut Tr::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); diff --git a/core/lib/multivm/src/versions/vm_latest/vm.rs b/core/lib/multivm/src/versions/vm_latest/vm.rs index ac6f2a92da06..ef6cee454a87 100644 --- a/core/lib/multivm/src/versions/vm_latest/vm.rs +++ b/core/lib/multivm/src/versions/vm_latest/vm.rs @@ -186,8 +186,7 @@ impl VmInterface for Vm { } } - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { - let pubdata_builder = pubdata_builder.expect("`pubdata_builder` is required"); + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { let pubdata_tracer = Some(PubdataTracer::new( self.batch_env.clone(), VmExecutionMode::Batch, diff --git a/core/lib/multivm/src/versions/vm_m5/vm.rs b/core/lib/multivm/src/versions/vm_m5/vm.rs index a3d5f107bc68..55afeed17cd1 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm.rs @@ -115,10 +115,7 @@ impl VmInterface for Vm { ) } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { self.vm .execute_till_block_end( crate::vm_m5::vm_with_bootloader::BootloaderJobType::BlockPostprocessing, diff --git a/core/lib/multivm/src/versions/vm_m6/vm.rs b/core/lib/multivm/src/versions/vm_m6/vm.rs index 9456af1bc959..4c67a2184180 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm.rs @@ -207,10 +207,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { self.vm .execute_till_block_end( crate::vm_m6::vm_with_bootloader::BootloaderJobType::BlockPostprocessing, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs index 36e22eaaa9a5..81b0c52cce5e 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs @@ -125,10 +125,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner(&mut TracerDispatcher::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs index b7a5e5f6ba95..a2d18e10de44 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs @@ -125,10 +125,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner(&mut TracerDispatcher::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs index bcfbd769062c..5ff27046377a 100644 --- a/core/lib/multivm/src/vm_instance.rs +++ b/core/lib/multivm/src/vm_instance.rs @@ -88,7 +88,7 @@ impl VmInterface for LegacyVmInstance { } /// Return the results of execution of all batch - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { dispatch_legacy_vm!(self.finish_batch(pubdata_builder)) } } @@ -293,7 +293,7 @@ impl VmInterface for FastVmInsta } } - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { dispatch_fast_vm!(self.finish_batch(pubdata_builder)) } } diff --git a/core/lib/tee_verifier/src/lib.rs b/core/lib/tee_verifier/src/lib.rs index e12e9f611dfb..140085dbb9fe 100644 --- a/core/lib/tee_verifier/src/lib.rs +++ b/core/lib/tee_verifier/src/lib.rs @@ -209,7 +209,7 @@ fn execute_vm( tracing::trace!("about to vm.finish_batch()"); - Ok(vm.finish_batch(Some(pubdata_params_to_builder(pubdata_params)))) + Ok(vm.finish_batch(pubdata_params_to_builder(pubdata_params))) } /// Map `LogQuery` and `TreeLogEntry` to a `TreeInstruction` diff --git a/core/lib/vm_executor/src/batch/factory.rs b/core/lib/vm_executor/src/batch/factory.rs index 75a35c91a42f..f974d17f4a75 100644 --- a/core/lib/vm_executor/src/batch/factory.rs +++ b/core/lib/vm_executor/src/batch/factory.rs @@ -138,7 +138,7 @@ impl BatchExecutorFactory storage, l1_batch_params, system_env, - Some(pubdata_params_to_builder(pubdata_params)), + pubdata_params_to_builder(pubdata_params), ) }); Box::new(MainBatchExecutor::new(handle, commands_sender)) @@ -192,7 +192,7 @@ impl BatchVm { dispatch_batch_vm!(self.start_new_l2_block(l2_block)); } - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { dispatch_batch_vm!(self.finish_batch(pubdata_builder)) } @@ -269,7 +269,7 @@ impl CommandReceiver { storage: S, l1_batch_params: L1BatchEnv, system_env: SystemEnv, - pubdata_builder: Option>, + pubdata_builder: Rc, ) -> anyhow::Result> { tracing::info!("Starting executing L1 batch #{}", &l1_batch_params.number); @@ -378,7 +378,7 @@ impl CommandReceiver { fn finish_batch( &self, vm: &mut BatchVm, - pubdata_builder: Option>, + pubdata_builder: Rc, ) -> anyhow::Result { // The vm execution was paused right after the last transaction was executed. // There is some post-processing work that the VM needs to do before the block is fully processed. diff --git a/core/lib/vm_interface/src/utils/dump.rs b/core/lib/vm_interface/src/utils/dump.rs index 4e60f166b608..19e847dae6c5 100644 --- a/core/lib/vm_interface/src/utils/dump.rs +++ b/core/lib/vm_interface/src/utils/dump.rs @@ -178,7 +178,7 @@ impl VmInterface for DumpingVm { .inspect_transaction_with_bytecode_compression(tracer, tx, with_compression) } - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { self.inner.finish_batch(pubdata_builder) } } diff --git a/core/lib/vm_interface/src/utils/shadow.rs b/core/lib/vm_interface/src/utils/shadow.rs index c343e61c4022..a8b84a338a9c 100644 --- a/core/lib/vm_interface/src/utils/shadow.rs +++ b/core/lib/vm_interface/src/utils/shadow.rs @@ -254,7 +254,7 @@ where (main_bytecodes_result, main_tx_result) } - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { let main_batch = self.main.finish_batch(pubdata_builder.clone()); if let Some(shadow) = self.shadow.get_mut() { let shadow_batch = shadow.vm.finish_batch(pubdata_builder.clone()); diff --git a/core/lib/vm_interface/src/vm.rs b/core/lib/vm_interface/src/vm.rs index 3e9afb412f7f..2c25d729e318 100644 --- a/core/lib/vm_interface/src/vm.rs +++ b/core/lib/vm_interface/src/vm.rs @@ -54,7 +54,7 @@ pub trait VmInterface { /// Execute batch till the end and return the result, with final execution state /// and bootloader memory. - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch; + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch; } /// Extension trait for [`VmInterface`] that provides some additional methods. diff --git a/core/node/commitment_generator/src/lib.rs b/core/node/commitment_generator/src/lib.rs index be14acd9fc46..3a36f3970da7 100644 --- a/core/node/commitment_generator/src/lib.rs +++ b/core/node/commitment_generator/src/lib.rs @@ -296,7 +296,11 @@ impl CommitmentGenerator { .connection_pool .connection_tagged("commitment_generator") .await?; - let aggregation_root = read_aggregation_root(&mut connection, l1_batch_number).await?; + let aggregation_root = if protocol_version.is_pre_gateway() { + read_aggregation_root(&mut connection, l1_batch_number).await? + } else { + H256::zero() + }; CommitmentInput::PostBoojum { common, @@ -384,9 +388,9 @@ impl CommitmentGenerator { // Do nothing } (L1BatchCommitmentMode::Validium, CommitmentInput::PostBoojum { blob_hashes, .. }) => { - blob_hashes - .iter_mut() - .for_each(|b| b.commitment = H256::zero()); + for hashes in blob_hashes { + hashes.commitment = H256::zero(); + } } (L1BatchCommitmentMode::Validium, _) => { /* Do nothing */ } } diff --git a/core/node/consensus/src/storage/store.rs b/core/node/consensus/src/storage/store.rs index 05a3bac0add6..53be2fc63c75 100644 --- a/core/node/consensus/src/storage/store.rs +++ b/core/node/consensus/src/storage/store.rs @@ -28,6 +28,13 @@ fn to_fetched_block( .context("Integer overflow converting block number")?, ); let payload = Payload::decode(payload).context("Payload::decode()")?; + let pubdata_params = if payload.protocol_version.is_pre_gateway() { + payload.pubdata_params.unwrap_or_default() + } else { + payload + .pubdata_params + .context("Missing `pubdata_params` for post-gateway payload")? + }; Ok(FetchedBlock { number, l1_batch_number: payload.l1_batch_number, @@ -38,7 +45,7 @@ fn to_fetched_block( l1_gas_price: payload.l1_gas_price, l2_fair_gas_price: payload.l2_fair_gas_price, fair_pubdata_price: payload.fair_pubdata_price, - pubdata_params: payload.pubdata_params.unwrap_or_default(), + pubdata_params, virtual_blocks: payload.virtual_blocks, operator_address: payload.operator_address, transactions: payload diff --git a/core/node/node_sync/src/fetcher.rs b/core/node/node_sync/src/fetcher.rs index 08e3d4262433..9c76d1d93ca3 100644 --- a/core/node/node_sync/src/fetcher.rs +++ b/core/node/node_sync/src/fetcher.rs @@ -1,3 +1,4 @@ +use anyhow::Context; use zksync_dal::{Connection, Core, CoreDal}; use zksync_shared_metrics::{TxStage, APP_METRICS}; use zksync_state_keeper::io::{common::IoCursor, L1BatchParams, L2BlockParams}; @@ -78,6 +79,14 @@ impl TryFrom for FetchedBlock { )); } + let pubdata_params = if block.protocol_version.is_pre_gateway() { + block.pubdata_params.unwrap_or_default() + } else { + block + .pubdata_params + .context("Missing `pubdata_params` for post-gateway payload")? + }; + Ok(Self { number: block.number, l1_batch_number: block.l1_batch_number, @@ -94,7 +103,7 @@ impl TryFrom for FetchedBlock { .into_iter() .map(FetchedTransaction::new) .collect(), - pubdata_params: block.pubdata_params.unwrap_or_default(), + pubdata_params, }) } } diff --git a/core/node/state_keeper/src/io/mempool.rs b/core/node/state_keeper/src/io/mempool.rs index fe1323bf56af..dfddd36aba71 100644 --- a/core/node/state_keeper/src/io/mempool.rs +++ b/core/node/state_keeper/src/io/mempool.rs @@ -165,19 +165,7 @@ impl StateKeeperIO for MempoolIO { { let protocol_version = unsealed_storage_batch .protocol_version - .expect("unsealed batch is missing protocol version"); - let pubdata_params = match ( - protocol_version.is_pre_gateway(), - self.l2_da_validator_address, - ) { - (true, _) => PubdataParams::default(), - (false, Some(l2_da_validator_address)) => PubdataParams { - l2_da_validator_address, - pubdata_type: self.pubdata_type, - }, - (false, None) => anyhow::bail!("L2 DA validator address not found"), - }; - + .context("unsealed batch is missing protocol version")?; return Ok(Some(L1BatchParams { protocol_version, validation_computational_gas_limit: self.validation_computational_gas_limit, @@ -188,7 +176,7 @@ impl StateKeeperIO for MempoolIO { // This value is effectively ignored by the protocol. virtual_blocks: 1, }, - pubdata_params, + pubdata_params: self.pubdata_params(protocol_version)?, })); } @@ -235,18 +223,6 @@ impl StateKeeperIO for MempoolIO { continue; } - let pubdata_params = match ( - protocol_version.is_pre_gateway(), - self.l2_da_validator_address, - ) { - (true, _) => PubdataParams::default(), - (false, Some(l2_da_validator_address)) => PubdataParams { - l2_da_validator_address, - pubdata_type: self.pubdata_type, - }, - (false, None) => anyhow::bail!("L2 DA validator address not found"), - }; - self.pool .connection_tagged("state_keeper") .await? @@ -270,7 +246,7 @@ impl StateKeeperIO for MempoolIO { // This value is effectively ignored by the protocol. virtual_blocks: 1, }, - pubdata_params, + pubdata_params: self.pubdata_params(protocol_version)?, })); } Ok(None) @@ -508,6 +484,22 @@ impl MempoolIO { pubdata_type, }) } + + fn pubdata_params(&self, protocol_version: ProtocolVersionId) -> anyhow::Result { + let pubdata_params = match ( + protocol_version.is_pre_gateway(), + self.l2_da_validator_address, + ) { + (true, _) => PubdataParams::default(), + (false, Some(l2_da_validator_address)) => PubdataParams { + l2_da_validator_address, + pubdata_type: self.pubdata_type, + }, + (false, None) => anyhow::bail!("L2 DA validator address not found"), + }; + + Ok(pubdata_params) + } } /// Getters required for testing the MempoolIO. diff --git a/core/node/state_keeper/src/io/persistence.rs b/core/node/state_keeper/src/io/persistence.rs index c01c67a3bbd2..06f1972a02aa 100644 --- a/core/node/state_keeper/src/io/persistence.rs +++ b/core/node/state_keeper/src/io/persistence.rs @@ -45,7 +45,7 @@ impl StateKeeperPersistence { pool: &ConnectionPool, l2_legacy_shared_bridge_addr: Option
, ) -> anyhow::Result<()> { - let mut connection = pool.connection().await.context("Get DB connection")?; + let mut connection = pool.connection_tagged("state_keeper").await?; if let Some(l2_block) = connection .blocks_dal() @@ -64,9 +64,7 @@ impl StateKeeperPersistence { .unwrap_or_else(ProtocolVersionId::last_potentially_undefined); if protocol_version.is_pre_gateway() && l2_legacy_shared_bridge_addr.is_none() { - anyhow::bail!( - "Missing `l2_legacy_shared_bridge_addr` for chain that was initialized before gateway upgrade".to_string() - ); + anyhow::bail!("Missing `l2_legacy_shared_bridge_addr` for chain that was initialized before gateway upgrade"); } } From f8c68639d1163fae99deb965f2d88fe23bcea015 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Tue, 22 Oct 2024 20:48:09 +0300 Subject: [PATCH 22/23] nits --- core/lib/vm_interface/src/types/inputs/execution_mode.rs | 4 ++-- core/lib/vm_interface/src/utils/shadow.rs | 2 +- core/node/commitment_generator/src/lib.rs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/lib/vm_interface/src/types/inputs/execution_mode.rs b/core/lib/vm_interface/src/types/inputs/execution_mode.rs index 9a93d3e06174..f091a259d30d 100644 --- a/core/lib/vm_interface/src/types/inputs/execution_mode.rs +++ b/core/lib/vm_interface/src/types/inputs/execution_mode.rs @@ -27,8 +27,8 @@ pub enum InspectExecutionMode { impl From for VmExecutionMode { fn from(mode: InspectExecutionMode) -> Self { match mode { - InspectExecutionMode::Bootloader => VmExecutionMode::Bootloader, - InspectExecutionMode::OneTx => VmExecutionMode::OneTx, + InspectExecutionMode::Bootloader => Self::Bootloader, + InspectExecutionMode::OneTx => Self::OneTx, } } } diff --git a/core/lib/vm_interface/src/utils/shadow.rs b/core/lib/vm_interface/src/utils/shadow.rs index a8b84a338a9c..724ca54187d5 100644 --- a/core/lib/vm_interface/src/utils/shadow.rs +++ b/core/lib/vm_interface/src/utils/shadow.rs @@ -257,7 +257,7 @@ where fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { let main_batch = self.main.finish_batch(pubdata_builder.clone()); if let Some(shadow) = self.shadow.get_mut() { - let shadow_batch = shadow.vm.finish_batch(pubdata_builder.clone()); + let shadow_batch = shadow.vm.finish_batch(pubdata_builder); let mut errors = DivergenceErrors::new(); errors.check_results_match( &main_batch.block_tip_execution_result, diff --git a/core/node/commitment_generator/src/lib.rs b/core/node/commitment_generator/src/lib.rs index 3a36f3970da7..9a33d4766f6e 100644 --- a/core/node/commitment_generator/src/lib.rs +++ b/core/node/commitment_generator/src/lib.rs @@ -292,11 +292,11 @@ impl CommitmentGenerator { vec![Default::default(); num_blobs_required(&protocol_version)] }; - let mut connection = self - .connection_pool - .connection_tagged("commitment_generator") - .await?; let aggregation_root = if protocol_version.is_pre_gateway() { + let mut connection = self + .connection_pool + .connection_tagged("commitment_generator") + .await?; read_aggregation_root(&mut connection, l1_batch_number).await? } else { H256::zero() From fadb3764fee6f7c223b9f9e0c75c757a16666b32 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Thu, 24 Oct 2024 11:09:42 +0300 Subject: [PATCH 23/23] fix bootloader tests --- core/lib/multivm/src/versions/shadow/tests.rs | 7 +++++++ core/lib/multivm/src/versions/testonly/bootloader.rs | 7 +++---- core/lib/multivm/src/versions/testonly/tester/mod.rs | 2 ++ core/lib/multivm/src/versions/vm_fast/tests/mod.rs | 6 +++++- core/lib/multivm/src/versions/vm_fast/vm.rs | 2 +- core/lib/multivm/src/versions/vm_latest/tests/mod.rs | 8 ++++++++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/core/lib/multivm/src/versions/shadow/tests.rs b/core/lib/multivm/src/versions/shadow/tests.rs index 80cd294f48e8..6a39a28f7630 100644 --- a/core/lib/multivm/src/versions/shadow/tests.rs +++ b/core/lib/multivm/src/versions/shadow/tests.rs @@ -57,6 +57,13 @@ impl TestedVm for ShadowedFastVm { }) } + fn finish_batch_without_pubdata(&mut self) -> VmExecutionResultAndLogs { + self.get_custom_mut("finish_batch_without_pubdata", |r| match r { + ShadowMut::Main(vm) => vm.finish_batch_without_pubdata(), + ShadowMut::Shadow(vm) => vm.finish_batch_without_pubdata(), + }) + } + fn insert_bytecodes(&mut self, bytecodes: &[&[u8]]) { self.get_mut("insert_bytecodes", |r| match r { ShadowMut::Main(vm) => vm.insert_bytecodes(bytecodes), diff --git a/core/lib/multivm/src/versions/testonly/bootloader.rs b/core/lib/multivm/src/versions/testonly/bootloader.rs index 9b32d66592ad..4b9b63252d6a 100644 --- a/core/lib/multivm/src/versions/testonly/bootloader.rs +++ b/core/lib/multivm/src/versions/testonly/bootloader.rs @@ -1,9 +1,8 @@ use assert_matches::assert_matches; use zksync_types::U256; -use zksync_vm_interface::InspectExecutionMode; use super::{get_bootloader, tester::VmTesterBuilder, TestedVm, BASE_SYSTEM_CONTRACTS}; -use crate::interface::{ExecutionResult, Halt, TxExecutionMode, VmInterfaceExt}; +use crate::interface::{ExecutionResult, Halt, TxExecutionMode}; pub(crate) fn test_dummy_bootloader() { let mut base_system_contracts = BASE_SYSTEM_CONTRACTS.clone(); @@ -15,7 +14,7 @@ pub(crate) fn test_dummy_bootloader() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build::(); - let result = vm.vm.execute(InspectExecutionMode::Bootloader); + let result = vm.vm.finish_batch_without_pubdata(); assert!(!result.result.is_failed()); let correct_first_cell = U256::from_str_radix("123123123", 16).unwrap(); @@ -34,7 +33,7 @@ pub(crate) fn test_bootloader_out_of_gas() { .with_execution_mode(TxExecutionMode::VerifyExecute) .build::(); - let res = vm.vm.execute(InspectExecutionMode::Bootloader); + let res = vm.vm.finish_batch_without_pubdata(); assert_matches!( res.result, diff --git a/core/lib/multivm/src/versions/testonly/tester/mod.rs b/core/lib/multivm/src/versions/testonly/tester/mod.rs index 982a24503490..716b9386235f 100644 --- a/core/lib/multivm/src/versions/testonly/tester/mod.rs +++ b/core/lib/multivm/src/versions/testonly/tester/mod.rs @@ -193,6 +193,8 @@ pub(crate) trait TestedVm: pubdata_builder: Rc, ) -> VmExecutionResultAndLogs; + fn finish_batch_without_pubdata(&mut self) -> VmExecutionResultAndLogs; + fn insert_bytecodes(&mut self, bytecodes: &[&[u8]]); /// Includes bytecodes that have failed to decommit. Should exclude base system contract bytecodes (default AA / EVM emulator). diff --git a/core/lib/multivm/src/versions/vm_fast/tests/mod.rs b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs index bb766b7a98dc..2b4665f82241 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/mod.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs @@ -5,7 +5,7 @@ use zksync_utils::h256_to_u256; use zksync_vm2::interface::{Event, HeapId, StateInterface}; use zksync_vm_interface::{ pubdata::PubdataBuilder, storage::ReadStorage, CurrentExecutionState, L2BlockEnv, - VmExecutionResultAndLogs, VmInterface, + VmExecutionMode, VmExecutionResultAndLogs, VmInterface, }; use super::Vm; @@ -109,6 +109,10 @@ impl TestedVm for Vm> { .block_tip_execution_result } + fn finish_batch_without_pubdata(&mut self) -> VmExecutionResultAndLogs { + self.inspect_inner(&mut Default::default(), VmExecutionMode::Batch) + } + fn insert_bytecodes(&mut self, bytecodes: &[&[u8]]) { self.insert_bytecodes(bytecodes.iter().copied()) } diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index 9e8676f09926..a2114a339481 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -535,7 +535,7 @@ impl Vm { } } - fn inspect_inner( + pub(crate) fn inspect_inner( &mut self, tracer: &mut Tr, execution_mode: VmExecutionMode, diff --git a/core/lib/multivm/src/versions/vm_latest/tests/mod.rs b/core/lib/multivm/src/versions/vm_latest/tests/mod.rs index a11c895bc756..96d59f208b03 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/mod.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/mod.rs @@ -98,6 +98,14 @@ impl TestedVm for TestedLatestVm { ) } + fn finish_batch_without_pubdata(&mut self) -> VmExecutionResultAndLogs { + self.inspect_inner( + &mut TracerDispatcher::default(), + VmExecutionMode::Batch, + None, + ) + } + fn insert_bytecodes(&mut self, bytecodes: &[&[u8]]) { let bytecodes = bytecodes .iter()