From 16f275756cd28024a6b11ac1ac327eb5b8b446e1 Mon Sep 17 00:00:00 2001
From: perekopskiy <53865202+perekopskiy@users.noreply.github.com>
Date: Thu, 24 Oct 2024 12:07:20 +0300
Subject: [PATCH] feat: gateway preparation (#3006)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## What ❔
- adds new fields to DB tables and rust structs
- adds new config variables
- update commitment generator to work with post-gateway
- adds new vm subversion (vm fast is not changed yet)
## Why ❔
prepare for gateway, reduce sync-layer-stable diff
## Checklist
- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk_supervisor fmt` and `zk_supervisor
lint`.
---
Cargo.lock | 2 +
core/bin/external_node/src/config/mod.rs | 8 +
core/bin/external_node/src/node_builder.rs | 20 +-
core/bin/snapshots_creator/src/tests.rs | 1 +
.../system-constants-generator/src/utils.rs | 9 +-
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 | 26 +-
core/lib/constants/src/lib.rs | 1 +
core/lib/constants/src/message_root.rs | 5 +
core/lib/constants/src/system_logs.rs | 11 +-
core/lib/contracts/src/lib.rs | 14 +
...01396dacefc0cea8cbcf5807185eb00fc0f7.json} | 30 +-
...0cc9e176729744c779fee97ca9392ae8a8c8.json} | 18 +-
...11345ef888824e0ca3c5f39befbbc5bd0388.json} | 7 +-
...892118f5732374e62f35e27800422afb5746.json} | 30 +-
...2f38816f163a3e3fba4fdbb81076b969e970.json} | 30 +-
...911add046315e5f8877bc57a34e3dadf9e37.json} | 30 +-
...7bd02627ebaf2df7c5ad517cb60a243182d2.json} | 16 +-
...3369701d7cd5f75ca031bf77ca27d0437cb9.json} | 30 +-
...33f6503bc79cc9f809d35c558e275ba117ba.json} | 8 +-
...806fcc54d73216a7dc54be6ba210ef02d789.json} | 30 +-
...0e9c138d0a6d35e9ce7fc396c5e76fbc25dd.json} | 30 +-
...673e4b5bba059ebe07bbbb64578881db030b.json} | 30 +-
...7999eabb611338925abe9dc9e64c837183d9.json} | 18 +-
.../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/conv.rs | 45 +-
core/lib/dal/src/consensus/mod.rs | 5 +-
core/lib/dal/src/consensus/proto/mod.proto | 11 +
core/lib/dal/src/consensus/tests.rs | 11 +-
core/lib/dal/src/consensus_dal/tests.rs | 3 +
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/lib.rs | 1 +
core/lib/multivm/src/pubdata_builders/mod.rs | 24 +
.../multivm/src/pubdata_builders/rollup.rs | 128 ++
.../lib/multivm/src/pubdata_builders/tests.rs | 123 +
.../lib/multivm/src/pubdata_builders/utils.rs | 70 +
.../multivm/src/pubdata_builders/validium.rs | 93 +
core/lib/multivm/src/utils/events.rs | 56 +-
core/lib/multivm/src/utils/mod.rs | 69 +-
core/lib/multivm/src/versions/shadow/mod.rs | 1 -
core/lib/multivm/src/versions/shadow/tests.rs | 26 +-
.../src/versions/testonly/block_tip.rs | 8 +-
.../src/versions/testonly/bootloader.rs | 6 +-
.../versions/testonly/bytecode_publishing.rs | 8 +-
.../multivm/src/versions/testonly/circuits.rs | 4 +-
.../src/versions/testonly/code_oracle.rs | 10 +-
.../src/versions/testonly/default_aa.rs | 8 +-
.../versions/testonly/get_used_contracts.rs | 7 +-
.../src/versions/testonly/is_write_initial.rs | 6 +-
.../src/versions/testonly/l1_tx_execution.rs | 14 +-
.../src/versions/testonly/l2_blocks.rs | 18 +-
core/lib/multivm/src/versions/testonly/mod.rs | 13 +-
.../src/versions/testonly/nonce_holder.rs | 4 +-
.../src/versions/testonly/precompiles.rs | 8 +-
.../multivm/src/versions/testonly/refunds.rs | 27 +-
.../src/versions/testonly/require_eip712.rs | 8 +-
.../src/versions/testonly/secp256r1.rs | 4 +-
.../src/versions/testonly/simple_execution.rs | 16 +-
.../multivm/src/versions/testonly/storage.rs | 8 +-
.../src/versions/testonly/tester/mod.rs | 16 +-
.../testonly/tester/transaction_test_info.rs | 13 +-
.../multivm/src/versions/testonly/transfer.rs | 22 +-
.../multivm/src/versions/testonly/upgrade.rs | 22 +-
core/lib/multivm/src/versions/vm_1_3_2/vm.rs | 17 +-
.../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 | 15 +-
.../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 | 11 +-
.../tracers/pubdata_tracer.rs | 3 +-
.../types/internals/pubdata.rs | 2 +-
.../src/versions/vm_boojum_integration/vm.rs | 11 +-
.../multivm/src/versions/vm_fast/pubdata.rs | 2 +-
.../multivm/src/versions/vm_fast/tests/mod.rs | 17 +-
core/lib/multivm/src/versions/vm_fast/vm.rs | 81 +-
.../vm_latest/bootloader_state/state.rs | 43 +-
.../vm_latest/bootloader_state/utils.rs | 77 +-
.../src/versions/vm_latest/constants.rs | 3 +-
.../vm_latest/implementation/execution.rs | 1 +
.../versions/vm_latest/tests/call_tracer.rs | 6 +-
.../src/versions/vm_latest/tests/mod.rs | 25 +-
.../vm_latest/tests/prestate_tracer.rs | 10 +-
.../src/versions/vm_latest/tests/rollbacks.rs | 10 +-
.../vm_latest/tracers/pubdata_tracer.rs | 30 +-
.../versions/vm_latest/types/internals/mod.rs | 2 -
.../vm_latest/types/internals/pubdata.rs | 123 -
.../vm_latest/types/internals/vm_state.rs | 1 +
core/lib/multivm/src/versions/vm_latest/vm.rs | 35 +-
core/lib/multivm/src/versions/vm_m5/vm.rs | 19 +-
core/lib/multivm/src/versions/vm_m6/vm.rs | 14 +-
.../src/versions/vm_refunds_enhancement/vm.rs | 13 +-
.../src/versions/vm_virtual_blocks/vm.rs | 11 +-
core/lib/multivm/src/vm_instance.rs | 28 +-
core/lib/protobuf_config/src/contracts.rs | 16 +
.../src/proto/config/contracts.proto | 2 +
core/lib/prover_interface/src/inputs.rs | 5 +-
core/lib/snapshots_applier/src/tests/utils.rs | 1 +
core/lib/state/src/test_utils.rs | 1 +
core/lib/tee_verifier/src/lib.rs | 10 +-
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 | 140 +-
core/lib/types/src/commitment/tests/mod.rs | 5 +
.../tests/post_boojum_1_4_1_test.json | 33 +-
.../tests/post_boojum_1_4_2_test.json | 33 +-
.../tests/post_boojum_1_5_0_test.json | 187 +-
.../post_boojum_1_5_0_test_with_evm.json | 187 +-
.../commitment/tests/post_gateway_test.json | 1977 +++++++++++++++++
core/lib/types/src/l2_to_l1_log.rs | 15 +-
core/lib/vm_executor/src/batch/factory.rs | 30 +-
core/lib/vm_executor/src/oneshot/block.rs | 1 +
core/lib/vm_executor/src/oneshot/contracts.rs | 5 +
core/lib/vm_executor/src/oneshot/mod.rs | 7 +-
core/lib/vm_executor/src/storage.rs | 17 +-
core/lib/vm_interface/src/executor.rs | 3 +-
core/lib/vm_interface/src/lib.rs | 5 +-
core/lib/vm_interface/src/pubdata/mod.rs | 90 +
.../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 | 17 +-
core/lib/vm_interface/src/utils/shadow.rs | 16 +-
core/lib/vm_interface/src/vm.rs | 13 +-
core/node/api_server/src/web3/state.rs | 1 +
core/node/block_reverter/src/tests.rs | 1 +
core/node/commitment_generator/Cargo.toml | 1 +
core/node/commitment_generator/src/lib.rs | 63 +-
core/node/commitment_generator/src/utils.rs | 88 +-
core/node/consensus/src/storage/store.rs | 8 +
core/node/consensus/src/testonly.rs | 13 +-
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 | 15 +-
core/node/node_sync/src/external_io.rs | 5 +-
core/node/node_sync/src/fetcher.rs | 16 +-
core/node/node_sync/src/sync_action.rs | 1 +
core/node/node_sync/src/tests.rs | 6 +-
.../src/request_processor.rs | 91 +-
.../src/tee_request_processor.rs | 3 +-
.../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 | 83 +-
core/node/state_keeper/src/io/mod.rs | 16 +-
core/node/state_keeper/src/io/persistence.rs | 85 +-
.../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 | 14 +-
core/node/state_keeper/src/io/tests/tester.rs | 2 +
core/node/state_keeper/src/keeper.rs | 25 +-
core/node/state_keeper/src/testonly/mod.rs | 7 +-
.../src/testonly/test_batch_executor.rs | 7 +-
core/node/state_keeper/src/tests/mod.rs | 3 +-
core/node/state_keeper/src/updates/mod.rs | 20 +-
core/node/test_utils/src/lib.rs | 9 +
core/node/vm_runner/src/process.rs | 1 +
core/node/vm_runner/src/storage.rs | 9 +-
core/tests/vm-benchmark/src/vm.rs | 8 +-
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 +
yarn.lock | 235 +-
zkstack_cli/crates/config/src/contracts.rs | 2 +
188 files changed, 4838 insertions(+), 1207 deletions(-)
create mode 100644 core/lib/constants/src/message_root.rs
rename core/lib/dal/.sqlx/{query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json => query-1cb61327bed4d65a3fc81aa2229e01396dacefc0cea8cbcf5807185eb00fc0f7.json} (78%)
rename core/lib/dal/.sqlx/{query-a62f400a5b0b66300f5febf762c7e0c8a39a49d1cea78ef771d4c64fbbc16756.json => query-250cc655f48144137906a72490680cc9e176729744c779fee97ca9392ae8a8c8.json} (83%)
rename core/lib/dal/.sqlx/{query-55f4585be3d0f1a147cb10f6e59325fad494a512ba92df95439d2d7fe0f3a285.json => query-398598e20f1892b47bf749b220f611345ef888824e0ca3c5f39befbbc5bd0388.json} (65%)
rename core/lib/dal/.sqlx/{query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json => query-45154c2efc8d07c4f83ae3e229f9892118f5732374e62f35e27800422afb5746.json} (70%)
rename core/lib/dal/.sqlx/{query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json => query-4bd1a4e612d10f2ca26068c140442f38816f163a3e3fba4fdbb81076b969e970.json} (79%)
rename core/lib/dal/.sqlx/{query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json => query-62e8330881b73917394384adbf73911add046315e5f8877bc57a34e3dadf9e37.json} (79%)
rename core/lib/dal/.sqlx/{query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.json => query-7553d8013d101af0451830d26b7d7bd02627ebaf2df7c5ad517cb60a243182d2.json} (83%)
rename core/lib/dal/.sqlx/{query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json => query-77864e5eb5eada8edf8f4457aa153369701d7cd5f75ca031bf77ca27d0437cb9.json} (80%)
rename core/lib/dal/.sqlx/{query-34910600545933d85931d41bfe2dfcb3522a0772ac3d2476652df4216d823e04.json => query-7d8c19c3568c03ec3e4a788b22c233f6503bc79cc9f809d35c558e275ba117ba.json} (55%)
rename core/lib/dal/.sqlx/{query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json => query-a42121cd85daeb95ee268ba5cff1806fcc54d73216a7dc54be6ba210ef02d789.json} (73%)
rename core/lib/dal/.sqlx/{query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json => query-b7d448837439a3e3dfe73070d3c20e9c138d0a6d35e9ce7fc396c5e76fbc25dd.json} (73%)
rename core/lib/dal/.sqlx/{query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json => query-c5aedd2b1871d8f6276a31482caa673e4b5bba059ebe07bbbb64578881db030b.json} (77%)
rename core/lib/dal/.sqlx/{query-f208ac4d454220cdd5cf8fa1405b21ca4cc94c38a7d18023ef1e89de484e60d8.json => query-d4cdd4eed07dfdad2757c480903f7999eabb611338925abe9dc9e64c837183d9.json} (84%)
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/multivm/src/pubdata_builders/mod.rs
create mode 100644 core/lib/multivm/src/pubdata_builders/rollup.rs
create mode 100644 core/lib/multivm/src/pubdata_builders/tests.rs
create mode 100644 core/lib/multivm/src/pubdata_builders/utils.rs
create mode 100644 core/lib/multivm/src/pubdata_builders/validium.rs
delete mode 100644 core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs
create mode 100644 core/lib/types/src/commitment/tests/post_gateway_test.json
create mode 100644 core/lib/vm_interface/src/pubdata/mod.rs
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 a42ef8e3fdcc..64ae0a9a12f4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -9667,6 +9667,7 @@ dependencies = [
"zksync_multivm",
"zksync_node_genesis",
"zksync_node_test_utils",
+ "zksync_system_constants",
"zksync_types",
"zksync_utils",
"zksync_web3_decl",
@@ -10532,6 +10533,7 @@ dependencies = [
"zk_evm 0.150.6",
"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 56ee3edfd253..70803a663110 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,
}
@@ -1403,6 +1410,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 7d8489013535..883f3f8a5fae 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,11 +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`.
+ Some(l2_shared_bridge_addr)
+ };
+
let persistence_layer = OutputHandlerLayer::new(
- self.config
- .remote
- .l2_shared_bridge_addr
- .expect("L2 shared bridge address is not set"),
+ 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 800da68ee50d..16167975cf0e 100644
--- a/core/bin/system-constants-generator/src/utils.rs
+++ b/core/bin/system-constants-generator/src/utils.rs
@@ -9,7 +9,7 @@ use zksync_multivm::{
interface::{
storage::{InMemoryStorage, StorageView, WriteStorage},
tracer::VmExecutionStopReason,
- L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory,
+ InspectExecutionMode, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmFactory,
VmInterface, VmInterfaceExt,
},
tracers::dynamic::vm_1_5_0::DynTracer,
@@ -271,8 +271,9 @@ 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 result = vm.inspect(&mut tracer.into(), VmExecutionMode::Bootloader);
+ let result = vm.inspect(&mut tracer.into(), InspectExecutionMode::Bootloader);
assert!(!result.result.is_failed(), "The internal call has reverted");
tracer_result.take()
@@ -331,7 +332,7 @@ pub(super) fn execute_user_txs_in_test_gas_vm(
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 {
@@ -343,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/bin/zksync_server/src/node_builder.rs b/core/bin/zksync_server/src/node_builder.rs
index 234e22894240..e2bd487f22b6 100644
--- a/core/bin/zksync_server/src/node_builder.rs
+++ b/core/bin/zksync_server/src/node_builder.rs
@@ -238,9 +238,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);
@@ -249,6 +247,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 e01586cdad7d..ebecfaa1b872 100644
--- a/core/lib/basic_types/src/protocol_version.rs
+++ b/core/lib/basic_types/src/protocol_version.rs
@@ -69,6 +69,7 @@ pub enum ProtocolVersionId {
Version24,
Version25,
Version26,
+ Version27,
}
impl ProtocolVersionId {
@@ -122,6 +123,7 @@ impl ProtocolVersionId {
ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version25 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version26 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
+ ProtocolVersionId::Version27 => VmVersion::VmGateway,
}
}
@@ -139,6 +141,10 @@ impl ProtocolVersionId {
self <= &Self::Version22
}
+ pub fn is_pre_gateway(&self) -> bool {
+ self <= &Self::Version26
+ }
+
pub fn is_1_4_0(&self) -> bool {
self >= &ProtocolVersionId::Version18 && self < &ProtocolVersionId::Version20
}
@@ -278,6 +284,7 @@ impl From for VmVersion {
ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version25 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version26 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
+ ProtocolVersionId::Version27 => 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 880bc5aa98d2..ce681cc0cc43 100644
--- a/core/lib/config/src/testonly.rs
+++ b/core/lib/config/src/testonly.rs
@@ -262,6 +262,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()),
@@ -269,6 +270,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 fe37ef6c69fd..4f0f362d9149 100644
--- a/core/lib/constants/src/contracts.rs
+++ b/core/lib/constants/src/contracts.rs
@@ -135,12 +135,36 @@ pub const EVM_GAS_MANAGER_ADDRESS: Address = H160([
0x00, 0x00, 0x80, 0x13,
]);
-/// Note, that the `Create2Factory` is explicitly deployed on a non-system-contract address.
pub const CREATE2_FACTORY_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00,
]);
+pub const 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/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/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 0ee773abcd4a..cb5be504c8a0 100644
--- a/core/lib/contracts/src/lib.rs
+++ b/core/lib/contracts/src/lib.rs
@@ -516,6 +516,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",
@@ -586,6 +593,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-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json b/core/lib/dal/.sqlx/query-1cb61327bed4d65a3fc81aa2229e01396dacefc0cea8cbcf5807185eb00fc0f7.json
similarity index 78%
rename from core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json
rename to core/lib/dal/.sqlx/query-1cb61327bed4d65a3fc81aa2229e01396dacefc0cea8cbcf5807185eb00fc0f7.json
index dffd3ed8f9d2..48adcd412676 100644
--- a/core/lib/dal/.sqlx/query-7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8.json
+++ b/core/lib/dal/.sqlx/query-1cb61327bed4d65a3fc81aa2229e01396dacefc0cea8cbcf5807185eb00fc0f7.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 evm_emulator_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 fee_address\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 evm_emulator_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 fee_address,\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": [
{
@@ -142,6 +142,26 @@
"ordinal": 27,
"name": "fee_address",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 28,
+ "name": "aggregation_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 29,
+ "name": "local_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 30,
+ "name": "state_diff_hash",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 31,
+ "name": "inclusion_data",
+ "type_info": "Bytea"
}
],
"parameters": {
@@ -175,8 +195,12 @@
true,
true,
true,
- false
+ false,
+ true,
+ true,
+ true,
+ true
]
},
- "hash": "7aebc0d8eb43bd835c4f175edc4c0371bdc118b25d64fcf526bd6575e4d675c8"
+ "hash": "1cb61327bed4d65a3fc81aa2229e01396dacefc0cea8cbcf5807185eb00fc0f7"
}
diff --git a/core/lib/dal/.sqlx/query-a62f400a5b0b66300f5febf762c7e0c8a39a49d1cea78ef771d4c64fbbc16756.json b/core/lib/dal/.sqlx/query-250cc655f48144137906a72490680cc9e176729744c779fee97ca9392ae8a8c8.json
similarity index 83%
rename from core/lib/dal/.sqlx/query-a62f400a5b0b66300f5febf762c7e0c8a39a49d1cea78ef771d4c64fbbc16756.json
rename to core/lib/dal/.sqlx/query-250cc655f48144137906a72490680cc9e176729744c779fee97ca9392ae8a8c8.json
index c8c438295e49..5c4ce3d6a4e3 100644
--- a/core/lib/dal/.sqlx/query-a62f400a5b0b66300f5febf762c7e0c8a39a49d1cea78ef771d4c64fbbc16756.json
+++ b/core/lib/dal/.sqlx/query-250cc655f48144137906a72490680cc9e176729744c779fee97ca9392ae8a8c8.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 evm_emulator_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 evm_emulator_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": [
{
@@ -92,6 +92,16 @@
"ordinal": 17,
"name": "logs_bloom",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 18,
+ "name": "l2_da_validator_address",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 19,
+ "name": "pubdata_type",
+ "type_info": "Text"
}
],
"parameters": {
@@ -115,8 +125,10 @@
false,
true,
true,
- true
+ true,
+ false,
+ false
]
},
- "hash": "a62f400a5b0b66300f5febf762c7e0c8a39a49d1cea78ef771d4c64fbbc16756"
+ "hash": "250cc655f48144137906a72490680cc9e176729744c779fee97ca9392ae8a8c8"
}
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-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json b/core/lib/dal/.sqlx/query-45154c2efc8d07c4f83ae3e229f9892118f5732374e62f35e27800422afb5746.json
similarity index 70%
rename from core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json
rename to core/lib/dal/.sqlx/query-45154c2efc8d07c4f83ae3e229f9892118f5732374e62f35e27800422afb5746.json
index 8c22b4f92c4e..11bff1102932 100644
--- a/core/lib/dal/.sqlx/query-942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf.json
+++ b/core/lib/dal/.sqlx/query-45154c2efc8d07c4f83ae3e229f9892118f5732374e62f35e27800422afb5746.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 l1_batches.evm_emulator_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 fee_address\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 l1_batches.evm_emulator_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 fee_address,\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": [
{
@@ -142,6 +142,26 @@
"ordinal": 27,
"name": "fee_address",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 28,
+ "name": "aggregation_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 29,
+ "name": "local_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 30,
+ "name": "state_diff_hash",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 31,
+ "name": "inclusion_data",
+ "type_info": "Bytea"
}
],
"parameters": {
@@ -181,8 +201,12 @@
true,
true,
true,
- false
+ false,
+ true,
+ true,
+ true,
+ true
]
},
- "hash": "942d6d948770c374ba4d3566c50e56e43137ac0cf45312d70dec0c407cadc1bf"
+ "hash": "45154c2efc8d07c4f83ae3e229f9892118f5732374e62f35e27800422afb5746"
}
diff --git a/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json b/core/lib/dal/.sqlx/query-4bd1a4e612d10f2ca26068c140442f38816f163a3e3fba4fdbb81076b969e970.json
similarity index 79%
rename from core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json
rename to core/lib/dal/.sqlx/query-4bd1a4e612d10f2ca26068c140442f38816f163a3e3fba4fdbb81076b969e970.json
index e55d10d6f9a8..66d3e18075bf 100644
--- a/core/lib/dal/.sqlx/query-e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7.json
+++ b/core/lib/dal/.sqlx/query-4bd1a4e612d10f2ca26068c140442f38816f163a3e3fba4fdbb81076b969e970.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 evm_emulator_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 fee_address\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 evm_emulator_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 fee_address,\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": [
{
@@ -142,6 +142,26 @@
"ordinal": 27,
"name": "fee_address",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 28,
+ "name": "aggregation_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 29,
+ "name": "local_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 30,
+ "name": "state_diff_hash",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 31,
+ "name": "inclusion_data",
+ "type_info": "Bytea"
}
],
"parameters": {
@@ -179,8 +199,12 @@
true,
true,
true,
- false
+ false,
+ true,
+ true,
+ true,
+ true
]
},
- "hash": "e2d0bd978f76e0ce09b36b0e4b0a2baec4b2531ecaa8da234863e2eb810761c7"
+ "hash": "4bd1a4e612d10f2ca26068c140442f38816f163a3e3fba4fdbb81076b969e970"
}
diff --git a/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json b/core/lib/dal/.sqlx/query-62e8330881b73917394384adbf73911add046315e5f8877bc57a34e3dadf9e37.json
similarity index 79%
rename from core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json
rename to core/lib/dal/.sqlx/query-62e8330881b73917394384adbf73911add046315e5f8877bc57a34e3dadf9e37.json
index 84f677a36c86..dfdb4b6c82e7 100644
--- a/core/lib/dal/.sqlx/query-0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e.json
+++ b/core/lib/dal/.sqlx/query-62e8330881b73917394384adbf73911add046315e5f8877bc57a34e3dadf9e37.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 evm_emulator_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 fee_address\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 evm_emulator_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 fee_address,\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": [
{
@@ -142,6 +142,26 @@
"ordinal": 27,
"name": "fee_address",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 28,
+ "name": "aggregation_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 29,
+ "name": "local_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 30,
+ "name": "state_diff_hash",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 31,
+ "name": "inclusion_data",
+ "type_info": "Bytea"
}
],
"parameters": {
@@ -177,8 +197,12 @@
true,
true,
true,
- false
+ false,
+ true,
+ true,
+ true,
+ true
]
},
- "hash": "0784f2cc13f85763cc7da29902850fa76a03907957b7a0d87ea55a7873f3312e"
+ "hash": "62e8330881b73917394384adbf73911add046315e5f8877bc57a34e3dadf9e37"
}
diff --git a/core/lib/dal/.sqlx/query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.json b/core/lib/dal/.sqlx/query-7553d8013d101af0451830d26b7d7bd02627ebaf2df7c5ad517cb60a243182d2.json
similarity index 83%
rename from core/lib/dal/.sqlx/query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.json
rename to core/lib/dal/.sqlx/query-7553d8013d101af0451830d26b7d7bd02627ebaf2df7c5ad517cb60a243182d2.json
index b8f8db874b63..6cc2e22382dd 100644
--- a/core/lib/dal/.sqlx/query-2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f.json
+++ b/core/lib/dal/.sqlx/query-7553d8013d101af0451830d26b7d7bd02627ebaf2df7c5ad517cb60a243182d2.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 WHERE\n is_sealed\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.evm_emulator_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 WHERE\n is_sealed\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.evm_emulator_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": [
{
@@ -72,6 +72,16 @@
"ordinal": 13,
"name": "fee_account_address!",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 14,
+ "name": "l2_da_validator_address!",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 15,
+ "name": "pubdata_type!",
+ "type_info": "Text"
}
],
"parameters": {
@@ -94,8 +104,10 @@
false,
false,
true,
+ false,
+ false,
false
]
},
- "hash": "2049362aad5e32981e48e5c5ef7a00a91254ec6c8a68a359d22b02df5a40911f"
+ "hash": "7553d8013d101af0451830d26b7d7bd02627ebaf2df7c5ad517cb60a243182d2"
}
diff --git a/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json b/core/lib/dal/.sqlx/query-77864e5eb5eada8edf8f4457aa153369701d7cd5f75ca031bf77ca27d0437cb9.json
similarity index 80%
rename from core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json
rename to core/lib/dal/.sqlx/query-77864e5eb5eada8edf8f4457aa153369701d7cd5f75ca031bf77ca27d0437cb9.json
index 80a6946026b0..f4e08abe31c5 100644
--- a/core/lib/dal/.sqlx/query-b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960.json
+++ b/core/lib/dal/.sqlx/query-77864e5eb5eada8edf8f4457aa153369701d7cd5f75ca031bf77ca27d0437cb9.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 evm_emulator_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 fee_address\n FROM\n l1_batches\n LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number\n WHERE\n is_sealed\n AND 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 evm_emulator_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 fee_address,\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 is_sealed\n AND number = $1\n ",
"describe": {
"columns": [
{
@@ -142,6 +142,26 @@
"ordinal": 27,
"name": "fee_address",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 28,
+ "name": "aggregation_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 29,
+ "name": "local_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 30,
+ "name": "state_diff_hash",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 31,
+ "name": "inclusion_data",
+ "type_info": "Bytea"
}
],
"parameters": {
@@ -177,8 +197,12 @@
true,
true,
true,
- false
+ false,
+ true,
+ true,
+ true,
+ true
]
},
- "hash": "b456147560b107640abdc10f7ac76b563ff2f0f3a818e8c8a02c2ef632d0b960"
+ "hash": "77864e5eb5eada8edf8f4457aa153369701d7cd5f75ca031bf77ca27d0437cb9"
}
diff --git a/core/lib/dal/.sqlx/query-34910600545933d85931d41bfe2dfcb3522a0772ac3d2476652df4216d823e04.json b/core/lib/dal/.sqlx/query-7d8c19c3568c03ec3e4a788b22c233f6503bc79cc9f809d35c558e275ba117ba.json
similarity index 55%
rename from core/lib/dal/.sqlx/query-34910600545933d85931d41bfe2dfcb3522a0772ac3d2476652df4216d823e04.json
rename to core/lib/dal/.sqlx/query-7d8c19c3568c03ec3e4a788b22c233f6503bc79cc9f809d35c558e275ba117ba.json
index 35c606bf22bb..f89f531c4463 100644
--- a/core/lib/dal/.sqlx/query-34910600545933d85931d41bfe2dfcb3522a0772ac3d2476652df4216d823e04.json
+++ b/core/lib/dal/.sqlx/query-7d8c19c3568c03ec3e4a788b22c233f6503bc79cc9f809d35c558e275ba117ba.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 evm_emulator_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 $18,\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 evm_emulator_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 $20,\n NOW(),\n NOW()\n )\n ",
"describe": {
"columns": [],
"parameters": {
@@ -22,10 +22,12 @@
"Int8",
"Int8",
"Int8",
- "Bytea"
+ "Bytea",
+ "Bytea",
+ "Text"
]
},
"nullable": []
},
- "hash": "34910600545933d85931d41bfe2dfcb3522a0772ac3d2476652df4216d823e04"
+ "hash": "7d8c19c3568c03ec3e4a788b22c233f6503bc79cc9f809d35c558e275ba117ba"
}
diff --git a/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json b/core/lib/dal/.sqlx/query-a42121cd85daeb95ee268ba5cff1806fcc54d73216a7dc54be6ba210ef02d789.json
similarity index 73%
rename from core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json
rename to core/lib/dal/.sqlx/query-a42121cd85daeb95ee268ba5cff1806fcc54d73216a7dc54be6ba210ef02d789.json
index 4f138822ad1b..9a93ba45978e 100644
--- a/core/lib/dal/.sqlx/query-f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8.json
+++ b/core/lib/dal/.sqlx/query-a42121cd85daeb95ee268ba5cff1806fcc54d73216a7dc54be6ba210ef02d789.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 evm_emulator_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 fee_address\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 evm_emulator_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 fee_address,\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": [
{
@@ -142,6 +142,26 @@
"ordinal": 27,
"name": "fee_address",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 28,
+ "name": "aggregation_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 29,
+ "name": "local_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 30,
+ "name": "state_diff_hash",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 31,
+ "name": "inclusion_data",
+ "type_info": "Bytea"
}
],
"parameters": {
@@ -178,8 +198,12 @@
true,
true,
true,
- false
+ false,
+ true,
+ true,
+ true,
+ true
]
},
- "hash": "f30748bef5f8d08b60739cdfd9508c8132d0958e4e25f4954e93d2095b4f11e8"
+ "hash": "a42121cd85daeb95ee268ba5cff1806fcc54d73216a7dc54be6ba210ef02d789"
}
diff --git a/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json b/core/lib/dal/.sqlx/query-b7d448837439a3e3dfe73070d3c20e9c138d0a6d35e9ce7fc396c5e76fbc25dd.json
similarity index 73%
rename from core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json
rename to core/lib/dal/.sqlx/query-b7d448837439a3e3dfe73070d3c20e9c138d0a6d35e9ce7fc396c5e76fbc25dd.json
index afac14e6d5cd..8a68b1a9b9bd 100644
--- a/core/lib/dal/.sqlx/query-2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b.json
+++ b/core/lib/dal/.sqlx/query-b7d448837439a3e3dfe73070d3c20e9c138d0a6d35e9ce7fc396c5e76fbc25dd.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 l1_batches.evm_emulator_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 fee_address\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 l1_batches.evm_emulator_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 fee_address,\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": [
{
@@ -142,6 +142,26 @@
"ordinal": 27,
"name": "fee_address",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 28,
+ "name": "aggregation_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 29,
+ "name": "local_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 30,
+ "name": "state_diff_hash",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 31,
+ "name": "inclusion_data",
+ "type_info": "Bytea"
}
],
"parameters": {
@@ -180,8 +200,12 @@
true,
true,
true,
- false
+ false,
+ true,
+ true,
+ true,
+ true
]
},
- "hash": "2def67eb8372245ed59e76e07d615598f5d22a3aebd893afddded0e3c6b94a3b"
+ "hash": "b7d448837439a3e3dfe73070d3c20e9c138d0a6d35e9ce7fc396c5e76fbc25dd"
}
diff --git a/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json b/core/lib/dal/.sqlx/query-c5aedd2b1871d8f6276a31482caa673e4b5bba059ebe07bbbb64578881db030b.json
similarity index 77%
rename from core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json
rename to core/lib/dal/.sqlx/query-c5aedd2b1871d8f6276a31482caa673e4b5bba059ebe07bbbb64578881db030b.json
index 4eae4f778cee..f97ea8a6ccd5 100644
--- a/core/lib/dal/.sqlx/query-5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2.json
+++ b/core/lib/dal/.sqlx/query-c5aedd2b1871d8f6276a31482caa673e4b5bba059ebe07bbbb64578881db030b.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 evm_emulator_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 fee_address\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 evm_emulator_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 fee_address,\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": [
{
@@ -142,6 +142,26 @@
"ordinal": 27,
"name": "fee_address",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 28,
+ "name": "aggregation_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 29,
+ "name": "local_root",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 30,
+ "name": "state_diff_hash",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 31,
+ "name": "inclusion_data",
+ "type_info": "Bytea"
}
],
"parameters": {
@@ -177,8 +197,12 @@
true,
true,
true,
- false
+ false,
+ true,
+ true,
+ true,
+ true
]
},
- "hash": "5aa487a98dff53a5d32a5916a26cbf3ffb03b3791c0e9a9f39fb85cfffc65db2"
+ "hash": "c5aedd2b1871d8f6276a31482caa673e4b5bba059ebe07bbbb64578881db030b"
}
diff --git a/core/lib/dal/.sqlx/query-f208ac4d454220cdd5cf8fa1405b21ca4cc94c38a7d18023ef1e89de484e60d8.json b/core/lib/dal/.sqlx/query-d4cdd4eed07dfdad2757c480903f7999eabb611338925abe9dc9e64c837183d9.json
similarity index 84%
rename from core/lib/dal/.sqlx/query-f208ac4d454220cdd5cf8fa1405b21ca4cc94c38a7d18023ef1e89de484e60d8.json
rename to core/lib/dal/.sqlx/query-d4cdd4eed07dfdad2757c480903f7999eabb611338925abe9dc9e64c837183d9.json
index 700352c1a8bf..111234e02b75 100644
--- a/core/lib/dal/.sqlx/query-f208ac4d454220cdd5cf8fa1405b21ca4cc94c38a7d18023ef1e89de484e60d8.json
+++ b/core/lib/dal/.sqlx/query-d4cdd4eed07dfdad2757c480903f7999eabb611338925abe9dc9e64c837183d9.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 evm_emulator_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 evm_emulator_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": [
{
@@ -92,6 +92,16 @@
"ordinal": 17,
"name": "logs_bloom",
"type_info": "Bytea"
+ },
+ {
+ "ordinal": 18,
+ "name": "l2_da_validator_address",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 19,
+ "name": "pubdata_type",
+ "type_info": "Text"
}
],
"parameters": {
@@ -117,8 +127,10 @@
false,
true,
true,
- true
+ true,
+ false,
+ false
]
},
- "hash": "f208ac4d454220cdd5cf8fa1405b21ca4cc94c38a7d18023ef1e89de484e60d8"
+ "hash": "d4cdd4eed07dfdad2757c480903f7999eabb611338925abe9dc9e64c837183d9"
}
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 f71dc68ce757..943aa12caf75 100644
--- a/core/lib/dal/src/blocks_dal.rs
+++ b/core/lib/dal/src/blocks_dal.rs
@@ -344,10 +344,17 @@ impl BlocksDal<'_, '_> {
events_queue_commitment,
bootloader_initial_content_commitment,
pubdata_input,
- fee_address
+ fee_address,
+ 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
is_sealed
AND number = $1
@@ -841,6 +848,8 @@ impl BlocksDal<'_, '_> {
fair_pubdata_price,
gas_limit,
logs_bloom,
+ l2_da_validator_address,
+ pubdata_type,
created_at,
updated_at
)
@@ -864,6 +873,8 @@ impl BlocksDal<'_, '_> {
$16,
$17,
$18,
+ $19,
+ $20,
NOW(),
NOW()
)
@@ -896,6 +907,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?;
@@ -924,7 +940,9 @@ impl BlocksDal<'_, '_> {
virtual_blocks,
fair_pubdata_price,
gas_limit,
- logs_bloom
+ logs_bloom,
+ l2_da_validator_address,
+ pubdata_type
FROM
miniblocks
ORDER BY
@@ -965,7 +983,9 @@ impl BlocksDal<'_, '_> {
virtual_blocks,
fair_pubdata_price,
gas_limit,
- logs_bloom
+ logs_bloom,
+ l2_da_validator_address,
+ pubdata_type
FROM
miniblocks
WHERE
@@ -1062,9 +1082,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(),
@@ -1082,6 +1105,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")
@@ -1189,10 +1215,17 @@ impl BlocksDal<'_, '_> {
events_queue_commitment,
bootloader_initial_content_commitment,
pubdata_input,
- fee_address
+ fee_address,
+ 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
@@ -1377,10 +1410,17 @@ impl BlocksDal<'_, '_> {
events_queue_commitment,
bootloader_initial_content_commitment,
pubdata_input,
- fee_address
+ fee_address,
+ 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
@@ -1459,7 +1499,11 @@ impl BlocksDal<'_, '_> {
events_queue_commitment,
bootloader_initial_content_commitment,
pubdata_input,
- fee_address
+ fee_address,
+ aggregation_root,
+ local_root,
+ state_diff_hash,
+ data_availability.inclusion_data
FROM
(
SELECT
@@ -1480,6 +1524,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
"#,
@@ -1534,10 +1579,17 @@ impl BlocksDal<'_, '_> {
events_queue_commitment,
bootloader_initial_content_commitment,
pubdata_input,
- fee_address
+ fee_address,
+ 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
@@ -1663,10 +1715,17 @@ impl BlocksDal<'_, '_> {
events_queue_commitment,
bootloader_initial_content_commitment,
pubdata_input,
- fee_address
+ fee_address,
+ 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
@@ -1729,11 +1788,18 @@ impl BlocksDal<'_, '_> {
events_queue_commitment,
bootloader_initial_content_commitment,
pubdata_input,
- fee_address
+ fee_address,
+ 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
@@ -1809,7 +1875,11 @@ impl BlocksDal<'_, '_> {
events_queue_commitment,
bootloader_initial_content_commitment,
pubdata_input,
- fee_address
+ fee_address,
+ 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/conv.rs b/core/lib/dal/src/consensus/conv.rs
index 269c47fa2dd1..2b8488dd0c2a 100644
--- a/core/lib/dal/src/consensus/conv.rs
+++ b/core/lib/dal/src/consensus/conv.rs
@@ -4,7 +4,9 @@ use zksync_concurrency::net;
use zksync_consensus_roles::{attester, node};
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,
@@ -135,6 +137,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("l2_da_validator_address")?,
+ pubdata_type: required(&pubdata_params.pubdata_type)
+ .and_then(|x| Ok(proto::L1BatchCommitDataGeneratorMode::try_from(*x)?))
+ .context("pubdata_type")?
+ .parse(),
+ })
+ } else {
+ None
+ };
+
Ok(Self {
protocol_version,
hash: required(&r.hash)
@@ -153,6 +169,7 @@ impl ProtoFmt for Payload {
.context("operator_address")?,
transactions,
last_in_batch: *required(&r.last_in_batch).context("last_in_batch")?,
+ pubdata_params,
})
}
@@ -171,6 +188,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 => {
@@ -517,3 +544,19 @@ impl ProtoRepr for proto::AttesterCommittee {
}
}
}
+
+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,
+ }
+ }
+}
diff --git a/core/lib/dal/src/consensus/mod.rs b/core/lib/dal/src/consensus/mod.rs
index 8e88265730e9..c7e46b2cf1b7 100644
--- a/core/lib/dal/src/consensus/mod.rs
+++ b/core/lib/dal/src/consensus/mod.rs
@@ -2,7 +2,9 @@ use std::collections::BTreeMap;
use zksync_concurrency::net;
use zksync_consensus_roles::{attester, node, validator};
-use zksync_types::{ethabi, Address, L1BatchNumber, ProtocolVersionId, Transaction, H256};
+use zksync_types::{
+ commitment::PubdataParams, ethabi, Address, L1BatchNumber, ProtocolVersionId, Transaction, H256,
+};
mod conv;
pub mod proto;
@@ -46,6 +48,7 @@ pub struct Payload {
pub operator_address: Address,
pub transactions: Vec,
pub last_in_batch: bool,
+ pub pubdata_params: Option,
}
impl Payload {
diff --git a/core/lib/dal/src/consensus/proto/mod.proto b/core/lib/dal/src/consensus/proto/mod.proto
index 421904bf966b..49a69e8a36ec 100644
--- a/core/lib/dal/src/consensus/proto/mod.proto
+++ b/core/lib/dal/src/consensus/proto/mod.proto
@@ -26,6 +26,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 {
@@ -142,3 +148,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 e8342b7446cc..c9fd91748b2b 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::*;
@@ -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/consensus_dal/tests.rs b/core/lib/dal/src/consensus_dal/tests.rs
index 772e7b2bf5e7..694abc8508b6 100644
--- a/core/lib/dal/src/consensus_dal/tests.rs
+++ b/core/lib/dal/src/consensus_dal/tests.rs
@@ -131,6 +131,9 @@ async fn test_batch_certificate() {
compressed_repeated_writes: None,
zkporter_is_available: false,
aux_commitments: None,
+ aggregation_root: rng.gen(),
+ local_root: rng.gen(),
+ state_diff_hash: rng.gen(),
},
)
.await
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 fbe225beb902..20b428adec44 100644
--- a/core/lib/dal/src/lib.rs
+++ b/core/lib/dal/src/lib.rs
@@ -131,7 +131,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)]
@@ -255,7 +255,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 3bb433a05cf8..159ed71cc3e9 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, UnsealedL1BatchHeader},
- 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,
@@ -155,6 +155,10 @@ pub(crate) struct StorageL1Batch {
pub bootloader_initial_content_commitment: Option>,
pub pubdata_input: Option>,
pub fee_address: Vec,
+ pub aggregation_root: Option>,
+ pub local_root: Option>,
+ pub state_diff_hash: Option>,
+ pub inclusion_data: Option>,
}
impl StorageL1Batch {
@@ -263,6 +267,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,
})
}
}
@@ -485,6 +493,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 {
@@ -532,6 +542,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 7a4ebe074fe0..0eb65a606d1f 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, parse_h160, parse_h256, parse_h256_opt, Address, L1BatchNumber, L2BlockNumber,
+ api::en,
+ commitment::{L1BatchCommitmentMode, PubdataParams},
+ parse_h160, parse_h256, parse_h256_opt, Address, L1BatchNumber, L2BlockNumber,
ProtocolVersionId, Transaction, H256,
};
@@ -25,6 +29,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 {
@@ -40,6 +46,7 @@ pub(crate) struct SyncBlock {
pub virtual_blocks: u32,
pub hash: H256,
pub protocol_version: ProtocolVersionId,
+ pub pubdata_params: PubdataParams,
}
impl TryFrom for SyncBlock {
@@ -89,6 +96,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)
+ .decode_column("Invalid pubdata type")?,
+ l2_da_validator_address: parse_h160(&block.l2_da_validator_address)
+ .decode_column("l2_da_validator_address")?,
+ },
})
}
}
@@ -109,6 +122,7 @@ impl SyncBlock {
virtual_blocks: Some(self.virtual_blocks),
hash: Some(self.hash),
protocol_version: self.protocol_version,
+ pubdata_params: Some(self.pubdata_params),
}
}
@@ -125,6 +139,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 265c61354887..55e6543c0285 100644
--- a/core/lib/dal/src/sync_dal.rs
+++ b/core/lib/dal/src/sync_dal.rs
@@ -56,7 +56,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 bf85008f7b58..baa2ee584856 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(),
}
}
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 5e788509461d..de115cf6e7a6 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 = client
.fee_history(U64::from(chunk_size).into(), chunk_end.into(), vec![])
@@ -403,19 +431,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 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/lib.rs b/core/lib/multivm/src/lib.rs
index 520274c14ae0..1cba2c0fb92b 100644
--- a/core/lib/multivm/src/lib.rs
+++ b/core/lib/multivm/src/lib.rs
@@ -20,6 +20,7 @@ pub use crate::{
};
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..c52c4c70c86a
--- /dev/null
+++ b/core/lib/multivm/src/pubdata_builders/mod.rs
@@ -0,0 +1,24 @@
+use std::rc::Rc;
+
+pub use rollup::RollupPubdataBuilder;
+pub use validium::ValidiumPubdataBuilder;
+use zksync_types::commitment::{L1BatchCommitmentMode, PubdataParams};
+
+use crate::interface::pubdata::PubdataBuilder;
+
+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/multivm/src/pubdata_builders/rollup.rs b/core/lib/multivm/src/pubdata_builders/rollup.rs
new file mode 100644
index 000000000000..4a818dfe2314
--- /dev/null
+++ b/core/lib/multivm/src/pubdata_builders/rollup.rs
@@ -0,0 +1,128 @@
+use zksync_types::{
+ ethabi,
+ ethabi::{ParamType, Token},
+ l2_to_l1_log::l2_to_l1_logs_tree_size,
+ writes::compress_state_diffs,
+ 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 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 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/multivm/src/pubdata_builders/tests.rs b/core/lib/multivm/src/pubdata_builders/tests.rs
new file mode 100644
index 000000000000..bc24b8e47346
--- /dev/null
+++ b/core/lib/multivm/src/pubdata_builders/tests.rs
@@ -0,0 +1,123 @@
+use zksync_types::{
+ writes::StateDiffRecord, Address, ProtocolVersionId, ACCOUNT_CODE_STORAGE_ADDRESS,
+ BOOTLOADER_ADDRESS,
+};
+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
+ 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, 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, 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, ProtocolVersionId::Version27);
+ 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, ProtocolVersionId::Version27);
+ 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, ProtocolVersionId::Version27);
+ let expected = "89f9a07233e608561d90f7c4e7bcea24d718e425a6bd6c8eefb48a334366143694c75fae278944d856d68e33bbd32937cb3a1ea35cbf7d6eeeb1150f500dd0d64d0efe420d6dafe5897eab2fc27b2e47af303397ed285ace146d836d042717b0a3dc4b28a603a33b28ce1d5c52c593a46a15a99f1afa1c1d92715284288958fd54a93de700000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000005c000000010000000000000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000";
+ assert_eq!(
+ &hex::encode(actual),
+ expected,
+ "mismatch for `l1_messenger_operator_input`"
+ );
+
+ let actual =
+ validium_pubdata_builder.settlement_layer_pubdata(&input, ProtocolVersionId::Version27);
+ let expected = "fa96e2436e6fb4d668f5a06681a7c53fcb199b2747ee624ee52a13e85aac5f1e";
+ assert_eq!(
+ &hex::encode(actual),
+ expected,
+ "mismatch for `settlement_layer_pubdata`"
+ );
+}
diff --git a/core/lib/multivm/src/pubdata_builders/utils.rs b/core/lib/multivm/src/pubdata_builders/utils.rs
new file mode 100644
index 000000000000..57361a674fb7
--- /dev/null
+++ b/core/lib/multivm/src/pubdata_builders/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::interface::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/multivm/src/pubdata_builders/validium.rs b/core/lib/multivm/src/pubdata_builders/validium.rs
new file mode 100644
index 000000000000..a9156e970aad
--- /dev/null
+++ b/core/lib/multivm/src/pubdata_builders/validium.rs
@@ -0,0 +1,93 @@
+use zksync_types::{
+ ethabi,
+ ethabi::{ParamType, Token},
+ l2_to_l1_log::l2_to_l1_logs_tree_size,
+ web3::keccak256,
+ 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,
+}
+
+impl ValidiumPubdataBuilder {
+ pub fn new(l2_da_validator: Address) -> Self {
+ Self { l2_da_validator }
+ }
+}
+
+impl PubdataBuilder for ValidiumPubdataBuilder {
+ 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
+ .iter()
+ .flat_map(|diff| diff.encode_padded())
+ .collect::>();
+
+ keccak256(&state_diffs_packed).to_vec()
+ }
+}
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/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/shadow/mod.rs b/core/lib/multivm/src/versions/shadow/mod.rs
index fe9ce8eefcb9..42a0fbb1b8ba 100644
--- a/core/lib/multivm/src/versions/shadow/mod.rs
+++ b/core/lib/multivm/src/versions/shadow/mod.rs
@@ -198,7 +198,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();
}
}
diff --git a/core/lib/multivm/src/versions/shadow/tests.rs b/core/lib/multivm/src/versions/shadow/tests.rs
index 64179f59be16..6a39a28f7630 100644
--- a/core/lib/multivm/src/versions/shadow/tests.rs
+++ b/core/lib/multivm/src/versions/shadow/tests.rs
@@ -1,14 +1,15 @@
//! Unit tests from the `testonly` test suite.
-use std::collections::HashSet;
+use std::{collections::HashSet, rc::Rc};
use zksync_types::{writes::StateDiffRecord, StorageKey, Transaction, H256, U256};
+use zksync_vm_interface::pubdata::PubdataBuilder;
use super::ShadowedFastVm;
use crate::{
interface::{
utils::{ShadowMut, ShadowRef},
- CurrentExecutionState, L2BlockEnv, VmExecutionMode, VmExecutionResultAndLogs,
+ CurrentExecutionState, L2BlockEnv, VmExecutionResultAndLogs,
},
versions::testonly::TestedVm,
};
@@ -41,14 +42,25 @@ impl TestedVm for ShadowedFastVm {
})
}
- fn execute_with_state_diffs(
+ fn finish_batch_with_state_diffs(
&mut self,
diffs: Vec,
- mode: VmExecutionMode,
+ pubdata_builder: Rc,
) -> VmExecutionResultAndLogs {
- self.get_custom_mut("execute_with_state_diffs", |r| match r {
- ShadowMut::Main(vm) => vm.execute_with_state_diffs(diffs.clone(), mode),
- ShadowMut::Shadow(vm) => vm.execute_with_state_diffs(diffs.clone(), mode),
+ self.get_custom_mut("finish_batch_with_state_diffs", |r| match r {
+ ShadowMut::Main(vm) => {
+ vm.finish_batch_with_state_diffs(diffs.clone(), pubdata_builder.clone())
+ }
+ ShadowMut::Shadow(vm) => {
+ vm.finish_batch_with_state_diffs(diffs.clone(), pubdata_builder.clone())
+ }
+ })
+ }
+
+ 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(),
})
}
diff --git a/core/lib/multivm/src/versions/testonly/block_tip.rs b/core/lib/multivm/src/versions/testonly/block_tip.rs
index 7700f347ca6a..220653308a7e 100644
--- a/core/lib/multivm/src/versions/testonly/block_tip.rs
+++ b/core/lib/multivm/src/versions/testonly/block_tip.rs
@@ -11,11 +11,11 @@ use zksync_types::{
use zksync_utils::{bytecode::hash_bytecode, u256_to_h256};
use super::{
- get_complex_upgrade_abi, get_empty_storage, read_complex_upgrade,
+ default_pubdata_builder, get_complex_upgrade_abi, get_empty_storage, read_complex_upgrade,
tester::{TestedVm, VmTesterBuilder},
};
use crate::{
- interface::{L1BatchEnv, TxExecutionMode, VmExecutionMode, VmInterfaceExt},
+ interface::{InspectExecutionMode, L1BatchEnv, TxExecutionMode, VmInterfaceExt},
versions::testonly::default_l1_batch,
vm_latest::constants::{
BOOTLOADER_BATCH_TIP_CIRCUIT_STATISTICS_OVERHEAD,
@@ -156,7 +156,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: {:#?}",
@@ -169,7 +169,7 @@ fn execute_test(test_data: L1MessengerTestData) -> TestStatistics
let gas_before = vm.vm.gas_remaining();
let result = vm
.vm
- .execute_with_state_diffs(test_data.state_diffs.clone(), VmExecutionMode::Batch);
+ .finish_batch_with_state_diffs(test_data.state_diffs.clone(), default_pubdata_builder());
assert!(
!result.result.is_failed(),
"Batch wasn't successful for input: {test_data:?}"
diff --git a/core/lib/multivm/src/versions/testonly/bootloader.rs b/core/lib/multivm/src/versions/testonly/bootloader.rs
index e3177e078518..4b9b63252d6a 100644
--- a/core/lib/multivm/src/versions/testonly/bootloader.rs
+++ b/core/lib/multivm/src/versions/testonly/bootloader.rs
@@ -2,7 +2,7 @@ use assert_matches::assert_matches;
use zksync_types::U256;
use super::{get_bootloader, tester::VmTesterBuilder, TestedVm, BASE_SYSTEM_CONTRACTS};
-use crate::interface::{ExecutionResult, Halt, TxExecutionMode, VmExecutionMode, VmInterfaceExt};
+use crate::interface::{ExecutionResult, Halt, TxExecutionMode};
pub(crate) fn test_dummy_bootloader() {
let mut base_system_contracts = BASE_SYSTEM_CONTRACTS.clone();
@@ -14,7 +14,7 @@ pub(crate) fn test_dummy_bootloader() {
.with_execution_mode(TxExecutionMode::VerifyExecute)
.build::();
- let result = vm.vm.execute(VmExecutionMode::Batch);
+ let result = vm.vm.finish_batch_without_pubdata();
assert!(!result.result.is_failed());
let correct_first_cell = U256::from_str_radix("123123123", 16).unwrap();
@@ -33,7 +33,7 @@ pub(crate) fn test_bootloader_out_of_gas() {
.with_execution_mode(TxExecutionMode::VerifyExecute)
.build::();
- let res = vm.vm.execute(VmExecutionMode::Batch);
+ let res = vm.vm.finish_batch_without_pubdata();
assert_matches!(
res.result,
diff --git a/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs b/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs
index 346241a96245..9da005b995d3 100644
--- a/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs
+++ b/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs
@@ -1,8 +1,8 @@
use zksync_test_account::TxType;
-use super::{read_test_contract, tester::VmTesterBuilder, TestedVm};
+use super::{default_pubdata_builder, read_test_contract, tester::VmTesterBuilder, TestedVm};
use crate::{
- interface::{TxExecutionMode, VmEvent, VmExecutionMode, VmInterfaceExt},
+ interface::{InspectExecutionMode, TxExecutionMode, VmEvent, VmInterfaceExt},
utils::bytecode,
};
@@ -30,10 +30,10 @@ pub(crate) fn test_bytecode_publishing() {
compressed_bytecode
);
- 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.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/circuits.rs b/core/lib/multivm/src/versions/testonly/circuits.rs
index 9503efe9208f..de987a8912db 100644
--- a/core/lib/multivm/src/versions/testonly/circuits.rs
+++ b/core/lib/multivm/src/versions/testonly/circuits.rs
@@ -2,7 +2,7 @@ use zksync_types::{Address, Execute, U256};
use super::tester::VmTesterBuilder;
use crate::{
- interface::{TxExecutionMode, VmExecutionMode, VmInterfaceExt},
+ interface::{InspectExecutionMode, TxExecutionMode, VmInterfaceExt},
versions::testonly::TestedVm,
vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT,
};
@@ -28,7 +28,7 @@ pub(crate) 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/testonly/code_oracle.rs b/core/lib/multivm/src/versions/testonly/code_oracle.rs
index b786539329b9..767a294f44ab 100644
--- a/core/lib/multivm/src/versions/testonly/code_oracle.rs
+++ b/core/lib/multivm/src/versions/testonly/code_oracle.rs
@@ -9,7 +9,7 @@ use super::{
tester::VmTesterBuilder, TestedVm,
};
use crate::{
- interface::{TxExecutionMode, VmExecutionMode, VmInterfaceExt},
+ interface::{InspectExecutionMode, TxExecutionMode, VmInterfaceExt},
versions::testonly::ContractToDeploy,
};
@@ -68,7 +68,7 @@ pub(crate) 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:#?}"
@@ -91,7 +91,7 @@ pub(crate) 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:#?}"
@@ -160,7 +160,7 @@ pub(crate) 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:#?}"
@@ -222,7 +222,7 @@ pub(crate) fn test_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/testonly/default_aa.rs b/core/lib/multivm/src/versions/testonly/default_aa.rs
index 3f121dcf7e6c..c69c00de4508 100644
--- a/core/lib/multivm/src/versions/testonly/default_aa.rs
+++ b/core/lib/multivm/src/versions/testonly/default_aa.rs
@@ -7,9 +7,9 @@ use zksync_types::{
};
use zksync_utils::h256_to_u256;
-use super::{read_test_contract, tester::VmTesterBuilder, TestedVm};
+use super::{default_pubdata_builder, read_test_contract, tester::VmTesterBuilder, TestedVm};
use crate::{
- interface::{TxExecutionMode, VmExecutionMode, VmInterfaceExt},
+ interface::{InspectExecutionMode, TxExecutionMode, VmInterfaceExt},
vm_latest::utils::fee::get_batch_base_fee,
};
@@ -32,10 +32,10 @@ pub(crate) fn test_default_aa_interaction() {
let maximal_fee = tx.gas_limit() * get_batch_base_fee(&vm.l1_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.finish_batch(default_pubdata_builder());
vm.vm.get_current_execution_state();
diff --git a/core/lib/multivm/src/versions/testonly/get_used_contracts.rs b/core/lib/multivm/src/versions/testonly/get_used_contracts.rs
index d3ffee20c344..9d0908807e21 100644
--- a/core/lib/multivm/src/versions/testonly/get_used_contracts.rs
+++ b/core/lib/multivm/src/versions/testonly/get_used_contracts.rs
@@ -15,7 +15,8 @@ use super::{
};
use crate::{
interface::{
- ExecutionResult, TxExecutionMode, VmExecutionMode, VmExecutionResultAndLogs, VmInterfaceExt,
+ ExecutionResult, InspectExecutionMode, TxExecutionMode, VmExecutionResultAndLogs,
+ VmInterfaceExt,
},
versions::testonly::ContractToDeploy,
};
@@ -35,7 +36,7 @@ pub(crate) fn test_get_used_contracts() {
let account = &mut vm.rich_accounts[0];
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
@@ -70,7 +71,7 @@ pub(crate) 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/testonly/is_write_initial.rs b/core/lib/multivm/src/versions/testonly/is_write_initial.rs
index ef1fe2088c10..cac9be173639 100644
--- a/core/lib/multivm/src/versions/testonly/is_write_initial.rs
+++ b/core/lib/multivm/src/versions/testonly/is_write_initial.rs
@@ -2,7 +2,9 @@ use zksync_test_account::TxType;
use zksync_types::get_nonce_key;
use super::{read_test_contract, tester::VmTesterBuilder, TestedVm};
-use crate::interface::{storage::ReadStorage, TxExecutionMode, VmExecutionMode, VmInterfaceExt};
+use crate::interface::{
+ storage::ReadStorage, InspectExecutionMode, TxExecutionMode, VmInterfaceExt,
+};
pub(crate) fn test_is_write_initial_behaviour() {
// In this test, we check result of `is_write_initial` at different stages.
@@ -27,7 +29,7 @@ pub(crate) 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/testonly/l1_tx_execution.rs b/core/lib/multivm/src/versions/testonly/l1_tx_execution.rs
index 212b1f16f207..e98a8385f020 100644
--- a/core/lib/multivm/src/versions/testonly/l1_tx_execution.rs
+++ b/core/lib/multivm/src/versions/testonly/l1_tx_execution.rs
@@ -11,7 +11,7 @@ use zksync_utils::{h256_to_u256, u256_to_h256};
use super::{read_test_contract, tester::VmTesterBuilder, TestedVm, BASE_SYSTEM_CONTRACTS};
use crate::{
- interface::{TxExecutionMode, VmExecutionMode, VmInterfaceExt},
+ interface::{InspectExecutionMode, TxExecutionMode, VmInterfaceExt},
utils::StorageWritesDeduplicator,
};
@@ -60,7 +60,7 @@ pub(crate) 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);
@@ -84,7 +84,7 @@ pub(crate) 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);
@@ -99,7 +99,7 @@ pub(crate) 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.
@@ -110,7 +110,7 @@ pub(crate) 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.
@@ -125,7 +125,7 @@ pub(crate) 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");
@@ -176,7 +176,7 @@ pub(crate) 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/testonly/l2_blocks.rs b/core/lib/multivm/src/versions/testonly/l2_blocks.rs
index 634a9b34bf6d..947d8b5859f8 100644
--- a/core/lib/multivm/src/versions/testonly/l2_blocks.rs
+++ b/core/lib/multivm/src/versions/testonly/l2_blocks.rs
@@ -17,8 +17,8 @@ use zksync_utils::{h256_to_u256, u256_to_h256};
use super::{default_l1_batch, get_empty_storage, tester::VmTesterBuilder, TestedVm};
use crate::{
interface::{
- storage::StorageView, ExecutionResult, Halt, L2BlockEnv, TxExecutionMode, VmExecutionMode,
- VmInterfaceExt,
+ storage::StorageView, ExecutionResult, Halt, InspectExecutionMode, L2BlockEnv,
+ TxExecutionMode, VmInterfaceExt,
},
vm_latest::{
constants::{TX_OPERATOR_L2_BLOCK_INFO_OFFSET, TX_OPERATOR_SLOTS_PER_L2_BLOCK_INFO},
@@ -66,7 +66,7 @@ pub(crate) 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_matches!(
res.result,
@@ -100,7 +100,7 @@ pub(crate) 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,
@@ -128,7 +128,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.l1_batch_env.first_l2_block;
@@ -147,7 +147,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 });
@@ -203,7 +203,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.l1_batch_env.first_l2_block;
second_l2_block.number += 1;
@@ -223,7 +223,7 @@ fn test_new_l2_block(
vm.vm.push_l2_block_unchecked(second_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 {
@@ -350,7 +350,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/testonly/mod.rs b/core/lib/multivm/src/versions/testonly/mod.rs
index 74cda6a95229..eece1d475bba 100644
--- a/core/lib/multivm/src/versions/testonly/mod.rs
+++ b/core/lib/multivm/src/versions/testonly/mod.rs
@@ -9,7 +9,7 @@
//! - Tests use [`VmTester`] built using [`VmTesterBuilder`] to create a VM instance. This allows to set up storage for the VM,
//! custom [`SystemEnv`] / [`L1BatchEnv`], deployed contracts, pre-funded accounts etc.
-use std::collections::HashSet;
+use std::{collections::HashSet, rc::Rc};
use ethabi::Contract;
use once_cell::sync::Lazy;
@@ -23,11 +23,14 @@ use zksync_types::{
ProtocolVersionId, U256,
};
use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256, u256_to_h256};
-use zksync_vm_interface::{L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode};
+use zksync_vm_interface::{
+ pubdata::PubdataBuilder, L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode,
+};
pub(super) use self::tester::{TestedVm, VmTester, VmTesterBuilder};
use crate::{
- interface::storage::InMemoryStorage, vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT,
+ interface::storage::InMemoryStorage, pubdata_builders::RollupPubdataBuilder,
+ vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT,
};
pub(super) mod block_tip;
@@ -175,6 +178,10 @@ pub(super) fn default_l1_batch(number: L1BatchNumber) -> L1BatchEnv {
}
}
+pub(super) fn default_pubdata_builder() -> Rc {
+ Rc::new(RollupPubdataBuilder::new(Address::zero()))
+}
+
pub(super) fn make_address_rich(storage: &mut InMemoryStorage, address: Address) {
let key = storage_key_for_eth_balance(&address);
storage.set_value(key, u256_to_h256(U256::from(10_u64.pow(19))));
diff --git a/core/lib/multivm/src/versions/testonly/nonce_holder.rs b/core/lib/multivm/src/versions/testonly/nonce_holder.rs
index 8ef120c693ca..36f736c0bbe5 100644
--- a/core/lib/multivm/src/versions/testonly/nonce_holder.rs
+++ b/core/lib/multivm/src/versions/testonly/nonce_holder.rs
@@ -3,7 +3,7 @@ use zksync_types::{Execute, ExecuteTransactionCommon, Nonce};
use super::{read_nonce_holder_tester, tester::VmTesterBuilder, ContractToDeploy, TestedVm};
use crate::interface::{
- ExecutionResult, Halt, TxExecutionMode, TxRevertReason, VmExecutionMode, VmInterfaceExt,
+ ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, TxRevertReason, VmInterfaceExt,
VmRevertReason,
};
@@ -53,7 +53,7 @@ fn run_nonce_test(
};
tx_data.signature = vec![test_mode.into()];
vm.push_transaction(transaction);
- let result = vm.execute(VmExecutionMode::OneTx);
+ let result = vm.execute(InspectExecutionMode::OneTx);
if let Some(msg) = error_message {
let expected_error =
diff --git a/core/lib/multivm/src/versions/testonly/precompiles.rs b/core/lib/multivm/src/versions/testonly/precompiles.rs
index 270afab07317..2e26dc134b07 100644
--- a/core/lib/multivm/src/versions/testonly/precompiles.rs
+++ b/core/lib/multivm/src/versions/testonly/precompiles.rs
@@ -3,7 +3,7 @@ use zksync_types::{Address, Execute};
use super::{read_precompiles_contract, tester::VmTesterBuilder, TestedVm};
use crate::{
- interface::{TxExecutionMode, VmExecutionMode, VmInterfaceExt},
+ interface::{InspectExecutionMode, TxExecutionMode, VmInterfaceExt},
versions::testonly::ContractToDeploy,
vm_latest::constants::BATCH_COMPUTATIONAL_GAS_LIMIT,
};
@@ -36,7 +36,7 @@ pub(crate) 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
@@ -72,7 +72,7 @@ pub(crate) 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
@@ -101,7 +101,7 @@ pub(crate) 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/testonly/refunds.rs b/core/lib/multivm/src/versions/testonly/refunds.rs
index 565607dff105..874425fc435c 100644
--- a/core/lib/multivm/src/versions/testonly/refunds.rs
+++ b/core/lib/multivm/src/versions/testonly/refunds.rs
@@ -3,10 +3,10 @@ use zksync_test_account::TxType;
use zksync_types::{Address, Execute, U256};
use super::{
- read_expensive_contract, read_test_contract, tester::VmTesterBuilder, ContractToDeploy,
- TestedVm,
+ default_pubdata_builder, read_expensive_contract, read_test_contract, tester::VmTesterBuilder,
+ ContractToDeploy, TestedVm,
};
-use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterfaceExt};
+use crate::interface::{InspectExecutionMode, TxExecutionMode, VmInterfaceExt};
pub(crate) fn test_predetermined_refunded_gas() {
// In this test, we compare the execution of the bootloader with the predefined
@@ -24,7 +24,7 @@ pub(crate) fn test_predetermined_refunded_gas() {
let tx = account.get_deploy_tx(&counter, None, TxType::L2).tx;
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());
@@ -37,7 +37,10 @@ pub(crate) 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
+ .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(),);
@@ -56,7 +59,10 @@ pub(crate) fn test_predetermined_refunded_gas() {
vm.vm
.push_transaction_with_refund(tx.clone(), result.refunds.gas_refunded);
- let result_with_predefined_refunds = vm.vm.execute(VmExecutionMode::Batch);
+ let result_with_predefined_refunds = vm
+ .vm
+ .finish_batch(default_pubdata_builder())
+ .block_tip_execution_result;
let mut current_state_with_predefined_refunds = vm.vm.get_current_execution_state();
assert!(!result_with_predefined_refunds.result.is_failed());
@@ -107,7 +113,10 @@ pub(crate) fn test_predetermined_refunded_gas() {
let changed_operator_suggested_refund = result.refunds.gas_refunded + 1000;
vm.vm
.push_transaction_with_refund(tx, changed_operator_suggested_refund);
- let result = vm.vm.execute(VmExecutionMode::Batch);
+ let result = vm
+ .vm
+ .finish_batch(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());
@@ -185,7 +194,7 @@ pub(crate) fn test_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:#?}"
@@ -202,7 +211,7 @@ pub(crate) fn test_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/testonly/require_eip712.rs b/core/lib/multivm/src/versions/testonly/require_eip712.rs
index 1ea3964d7cd1..e789fbda2902 100644
--- a/core/lib/multivm/src/versions/testonly/require_eip712.rs
+++ b/core/lib/multivm/src/versions/testonly/require_eip712.rs
@@ -8,7 +8,7 @@ use zksync_types::{
use super::{
read_many_owners_custom_account_contract, tester::VmTesterBuilder, ContractToDeploy, TestedVm,
};
-use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterfaceExt};
+use crate::interface::{InspectExecutionMode, TxExecutionMode, VmInterfaceExt};
/// This test deploys 'buggy' account abstraction code, and then tries accessing it both with legacy
/// and EIP712 transactions.
@@ -52,7 +52,7 @@ pub(crate) 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);
@@ -85,7 +85,7 @@ pub(crate) 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!(
@@ -133,7 +133,7 @@ pub(crate) 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/testonly/secp256r1.rs b/core/lib/multivm/src/versions/testonly/secp256r1.rs
index 60197913601e..37d428f82101 100644
--- a/core/lib/multivm/src/versions/testonly/secp256r1.rs
+++ b/core/lib/multivm/src/versions/testonly/secp256r1.rs
@@ -4,7 +4,7 @@ use zksync_types::{web3::keccak256, Execute, H256, U256};
use zksync_utils::h256_to_u256;
use super::{tester::VmTesterBuilder, TestedVm};
-use crate::interface::{ExecutionResult, TxExecutionMode, VmExecutionMode, VmInterfaceExt};
+use crate::interface::{ExecutionResult, InspectExecutionMode, TxExecutionMode, VmInterfaceExt};
pub(crate) fn test_secp256r1() {
// In this test, we aim to test whether a simple account interaction (without any fee logic)
@@ -55,7 +55,7 @@ pub(crate) fn test_secp256r1() {
vm.vm.push_transaction(tx);
- let execution_result = vm.vm.execute(VmExecutionMode::Batch);
+ let execution_result = vm.vm.execute(InspectExecutionMode::OneTx);
let ExecutionResult::Success { output } = execution_result.result else {
panic!("batch failed")
diff --git a/core/lib/multivm/src/versions/testonly/simple_execution.rs b/core/lib/multivm/src/versions/testonly/simple_execution.rs
index fcd7a144ab1f..96239fb362d2 100644
--- a/core/lib/multivm/src/versions/testonly/simple_execution.rs
+++ b/core/lib/multivm/src/versions/testonly/simple_execution.rs
@@ -1,8 +1,8 @@
use assert_matches::assert_matches;
use zksync_test_account::TxType;
-use super::{tester::VmTesterBuilder, TestedVm};
-use crate::interface::{ExecutionResult, VmExecutionMode, VmInterfaceExt};
+use super::{default_pubdata_builder, tester::VmTesterBuilder, TestedVm};
+use crate::interface::{ExecutionResult, InspectExecutionMode, VmInterfaceExt};
pub(crate) fn test_estimate_fee() {
let mut vm_tester = VmTesterBuilder::new()
@@ -23,7 +23,7 @@ pub(crate) fn test_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 { .. });
}
@@ -64,12 +64,14 @@ pub(crate) fn test_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
+ .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/storage.rs b/core/lib/multivm/src/versions/testonly/storage.rs
index 4951272a60c4..efe7be1edbd1 100644
--- a/core/lib/multivm/src/versions/testonly/storage.rs
+++ b/core/lib/multivm/src/versions/testonly/storage.rs
@@ -3,7 +3,7 @@ use zksync_contracts::{load_contract, read_bytecode};
use zksync_types::{Address, Execute, U256};
use super::{tester::VmTesterBuilder, ContractToDeploy, TestedVm};
-use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterfaceExt};
+use crate::interface::{InspectExecutionMode, TxExecutionMode, VmInterfaceExt};
fn test_storage(first_tx_calldata: Vec, second_tx_calldata: Vec) -> u32 {
let bytecode = read_bytecode(
@@ -45,20 +45,20 @@ fn test_storage(first_tx_calldata: Vec, second_tx_calldata: Ve
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/testonly/tester/mod.rs b/core/lib/multivm/src/versions/testonly/tester/mod.rs
index 7432322e0c8d..716b9386235f 100644
--- a/core/lib/multivm/src/versions/testonly/tester/mod.rs
+++ b/core/lib/multivm/src/versions/testonly/tester/mod.rs
@@ -1,4 +1,4 @@
-use std::{collections::HashSet, fmt};
+use std::{collections::HashSet, fmt, rc::Rc};
use zksync_contracts::BaseSystemContracts;
use zksync_test_account::{Account, TxType};
@@ -8,7 +8,8 @@ use zksync_types::{
Address, L1BatchNumber, StorageKey, Transaction, H256, U256,
};
use zksync_vm_interface::{
- CurrentExecutionState, VmExecutionResultAndLogs, VmInterfaceHistoryEnabled,
+ pubdata::PubdataBuilder, CurrentExecutionState, InspectExecutionMode, VmExecutionResultAndLogs,
+ VmInterfaceHistoryEnabled,
};
pub(crate) use self::transaction_test_info::{ExpectedError, TransactionTestInfo, TxModifier};
@@ -16,8 +17,7 @@ use super::{get_empty_storage, read_test_contract};
use crate::{
interface::{
storage::{InMemoryStorage, StoragePtr, StorageView},
- L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory,
- VmInterfaceExt,
+ L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmFactory, VmInterfaceExt,
},
versions::testonly::{
default_l1_batch, default_system_env, make_address_rich, ContractToDeploy,
@@ -44,7 +44,7 @@ impl VmTester {
let tx = account.get_deploy_tx(&contract, None, TxType::L2).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(account.address, nonce);
self.test_contract = Some(deployed_address);
}
@@ -187,12 +187,14 @@ pub(crate) trait TestedVm:
/// Unlike [`Self::known_bytecode_hashes()`], the output should only include successfully decommitted bytecodes.
fn decommitted_hashes(&self) -> HashSet;
- fn execute_with_state_diffs(
+ fn finish_batch_with_state_diffs(
&mut self,
diffs: Vec,
- mode: VmExecutionMode,
+ 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/testonly/tester/transaction_test_info.rs b/core/lib/multivm/src/versions/testonly/tester/transaction_test_info.rs
index 87468d3e4d5f..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
@@ -1,9 +1,12 @@
use zksync_types::{ExecuteTransactionCommon, Nonce, Transaction, H160};
use super::{TestedVm, VmTester};
-use crate::interface::{
- CurrentExecutionState, ExecutionResult, Halt, TxRevertReason, VmExecutionMode,
- VmExecutionResultAndLogs, VmInterfaceExt, VmRevertReason,
+use crate::{
+ interface::{
+ CurrentExecutionState, ExecutionResult, Halt, InspectExecutionMode, TxRevertReason,
+ VmExecutionResultAndLogs, VmInterfaceExt, VmRevertReason,
+ },
+ versions::testonly::default_pubdata_builder,
};
#[derive(Debug, Clone)]
@@ -181,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.finish_batch(default_pubdata_builder());
let mut state = self.vm.get_current_execution_state();
state.used_contract_hashes.sort();
state
@@ -202,7 +205,7 @@ fn execute_tx_and_verify(
let inner_state_before = vm.dump_state();
vm.make_snapshot();
vm.push_transaction(tx_test_info.tx.clone());
- let result = vm.execute(VmExecutionMode::OneTx);
+ let result = vm.execute(InspectExecutionMode::OneTx);
tx_test_info.verify_result(&result);
if tx_test_info.should_rollback() {
vm.rollback_to_the_latest_snapshot();
diff --git a/core/lib/multivm/src/versions/testonly/transfer.rs b/core/lib/multivm/src/versions/testonly/transfer.rs
index 051826a64f24..3572adba147c 100644
--- a/core/lib/multivm/src/versions/testonly/transfer.rs
+++ b/core/lib/multivm/src/versions/testonly/transfer.rs
@@ -3,8 +3,10 @@ use zksync_contracts::{load_contract, read_bytecode};
use zksync_types::{utils::storage_key_for_eth_balance, Address, Execute, U256};
use zksync_utils::u256_to_h256;
-use super::{get_empty_storage, tester::VmTesterBuilder, ContractToDeploy, TestedVm};
-use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterfaceExt};
+use super::{
+ default_pubdata_builder, get_empty_storage, tester::VmTesterBuilder, ContractToDeploy, TestedVm,
+};
+use crate::interface::{InspectExecutionMode, TxExecutionMode, VmInterfaceExt};
enum TestOptions {
Send(U256),
@@ -72,13 +74,16 @@ 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
+ .finish_batch(default_pubdata_builder())
+ .block_tip_execution_result;
assert!(!batch_result.result.is_failed(), "Batch wasn't successful");
let new_recipient_balance = vm.get_eth_balance(recipient_address);
@@ -161,7 +166,7 @@ fn test_reentrancy_protection_send_or_transfer(test_option: TestOp
);
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"
@@ -178,13 +183,16 @@ fn test_reentrancy_protection_send_or_transfer(test_option: TestOp
);
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
+ .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/testonly/upgrade.rs b/core/lib/multivm/src/versions/testonly/upgrade.rs
index 9401cbb4ba84..359f19faedb2 100644
--- a/core/lib/multivm/src/versions/testonly/upgrade.rs
+++ b/core/lib/multivm/src/versions/testonly/upgrade.rs
@@ -14,7 +14,9 @@ use super::{
get_complex_upgrade_abi, get_empty_storage, read_complex_upgrade, read_test_contract,
tester::VmTesterBuilder, TestedVm,
};
-use crate::interface::{ExecutionResult, Halt, TxExecutionMode, VmExecutionMode, VmInterfaceExt};
+use crate::interface::{
+ ExecutionResult, Halt, InspectExecutionMode, TxExecutionMode, VmInterfaceExt,
+};
/// In this test we ensure that the requirements for protocol upgrade transactions are enforced by the bootloader:
/// - This transaction must be the only one in block
@@ -71,9 +73,9 @@ pub(crate) 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 {
@@ -87,8 +89,8 @@ pub(crate) 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 {
@@ -101,8 +103,8 @@ pub(crate) 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());
}
@@ -137,7 +139,7 @@ pub(crate) 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"
@@ -186,7 +188,7 @@ pub(crate) 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_1_3_2/vm.rs b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs
index 31457fc9676a..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
@@ -1,16 +1,16 @@
-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, InspectExecutionMode};
use crate::{
glue::{history_mode::HistoryMode, GlueInto},
interface::{
storage::{StoragePtr, WriteStorage},
BytecodeCompressionError, BytecodeCompressionResult, FinishedL1Batch, L1BatchEnv,
- L2BlockEnv, PushTransactionResult, SystemEnv, TxExecutionMode, VmExecutionMode,
- VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled,
- VmMemoryMetrics,
+ L2BlockEnv, PushTransactionResult, SystemEnv, TxExecutionMode, VmExecutionResultAndLogs,
+ VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics,
},
tracers::old::TracerDispatcher,
utils::bytecode,
@@ -61,7 +61,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
@@ -70,7 +70,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
@@ -93,8 +93,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(),
}
}
@@ -184,7 +183,7 @@ impl VmInterface for Vm {
}
}
- fn finish_batch(&mut self) -> 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/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 1c38958bb318..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
@@ -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, InspectExecutionMode};
use crate::{
glue::GlueInto,
@@ -95,9 +98,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) {
@@ -128,8 +131,12 @@ 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: Rc) -> 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 {
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 ca69a191e26f..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
@@ -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, InspectExecutionMode};
use crate::{
glue::GlueInto,
@@ -97,9 +98,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) {
@@ -130,8 +131,8 @@ 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: 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();
FinishedL1Batch {
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 bfd055a5cc84..43c9900486db 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, InspectExecutionMode};
use crate::{
glue::GlueInto,
@@ -95,9 +98,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) {
@@ -129,8 +132,8 @@ 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: 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();
FinishedL1Batch {
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/tests/mod.rs b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs
index f385ca2a438f..2b4665f82241 100644
--- a/core/lib/multivm/src/versions/vm_fast/tests/mod.rs
+++ b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs
@@ -1,11 +1,11 @@
-use std::{any::Any, collections::HashSet, fmt};
+use std::{any::Any, collections::HashSet, fmt, rc::Rc};
use zksync_types::{writes::StateDiffRecord, StorageKey, Transaction, H160, H256, U256};
use zksync_utils::h256_to_u256;
use zksync_vm2::interface::{Event, HeapId, StateInterface};
use zksync_vm_interface::{
- storage::ReadStorage, CurrentExecutionState, L2BlockEnv, VmExecutionMode,
- VmExecutionResultAndLogs, VmInterfaceExt,
+ pubdata::PubdataBuilder, storage::ReadStorage, CurrentExecutionState, L2BlockEnv,
+ VmExecutionMode, VmExecutionResultAndLogs, VmInterface,
};
use super::Vm;
@@ -99,13 +99,18 @@ impl TestedVm for Vm> {
self.decommitted_hashes().collect()
}
- fn execute_with_state_diffs(
+ fn finish_batch_with_state_diffs(
&mut self,
diffs: Vec,
- mode: VmExecutionMode,
+ pubdata_builder: Rc,
) -> VmExecutionResultAndLogs {
self.enforce_state_diffs(diffs);
- self.execute(mode)
+ self.finish_batch(pubdata_builder)
+ .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]]) {
diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs
index 88e0b10b5eaf..a2114a339481 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::{
aux_structures::LogQuery, zkevm_opcode_defs::system_params::INITIAL_FRAME_FORMAL_EH_LOCATION,
@@ -21,6 +21,7 @@ use zksync_vm2::{
interface::{CallframeInterface, HeapId, StateInterface, Tracer},
ExecutionEnd, FatPointer, Program, Settings, StorageSlot, VirtualMachine,
};
+use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode};
use super::{
bootloader_state::{BootloaderState, BootloaderStateSnapshot},
@@ -103,7 +104,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),
@@ -533,39 +534,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>,
- ) -> 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: Transaction) -> PushTransactionResult<'_> {
- self.push_transaction_inner(tx, 0, true);
- PushTransactionResult {
- compressed_bytecodes: self
- .bootloader_state
- .get_last_tx_compressed_bytecodes()
- .into(),
- }
- }
-
- fn inspect(
+ pub(crate) fn inspect_inner(
&mut self,
- tracer: &mut Self::TracerDispatcher,
+ tracer: &mut Tr,
execution_mode: VmExecutionMode,
) -> VmExecutionResultAndLogs {
let mut track_refunds = false;
@@ -655,6 +627,43 @@ 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: Transaction) -> PushTransactionResult<'_> {
+ self.push_transaction_inner(tx, 0, true);
+ PushTransactionResult {
+ compressed_bytecodes: self
+ .bootloader_state
+ .get_last_tx_compressed_bytecodes()
+ .into(),
+ }
+ }
+
+ 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,
@@ -663,7 +672,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)
@@ -680,8 +689,8 @@ 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: 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();
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 4ba27b14bad6..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,11 +1,15 @@
use std::cmp::Ordering;
use once_cell::sync::OnceCell;
-use zksync_types::{L2ChainId, U256};
+use zksync_types::{L2ChainId, ProtocolVersionId, U256};
+use zksync_vm_interface::pubdata::PubdataBuilder;
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,
@@ -13,7 +17,7 @@ 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,
},
};
@@ -45,6 +49,8 @@ pub struct BootloaderState {
free_tx_offset: usize,
/// Information about the the pubdata that will be needed to supply to the L1Messenger
pubdata_information: OnceCell,
+ /// Protocol version.
+ protocol_version: ProtocolVersionId,
}
impl BootloaderState {
@@ -52,6 +58,7 @@ impl BootloaderState {
execution_mode: TxExecutionMode,
initial_memory: BootloaderMemory,
first_l2_block: L2BlockEnv,
+ protocol_version: ProtocolVersionId,
) -> Self {
let l2_block = BootloaderL2Block::new(first_l2_block, 0);
Self {
@@ -62,6 +69,7 @@ impl BootloaderState {
execution_mode,
free_tx_offset: 0,
pubdata_information: Default::default(),
+ protocol_version,
}
}
@@ -135,18 +143,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 settlement_layer_pubdata(&self, pubdata_builder: &dyn PubdataBuilder) -> Vec {
+ let pubdata_information = self
+ .pubdata_information
+ .get()
+ .expect("Pubdata information is not set");
+
+ pubdata_builder.settlement_layer_pubdata(pubdata_information, self.protocol_version)
+ }
+
fn last_mut_l2_block(&mut self) -> &mut BootloaderL2Block {
self.l2_blocks.last_mut().unwrap()
}
/// Apply all bootloader transaction to the initial memory
- pub(crate) fn bootloader_memory(&self) -> BootloaderMemory {
+ pub(crate) fn bootloader_memory(
+ &self,
+ pubdata_builder: &dyn PubdataBuilder,
+ ) -> BootloaderMemory {
let mut initial_memory = self.initial_memory.clone();
let mut offset = 0;
let mut compressed_bytecodes_offset = 0;
@@ -174,11 +195,15 @@ impl BootloaderState {
let pubdata_information = self
.pubdata_information
- .clone()
- .into_inner()
+ .get()
.expect("Empty pubdata information");
- apply_pubdata_to_memory(&mut initial_memory, pubdata_information);
+ apply_pubdata_to_memory(
+ &mut initial_memory,
+ pubdata_builder,
+ pubdata_information,
+ self.protocol_version,
+ );
initial_memory
}
@@ -291,4 +316,8 @@ impl BootloaderState {
);
}
}
+
+ 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 23c079202c1f..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,9 +1,12 @@
-use zksync_types::{ethabi, U256};
+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,
@@ -14,7 +17,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::PubdataInput,
},
};
@@ -124,26 +126,61 @@ fn apply_l2_block_inner(
])
}
+fn bootloader_memory_input(
+ pubdata_builder: &dyn PubdataBuilder,
+ 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_information: PubdataInput,
+ pubdata_builder: &dyn PubdataBuilder,
+ pubdata_information: &PubdataInput,
+ protocol_version: ProtocolVersionId,
) {
- // 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) = 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 =
+ 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
+ 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 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/call_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tests/call_tracer.rs
index e1dfdc7e68c5..b502ea50b1af 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
@@ -5,7 +5,7 @@ use zksync_types::{Address, Execute};
use super::TestedLatestVm;
use crate::{
- interface::{TxExecutionMode, VmExecutionMode, VmInterface},
+ interface::{InspectExecutionMode, TxExecutionMode, VmInterface},
tracers::CallTracer,
versions::testonly::{
read_max_depth_contract, read_test_contract, ContractToDeploy, VmTesterBuilder,
@@ -43,7 +43,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());
}
@@ -79,7 +79,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/mod.rs b/core/lib/multivm/src/versions/vm_latest/tests/mod.rs
index 6f748d543d35..96d59f208b03 100644
--- a/core/lib/multivm/src/versions/vm_latest/tests/mod.rs
+++ b/core/lib/multivm/src/versions/vm_latest/tests/mod.rs
@@ -1,4 +1,7 @@
-use std::collections::{HashMap, HashSet};
+use std::{
+ collections::{HashMap, HashSet},
+ rc::Rc,
+};
use zk_evm_1_5_0::{
aux_structures::{MemoryPage, Timestamp},
@@ -7,6 +10,7 @@ use zk_evm_1_5_0::{
};
use zksync_types::{writes::StateDiffRecord, StorageKey, StorageValue, Transaction, H256, U256};
use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, h256_to_u256};
+use zksync_vm_interface::pubdata::PubdataBuilder;
use super::{HistoryEnabled, Vm};
use crate::{
@@ -75,18 +79,31 @@ impl TestedVm for TestedLatestVm {
self.get_used_contracts().into_iter().collect()
}
- fn execute_with_state_diffs(
+ fn finish_batch_with_state_diffs(
&mut self,
diffs: Vec,
- mode: VmExecutionMode,
+ pubdata_builder: Rc,
) -> VmExecutionResultAndLogs {
let pubdata_tracer = PubdataTracer::new_with_forced_state_diffs(
self.batch_env.clone(),
VmExecutionMode::Batch,
diffs,
crate::vm_latest::MultiVMSubversion::latest(),
+ Some(pubdata_builder),
);
- self.inspect_inner(&mut TracerDispatcher::default(), mode, Some(pubdata_tracer))
+ self.inspect_inner(
+ &mut TracerDispatcher::default(),
+ VmExecutionMode::Batch,
+ Some(pubdata_tracer),
+ )
+ }
+
+ fn finish_batch_without_pubdata(&mut self) -> VmExecutionResultAndLogs {
+ self.inspect_inner(
+ &mut TracerDispatcher::default(),
+ VmExecutionMode::Batch,
+ None,
+ )
}
fn insert_bytecodes(&mut self, bytecodes: &[&[u8]]) {
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 838c4e342dcb..7028f7a89711 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
@@ -6,7 +6,7 @@ use zksync_types::{utils::deployed_address_create, Execute, U256};
use super::TestedLatestVm;
use crate::{
- interface::{TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt},
+ interface::{InspectExecutionMode, TxExecutionMode, VmInterface, VmInterfaceExt},
tracers::PrestateTracer,
versions::testonly::{read_simple_transfer_contract, VmTesterBuilder},
vm_latest::{constants::BATCH_COMPUTATIONAL_GAS_LIMIT, ToTracerPointer},
@@ -38,7 +38,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::OneTx);
let prestate_result = Arc::try_unwrap(prestate_tracer_result)
.unwrap()
@@ -61,7 +61,7 @@ fn test_prestate_tracer_diff_mode() {
let tx = account.get_deploy_tx(&contract, None, TxType::L2).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(account.address, nonce);
vm.test_contract = Some(deployed_address);
@@ -69,7 +69,7 @@ fn test_prestate_tracer_diff_mode() {
let tx2 = account.get_deploy_tx(&contract, None, TxType::L2).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(account.address, nonce2);
let account = &mut vm.rich_accounts[0];
@@ -98,7 +98,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/rollbacks.rs b/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs
index c948315266ad..de674498427d 100644
--- a/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs
+++ b/core/lib/multivm/src/versions/vm_latest/tests/rollbacks.rs
@@ -2,13 +2,14 @@ use ethabi::Token;
use zksync_contracts::{get_loadnext_contract, test_contracts::LoadnextContractExecutionParams};
use zksync_test_account::{DeployContractsTx, TxType};
use zksync_types::{get_nonce_key, U256};
+use zksync_vm_interface::InspectExecutionMode;
use super::TestedLatestVm;
use crate::{
interface::{
storage::WriteStorage,
tracer::{TracerExecutionStatus, TracerExecutionStopReason},
- TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled,
+ TxExecutionMode, VmInterface, VmInterfaceExt, VmInterfaceHistoryEnabled,
},
tracers::dynamic::vm_1_5_0::DynTracer,
versions::testonly::{
@@ -80,7 +81,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(
@@ -107,7 +108,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
@@ -134,7 +136,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/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs
index 32f3984834c8..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,4 +1,4 @@
-use std::marker::PhantomData;
+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::{
@@ -7,9 +7,11 @@ 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::{
+ pubdata::{L1MessengerL2ToL1Log, PubdataInput},
storage::{StoragePtr, WriteStorage},
tracer::{TracerExecutionStatus, TracerExecutionStopReason},
L1BatchEnv, VmEvent, VmExecutionMode,
@@ -17,14 +19,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,
@@ -41,6 +43,7 @@ pub(crate) struct PubdataTracer {
// to the L1Messenger.
enforced_state_diffs: Option>,
subversion: MultiVMSubversion,
+ pubdata_builder: Option>,
_phantom_data: PhantomData,
}
@@ -49,6 +52,7 @@ impl PubdataTracer {
l1_batch_env: L1BatchEnv,
execution_mode: VmExecutionMode,
subversion: MultiVMSubversion,
+ pubdata_builder: Option>,
) -> Self {
Self {
l1_batch_env,
@@ -56,6 +60,7 @@ impl PubdataTracer {
execution_mode,
enforced_state_diffs: None,
subversion,
+ pubdata_builder,
_phantom_data: Default::default(),
}
}
@@ -68,6 +73,7 @@ impl PubdataTracer {
execution_mode: VmExecutionMode,
forced_state_diffs: Vec,
subversion: MultiVMSubversion,
+ pubdata_builder: Option>,
) -> Self {
Self {
l1_batch_env,
@@ -75,6 +81,7 @@ impl PubdataTracer {
execution_mode,
enforced_state_diffs: Some(forced_state_diffs),
subversion,
+ pubdata_builder,
_phantom_data: Default::default(),
}
}
@@ -221,13 +228,22 @@ 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![];
- apply_pubdata_to_memory(&mut memory_to_apply, pubdata_input);
+ apply_pubdata_to_memory(
+ &mut memory_to_apply,
+ self.pubdata_builder
+ .as_ref()
+ .expect("`pubdata_builder` is required to finish batch")
+ .as_ref(),
+ &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/multivm/src/versions/vm_latest/types/internals/mod.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/mod.rs
index 7dc60ec5b0fb..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;
-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 d07732ae4350..000000000000
--- a/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs
+++ /dev/null
@@ -1,123 +0,0 @@
-use zksync_types::writes::{compress_state_diffs, StateDiffRecord};
-
-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,
-}
-
-impl PubdataInput {
- pub(crate) fn build_pubdata(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
- }
-}
-
-#[cfg(test)]
-mod tests {
- use zksync_system_constants::{ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS};
- 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,
- };
-
- let pubdata =
- ethabi::encode(&[ethabi::Token::Bytes(input.build_pubdata(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 cb4b13eecdf0..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
@@ -191,6 +191,7 @@ pub(crate) fn new_vm_state(
system_env.execution_mode,
bootloader_initial_memory,
first_l2_block,
+ system_env.version,
);
(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 3a36b008e884..ef6cee454a87 100644
--- a/core/lib/multivm/src/versions/vm_latest/vm.rs
+++ b/core/lib/multivm/src/versions/vm_latest/vm.rs
@@ -1,4 +1,4 @@
-use std::collections::HashMap;
+use std::{collections::HashMap, rc::Rc};
use circuit_sequencer_api_1_5_0::sort_storage_access::sort_storage_access_queries;
use zksync_types::{
@@ -7,6 +7,7 @@ use zksync_types::{
Transaction, H256,
};
use zksync_utils::{be_words_to_bytes, h256_to_u256, u256_to_h256};
+use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode};
use crate::{
glue::GlueInto,
@@ -21,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,
@@ -38,6 +39,8 @@ pub(crate) enum MultiVMSubversion {
SmallBootloaderMemory,
/// The final correct version of v1.5.0
IncreasedBootloaderMemory,
+ /// VM for post-gateway versions.
+ Gateway,
}
impl MultiVMSubversion {
@@ -55,6 +58,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),
}
}
@@ -148,9 +152,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) {
@@ -182,19 +186,30 @@ 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: Rc) -> FinishedL1Batch {
+ 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.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
- .get_pubdata_information()
- .clone()
- .build_pubdata(false),
+ .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 3d57d1cd5439..55afeed17cd1 100644
--- a/core/lib/multivm/src/versions/vm_m5/vm.rs
+++ b/core/lib/multivm/src/versions/vm_m5/vm.rs
@@ -1,13 +1,15 @@
+use std::rc::Rc;
+
use zksync_types::{vm::VmVersion, Transaction};
use zksync_utils::h256_to_u256;
+use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode};
use crate::{
glue::{history_mode::HistoryMode, GlueInto},
interface::{
storage::StoragePtr, BytecodeCompressionResult, FinishedL1Batch, L1BatchEnv, L2BlockEnv,
- PushTransactionResult, SystemEnv, TxExecutionMode, VmExecutionMode,
- VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled,
- VmMemoryMetrics,
+ PushTransactionResult, SystemEnv, TxExecutionMode, VmExecutionResultAndLogs, VmFactory,
+ VmInterface, VmInterfaceHistoryEnabled, VmMemoryMetrics,
},
vm_m5::{
storage::Storage,
@@ -75,10 +77,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
@@ -87,8 +89,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(),
}
}
@@ -110,11 +111,11 @@ 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: 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 1ee6aa618220..4c67a2184180 100644
--- a/core/lib/multivm/src/versions/vm_m6/vm.rs
+++ b/core/lib/multivm/src/versions/vm_m6/vm.rs
@@ -1,13 +1,14 @@
-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, InspectExecutionMode};
use crate::{
glue::{history_mode::HistoryMode, GlueInto},
interface::{
storage::StoragePtr, BytecodeCompressionError, BytecodeCompressionResult, FinishedL1Batch,
- L1BatchEnv, L2BlockEnv, PushTransactionResult, SystemEnv, TxExecutionMode, VmExecutionMode,
+ L1BatchEnv, L2BlockEnv, PushTransactionResult, SystemEnv, TxExecutionMode,
VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled,
VmMemoryMetrics,
},
@@ -88,7 +89,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
@@ -97,7 +98,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(
@@ -116,8 +117,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(),
}
}
@@ -207,7 +207,7 @@ impl VmInterface for Vm {
}
}
- fn finish_batch(&mut self) -> 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 2bcd68bec044..81b0c52cce5e 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, InspectExecutionMode};
use crate::{
glue::GlueInto,
@@ -88,9 +91,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) {
@@ -105,7 +108,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),
@@ -122,8 +125,8 @@ 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: 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();
FinishedL1Batch {
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 497128c64bd9..a2d18e10de44 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, InspectExecutionMode};
use crate::{
glue::GlueInto,
@@ -88,9 +91,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) {
@@ -122,8 +125,8 @@ 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: 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();
FinishedL1Batch {
diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs
index 43a6c48aa9c5..5ff27046377a 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, ProtocolVersionId, Transaction};
use zksync_vm2::interface::Tracer;
+use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode};
use crate::{
glue::history_mode::HistoryMode,
@@ -9,8 +10,8 @@ use crate::{
storage::{ImmutableStorageView, ReadStorage, StoragePtr, StorageView},
utils::ShadowVm,
BytecodeCompressionResult, FinishedL1Batch, L1BatchEnv, L2BlockEnv, PushTransactionResult,
- SystemEnv, VmExecutionMode, VmExecutionResultAndLogs, VmFactory, VmInterface,
- VmInterfaceHistoryEnabled, VmMemoryMetrics,
+ SystemEnv, VmExecutionResultAndLogs, VmFactory, VmInterface, VmInterfaceHistoryEnabled,
+ VmMemoryMetrics,
},
tracers::TracerDispatcher,
vm_latest::HistoryEnabled,
@@ -63,7 +64,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))
}
@@ -87,8 +88,8 @@ impl