diff --git a/core/lib/contracts/src/lib.rs b/core/lib/contracts/src/lib.rs index 5f98d65fcf2..1e14d59efc3 100644 --- a/core/lib/contracts/src/lib.rs +++ b/core/lib/contracts/src/lib.rs @@ -922,3 +922,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/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..948108eaa62 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 @@ -26,16 +26,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 { 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..65aea1944b2 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 commit_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(commit_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..60c68f69080 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,46 +36,39 @@ 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 commit_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(commit_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![])]); 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/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/eth_sender/src/eth_tx_aggregator.rs b/core/node/eth_sender/src/eth_tx_aggregator.rs index 0d5acc624d0..92ef3fc2643 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(is_op_pre_gateway); 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/state_keeper/src/io/mempool.rs b/core/node/state_keeper/src/io/mempool.rs index 1a89cec9a40..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,11 +195,16 @@ impl StateKeeperIO for MempoolIO { continue; } - // Pubdata type should be `Rollup` for pre-gateway batches. - let pubdata_type = if protocol_version.is_pre_gateway() { - L1BatchCommitmentMode::Rollup - } else { - self.pubdata_type + 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 { @@ -212,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, - }, + pubdata_params, })); } Ok(None) @@ -430,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/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/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