diff --git a/core/bin/external_node/src/config/mod.rs b/core/bin/external_node/src/config/mod.rs
index 80e28f1bf28..94c7ea74866 100644
--- a/core/bin/external_node/src/config/mod.rs
+++ b/core/bin/external_node/src/config/mod.rs
@@ -110,7 +110,11 @@ 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,
@@ -122,7 +126,6 @@ pub(crate) struct RemoteENConfig {
pub dummy_verifier: bool,
pub user_facing_bridgehub: Option,
- pub l2_native_token_vault_proxy_addr: Option,
}
impl RemoteENConfig {
@@ -135,14 +138,6 @@ impl RemoteENConfig {
.get_testnet_paymaster()
.rpc_context("get_testnet_paymaster")
.await?;
- let l2_native_token_vault_proxy_addr = client
- .get_native_token_vault_proxy_addr()
- .rpc_context("get_native_token_vault")
- .await?;
- let l2_legacy_shared_bridge_addr = client
- .get_legacy_shared_bridge()
- .rpc_context("get_legacy_shared_bridge")
- .await?;
let genesis = client.genesis_config().rpc_context("genesis").await.ok();
let ecosystem_contracts = client
.get_ecosystem_contracts()
@@ -208,7 +203,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,
+ 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,
@@ -220,7 +215,6 @@ impl RemoteENConfig {
.as_ref()
.map(|a| a.dummy_verifier)
.unwrap_or_default(),
- l2_native_token_vault_proxy_addr,
})
}
@@ -243,7 +237,6 @@ impl RemoteENConfig {
l2_legacy_shared_bridge_addr: Some(Address::repeat_byte(7)),
l1_batch_commit_data_generator_mode: L1BatchCommitmentMode::Rollup,
dummy_verifier: true,
- l2_native_token_vault_proxy_addr: Some(Address::repeat_byte(7)),
}
}
}
@@ -1415,6 +1408,7 @@ impl From<&ExternalNodeConfig> for InternalApiConfig {
l2_shared_default_bridge: config.remote.l2_shared_bridge_addr,
l1_weth_bridge: config.remote.l1_weth_bridge_addr,
l2_weth_bridge: config.remote.l2_weth_bridge_addr,
+ l2_legacy_shared_bridge: config.remote.l2_legacy_shared_bridge_addr,
},
bridgehub_proxy_addr: config.remote.bridgehub_proxy_addr,
state_transition_proxy_addr: config.remote.state_transition_proxy_addr,
@@ -1428,8 +1422,6 @@ impl From<&ExternalNodeConfig> for InternalApiConfig {
filters_disabled: config.optional.filters_disabled,
dummy_verifier: config.remote.dummy_verifier,
l1_batch_commit_data_generator_mode: config.remote.l1_batch_commit_data_generator_mode,
- l2_native_token_vault_proxy_addr: config.remote.l2_native_token_vault_proxy_addr,
- l2_legacy_shared_bridge_addr: config.remote.l2_legacy_shared_bridge_addr,
}
}
}
diff --git a/core/bin/external_node/src/node_builder.rs b/core/bin/external_node/src/node_builder.rs
index 4601b49bd05..e6284cb7f24 100644
--- a/core/bin/external_node/src/node_builder.rs
+++ b/core/bin/external_node/src/node_builder.rs
@@ -192,18 +192,7 @@ impl ExternalNodeBuilder {
const OPTIONAL_BYTECODE_COMPRESSION: bool = true;
let persistence_layer = OutputHandlerLayer::new(
- self.config
- .remote
- .l2_shared_bridge_addr
- .expect("L2 shared bridge address is not set"),
- self.config
- .remote
- .l2_native_token_vault_proxy_addr
- .expect("L2 native token vault proxy address is not set"),
- self.config
- .remote
- .l2_legacy_shared_bridge_addr
- .expect("L2 legacy shared bridge address is not set"),
+ self.config.remote.l2_legacy_shared_bridge_addr,
self.config.optional.l2_block_seal_queue_capacity,
)
.with_pre_insert_txs(true) // EN requires txs to be pre-inserted.
diff --git a/core/bin/zksync_server/src/node_builder.rs b/core/bin/zksync_server/src/node_builder.rs
index 4ee8e5c7376..5c55d060e92 100644
--- a/core/bin/zksync_server/src/node_builder.rs
+++ b/core/bin/zksync_server/src/node_builder.rs
@@ -240,15 +240,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_native_token_vault_proxy_addr
- .context("L2 native token vault proxy address")?,
- self.contracts_config
- .l2_legacy_shared_bridge_addr
- .context("L2 legacy 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);
diff --git a/core/lib/basic_types/src/protocol_version.rs b/core/lib/basic_types/src/protocol_version.rs
index ce915014595..132b78b51b5 100644
--- a/core/lib/basic_types/src/protocol_version.rs
+++ b/core/lib/basic_types/src/protocol_version.rs
@@ -120,8 +120,8 @@ impl ProtocolVersionId {
ProtocolVersionId::Version22 => VmVersion::Vm1_4_2,
ProtocolVersionId::Version23 => VmVersion::Vm1_5_0SmallBootloaderMemory,
ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
- ProtocolVersionId::Version25 => VmVersion::VmSyncLayer,
- ProtocolVersionId::Version26 => VmVersion::VmSyncLayer,
+ ProtocolVersionId::Version25 => VmVersion::VmGateway,
+ ProtocolVersionId::Version26 => VmVersion::VmGateway,
}
}
@@ -280,8 +280,8 @@ impl From for VmVersion {
ProtocolVersionId::Version22 => VmVersion::Vm1_4_2,
ProtocolVersionId::Version23 => VmVersion::Vm1_5_0SmallBootloaderMemory,
ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
- ProtocolVersionId::Version25 => VmVersion::VmSyncLayer,
- ProtocolVersionId::Version26 => VmVersion::VmSyncLayer,
+ ProtocolVersionId::Version25 => VmVersion::VmGateway,
+ ProtocolVersionId::Version26 => VmVersion::VmGateway,
}
}
}
diff --git a/core/lib/basic_types/src/vm.rs b/core/lib/basic_types/src/vm.rs
index ac31cae64f0..f11f98596f1 100644
--- a/core/lib/basic_types/src/vm.rs
+++ b/core/lib/basic_types/src/vm.rs
@@ -16,7 +16,7 @@ pub enum VmVersion {
Vm1_4_2,
Vm1_5_0SmallBootloaderMemory,
Vm1_5_0IncreasedBootloaderMemory,
- VmSyncLayer,
+ VmGateway,
}
impl VmVersion {
diff --git a/core/lib/config/src/configs/contracts.rs b/core/lib/config/src/configs/contracts.rs
index bf88c100cce..2a17f74265d 100644
--- a/core/lib/config/src/configs/contracts.rs
+++ b/core/lib/config/src/configs/contracts.rs
@@ -29,7 +29,12 @@ 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,
@@ -44,7 +49,6 @@ pub struct ContractsConfig {
// FIXME: maybe refactor
pub user_facing_bridgehub_proxy_addr: Option,
pub user_facing_diamond_proxy_addr: Option,
- pub l2_native_token_vault_proxy_addr: Option,
pub l2_da_validator_addr: Option,
@@ -62,7 +66,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(0x10)),
+ l2_legacy_shared_bridge_addr: Some(Address::repeat_byte(0xff)),
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)),
@@ -72,7 +76,6 @@ impl ContractsConfig {
ecosystem_contracts: Some(EcosystemContracts::for_tests()),
user_facing_bridgehub_proxy_addr: Some(Address::repeat_byte(0x15)),
user_facing_diamond_proxy_addr: Some(Address::repeat_byte(0x16)),
- l2_native_token_vault_proxy_addr: Some(Address::repeat_byte(0x0d)),
chain_admin_addr: Some(Address::repeat_byte(0x18)),
l2_da_validator_addr: Some(Address::repeat_byte(0x19)),
}
diff --git a/core/lib/config/src/testonly.rs b/core/lib/config/src/testonly.rs
index c913d54dffd..abb23052149 100644
--- a/core/lib/config/src/testonly.rs
+++ b/core/lib/config/src/testonly.rs
@@ -262,7 +262,6 @@ impl Distribution for EncodeDist {
ecosystem_contracts: self.sample(rng),
user_facing_bridgehub_proxy_addr: rng.gen(),
user_facing_diamond_proxy_addr: rng.gen(),
- l2_native_token_vault_proxy_addr: rng.gen(),
l2_da_validator_addr: rng.gen(),
base_token_addr: self.sample_opt(|| rng.gen()),
chain_admin_addr: self.sample_opt(|| rng.gen()),
diff --git a/core/lib/contracts/src/lib.rs b/core/lib/contracts/src/lib.rs
index 65ff48a74ce..06d6a235337 100644
--- a/core/lib/contracts/src/lib.rs
+++ b/core/lib/contracts/src/lib.rs
@@ -914,3 +914,319 @@ pub static DIAMOND_CUT: Lazy = Lazy::new(|| {
}"#;
serde_json::from_str(abi).unwrap()
});
+
+pub static POST_SHARED_BRIDGE_COMMIT_FUNCTION: Lazy = Lazy::new(|| {
+ let abi = r#"
+ {
+ "inputs": [
+ {
+ "internalType": "uint256",
+ "name": "_chainId",
+ "type": "uint256"
+ },
+ {
+ "components": [
+ {
+ "internalType": "uint64",
+ "name": "batchNumber",
+ "type": "uint64"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "batchHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "uint64",
+ "name": "indexRepeatedStorageChanges",
+ "type": "uint64"
+ },
+ {
+ "internalType": "uint256",
+ "name": "numberOfLayer1Txs",
+ "type": "uint256"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "priorityOperationsHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "l2LogsTreeRoot",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "uint256",
+ "name": "timestamp",
+ "type": "uint256"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "commitment",
+ "type": "bytes32"
+ }
+ ],
+ "internalType": "struct IExecutor.StoredBatchInfo",
+ "name": "_lastCommittedBatchData",
+ "type": "tuple"
+ },
+ {
+ "components": [
+ {
+ "internalType": "uint64",
+ "name": "batchNumber",
+ "type": "uint64"
+ },
+ {
+ "internalType": "uint64",
+ "name": "timestamp",
+ "type": "uint64"
+ },
+ {
+ "internalType": "uint64",
+ "name": "indexRepeatedStorageChanges",
+ "type": "uint64"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "newStateRoot",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "uint256",
+ "name": "numberOfLayer1Txs",
+ "type": "uint256"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "priorityOperationsHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "bootloaderHeapInitialContentsHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "eventsQueueStateHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes",
+ "name": "systemLogs",
+ "type": "bytes"
+ },
+ {
+ "internalType": "bytes",
+ "name": "pubdataCommitments",
+ "type": "bytes"
+ }
+ ],
+ "internalType": "struct IExecutor.CommitBatchInfo[]",
+ "name": "_newBatchesData",
+ "type": "tuple[]"
+ }
+ ],
+ "name": "commitBatchesSharedBridge",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ }"#;
+ serde_json::from_str(abi).unwrap()
+});
+
+pub static POST_SHARED_BRIDGE_PROVE_FUNCTION: Lazy = Lazy::new(|| {
+ let abi = r#"
+ {
+ "inputs": [
+ {
+ "internalType": "uint256",
+ "name": "_chainId",
+ "type": "uint256"
+ },
+ {
+ "components": [
+ {
+ "internalType": "uint64",
+ "name": "batchNumber",
+ "type": "uint64"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "batchHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "uint64",
+ "name": "indexRepeatedStorageChanges",
+ "type": "uint64"
+ },
+ {
+ "internalType": "uint256",
+ "name": "numberOfLayer1Txs",
+ "type": "uint256"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "priorityOperationsHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "l2LogsTreeRoot",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "uint256",
+ "name": "timestamp",
+ "type": "uint256"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "commitment",
+ "type": "bytes32"
+ }
+ ],
+ "internalType": "struct IExecutor.StoredBatchInfo",
+ "name": "_prevBatch",
+ "type": "tuple"
+ },
+ {
+ "components": [
+ {
+ "internalType": "uint64",
+ "name": "batchNumber",
+ "type": "uint64"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "batchHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "uint64",
+ "name": "indexRepeatedStorageChanges",
+ "type": "uint64"
+ },
+ {
+ "internalType": "uint256",
+ "name": "numberOfLayer1Txs",
+ "type": "uint256"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "priorityOperationsHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "l2LogsTreeRoot",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "uint256",
+ "name": "timestamp",
+ "type": "uint256"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "commitment",
+ "type": "bytes32"
+ }
+ ],
+ "internalType": "struct IExecutor.StoredBatchInfo[]",
+ "name": "_committedBatches",
+ "type": "tuple[]"
+ },
+ {
+ "components": [
+ {
+ "internalType": "uint256[]",
+ "name": "recursiveAggregationInput",
+ "type": "uint256[]"
+ },
+ {
+ "internalType": "uint256[]",
+ "name": "serializedProof",
+ "type": "uint256[]"
+ }
+ ],
+ "internalType": "struct IExecutor.ProofInput",
+ "name": "_proof",
+ "type": "tuple"
+ }
+ ],
+ "name": "proveBatchesSharedBridge",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ }"#;
+ serde_json::from_str(abi).unwrap()
+});
+
+pub static POST_SHARED_BRIDGE_EXECUTE_FUNCTION: Lazy = Lazy::new(|| {
+ let abi = r#"
+ {
+ "inputs": [
+ {
+ "internalType": "uint256",
+ "name": "_chainId",
+ "type": "uint256"
+ },
+ {
+ "components": [
+ {
+ "internalType": "uint64",
+ "name": "batchNumber",
+ "type": "uint64"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "batchHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "uint64",
+ "name": "indexRepeatedStorageChanges",
+ "type": "uint64"
+ },
+ {
+ "internalType": "uint256",
+ "name": "numberOfLayer1Txs",
+ "type": "uint256"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "priorityOperationsHash",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "l2LogsTreeRoot",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "uint256",
+ "name": "timestamp",
+ "type": "uint256"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "commitment",
+ "type": "bytes32"
+ }
+ ],
+ "internalType": "struct IExecutor.StoredBatchInfo[]",
+ "name": "_batchesData",
+ "type": "tuple[]"
+ }
+ ],
+ "name": "executeBatchesSharedBridge",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ }"#;
+ serde_json::from_str(abi).unwrap()
+});
diff --git a/core/lib/dal/src/consensus/mod.rs b/core/lib/dal/src/consensus/mod.rs
index 763c13cc387..2a2df0adb45 100644
--- a/core/lib/dal/src/consensus/mod.rs
+++ b/core/lib/dal/src/consensus/mod.rs
@@ -142,7 +142,7 @@ pub struct Payload {
pub fair_pubdata_price: Option,
pub virtual_blocks: u32,
pub operator_address: Address,
- pub pubdata_params: PubdataParams,
+ pub pubdata_params: Option,
pub transactions: Vec,
pub last_in_batch: bool,
}
@@ -180,9 +180,19 @@ impl ProtoFmt for Payload {
}
}
- let pubdata_params = required(&r.pubdata_params)
- .context("pubdata_params")?
- .clone();
+ let pubdata_params = if let Some(pubdata_params) = &r.pubdata_params {
+ Some(PubdataParams {
+ l2_da_validator_address: required(&pubdata_params.l2_da_validator_address)
+ .and_then(|a| parse_h160(a))
+ .context("operator_address")?,
+ pubdata_type: required(&pubdata_params.pubdata_type)
+ .and_then(|x| Ok(proto::L1BatchCommitDataGeneratorMode::try_from(*x)?))
+ .context("l1_batch_commit_data_generator_mode")?
+ .parse(),
+ })
+ } else {
+ None
+ };
Ok(Self {
protocol_version,
@@ -202,15 +212,7 @@ impl ProtoFmt for Payload {
.context("operator_address")?,
transactions,
last_in_batch: *required(&r.last_in_batch).context("last_in_batch")?,
- pubdata_params: PubdataParams {
- l2_da_validator_address: required(&pubdata_params.l2_da_validator_address)
- .and_then(|a| parse_h160(a))
- .context("operator_address")?,
- pubdata_type: required(&pubdata_params.pubdata_type)
- .and_then(|x| Ok(proto::L1BatchCommitDataGeneratorMode::try_from(*x)?))
- .context("l1_batch_commit_data_generator_mode")?
- .parse(),
- },
+ pubdata_params,
})
}
@@ -229,17 +231,16 @@ impl ProtoFmt for Payload {
transactions: vec![],
transactions_v25: vec![],
last_in_batch: Some(self.last_in_batch),
- pubdata_params: Some(proto::PubdataParams {
- l2_da_validator_address: Some(
- self.pubdata_params
- .l2_da_validator_address
- .as_bytes()
- .into(),
- ),
- pubdata_type: Some(proto::L1BatchCommitDataGeneratorMode::new(
- &self.pubdata_params.pubdata_type,
- ) as i32),
- }),
+ pubdata_params: self
+ .pubdata_params
+ .map(|pubdata_params| proto::PubdataParams {
+ l2_da_validator_address: Some(
+ pubdata_params.l2_da_validator_address.as_bytes().into(),
+ ),
+ pubdata_type: Some(proto::L1BatchCommitDataGeneratorMode::new(
+ &pubdata_params.pubdata_type,
+ ) as i32),
+ }),
};
match self.protocol_version {
v if v >= ProtocolVersionId::Version25 => {
diff --git a/core/lib/dal/src/consensus/proto/mod.proto b/core/lib/dal/src/consensus/proto/mod.proto
index 24a8297031d..6083ad02910 100644
--- a/core/lib/dal/src/consensus/proto/mod.proto
+++ b/core/lib/dal/src/consensus/proto/mod.proto
@@ -27,7 +27,7 @@ message Payload {
// Set for protocol_version >= 25.
repeated TransactionV25 transactions_v25 = 12;
optional bool last_in_batch = 10; // required
- optional PubdataParams pubdata_params = 13; // required
+ optional PubdataParams pubdata_params = 13; // optional
}
message PubdataParams {
diff --git a/core/lib/dal/src/consensus/tests.rs b/core/lib/dal/src/consensus/tests.rs
index c99f8a37f7c..e50ff5b1cae 100644
--- a/core/lib/dal/src/consensus/tests.rs
+++ b/core/lib/dal/src/consensus/tests.rs
@@ -53,13 +53,13 @@ fn payload(rng: &mut impl Rng, protocol_version: ProtocolVersionId) -> Payload {
})
.collect(),
last_in_batch: rng.gen(),
- pubdata_params: PubdataParams {
+ 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/models/storage_sync.rs b/core/lib/dal/src/models/storage_sync.rs
index b9ef075f985..7bb3c228748 100644
--- a/core/lib/dal/src/models/storage_sync.rs
+++ b/core/lib/dal/src/models/storage_sync.rs
@@ -117,7 +117,7 @@ impl SyncBlock {
virtual_blocks: Some(self.virtual_blocks),
hash: Some(self.hash),
protocol_version: self.protocol_version,
- pubdata_params: self.pubdata_params,
+ pubdata_params: Some(self.pubdata_params),
}
}
@@ -134,7 +134,7 @@ impl SyncBlock {
operator_address: self.fee_account_address,
transactions,
last_in_batch: self.last_in_batch,
- pubdata_params: self.pubdata_params,
+ pubdata_params: Some(self.pubdata_params),
}
}
}
diff --git a/core/lib/env_config/src/contracts.rs b/core/lib/env_config/src/contracts.rs
index d1c6a252b02..b9ca4e88d07 100644
--- a/core/lib/env_config/src/contracts.rs
+++ b/core/lib/env_config/src/contracts.rs
@@ -81,6 +81,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 {
@@ -95,10 +96,6 @@ mod tests {
user_facing_diamond_proxy_addr: Some(addr(
"0xF00B988a98Ca742e7958DeF9F7823b5908715f4a",
)),
- l2_native_token_vault_proxy_addr: Some(addr(
- "0xfc073319977e314f251eae6ae6be76b0b3baeecf",
- )),
- l2_legacy_shared_bridge_addr: Some(addr("0x8656770FA78c830456B00B4fFCeE6b1De0e1b888")),
chain_admin_addr: Some(addr("0xdd6fa5c14e7550b4caf2aa2818d24c69cbc347ff")),
l2_da_validator_addr: Some(addr("0xed6fa5c14e7550b4caf2aa2818d24c69cbc347ff")),
}
@@ -122,6 +119,7 @@ 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"
@@ -131,7 +129,6 @@ CONTRACTS_USER_FACING_DIAMOND_PROXY_ADDR="0xF00B988a98Ca742e7958DeF9F7823b590871
CONTRACTS_L2_NATIVE_TOKEN_VAULT_PROXY_ADDR="0xfc073319977e314f251eae6ae6be76b0b3baeecf"
CONTRACTS_L2_DA_VALIDATOR_ADDR="0xed6fa5c14e7550b4caf2aa2818d24c69cbc347ff"
CONTRACTS_CHAIN_ADMIN_ADDR="0xdd6fa5c14e7550b4caf2aa2818d24c69cbc347ff"
-CONTRACTS_L2_LEGACY_SHARED_BRIDGE_ADDR="0x8656770FA78c830456B00B4fFCeE6b1De0e1b888"
"#;
lock.set_env(config);
diff --git a/core/lib/l1_contract_interface/src/i_executor/methods/commit_batches.rs b/core/lib/l1_contract_interface/src/i_executor/methods/commit_batches.rs
index e1bddf67ded..a805876ca40 100644
--- a/core/lib/l1_contract_interface/src/i_executor/methods/commit_batches.rs
+++ b/core/lib/l1_contract_interface/src/i_executor/methods/commit_batches.rs
@@ -6,8 +6,9 @@ use zksync_types::{
use crate::{
i_executor::structures::{CommitBatchInfo, StoredBatchInfo, SUPPORTED_ENCODING_VERSION},
- Tokenizable,
+ Tokenizable, Tokenize,
};
+
/// Input required to encode `commitBatches` call for a contract
#[derive(Debug)]
pub struct CommitBatches<'a> {
@@ -17,8 +18,9 @@ pub struct CommitBatches<'a> {
pub mode: L1BatchCommitmentMode,
}
-impl CommitBatches<'_> {
- pub fn into_tokens(self, pre_gateway: bool) -> Vec {
+impl Tokenize for &CommitBatches<'_> {
+ fn into_tokens(self) -> Vec {
+ let protocol_version = self.l1_batches[0].header.protocol_version.unwrap();
let stored_batch_info = StoredBatchInfo::from(self.last_committed_l1_batch).into_token();
let l1_batches_to_commit: Vec = self
.l1_batches
@@ -26,16 +28,16 @@ impl CommitBatches<'_> {
.map(|batch| CommitBatchInfo::new(self.mode, batch, self.pubdata_da).into_token())
.collect();
- let encoded_data = encode(&[
- stored_batch_info.clone(),
- Token::Array(l1_batches_to_commit.clone()),
- ]);
- let commit_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
- .concat()
- .to_vec();
- if pre_gateway {
+ if protocol_version.is_pre_gateway() {
vec![stored_batch_info, Token::Array(l1_batches_to_commit)]
} else {
+ let encoded_data = encode(&[
+ stored_batch_info.clone(),
+ Token::Array(l1_batches_to_commit.clone()),
+ ]);
+ let commit_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
+ .concat()
+ .to_vec();
vec![
Token::Uint((self.last_committed_l1_batch.header.number.0 + 1).into()),
Token::Uint(
diff --git a/core/lib/l1_contract_interface/src/i_executor/methods/execute_batches.rs b/core/lib/l1_contract_interface/src/i_executor/methods/execute_batches.rs
index bbf02201183..e2e29bfefcf 100644
--- a/core/lib/l1_contract_interface/src/i_executor/methods/execute_batches.rs
+++ b/core/lib/l1_contract_interface/src/i_executor/methods/execute_batches.rs
@@ -17,28 +17,45 @@ pub struct ExecuteBatches {
impl Tokenize for &ExecuteBatches {
fn into_tokens(self) -> Vec {
- let encoded_data = encode(&[
- Token::Array(
+ let protocol_version = self.l1_batches[0].header.protocol_version.unwrap();
+
+ if protocol_version.is_pre_gateway() {
+ vec![Token::Array(
self.l1_batches
.iter()
.map(|batch| StoredBatchInfo::from(batch).into_token())
.collect(),
- ),
- Token::Array(
- self.priority_ops_proofs
- .iter()
- .map(|proof| proof.into_token())
- .collect(),
- ),
- ]);
- let commit_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
- .concat()
- .to_vec();
+ )]
+ } else {
+ let encoded_data = encode(&[
+ Token::Array(
+ self.l1_batches
+ .iter()
+ .map(|batch| StoredBatchInfo::from(batch).into_token())
+ .collect(),
+ ),
+ Token::Array(
+ self.priority_ops_proofs
+ .iter()
+ .map(|proof| proof.into_token())
+ .collect(),
+ ),
+ ]);
+ let execute_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
+ .concat()
+ .to_vec();
- vec![
- Token::Uint((self.l1_batches[0].header.number.0).into()),
- Token::Uint((self.l1_batches[self.l1_batches.len() - 1].header.number.0).into()),
- Token::Bytes(commit_data),
- ]
+ vec![
+ Token::Uint(self.l1_batches[0].header.number.0.into()),
+ Token::Uint(
+ self.l1_batches[self.l1_batches.len() - 1]
+ .header
+ .number
+ .0
+ .into(),
+ ),
+ Token::Bytes(execute_data),
+ ]
+ }
}
}
diff --git a/core/lib/l1_contract_interface/src/i_executor/methods/prove_batches.rs b/core/lib/l1_contract_interface/src/i_executor/methods/prove_batches.rs
index 086ec84fb00..a54cf407d09 100644
--- a/core/lib/l1_contract_interface/src/i_executor/methods/prove_batches.rs
+++ b/core/lib/l1_contract_interface/src/i_executor/methods/prove_batches.rs
@@ -3,7 +3,6 @@ use zksync_prover_interface::outputs::L1BatchProofForL1;
use zksync_types::{
commitment::L1BatchWithMetadata,
ethabi::{encode, Token},
- U256,
};
use crate::{
@@ -29,6 +28,7 @@ impl Tokenize for &ProveBatches {
.map(|batch| StoredBatchInfo::from(batch).into_token())
.collect();
let batches_arg = Token::Array(batches_arg);
+ let protocol_version = self.l1_batches[0].header.protocol_version.unwrap();
if self.should_verify {
// currently we only support submitting a single proof
@@ -36,50 +36,43 @@ impl Tokenize for &ProveBatches {
assert_eq!(self.l1_batches.len(), 1);
let L1BatchProofForL1 {
- aggregation_result_coords,
- scheduler_proof,
- ..
+ scheduler_proof, ..
} = self.proofs.first().unwrap();
let (_, proof) = serialize_proof(scheduler_proof);
- let aggregation_result_coords = if self.l1_batches[0]
- .header
- .protocol_version
- .unwrap()
- .is_pre_boojum()
- {
- aggregation_result_coords
- .iter()
- .map(|bytes| Token::Uint(U256::from_big_endian(bytes)))
- .collect()
+ if protocol_version.is_pre_gateway() {
+ let proof_input = Token::Tuple(vec![
+ Token::Array(Vec::new()),
+ Token::Array(proof.into_iter().map(Token::Uint).collect()),
+ ]);
+
+ vec![prev_l1_batch_info, batches_arg, proof_input]
} else {
- Vec::new()
- };
- let proof_input = Token::Array(
- [
- aggregation_result_coords,
- proof.into_iter().map(Token::Uint).collect(),
- ]
- .concat()
- .to_vec(),
- ); // todo this changed, might have to be debugged.
+ let proof_input = Token::Array(proof.into_iter().map(Token::Uint).collect());
- let encoded_data = encode(&[prev_l1_batch_info, batches_arg, proof_input]);
- let commit_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
- .concat()
- .to_vec();
+ let encoded_data = encode(&[prev_l1_batch_info, batches_arg, proof_input]);
+ let prove_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
+ .concat()
+ .to_vec();
+ vec![
+ Token::Uint((self.prev_l1_batch.header.number.0 + 1).into()),
+ Token::Uint(
+ (self.prev_l1_batch.header.number.0 + self.l1_batches.len() as u32).into(),
+ ),
+ Token::Bytes(prove_data),
+ ]
+ }
+ } else if protocol_version.is_pre_gateway() {
vec![
- Token::Uint((self.prev_l1_batch.header.number.0 + 1).into()),
- Token::Uint(
- (self.prev_l1_batch.header.number.0 + self.l1_batches.len() as u32).into(),
- ),
- Token::Bytes(commit_data),
+ prev_l1_batch_info,
+ batches_arg,
+ Token::Tuple(vec![Token::Array(vec![]), Token::Array(vec![])]),
]
} else {
let encoded_data = encode(&[prev_l1_batch_info, batches_arg, Token::Array(vec![])]);
- let commit_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
+ let prove_data = [[SUPPORTED_ENCODING_VERSION].to_vec(), encoded_data]
.concat()
.to_vec();
@@ -88,7 +81,7 @@ impl Tokenize for &ProveBatches {
Token::Uint(
(self.prev_l1_batch.header.number.0 + self.l1_batches.len() as u32).into(),
),
- Token::Bytes(commit_data),
+ Token::Bytes(prove_data),
]
}
}
diff --git a/core/lib/l1_contract_interface/src/i_executor/structures/commit_batch_info.rs b/core/lib/l1_contract_interface/src/i_executor/structures/commit_batch_info.rs
index e39681d2e04..f9dcdaaed10 100644
--- a/core/lib/l1_contract_interface/src/i_executor/structures/commit_batch_info.rs
+++ b/core/lib/l1_contract_interface/src/i_executor/structures/commit_batch_info.rs
@@ -8,7 +8,7 @@ use zksync_types::{
ethabi::{ParamType, Token},
pubdata_da::PubdataDA,
web3::{contract::Error as ContractError, keccak256},
- ProtocolVersionId, H256, STATE_DIFF_HASH_KEY_PRE_GATEWAY, U256,
+ ProtocolVersionId, H256, U256,
};
use crate::{
@@ -19,6 +19,7 @@ use crate::{
/// These are used by the L1 Contracts to indicate what DA layer is used for pubdata
const PUBDATA_SOURCE_CALLDATA: u8 = 0;
const PUBDATA_SOURCE_BLOBS: u8 = 1;
+const PUBDATA_SOURCE_CUSTOM_PRE_GATEWAY: u8 = 2;
/// Encoding for `CommitBatchInfo` from `IExecutor.sol` for a contract running in rollup mode.
#[derive(Debug)]
@@ -215,23 +216,55 @@ impl Tokenizable for CommitBatchInfo<'_> {
// Here we're not pushing any pubdata on purpose; no pubdata is sent in Validium mode.
L1BatchCommitmentMode::Validium => vec![],
}));
+ } else if protocol_version.is_pre_gateway() {
+ tokens.push(Token::Bytes(match (self.mode, self.pubdata_da) {
+ // Here we're not pushing any pubdata on purpose; no pubdata is sent in Validium mode.
+ (
+ L1BatchCommitmentMode::Validium,
+ PubdataDA::Calldata | PubdataDA::RelayedL2Calldata,
+ ) => {
+ vec![PUBDATA_SOURCE_CALLDATA]
+ }
+ (L1BatchCommitmentMode::Validium, PubdataDA::Blobs) => {
+ vec![PUBDATA_SOURCE_BLOBS]
+ }
+ (L1BatchCommitmentMode::Rollup, PubdataDA::Custom) => {
+ panic!("Custom pubdata DA is incompatible with Rollup mode")
+ }
+ (L1BatchCommitmentMode::Validium, PubdataDA::Custom) => {
+ vec![PUBDATA_SOURCE_CUSTOM_PRE_GATEWAY]
+ }
+ (
+ L1BatchCommitmentMode::Rollup,
+ PubdataDA::Calldata | PubdataDA::RelayedL2Calldata,
+ ) => {
+ // We compute and add the blob commitment to the pubdata payload so that we can verify the proof
+ // even if we are not using blobs.
+ let pubdata = self.pubdata_input();
+ let blob_commitment = KzgInfo::new(&pubdata).to_blob_commitment();
+ iter::once(PUBDATA_SOURCE_CALLDATA)
+ .chain(pubdata)
+ .chain(blob_commitment)
+ .collect()
+ }
+ (L1BatchCommitmentMode::Rollup, PubdataDA::Blobs) => {
+ let pubdata = self.pubdata_input();
+ let pubdata_commitments =
+ pubdata.chunks(ZK_SYNC_BYTES_PER_BLOB).flat_map(|blob| {
+ let kzg_info = KzgInfo::new(blob);
+ kzg_info.to_pubdata_commitment()
+ });
+ iter::once(PUBDATA_SOURCE_BLOBS)
+ .chain(pubdata_commitments)
+ .collect()
+ }
+ }));
} else {
- let state_diff_hash = if protocol_version.is_pre_gateway() {
- self.l1_batch_with_metadata
- .header
- .system_logs
- .iter()
- .find_map(|log| {
- (log.0.key == H256::from_low_u64_be(STATE_DIFF_HASH_KEY_PRE_GATEWAY))
- .then_some(log.0.value)
- })
- .expect("Failed to get state_diff_hash from system logs")
- } else {
- self.l1_batch_with_metadata
- .metadata
- .state_diff_hash
- .expect("Failed to get state_diff_hash from metadata")
- };
+ let state_diff_hash = self
+ .l1_batch_with_metadata
+ .metadata
+ .state_diff_hash
+ .expect("Failed to get state_diff_hash from metadata");
tokens.push(Token::Bytes(match (self.mode, self.pubdata_da) {
// Validiums with custom DA need the inclusion data to be part of operator_da_input
(L1BatchCommitmentMode::Validium, PubdataDA::Custom) => {
diff --git a/core/lib/multivm/src/utils/mod.rs b/core/lib/multivm/src/utils/mod.rs
index 07d109a59ba..44ed004adc2 100644
--- a/core/lib/multivm/src/utils/mod.rs
+++ b/core/lib/multivm/src/utils/mod.rs
@@ -55,7 +55,7 @@ pub fn derive_base_fee_and_gas_per_pubdata(
),
VmVersion::Vm1_5_0SmallBootloaderMemory
| VmVersion::Vm1_5_0IncreasedBootloaderMemory
- | VmVersion::VmSyncLayer => {
+ | VmVersion::VmGateway => {
crate::vm_latest::utils::fee::derive_base_fee_and_gas_per_pubdata(
batch_fee_input.into_pubdata_independent(),
)
@@ -85,7 +85,7 @@ pub fn get_batch_base_fee(l1_batch_env: &L1BatchEnv, vm_version: VmVersion) -> u
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
- | VmVersion::VmSyncLayer => crate::vm_latest::utils::fee::get_batch_base_fee(l1_batch_env),
+ | VmVersion::VmGateway => crate::vm_latest::utils::fee::get_batch_base_fee(l1_batch_env),
}
}
@@ -213,7 +213,7 @@ pub fn derive_overhead(
VmVersion::Vm1_4_2 => crate::vm_1_4_2::utils::overhead::derive_overhead(encoded_len),
VmVersion::Vm1_5_0SmallBootloaderMemory
| VmVersion::Vm1_5_0IncreasedBootloaderMemory
- | VmVersion::VmSyncLayer => crate::vm_latest::utils::overhead::derive_overhead(encoded_len),
+ | VmVersion::VmGateway => crate::vm_latest::utils::overhead::derive_overhead(encoded_len),
}
}
@@ -247,7 +247,7 @@ pub fn get_bootloader_encoding_space(version: VmVersion) -> u32 {
crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory,
)
}
- VmVersion::VmSyncLayer => crate::vm_latest::constants::get_bootloader_tx_encoding_space(
+ VmVersion::VmGateway => crate::vm_latest::constants::get_bootloader_tx_encoding_space(
crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory,
),
}
@@ -271,7 +271,7 @@ pub fn get_bootloader_max_txs_in_batch(version: VmVersion) -> usize {
VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::MAX_TXS_IN_BATCH,
VmVersion::Vm1_5_0SmallBootloaderMemory
| VmVersion::Vm1_5_0IncreasedBootloaderMemory
- | VmVersion::VmSyncLayer => crate::vm_latest::constants::MAX_TXS_IN_BATCH,
+ | VmVersion::VmGateway => crate::vm_latest::constants::MAX_TXS_IN_BATCH,
}
}
@@ -294,7 +294,7 @@ pub fn gas_bootloader_batch_tip_overhead(version: VmVersion) -> u32 {
VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::BOOTLOADER_BATCH_TIP_OVERHEAD,
VmVersion::Vm1_5_0SmallBootloaderMemory
| VmVersion::Vm1_5_0IncreasedBootloaderMemory
- | VmVersion::VmSyncLayer => crate::vm_latest::constants::BOOTLOADER_BATCH_TIP_OVERHEAD,
+ | VmVersion::VmGateway => crate::vm_latest::constants::BOOTLOADER_BATCH_TIP_OVERHEAD,
}
}
@@ -317,7 +317,7 @@ pub fn circuit_statistics_bootloader_batch_tip_overhead(version: VmVersion) -> u
}
VmVersion::Vm1_5_0SmallBootloaderMemory
| VmVersion::Vm1_5_0IncreasedBootloaderMemory
- | VmVersion::VmSyncLayer => {
+ | VmVersion::VmGateway => {
crate::vm_latest::constants::BOOTLOADER_BATCH_TIP_CIRCUIT_STATISTICS_OVERHEAD as usize
}
}
@@ -342,7 +342,7 @@ pub fn execution_metrics_bootloader_batch_tip_overhead(version: VmVersion) -> us
}
VmVersion::Vm1_5_0SmallBootloaderMemory
| VmVersion::Vm1_5_0IncreasedBootloaderMemory
- | VmVersion::VmSyncLayer => {
+ | VmVersion::VmGateway => {
crate::vm_latest::constants::BOOTLOADER_BATCH_TIP_METRICS_SIZE_OVERHEAD as usize
}
}
@@ -368,7 +368,7 @@ pub fn get_max_gas_per_pubdata_byte(version: VmVersion) -> u64 {
VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::MAX_GAS_PER_PUBDATA_BYTE,
VmVersion::Vm1_5_0SmallBootloaderMemory
| VmVersion::Vm1_5_0IncreasedBootloaderMemory
- | VmVersion::VmSyncLayer => crate::vm_latest::constants::MAX_GAS_PER_PUBDATA_BYTE,
+ | VmVersion::VmGateway => crate::vm_latest::constants::MAX_GAS_PER_PUBDATA_BYTE,
}
}
@@ -397,7 +397,7 @@ pub fn get_used_bootloader_memory_bytes(version: VmVersion) -> usize {
crate::vm_latest::MultiVMSubversion::SmallBootloaderMemory,
)
}
- VmVersion::Vm1_5_0IncreasedBootloaderMemory | VmVersion::VmSyncLayer => {
+ VmVersion::Vm1_5_0IncreasedBootloaderMemory | VmVersion::VmGateway => {
crate::vm_latest::constants::get_used_bootloader_memory_bytes(
crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory,
)
@@ -430,7 +430,7 @@ pub fn get_used_bootloader_memory_words(version: VmVersion) -> usize {
crate::vm_latest::MultiVMSubversion::SmallBootloaderMemory,
)
}
- VmVersion::Vm1_5_0IncreasedBootloaderMemory | VmVersion::VmSyncLayer => {
+ VmVersion::Vm1_5_0IncreasedBootloaderMemory | VmVersion::VmGateway => {
crate::vm_latest::constants::get_used_bootloader_memory_bytes(
crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory,
)
@@ -458,7 +458,7 @@ pub fn get_max_batch_gas_limit(version: VmVersion) -> u64 {
VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::BLOCK_GAS_LIMIT as u64,
VmVersion::Vm1_5_0SmallBootloaderMemory
| VmVersion::Vm1_5_0IncreasedBootloaderMemory
- | VmVersion::VmSyncLayer => crate::vm_latest::constants::BATCH_GAS_LIMIT,
+ | VmVersion::VmGateway => crate::vm_latest::constants::BATCH_GAS_LIMIT,
}
}
@@ -484,7 +484,7 @@ pub fn get_eth_call_gas_limit(version: VmVersion) -> 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
- | VmVersion::VmSyncLayer => crate::vm_latest::constants::ETH_CALL_GAS_LIMIT,
+ | VmVersion::VmGateway => crate::vm_latest::constants::ETH_CALL_GAS_LIMIT,
}
}
@@ -507,7 +507,7 @@ pub fn get_max_batch_base_layer_circuits(version: VmVersion) -> usize {
}
VmVersion::Vm1_5_0SmallBootloaderMemory
| VmVersion::Vm1_5_0IncreasedBootloaderMemory
- | VmVersion::VmSyncLayer => crate::vm_latest::constants::MAX_BASE_LAYER_CIRCUITS,
+ | VmVersion::VmGateway => crate::vm_latest::constants::MAX_BASE_LAYER_CIRCUITS,
}
}
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 69c780194eb..122704c24b9 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
@@ -18,6 +18,7 @@ use crate::{
constants::TX_DESCRIPTION_OFFSET,
types::internals::{PubdataInput, TransactionData},
utils::l2_blocks::assert_next_block,
+ MultiVMSubversion,
},
};
@@ -48,7 +49,10 @@ pub struct BootloaderState {
free_tx_offset: usize,
/// Information about the the pubdata that will be needed to supply to the L1Messenger
pubdata_information: OnceCell,
- pub(crate) pubdata_params: PubdataParams,
+ /// Params related to how the pubdata should be processed by the bootloader in the batch
+ pubdata_params: PubdataParams,
+ /// VM subversion
+ subversion: MultiVMSubversion,
}
impl BootloaderState {
@@ -57,6 +61,7 @@ impl BootloaderState {
initial_memory: BootloaderMemory,
first_l2_block: L2BlockEnv,
pubdata_params: PubdataParams,
+ subversion: MultiVMSubversion,
) -> Self {
let l2_block = BootloaderL2Block::new(first_l2_block, 0);
Self {
@@ -68,6 +73,7 @@ impl BootloaderState {
free_tx_offset: 0,
pubdata_information: Default::default(),
pubdata_params,
+ subversion,
}
}
@@ -141,6 +147,7 @@ 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()
@@ -148,14 +155,21 @@ impl BootloaderState {
}
pub(crate) fn get_encoded_pubdata(&self) -> Vec {
- get_encoded_pubdata(
- self.pubdata_information
- .get()
- .expect("Pubdata information is not set")
- .clone(),
- self.pubdata_params,
- false,
- )
+ let pubdata_information = self
+ .pubdata_information
+ .get()
+ .expect("Pubdata information is not set")
+ .clone();
+
+ match self.subversion {
+ MultiVMSubversion::SmallBootloaderMemory
+ | MultiVMSubversion::IncreasedBootloaderMemory => {
+ pubdata_information.build_pubdata_legacy(false)
+ }
+ MultiVMSubversion::Gateway => {
+ get_encoded_pubdata(pubdata_information, self.pubdata_params, false)
+ }
+ }
}
fn last_mut_l2_block(&mut self) -> &mut BootloaderL2Block {
@@ -199,6 +213,7 @@ impl BootloaderState {
&mut initial_memory,
pubdata_information,
self.pubdata_params,
+ self.subversion,
);
initial_memory
}
@@ -312,4 +327,12 @@ impl BootloaderState {
);
}
}
+
+ pub(crate) fn get_pubdata_params(&self) -> PubdataParams {
+ self.pubdata_params
+ }
+
+ pub(crate) fn get_vm_subversion(&self) -> MultiVMSubversion {
+ self.subversion
+ }
}
diff --git a/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs b/core/lib/multivm/src/versions/vm_latest/bootloader_state/utils.rs
index 4c854223a63..09085402b0d 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
@@ -21,6 +21,7 @@ use crate::{
pubdata::{PubdataBuilder, RollupPubdataBuilder, ValidiumPubdataBuilder},
PubdataInput,
},
+ MultiVMSubversion,
},
};
@@ -156,19 +157,45 @@ pub(crate) fn apply_pubdata_to_memory(
memory: &mut BootloaderMemory,
pubdata_information: PubdataInput,
pubdata_params: PubdataParams,
+ subversion: MultiVMSubversion,
) {
- // Skipping two slots as they will be filled by the bootloader itself:
- // - One slot is for the selector of the call to the L1Messenger.
- // - The other slot is for the 0x20 offset for the calldata.
- let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 1;
-
- let pubdata = get_encoded_pubdata(pubdata_information, pubdata_params, true);
-
- assert!(
- // Note that unlike the previous version, the difference is `1`, since now it also includes the offset
- pubdata.len() / 32 < OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS,
- "The encoded pubdata is too big"
- );
+ let (l1_messenger_pubdata_start_slot, pubdata) = match subversion {
+ MultiVMSubversion::SmallBootloaderMemory | MultiVMSubversion::IncreasedBootloaderMemory => {
+ // Skipping two slots as they will be filled by the bootloader itself:
+ // - One slot is for the selector of the call to the L1Messenger.
+ // - The other slot is for the 0x20 offset for the calldata.
+ let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 2;
+
+ // Need to skip first word as it represents array offset
+ // while bootloader expects only [len || data]
+ let pubdata = ethabi::encode(&[ethabi::Token::Bytes(
+ pubdata_information.build_pubdata_legacy(true),
+ )])[32..]
+ .to_vec();
+
+ assert!(
+ pubdata.len() / 32 <= OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS - 2,
+ "The encoded pubdata is too big"
+ );
+
+ (l1_messenger_pubdata_start_slot, pubdata)
+ }
+ MultiVMSubversion::Gateway => {
+ // Skipping the first slot as it will be filled by the bootloader itself:
+ // It is for the selector of the call to the L1Messenger.
+ let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 1;
+
+ let pubdata = get_encoded_pubdata(pubdata_information, pubdata_params, true);
+
+ assert!(
+ // Note that unlike the previous version, the difference is `1`, since now it also includes the offset
+ pubdata.len() / 32 < OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS,
+ "The encoded pubdata is too big"
+ );
+
+ (l1_messenger_pubdata_start_slot, pubdata)
+ }
+ };
pubdata
.chunks(32)
diff --git a/core/lib/multivm/src/versions/vm_latest/constants.rs b/core/lib/multivm/src/versions/vm_latest/constants.rs
index 64a05d0d13e..c047e6ffa3b 100644
--- a/core/lib/multivm/src/versions/vm_latest/constants.rs
+++ b/core/lib/multivm/src/versions/vm_latest/constants.rs
@@ -26,7 +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::SyncLayer => 63_800_000,
+ MultiVMSubversion::Gateway => 63_800_000,
}
}
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 1701c501cd3..9e620f96af2 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
@@ -239,7 +239,8 @@ impl VmTracer for PubdataTracer {
apply_pubdata_to_memory(
&mut memory_to_apply,
pubdata_input,
- bootloader_state.pubdata_params,
+ bootloader_state.get_pubdata_params(),
+ bootloader_state.get_vm_subversion(),
);
state.memory.populate_page(
BOOTLOADER_HEAP_PAGE as usize,
diff --git a/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs b/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs
index fbd01f2b7a7..c0684624bd8 100644
--- a/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs
+++ b/core/lib/multivm/src/versions/vm_latest/types/internals/pubdata.rs
@@ -19,6 +19,55 @@ pub(crate) struct PubdataInput {
pub(crate) l2_to_l1_logs_tree_size: usize,
}
+impl PubdataInput {
+ pub(crate) fn build_pubdata_legacy(self, with_uncompressed_state_diffs: bool) -> Vec {
+ let mut l1_messenger_pubdata = vec![];
+
+ let PubdataInput {
+ user_logs,
+ l2_to_l1_messages,
+ published_bytecodes,
+ state_diffs,
+ ..
+ } = self;
+
+ // Encoding user L2->L1 logs.
+ // Format: `[(numberOfL2ToL1Logs as u32) || l2tol1logs[1] || ... || l2tol1logs[n]]`
+ l1_messenger_pubdata.extend((user_logs.len() as u32).to_be_bytes());
+ for l2tol1log in user_logs {
+ l1_messenger_pubdata.extend(l2tol1log.packed_encoding());
+ }
+
+ // Encoding L2->L1 messages
+ // Format: `[(numberOfMessages as u32) || (messages[1].len() as u32) || messages[1] || ... || (messages[n].len() as u32) || messages[n]]`
+ l1_messenger_pubdata.extend((l2_to_l1_messages.len() as u32).to_be_bytes());
+ for message in l2_to_l1_messages {
+ l1_messenger_pubdata.extend((message.len() as u32).to_be_bytes());
+ l1_messenger_pubdata.extend(message);
+ }
+ // Encoding bytecodes
+ // Format: `[(numberOfBytecodes as u32) || (bytecodes[1].len() as u32) || bytecodes[1] || ... || (bytecodes[n].len() as u32) || bytecodes[n]]`
+ l1_messenger_pubdata.extend((published_bytecodes.len() as u32).to_be_bytes());
+ for bytecode in published_bytecodes {
+ l1_messenger_pubdata.extend((bytecode.len() as u32).to_be_bytes());
+ l1_messenger_pubdata.extend(bytecode);
+ }
+ // Encoding state diffs
+ // Format: `[size of compressed state diffs u32 || compressed state diffs || (# state diffs: intial + repeated) as u32 || sorted state diffs by ]`
+ let state_diffs_compressed = compress_state_diffs(state_diffs.clone());
+ l1_messenger_pubdata.extend(state_diffs_compressed);
+
+ if with_uncompressed_state_diffs {
+ l1_messenger_pubdata.extend((state_diffs.len() as u32).to_be_bytes());
+ for state_diff in state_diffs {
+ l1_messenger_pubdata.extend(state_diff.encode_padded());
+ }
+ }
+
+ l1_messenger_pubdata
+ }
+}
+
pub trait PubdataBuilder {
// when `l2_version` is true it will return the data to be sent to the L1_MESSENGER
// otherwise it returns the array of bytes to be sent to L1 inside the operator input.
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 ab2f3d35d62..b6e5e127c85 100644
--- a/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs
+++ b/core/lib/multivm/src/versions/vm_latest/types/internals/vm_state.rs
@@ -33,6 +33,7 @@ use crate::{
oracles::storage::StorageOracle,
types::l1_batch::bootloader_initial_memory,
utils::l2_blocks::{assert_next_block, load_last_l2_block},
+ MultiVMSubversion,
},
};
@@ -64,6 +65,7 @@ pub(crate) fn new_vm_state(
storage: StoragePtr,
system_env: &SystemEnv,
l1_batch_env: &L1BatchEnv,
+ subversion: MultiVMSubversion,
) -> (ZkSyncVmState, BootloaderState) {
let last_l2_block = if let Some(last_l2_block) = load_last_l2_block(&storage) {
last_l2_block
@@ -182,6 +184,7 @@ pub(crate) fn new_vm_state(
bootloader_initial_memory,
first_l2_block,
system_env.pubdata_params,
+ subversion,
);
(vm, bootloader_state)
diff --git a/core/lib/multivm/src/versions/vm_latest/vm.rs b/core/lib/multivm/src/versions/vm_latest/vm.rs
index b1714ea7da9..63ec5f7451c 100644
--- a/core/lib/multivm/src/versions/vm_latest/vm.rs
+++ b/core/lib/multivm/src/versions/vm_latest/vm.rs
@@ -36,13 +36,14 @@ pub(crate) enum MultiVMSubversion {
SmallBootloaderMemory,
/// The final correct version of v1.5.0
IncreasedBootloaderMemory,
- SyncLayer,
+ /// Version for protocol v25
+ Gateway,
}
impl MultiVMSubversion {
#[cfg(test)]
pub(crate) fn latest() -> Self {
- Self::IncreasedBootloaderMemory
+ Self::Gateway
}
}
@@ -54,7 +55,7 @@ impl TryFrom for MultiVMSubversion {
match value {
VmVersion::Vm1_5_0SmallBootloaderMemory => Ok(Self::SmallBootloaderMemory),
VmVersion::Vm1_5_0IncreasedBootloaderMemory => Ok(Self::IncreasedBootloaderMemory),
- VmVersion::VmSyncLayer => Ok(Self::SyncLayer),
+ VmVersion::VmGateway => Ok(Self::Gateway),
_ => Err(VmVersionIsNotVm150Error),
}
}
@@ -205,7 +206,8 @@ impl Vm {
storage: StoragePtr,
subversion: MultiVMSubversion,
) -> Self {
- let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env);
+ let (state, bootloader_state) =
+ new_vm_state(storage.clone(), &system_env, &batch_env, subversion);
Self {
bootloader_state,
state,
diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs
index 5302b7ca0e5..bfb121a740e 100644
--- a/core/lib/multivm/src/vm_instance.rs
+++ b/core/lib/multivm/src/vm_instance.rs
@@ -211,12 +211,12 @@ impl LegacyVmInstance {
);
Self::Vm1_5_0(vm)
}
- VmVersion::VmSyncLayer => {
+ VmVersion::VmGateway => {
let vm = crate::vm_latest::Vm::new_with_subversion(
l1_batch_env,
system_env,
storage_view,
- crate::vm_latest::MultiVMSubversion::SyncLayer,
+ crate::vm_latest::MultiVMSubversion::Gateway,
);
Self::Vm1_5_0(vm)
}
diff --git a/core/lib/protobuf_config/src/contracts.rs b/core/lib/protobuf_config/src/contracts.rs
index a022c9aa1a1..f9670ead838 100644
--- a/core/lib/protobuf_config/src/contracts.rs
+++ b/core/lib/protobuf_config/src/contracts.rs
@@ -77,7 +77,7 @@ impl ProtoRepr for proto::Contracts {
.transpose()
.context("l2_shared_bridge_addr")?,
l2_legacy_shared_bridge_addr: l2
- .l2_legacy_shared_bridge_addr
+ .legacy_shared_bridge_addr
.as_ref()
.map(|x| parse_h160(x))
.transpose()
@@ -119,14 +119,8 @@ impl ProtoRepr for proto::Contracts {
.map(|x| parse_h160(x))
.transpose()
.context("base_token_addr")?,
- l2_native_token_vault_proxy_addr: l2
- .l2_native_token_vault_proxy_addr
- .as_ref()
- .map(|x| parse_h160(x))
- .transpose()
- .context("l2_native_token_vault_proxy_addr")?,
l2_da_validator_addr: l2
- .l2_da_validator_addr
+ .da_validator_addr
.as_ref()
.map(|x| parse_h160(x))
.transpose()
@@ -172,11 +166,8 @@ impl ProtoRepr for proto::Contracts {
}),
l2: Some(proto::L2 {
testnet_paymaster_addr: this.l2_testnet_paymaster_addr.map(|a| format!("{:?}", a)),
- l2_native_token_vault_proxy_addr: this
- .l2_native_token_vault_proxy_addr
- .map(|a| format!("{:?}", a)),
- l2_da_validator_addr: this.l2_da_validator_addr.map(|a| format!("{:?}", a)),
- l2_legacy_shared_bridge_addr: this
+ da_validator_addr: this.l2_da_validator_addr.map(|a| format!("{:?}", a)),
+ legacy_shared_bridge_addr: this
.l2_legacy_shared_bridge_addr
.map(|a| format!("{:?}", a)),
}),
diff --git a/core/lib/protobuf_config/src/proto/config/contracts.proto b/core/lib/protobuf_config/src/proto/config/contracts.proto
index 63e5eb1a3e9..54dda78afe5 100644
--- a/core/lib/protobuf_config/src/proto/config/contracts.proto
+++ b/core/lib/protobuf_config/src/proto/config/contracts.proto
@@ -21,9 +21,8 @@ message L1 {
message L2 {
optional string testnet_paymaster_addr = 1; // optional; H160
- optional string l2_native_token_vault_proxy_addr = 2; // optional; H160
- optional string l2_da_validator_addr = 3; // optional; H160
- optional string l2_legacy_shared_bridge_addr = 4; // optional; H160
+ optional string da_validator_addr = 2; // optional; H160
+ optional string legacy_shared_bridge_addr = 3; // optional; H160
}
message Bridge {
diff --git a/core/lib/types/src/api/en.rs b/core/lib/types/src/api/en.rs
index 4a847b99e3d..52d66a29458 100644
--- a/core/lib/types/src/api/en.rs
+++ b/core/lib/types/src/api/en.rs
@@ -43,7 +43,7 @@ pub struct SyncBlock {
/// Version of the protocol used for this block.
pub protocol_version: ProtocolVersionId,
/// Pubdata params used for this batch
- pub pubdata_params: PubdataParams,
+ pub pubdata_params: Option,
}
/// Global configuration of the consensus served by the main node to the external nodes.
diff --git a/core/lib/types/src/api/mod.rs b/core/lib/types/src/api/mod.rs
index 549ba710d97..e583d7abe58 100644
--- a/core/lib/types/src/api/mod.rs
+++ b/core/lib/types/src/api/mod.rs
@@ -267,6 +267,7 @@ pub struct BridgeAddresses {
pub l2_erc20_default_bridge: Option,
pub l1_weth_bridge: Option,
pub l2_weth_bridge: Option,
+ pub l2_legacy_shared_bridge: Option,
}
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
diff --git a/core/lib/web3_decl/src/namespaces/zks.rs b/core/lib/web3_decl/src/namespaces/zks.rs
index b27bf262877..169d27aac1d 100644
--- a/core/lib/web3_decl/src/namespaces/zks.rs
+++ b/core/lib/web3_decl/src/namespaces/zks.rs
@@ -52,12 +52,6 @@ pub trait ZksNamespace {
#[method(name = "getTestnetPaymaster")]
async fn get_testnet_paymaster(&self) -> RpcResult