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>; - #[method(name = "getNativeTokenVault")] - async fn get_native_token_vault_proxy_addr(&self) -> RpcResult>; - - #[method(name = "getLegacySharedBridge")] - async fn get_legacy_shared_bridge(&self) -> RpcResult>; - #[method(name = "getBridgeContracts")] async fn get_bridge_contracts(&self) -> RpcResult; diff --git a/core/node/api_server/src/web3/backend_jsonrpsee/namespaces/zks.rs b/core/node/api_server/src/web3/backend_jsonrpsee/namespaces/zks.rs index c32a5e10ad0..b55c6ca5946 100644 --- a/core/node/api_server/src/web3/backend_jsonrpsee/namespaces/zks.rs +++ b/core/node/api_server/src/web3/backend_jsonrpsee/namespaces/zks.rs @@ -54,14 +54,6 @@ impl ZksNamespaceServer for ZksNamespace { Ok(self.get_testnet_paymaster_impl()) } - async fn get_native_token_vault_proxy_addr(&self) -> RpcResult> { - Ok(self.get_native_token_vault_proxy_addr_impl()) - } - - async fn get_legacy_shared_bridge(&self) -> RpcResult> { - Ok(self.get_legacy_shared_bridge_impl()) - } - async fn get_bridge_contracts(&self) -> RpcResult { Ok(self.get_bridge_contracts_impl()) } diff --git a/core/node/api_server/src/web3/metrics.rs b/core/node/api_server/src/web3/metrics.rs index 9d8cbf813b0..2b78f58a16d 100644 --- a/core/node/api_server/src/web3/metrics.rs +++ b/core/node/api_server/src/web3/metrics.rs @@ -394,7 +394,9 @@ impl ApiMetrics { Web3Error::ProxyError(err) => { tracing::warn!("Error proxying call to main node in method `{method}`: {err}"); } - _ => { /* do nothing */ } + _ => { + tracing::debug!("Error in method `{method}`: {err:#}"); + } } let labels = Web3ErrorLabels { diff --git a/core/node/api_server/src/web3/namespaces/zks.rs b/core/node/api_server/src/web3/namespaces/zks.rs index 09f1ead54a5..78f3edf83f9 100644 --- a/core/node/api_server/src/web3/namespaces/zks.rs +++ b/core/node/api_server/src/web3/namespaces/zks.rs @@ -147,14 +147,6 @@ impl ZksNamespace { self.state.api_config.l2_testnet_paymaster_addr } - pub fn get_native_token_vault_proxy_addr_impl(&self) -> Option
{ - self.state.api_config.l2_native_token_vault_proxy_addr - } - - pub fn get_legacy_shared_bridge_impl(&self) -> Option
{ - self.state.api_config.l2_legacy_shared_bridge_addr - } - pub fn get_bridge_contracts_impl(&self) -> BridgeAddresses { self.state.api_config.bridge_addresses.clone() } diff --git a/core/node/api_server/src/web3/state.rs b/core/node/api_server/src/web3/state.rs index 203852346a9..0c236710c07 100644 --- a/core/node/api_server/src/web3/state.rs +++ b/core/node/api_server/src/web3/state.rs @@ -116,8 +116,6 @@ pub struct InternalApiConfig { pub dummy_verifier: bool, pub l1_batch_commit_data_generator_mode: L1BatchCommitmentMode, pub user_facing_bridgehub_addr: Option
, - pub l2_native_token_vault_proxy_addr: Option
, - pub l2_legacy_shared_bridge_addr: Option
, } impl InternalApiConfig { @@ -158,6 +156,7 @@ impl InternalApiConfig { .l1_weth_bridge_proxy_addr .unwrap_or_default(), ), + l2_legacy_shared_bridge: contracts_config.l2_legacy_shared_bridge_addr, }, bridgehub_proxy_addr: contracts_config .ecosystem_contracts @@ -187,8 +186,6 @@ impl InternalApiConfig { .as_ref() .map(|a| a.bridgehub_proxy_addr), ), - l2_native_token_vault_proxy_addr: contracts_config.l2_native_token_vault_proxy_addr, - l2_legacy_shared_bridge_addr: contracts_config.l2_legacy_shared_bridge_addr, } } } diff --git a/core/node/commitment_generator/src/utils.rs b/core/node/commitment_generator/src/utils.rs index 15ede4878ed..9ed6682733c 100644 --- a/core/node/commitment_generator/src/utils.rs +++ b/core/node/commitment_generator/src/utils.rs @@ -74,7 +74,7 @@ impl CommitmentComputer for RealCommitmentComputer { )), VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory - | VmVersion::VmSyncLayer => Ok(H256( + | VmVersion::VmGateway => Ok(H256( circuit_sequencer_api_1_5_0::commitments::events_queue_commitment_fixed( &events_queue .iter() @@ -113,7 +113,7 @@ impl CommitmentComputer for RealCommitmentComputer { )), VmVersion::Vm1_5_0SmallBootloaderMemory | VmVersion::Vm1_5_0IncreasedBootloaderMemory - | VmVersion::VmSyncLayer => Ok(H256( + | VmVersion::VmGateway => Ok(H256( circuit_sequencer_api_1_5_0::commitments::initial_heap_content_commitment_fixed( &full_bootloader_memory, ), diff --git a/core/node/consensus/src/storage/store.rs b/core/node/consensus/src/storage/store.rs index b3dd2bdac86..96a47f5abe7 100644 --- a/core/node/consensus/src/storage/store.rs +++ b/core/node/consensus/src/storage/store.rs @@ -35,7 +35,7 @@ fn to_fetched_block( l1_gas_price: payload.l1_gas_price, l2_fair_gas_price: payload.l2_fair_gas_price, fair_pubdata_price: payload.fair_pubdata_price, - pubdata_params: payload.pubdata_params, + pubdata_params: payload.pubdata_params.unwrap_or_default(), virtual_blocks: payload.virtual_blocks, operator_address: payload.operator_address, transactions: payload diff --git a/core/node/consensus/src/testonly.rs b/core/node/consensus/src/testonly.rs index d62de5611f8..071b3f9e553 100644 --- a/core/node/consensus/src/testonly.rs +++ b/core/node/consensus/src/testonly.rs @@ -568,9 +568,7 @@ impl StateKeeperRunner { let (stop_send, stop_recv) = sync::watch::channel(false); let (persistence, l2_block_sealer) = StateKeeperPersistence::new( self.pool.0.clone(), - ethabi::Address::repeat_byte(11), - ethabi::Address::repeat_byte(12), - ethabi::Address::repeat_byte(13), + Some(ethabi::Address::repeat_byte(11)), 5, ); @@ -682,9 +680,7 @@ impl StateKeeperRunner { let (stop_send, stop_recv) = sync::watch::channel(false); let (persistence, l2_block_sealer) = StateKeeperPersistence::new( self.pool.0.clone(), - ethabi::Address::repeat_byte(11), - ethabi::Address::repeat_byte(12), - ethabi::Address::repeat_byte(13), + Some(ethabi::Address::repeat_byte(11)), 5, ); let tree_writes_persistence = TreeWritesPersistence::new(self.pool.0.clone()); diff --git a/core/node/consistency_checker/src/tests/mod.rs b/core/node/consistency_checker/src/tests/mod.rs index 07e750b41c3..296780513e0 100644 --- a/core/node/consistency_checker/src/tests/mod.rs +++ b/core/node/consistency_checker/src/tests/mod.rs @@ -8,7 +8,7 @@ use tokio::sync::mpsc; use zksync_config::GenesisConfig; use zksync_dal::Connection; use zksync_eth_client::{clients::MockSettlementLayer, Options}; -use zksync_l1_contract_interface::{i_executor::methods::CommitBatches, Tokenizable}; +use zksync_l1_contract_interface::{i_executor::methods::CommitBatches, Tokenizable, Tokenize}; use zksync_node_genesis::{insert_genesis_batch, mock_genesis_config, GenesisParams}; use zksync_node_test_utils::{ create_l1_batch, create_l1_batch_metadata, l1_batch_metadata_to_commitment_artifacts, @@ -67,7 +67,7 @@ pub(crate) fn build_commit_tx_input_data( pubdata_da: PubdataDA::Calldata, mode, } - .into_tokens(protocol_version.is_pre_gateway()); + .into_tokens(); if protocol_version.is_pre_boojum() { PRE_BOOJUM_COMMIT_FUNCTION.encode_input(&tokens).unwrap() diff --git a/core/node/eth_sender/src/eth_tx_aggregator.rs b/core/node/eth_sender/src/eth_tx_aggregator.rs index 0d5acc624d0..1c618a53795 100644 --- a/core/node/eth_sender/src/eth_tx_aggregator.rs +++ b/core/node/eth_sender/src/eth_tx_aggregator.rs @@ -424,6 +424,7 @@ impl EthTxAggregator { fn encode_aggregated_op(&self, op: &AggregatedOperation) -> TxData { let mut args = vec![Token::Uint(self.rollup_chain_id.as_u64().into())]; + let is_op_pre_gateway = op.protocol_version().is_pre_gateway(); let (calldata, sidecar) = match op { AggregatedOperation::Commit(last_committed_l1_batch, l1_batches, pubdata_da) => { @@ -433,44 +434,46 @@ impl EthTxAggregator { pubdata_da: *pubdata_da, mode: self.aggregator.mode(), }; - let commit_data_base = commit_batches.into_tokens( - l1_batches[0] - .header - .protocol_version - .unwrap() - .is_pre_gateway(), - ); + let commit_data_base = commit_batches.into_tokens(); args.extend(commit_data_base); let commit_data = args; + let encoding_fn = if is_op_pre_gateway { + &self.functions.post_shared_bridge_commit + } else { + &self.functions.post_gateway_commit + }; + let l1_batch_for_sidecar = if PubdataDA::Blobs == self.aggregator.pubdata_da() { Some(l1_batches[0].clone()) } else { None }; - Self::encode_commit_data( - &self.functions.post_shared_bridge_commit, - &commit_data, - l1_batch_for_sidecar, - ) + Self::encode_commit_data(encoding_fn, &commit_data, l1_batch_for_sidecar) } AggregatedOperation::PublishProofOnchain(op) => { args.extend(op.into_tokens()); - let calldata = self - .functions - .post_shared_bridge_prove + let encoding_fn = if is_op_pre_gateway { + &self.functions.post_shared_bridge_prove + } else { + &self.functions.post_gateway_prove + }; + let calldata = encoding_fn .encode_input(&args) .expect("Failed to encode prove transaction data"); (calldata, None) } AggregatedOperation::Execute(op) => { args.extend(op.into_tokens()); - let calldata = self - .functions - .post_shared_bridge_execute + let encoding_fn = if is_op_pre_gateway { + &self.functions.post_shared_bridge_execute + } else { + &self.functions.post_gateway_execute + }; + let calldata = encoding_fn .encode_input(&args) .expect("Failed to encode execute transaction data"); (calldata, None) diff --git a/core/node/eth_sender/src/zksync_functions.rs b/core/node/eth_sender/src/zksync_functions.rs index b56009d0476..05c9805a4fc 100644 --- a/core/node/eth_sender/src/zksync_functions.rs +++ b/core/node/eth_sender/src/zksync_functions.rs @@ -1,4 +1,7 @@ -use zksync_contracts::{hyperchain_contract, multicall_contract, verifier_contract}; +use zksync_contracts::{ + hyperchain_contract, multicall_contract, verifier_contract, POST_SHARED_BRIDGE_COMMIT_FUNCTION, + POST_SHARED_BRIDGE_EXECUTE_FUNCTION, POST_SHARED_BRIDGE_PROVE_FUNCTION, +}; use zksync_types::ethabi::{Contract, Function}; #[derive(Debug)] @@ -6,6 +9,11 @@ pub(super) struct ZkSyncFunctions { pub(super) post_shared_bridge_commit: Function, pub(super) post_shared_bridge_prove: Function, pub(super) post_shared_bridge_execute: Function, + + pub(super) post_gateway_commit: Function, + pub(super) post_gateway_prove: Function, + pub(super) post_gateway_execute: Function, + pub(super) get_l2_bootloader_bytecode_hash: Function, pub(super) get_l2_default_account_bytecode_hash: Function, pub(super) get_verifier: Function, @@ -35,10 +43,14 @@ impl Default for ZkSyncFunctions { let verifier_contract = verifier_contract(); let multicall_contract = multicall_contract(); - let post_shared_bridge_commit = get_function(&zksync_contract, "commitBatchesSharedBridge"); - let post_shared_bridge_prove = get_function(&zksync_contract, "proveBatchesSharedBridge"); - let post_shared_bridge_execute = - get_function(&zksync_contract, "executeBatchesSharedBridge"); + let post_shared_bridge_commit = POST_SHARED_BRIDGE_COMMIT_FUNCTION.clone(); + let post_shared_bridge_prove = POST_SHARED_BRIDGE_PROVE_FUNCTION.clone(); + let post_shared_bridge_execute = POST_SHARED_BRIDGE_EXECUTE_FUNCTION.clone(); + + let post_gateway_commit = get_function(&zksync_contract, "commitBatchesSharedBridge"); + let post_gateway_prove = get_function(&zksync_contract, "proveBatchesSharedBridge"); + let post_gateway_execute = get_function(&zksync_contract, "executeBatchesSharedBridge"); + let get_l2_bootloader_bytecode_hash = get_function(&zksync_contract, "getL2BootloaderBytecodeHash"); let get_l2_default_account_bytecode_hash = @@ -53,6 +65,9 @@ impl Default for ZkSyncFunctions { post_shared_bridge_commit, post_shared_bridge_prove, post_shared_bridge_execute, + post_gateway_commit, + post_gateway_prove, + post_gateway_execute, get_l2_bootloader_bytecode_hash, get_l2_default_account_bytecode_hash, get_verifier, diff --git a/core/node/node_framework/src/implementations/layers/state_keeper/mempool_io.rs b/core/node/node_framework/src/implementations/layers/state_keeper/mempool_io.rs index 45088b40ee8..191b4a699b9 100644 --- a/core/node/node_framework/src/implementations/layers/state_keeper/mempool_io.rs +++ b/core/node/node_framework/src/implementations/layers/state_keeper/mempool_io.rs @@ -136,9 +136,7 @@ impl WiringLayer for MempoolIOLayer { mempool_db_pool, &self.state_keeper_config, self.wallets.fee_account.address(), - self.contracts_config - .l2_da_validator_addr - .expect("L2 DA validator address not found"), + self.contracts_config.l2_da_validator_addr, self.genesis_config.l1_batch_commit_data_generator_mode, self.mempool_config.delay_interval(), self.zksync_network_id, diff --git a/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs b/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs index 21531a0eba3..7a0de619364 100644 --- a/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs +++ b/core/node/node_framework/src/implementations/layers/state_keeper/output_handler.rs @@ -1,10 +1,12 @@ use anyhow::Context as _; +use zksync_dal::{Core, CoreDal}; +use zksync_db_connection::connection_pool::ConnectionPool; use zksync_node_framework_derive::FromContext; use zksync_state_keeper::{ io::seal_logic::l2_block_seal_subtasks::L2BlockSealProcess, L2BlockSealerTask, OutputHandler, StateKeeperPersistence, TreeWritesPersistence, }; -use zksync_types::Address; +use zksync_types::{Address, ProtocolVersionId}; use crate::{ implementations::resources::{ @@ -35,10 +37,8 @@ use crate::{ /// - `L2BlockSealerTask` #[derive(Debug)] pub struct OutputHandlerLayer { - l2_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, l2_block_seal_queue_capacity: usize, - l2_native_token_vault_proxy_addr: Address, - l2_legacy_shared_bridge_addr: Address, /// Whether transactions should be pre-inserted to DB. /// Should be set to `true` for EN's IO as EN doesn't store transactions in DB /// before they are included into L2 blocks. @@ -66,16 +66,12 @@ pub struct Output { impl OutputHandlerLayer { pub fn new( - l2_shared_bridge_addr: Address, - l2_native_token_vault_proxy_addr: Address, - l2_legacy_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, l2_block_seal_queue_capacity: usize, ) -> Self { Self { - l2_shared_bridge_addr, - l2_block_seal_queue_capacity, - l2_native_token_vault_proxy_addr, l2_legacy_shared_bridge_addr, + l2_block_seal_queue_capacity, pre_insert_txs: false, protective_reads_persistence_enabled: false, } @@ -93,6 +89,38 @@ impl OutputHandlerLayer { self.protective_reads_persistence_enabled = protective_reads_persistence_enabled; self } + + async fn validate_l2_legacy_shared_bridge_addr( + &self, + pool: &ConnectionPool, + ) -> Result<(), WiringError> { + let mut connection = pool.connection().await.context("Get DB connection")?; + + if let Some(l2_block) = connection + .blocks_dal() + .get_earliest_l2_block_number() + .await + .context("failed to load earliest l2 block number")? + { + let header = connection + .blocks_dal() + .get_l2_block_header(l2_block) + .await + .context("failed to load L2 block header")? + .context("missing L2 block header")?; + let protocol_version = header + .protocol_version + .unwrap_or_else(ProtocolVersionId::last_potentially_undefined); + + if protocol_version.is_pre_gateway() && self.l2_legacy_shared_bridge_addr.is_none() { + return Err(WiringError::Configuration( + "Missing `l2_legacy_shared_bridge_addr` for chain that was initialized before gateway upgrade".to_string() + )); + } + } + + Ok(()) + } } #[async_trait::async_trait] @@ -112,10 +140,11 @@ impl WiringLayer for OutputHandlerLayer { .get_custom(L2BlockSealProcess::subtasks_len()) .await .context("Get master pool")?; + self.validate_l2_legacy_shared_bridge_addr(&persistence_pool) + .await?; + let (mut persistence, l2_block_sealer) = StateKeeperPersistence::new( persistence_pool.clone(), - self.l2_shared_bridge_addr, - self.l2_native_token_vault_proxy_addr, self.l2_legacy_shared_bridge_addr, self.l2_block_seal_queue_capacity, ); diff --git a/core/node/node_sync/src/fetcher.rs b/core/node/node_sync/src/fetcher.rs index 6190a26d323..08e3d426243 100644 --- a/core/node/node_sync/src/fetcher.rs +++ b/core/node/node_sync/src/fetcher.rs @@ -94,7 +94,7 @@ impl TryFrom for FetchedBlock { .into_iter() .map(FetchedTransaction::new) .collect(), - pubdata_params: block.pubdata_params, + pubdata_params: block.pubdata_params.unwrap_or_default(), }) } } diff --git a/core/node/node_sync/src/tests.rs b/core/node/node_sync/src/tests.rs index 82d70dfa664..8582bbe9374 100644 --- a/core/node/node_sync/src/tests.rs +++ b/core/node/node_sync/src/tests.rs @@ -106,13 +106,8 @@ impl StateKeeperHandles { assert!(tx_hashes.iter().all(|tx_hashes| !tx_hashes.is_empty())); let sync_state = SyncState::default(); - let (persistence, l2_block_sealer) = StateKeeperPersistence::new( - pool.clone(), - Address::repeat_byte(1), - Address::default(), - Address::repeat_byte(13), - 5, - ); + let (persistence, l2_block_sealer) = + StateKeeperPersistence::new(pool.clone(), Some(Address::repeat_byte(1)), 5); let tree_writes_persistence = TreeWritesPersistence::new(pool.clone()); let output_handler = OutputHandler::new(Box::new(persistence.with_tx_insertion())) .with_handler(Box::new(tree_writes_persistence)) diff --git a/core/node/state_keeper/src/io/mempool.rs b/core/node/state_keeper/src/io/mempool.rs index ca20a2f6000..58e0d56be2d 100644 --- a/core/node/state_keeper/src/io/mempool.rs +++ b/core/node/state_keeper/src/io/mempool.rs @@ -51,7 +51,7 @@ pub struct MempoolIO { filter: L2TxFilter, l1_batch_params_provider: L1BatchParamsProvider, fee_account: Address, - l2_da_validator_address: Address, + l2_da_validator_address: Option
, pubdata_type: L1BatchCommitmentMode, validation_computational_gas_limit: u32, max_allowed_tx_gas_limit: U256, @@ -195,6 +195,18 @@ impl StateKeeperIO for MempoolIO { continue; } + let pubdata_params = match ( + protocol_version.is_pre_gateway(), + self.l2_da_validator_address, + ) { + (true, _) => PubdataParams::default(), + (false, Some(l2_da_validator_address)) => PubdataParams { + l2_da_validator_address, + pubdata_type: self.pubdata_type, + }, + (false, None) => anyhow::bail!("L2 DA validator address not found"), + }; + return Ok(Some(L1BatchParams { protocol_version, validation_computational_gas_limit: self.validation_computational_gas_limit, @@ -205,10 +217,7 @@ impl StateKeeperIO for MempoolIO { // This value is effectively ignored by the protocol. virtual_blocks: 1, }, - pubdata_params: PubdataParams { - l2_da_validator_address: self.l2_da_validator_address, - pubdata_type: self.pubdata_type, - }, + pubdata_params, })); } Ok(None) @@ -423,7 +432,7 @@ impl MempoolIO { pool: ConnectionPool, config: &StateKeeperConfig, fee_account: Address, - l2_da_validator_address: Address, + l2_da_validator_address: Option
, pubdata_type: L1BatchCommitmentMode, delay_interval: Duration, chain_id: L2ChainId, diff --git a/core/node/state_keeper/src/io/persistence.rs b/core/node/state_keeper/src/io/persistence.rs index cdca16b353f..dc854c9e58f 100644 --- a/core/node/state_keeper/src/io/persistence.rs +++ b/core/node/state_keeper/src/io/persistence.rs @@ -29,9 +29,7 @@ struct Completable { #[derive(Debug)] pub struct StateKeeperPersistence { pool: ConnectionPool, - l2_shared_bridge_addr: Address, - l2_native_token_vault_proxy_addr: Address, - l2_legacy_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, pre_insert_txs: bool, insert_protective_reads: bool, commands_sender: mpsc::Sender>, @@ -47,9 +45,7 @@ impl StateKeeperPersistence { /// `command_capacity` for unprocessed sealing commands. pub fn new( pool: ConnectionPool, - l2_shared_bridge_addr: Address, - l2_native_token_vault_proxy_addr: Address, - l2_legacy_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, mut command_capacity: usize, ) -> (Self, L2BlockSealerTask) { let is_sync = command_capacity == 0; @@ -64,8 +60,6 @@ impl StateKeeperPersistence { }; let this = Self { pool, - l2_shared_bridge_addr, - l2_native_token_vault_proxy_addr, l2_legacy_shared_bridge_addr, pre_insert_txs: false, insert_protective_reads: true, @@ -163,12 +157,8 @@ impl StateKeeperOutputHandler for StateKeeperPersistence { } async fn handle_l2_block(&mut self, updates_manager: &UpdatesManager) -> anyhow::Result<()> { - let command = updates_manager.seal_l2_block_command( - self.l2_shared_bridge_addr, - self.l2_native_token_vault_proxy_addr, - self.l2_legacy_shared_bridge_addr, - self.pre_insert_txs, - ); + let command = updates_manager + .seal_l2_block_command(self.l2_legacy_shared_bridge_addr, self.pre_insert_txs); self.submit_l2_block(command).await; Ok(()) } @@ -184,8 +174,6 @@ impl StateKeeperOutputHandler for StateKeeperPersistence { updates_manager .seal_l1_batch( self.pool.clone(), - self.l2_shared_bridge_addr, - self.l2_native_token_vault_proxy_addr, self.l2_legacy_shared_bridge_addr, self.insert_protective_reads, ) @@ -406,9 +394,7 @@ mod tests { let (persistence, l2_block_sealer) = StateKeeperPersistence::new( pool.clone(), - Address::default(), - Address::default(), - Address::default(), + Some(Address::default()), l2_block_sealer_capacity, ); let mut output_handler = OutputHandler::new(Box::new(persistence)) @@ -543,13 +529,8 @@ mod tests { .unwrap(); drop(storage); - let (mut persistence, l2_block_sealer) = StateKeeperPersistence::new( - pool.clone(), - Address::default(), - Address::default(), - Address::default(), - 1, - ); + let (mut persistence, l2_block_sealer) = + StateKeeperPersistence::new(pool.clone(), Some(Address::default()), 1); persistence = persistence.with_tx_insertion().without_protective_reads(); let mut output_handler = OutputHandler::new(Box::new(persistence)); tokio::spawn(l2_block_sealer.run()); @@ -587,22 +568,12 @@ mod tests { #[tokio::test] async fn l2_block_sealer_handle_blocking() { let pool = ConnectionPool::constrained_test_pool(1).await; - let (mut persistence, mut sealer) = StateKeeperPersistence::new( - pool, - Address::default(), - Address::default(), - Address::default(), - 1, - ); + let (mut persistence, mut sealer) = + StateKeeperPersistence::new(pool, Some(Address::default()), 1); // The first command should be successfully submitted immediately. let mut updates_manager = create_updates_manager(); - let seal_command = updates_manager.seal_l2_block_command( - Address::default(), - Address::default(), - Address::default(), - false, - ); + let seal_command = updates_manager.seal_l2_block_command(Some(Address::default()), false); persistence.submit_l2_block(seal_command).await; // The second command should lead to blocking @@ -610,12 +581,7 @@ mod tests { timestamp: 2, virtual_blocks: 1, }); - let seal_command = updates_manager.seal_l2_block_command( - Address::default(), - Address::default(), - Address::default(), - false, - ); + let seal_command = updates_manager.seal_l2_block_command(Some(Address::default()), false); { let submit_future = persistence.submit_l2_block(seal_command); futures::pin_mut!(submit_future); @@ -643,12 +609,7 @@ mod tests { timestamp: 3, virtual_blocks: 1, }); - let seal_command = updates_manager.seal_l2_block_command( - Address::default(), - Address::default(), - Address::default(), - false, - ); + let seal_command = updates_manager.seal_l2_block_command(Some(Address::default()), false); persistence.submit_l2_block(seal_command).await; let command = sealer.commands_receiver.recv().await.unwrap(); command.completion_sender.send(()).unwrap(); @@ -658,23 +619,14 @@ mod tests { #[tokio::test] async fn l2_block_sealer_handle_parallel_processing() { let pool = ConnectionPool::constrained_test_pool(1).await; - let (mut persistence, mut sealer) = StateKeeperPersistence::new( - pool, - Address::default(), - Address::default(), - Address::default(), - 5, - ); + let (mut persistence, mut sealer) = + StateKeeperPersistence::new(pool, Some(Address::default()), 5); // 5 L2 block sealing commands can be submitted without blocking. let mut updates_manager = create_updates_manager(); for i in 1..=5 { - let seal_command = updates_manager.seal_l2_block_command( - Address::default(), - Address::default(), - Address::default(), - false, - ); + let seal_command = + updates_manager.seal_l2_block_command(Some(Address::default()), false); updates_manager.push_l2_block(L2BlockParams { timestamp: i, virtual_blocks: 1, diff --git a/core/node/state_keeper/src/io/seal_logic/l2_block_seal_subtasks.rs b/core/node/state_keeper/src/io/seal_logic/l2_block_seal_subtasks.rs index 608e7f78f4b..9a57da5e18d 100644 --- a/core/node/state_keeper/src/io/seal_logic/l2_block_seal_subtasks.rs +++ b/core/node/state_keeper/src/io/seal_logic/l2_block_seal_subtasks.rs @@ -3,11 +3,11 @@ use async_trait::async_trait; use once_cell::sync::Lazy; use zksync_dal::{Connection, Core, CoreDal}; use zksync_multivm::interface::VmEvent; -use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; +use zksync_system_constants::{CONTRACT_DEPLOYER_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS}; use zksync_types::{ ethabi, tokens::{TokenInfo, TokenMetadata}, - Address, L2BlockNumber, H160, H256, + Address, L2BlockNumber, H256, }; use zksync_utils::h256_to_account_address; @@ -18,7 +18,7 @@ use crate::{ }; fn extract_added_tokens( - l2_shared_bridge_addr: Address, + l2_token_deployer_addr: Address, all_generated_events: &[VmEvent], ) -> Vec { let deployed_tokens = all_generated_events @@ -28,7 +28,7 @@ fn extract_added_tokens( event.address == CONTRACT_DEPLOYER_ADDRESS && event.indexed_topics.len() == 4 && event.indexed_topics[0] == VmEvent::DEPLOY_EVENT_SIGNATURE - && h256_to_account_address(&event.indexed_topics[1]) == l2_shared_bridge_addr + && h256_to_account_address(&event.indexed_topics[1]) == l2_token_deployer_addr }) .map(|event| h256_to_account_address(&event.indexed_topics[3])); @@ -333,12 +333,11 @@ impl L2BlockSealSubtask for InsertTokensSubtask { connection: &mut Connection<'_, Core>, ) -> anyhow::Result<()> { let is_fictive = command.is_l2_block_fictive(); - let mut deployer_address = command.l2_native_token_vault_proxy_addr; - if command.l2_legacy_shared_bridge_addr != H160::zero() { - deployer_address = command.l2_legacy_shared_bridge_addr; - } + let token_deployer_address = command + .l2_legacy_shared_bridge_addr + .unwrap_or(L2_NATIVE_TOKEN_VAULT_ADDRESS); let progress = L2_BLOCK_METRICS.start(L2BlockSealStage::ExtractAddedTokens, is_fictive); - let added_tokens = extract_added_tokens(deployer_address, &command.l2_block.events); + let added_tokens = extract_added_tokens(token_deployer_address, &command.l2_block.events); progress.observe(added_tokens.len()); @@ -558,8 +557,6 @@ mod tests { base_fee_per_gas: Default::default(), base_system_contracts_hashes: Default::default(), protocol_version: Some(ProtocolVersionId::latest()), - l2_shared_bridge_addr: Default::default(), - l2_native_token_vault_proxy_addr: Default::default(), l2_legacy_shared_bridge_addr: Default::default(), pre_insert_txs: false, }; diff --git a/core/node/state_keeper/src/io/seal_logic/mod.rs b/core/node/state_keeper/src/io/seal_logic/mod.rs index 0894ace7904..dce0ae090de 100644 --- a/core/node/state_keeper/src/io/seal_logic/mod.rs +++ b/core/node/state_keeper/src/io/seal_logic/mod.rs @@ -46,9 +46,7 @@ impl UpdatesManager { pub(super) async fn seal_l1_batch( &self, pool: ConnectionPool, - l2_shared_bridge_addr: Address, - l2_native_token_vault_proxy_addr: Address, - l2_legacy_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, insert_protective_reads: bool, ) -> anyhow::Result<()> { let started_at = Instant::now(); @@ -61,8 +59,6 @@ impl UpdatesManager { let progress = L1_BATCH_METRICS.start(L1BatchSealStage::FictiveL2Block); // Seal fictive L2 block with last events and storage logs. let l2_block_command = self.seal_l2_block_command( - l2_shared_bridge_addr, - l2_native_token_vault_proxy_addr, l2_legacy_shared_bridge_addr, false, // fictive L2 blocks don't have txs, so it's fine to pass `false` here. ); @@ -338,8 +334,6 @@ impl L2BlockSealCommand { /// that are created after the last processed tx in the L1 batch: after the last transaction is processed, /// the bootloader enters the "tip" phase in which it can still generate events (e.g., /// one for sending fees to the operator). - /// - /// `l2_shared_bridge_addr` is required to extract the information on newly added tokens. async fn seal_inner( &self, strategy: &mut SealStrategy<'_>, diff --git a/core/node/state_keeper/src/io/tests/mod.rs b/core/node/state_keeper/src/io/tests/mod.rs index e487efe0615..4cf4a7b5a70 100644 --- a/core/node/state_keeper/src/io/tests/mod.rs +++ b/core/node/state_keeper/src/io/tests/mod.rs @@ -285,9 +285,7 @@ async fn processing_storage_logs_when_sealing_l2_block() { pubdata_params: Default::default(), base_system_contracts_hashes: BaseSystemContractsHashes::default(), protocol_version: Some(ProtocolVersionId::latest()), - l2_shared_bridge_addr: Address::default(), - l2_native_token_vault_proxy_addr: Address::default(), - l2_legacy_shared_bridge_addr: Address::default(), + l2_legacy_shared_bridge_addr: Default::default(), pre_insert_txs: false, }; connection_pool @@ -377,9 +375,7 @@ async fn processing_events_when_sealing_l2_block() { base_fee_per_gas: 10, base_system_contracts_hashes: BaseSystemContractsHashes::default(), protocol_version: Some(ProtocolVersionId::latest()), - l2_shared_bridge_addr: Address::default(), - l2_native_token_vault_proxy_addr: Address::default(), - l2_legacy_shared_bridge_addr: Address::default(), + l2_legacy_shared_bridge_addr: Default::default(), pre_insert_txs: false, }; pool.connection() @@ -468,13 +464,8 @@ async fn l2_block_processing_after_snapshot_recovery(commitment_mode: L1BatchCom vec![], ); - let (mut persistence, l2_block_sealer) = StateKeeperPersistence::new( - connection_pool.clone(), - Address::default(), - Address::default(), - Address::default(), - 0, - ); + let (mut persistence, l2_block_sealer) = + StateKeeperPersistence::new(connection_pool.clone(), Some(Address::default()), 0); tokio::spawn(l2_block_sealer.run()); persistence.handle_l2_block(&updates).await.unwrap(); diff --git a/core/node/state_keeper/src/io/tests/tester.rs b/core/node/state_keeper/src/io/tests/tester.rs index 5b14922e6cf..6b7fc260b66 100644 --- a/core/node/state_keeper/src/io/tests/tester.rs +++ b/core/node/state_keeper/src/io/tests/tester.rs @@ -134,7 +134,7 @@ impl Tester { pool, &config, wallets.state_keeper.unwrap().fee_account.address(), - Default::default(), + Some(Default::default()), Default::default(), Duration::from_secs(1), L2ChainId::from(270), diff --git a/core/node/state_keeper/src/updates/mod.rs b/core/node/state_keeper/src/updates/mod.rs index b640bc8f66a..9d12d86de6f 100644 --- a/core/node/state_keeper/src/updates/mod.rs +++ b/core/node/state_keeper/src/updates/mod.rs @@ -85,9 +85,7 @@ impl UpdatesManager { pub(crate) fn seal_l2_block_command( &self, - l2_shared_bridge_addr: Address, - l2_native_token_vault_proxy_addr: Address, - l2_legacy_shared_bridge_addr: Address, + l2_legacy_shared_bridge_addr: Option
, pre_insert_txs: bool, ) -> L2BlockSealCommand { L2BlockSealCommand { @@ -100,8 +98,6 @@ impl UpdatesManager { pubdata_params: self.pubdata_params, base_system_contracts_hashes: self.base_system_contract_hashes, protocol_version: Some(self.protocol_version), - l2_shared_bridge_addr, - l2_native_token_vault_proxy_addr, l2_legacy_shared_bridge_addr, pre_insert_txs, } @@ -213,9 +209,7 @@ pub struct L2BlockSealCommand { pub base_fee_per_gas: u64, pub base_system_contracts_hashes: BaseSystemContractsHashes, pub protocol_version: Option, - pub l2_shared_bridge_addr: Address, - pub l2_native_token_vault_proxy_addr: Address, - pub l2_legacy_shared_bridge_addr: Address, + pub l2_legacy_shared_bridge_addr: Option
, pub pubdata_params: PubdataParams, /// Whether transactions should be pre-inserted to DB. /// Should be set to `true` for EN's IO as EN doesn't store transactions in DB diff --git a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/fee_estimate.yul/fee_estimate.yul.zbin b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/fee_estimate.yul/fee_estimate.yul.zbin index 82cfdf96d3d..75ee6377bdb 100644 Binary files a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/fee_estimate.yul/fee_estimate.yul.zbin and b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/fee_estimate.yul/fee_estimate.yul.zbin differ diff --git a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/gas_test.yul/gas_test.yul.zbin b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/gas_test.yul/gas_test.yul.zbin index c712f82cf0e..63898975f48 100644 Binary files a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/gas_test.yul/gas_test.yul.zbin and b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/gas_test.yul/gas_test.yul.zbin differ diff --git a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/playground_batch.yul/playground_batch.yul.zbin b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/playground_batch.yul/playground_batch.yul.zbin index 06829ec6331..b1a5e063d84 100644 Binary files a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/playground_batch.yul/playground_batch.yul.zbin and b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/playground_batch.yul/playground_batch.yul.zbin differ diff --git a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/proved_batch.yul/proved_batch.yul.zbin b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/proved_batch.yul/proved_batch.yul.zbin index 4de1149c20a..26bb767d1b3 100644 Binary files a/etc/multivm_bootloaders/vm_1_5_0_increased_memory/proved_batch.yul/proved_batch.yul.zbin and b/etc/multivm_bootloaders/vm_1_5_0_increased_memory/proved_batch.yul/proved_batch.yul.zbin differ diff --git a/zk_toolbox/crates/config/src/contracts.rs b/zk_toolbox/crates/config/src/contracts.rs index 1d43e086f7c..c2b69b7df8c 100644 --- a/zk_toolbox/crates/config/src/contracts.rs +++ b/zk_toolbox/crates/config/src/contracts.rs @@ -113,7 +113,7 @@ impl ContractsConfig { self.l1.access_control_restriction_addr = register_chain_output.access_control_restriction_addr; self.l1.chain_proxy_admin_addr = register_chain_output.chain_proxy_admin_addr; - self.l2.l2_legacy_shared_bridge_addr = register_chain_output.l2_legacy_shared_bridge_addr; + self.l2.legacy_shared_bridge_addr = register_chain_output.l2_legacy_shared_bridge_addr; self.user_facing_diamond_proxy = register_chain_output.diamond_proxy_addr; } @@ -125,7 +125,7 @@ impl ContractsConfig { self.bridges.shared.l2_address = Some(L2_ASSET_ROUTER_ADDRESS); self.bridges.erc20.l2_address = Some(L2_ASSET_ROUTER_ADDRESS); self.l2.l2_native_token_vault_proxy_addr = L2_NATIVE_TOKEN_VAULT_ADDRESS; - self.l2.l2_da_validator_addr = initialize_bridges_output.l2_da_validator_address; + self.l2.da_validator_addr = initialize_bridges_output.l2_da_validator_address; Ok(()) } @@ -211,9 +211,9 @@ pub struct L1Contracts { pub struct L2Contracts { pub testnet_paymaster_addr: Address, pub default_l2_upgrader: Address, - pub l2_da_validator_addr: Address, + pub da_validator_addr: Address, pub l2_native_token_vault_proxy_addr: Address, - pub l2_legacy_shared_bridge_addr: Address, + pub legacy_shared_bridge_addr: Address, pub consensus_registry: Option
, pub multicall3: Option
, } diff --git a/zk_toolbox/crates/zk_inception/src/commands/chain/init.rs b/zk_toolbox/crates/zk_inception/src/commands/chain/init.rs index 46f88509a4d..f2a6d597729 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/chain/init.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/chain/init.rs @@ -159,7 +159,7 @@ pub async fn init( chain_config.get_wallets_config()?.governor_private_key(), contracts_config.l1.diamond_proxy_addr, l1_da_validator_addr, - contracts_config.l2.l2_da_validator_addr, + contracts_config.l2.da_validator_addr, &init_args.forge_args.clone(), init_args.l1_rpc_url.clone(), ) diff --git a/zk_toolbox/crates/zk_inception/src/commands/chain/migrate_to_gateway.rs b/zk_toolbox/crates/zk_inception/src/commands/chain/migrate_to_gateway.rs index 7d8ad2ce6b7..8ec54c82339 100644 --- a/zk_toolbox/crates/zk_inception/src/commands/chain/migrate_to_gateway.rs +++ b/zk_toolbox/crates/zk_inception/src/commands/chain/migrate_to_gateway.rs @@ -214,7 +214,7 @@ pub async fn run(args: MigrateToGatewayArgs, shell: &Shell) -> anyhow::Result<() chain_access_control_restriction, U256::from(chain_config.chain_id.0), gateway_da_validator_address, - chain_contracts_config.l2.l2_da_validator_addr, + chain_contracts_config.l2.da_validator_addr, new_diamond_proxy_address, ), )