diff --git a/core/lib/dal/src/models/storage_sync.rs b/core/lib/dal/src/models/storage_sync.rs index f2842d26b9f7..0eb65a606d1f 100644 --- a/core/lib/dal/src/models/storage_sync.rs +++ b/core/lib/dal/src/models/storage_sync.rs @@ -98,7 +98,7 @@ impl TryFrom for SyncBlock { protocol_version: parse_protocol_version(block.protocol_version)?, pubdata_params: PubdataParams { pubdata_type: L1BatchCommitmentMode::from_str(&block.pubdata_type) - .expect("Invalid pubdata type"), + .decode_column("Invalid pubdata type")?, l2_da_validator_address: parse_h160(&block.l2_da_validator_address) .decode_column("l2_da_validator_address")?, }, diff --git a/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs b/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs index 7d55572d1d10..9da005b995d3 100644 --- a/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs +++ b/core/lib/multivm/src/versions/testonly/bytecode_publishing.rs @@ -33,7 +33,7 @@ pub(crate) fn test_bytecode_publishing() { let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.finish_batch(Some(default_pubdata_builder())); + vm.vm.finish_batch(default_pubdata_builder()); let state = vm.vm.get_current_execution_state(); let long_messages = VmEvent::extract_long_l2_to_l1_messages(&state.events); diff --git a/core/lib/multivm/src/versions/testonly/default_aa.rs b/core/lib/multivm/src/versions/testonly/default_aa.rs index d6f56e7f6ae9..c69c00de4508 100644 --- a/core/lib/multivm/src/versions/testonly/default_aa.rs +++ b/core/lib/multivm/src/versions/testonly/default_aa.rs @@ -35,7 +35,7 @@ pub(crate) fn test_default_aa_interaction() { let result = vm.vm.execute(InspectExecutionMode::OneTx); assert!(!result.result.is_failed(), "Transaction wasn't successful"); - vm.vm.finish_batch(Some(default_pubdata_builder())); + vm.vm.finish_batch(default_pubdata_builder()); vm.vm.get_current_execution_state(); diff --git a/core/lib/multivm/src/versions/testonly/refunds.rs b/core/lib/multivm/src/versions/testonly/refunds.rs index 71b4f57da2f6..874425fc435c 100644 --- a/core/lib/multivm/src/versions/testonly/refunds.rs +++ b/core/lib/multivm/src/versions/testonly/refunds.rs @@ -39,7 +39,7 @@ pub(crate) fn test_predetermined_refunded_gas() { let result_without_predefined_refunds = vm .vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; let mut current_state_without_predefined_refunds = vm.vm.get_current_execution_state(); assert!(!result_without_predefined_refunds.result.is_failed(),); @@ -61,7 +61,7 @@ pub(crate) fn test_predetermined_refunded_gas() { let result_with_predefined_refunds = vm .vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; let mut current_state_with_predefined_refunds = vm.vm.get_current_execution_state(); @@ -115,7 +115,7 @@ pub(crate) fn test_predetermined_refunded_gas() { .push_transaction_with_refund(tx, changed_operator_suggested_refund); let result = vm .vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; let mut current_state_with_changed_predefined_refunds = vm.vm.get_current_execution_state(); diff --git a/core/lib/multivm/src/versions/testonly/simple_execution.rs b/core/lib/multivm/src/versions/testonly/simple_execution.rs index fc421c305ebc..96239fb362d2 100644 --- a/core/lib/multivm/src/versions/testonly/simple_execution.rs +++ b/core/lib/multivm/src/versions/testonly/simple_execution.rs @@ -71,7 +71,7 @@ pub(crate) fn test_simple_execute() { let tx = vm.execute(InspectExecutionMode::OneTx); assert_matches!(tx.result, ExecutionResult::Success { .. }); let block_tip = vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; assert_matches!(block_tip.result, ExecutionResult::Success { .. }); } diff --git a/core/lib/multivm/src/versions/testonly/tester/transaction_test_info.rs b/core/lib/multivm/src/versions/testonly/tester/transaction_test_info.rs index 85a5fcb25e3f..b9373e331c30 100644 --- a/core/lib/multivm/src/versions/testonly/tester/transaction_test_info.rs +++ b/core/lib/multivm/src/versions/testonly/tester/transaction_test_info.rs @@ -184,7 +184,7 @@ impl VmTester { for tx_test_info in txs { self.execute_tx_and_verify(tx_test_info.clone()); } - self.vm.finish_batch(Some(default_pubdata_builder())); + self.vm.finish_batch(default_pubdata_builder()); let mut state = self.vm.get_current_execution_state(); state.used_contract_hashes.sort(); state diff --git a/core/lib/multivm/src/versions/testonly/transfer.rs b/core/lib/multivm/src/versions/testonly/transfer.rs index e94e6004e83c..3572adba147c 100644 --- a/core/lib/multivm/src/versions/testonly/transfer.rs +++ b/core/lib/multivm/src/versions/testonly/transfer.rs @@ -82,7 +82,7 @@ fn test_send_or_transfer(test_option: TestOptions) { let batch_result = vm .vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); @@ -191,7 +191,7 @@ fn test_reentrancy_protection_send_or_transfer(test_option: TestOp let batch_result = vm .vm - .finish_batch(Some(default_pubdata_builder())) + .finish_batch(default_pubdata_builder()) .block_tip_execution_result; assert!(!batch_result.result.is_failed(), "Batch wasn't successful"); } diff --git a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs index 395254ff6e58..d9768652c2f3 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs @@ -183,10 +183,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { self.vm .execute_till_block_end( crate::vm_1_3_2::vm_with_bootloader::BootloaderJobType::BlockPostprocessing, diff --git a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs index 04ee59e79720..af483feedd7e 100644 --- a/core/lib/multivm/src/versions/vm_1_4_1/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_1/vm.rs @@ -131,10 +131,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner( &mut TracerDispatcher::default(), VmExecutionMode::Batch, diff --git a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs index 2e0dcc5b03fc..e7c8e7acdd95 100644 --- a/core/lib/multivm/src/versions/vm_1_4_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_4_2/vm.rs @@ -131,10 +131,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner(TracerDispatcher::default(), VmExecutionMode::Batch, None); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); diff --git a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs index 539308fc3126..43c9900486db 100644 --- a/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs +++ b/core/lib/multivm/src/versions/vm_boojum_integration/vm.rs @@ -132,10 +132,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner(&mut TracerDispatcher::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); diff --git a/core/lib/multivm/src/versions/vm_fast/tests/mod.rs b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs index 7f215bf5748b..bb766b7a98dc 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/mod.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs @@ -105,7 +105,7 @@ impl TestedVm for Vm> { pubdata_builder: Rc, ) -> VmExecutionResultAndLogs { self.enforce_state_diffs(diffs); - self.finish_batch(Some(pubdata_builder)) + self.finish_batch(pubdata_builder) .block_tip_execution_result } diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index c0e9d276b6f0..9e8676f09926 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -689,10 +689,7 @@ impl VmInterface for Vm { self.bootloader_state.start_new_l2_block(l2_block_env) } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner(&mut Tr::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); diff --git a/core/lib/multivm/src/versions/vm_latest/vm.rs b/core/lib/multivm/src/versions/vm_latest/vm.rs index ac6f2a92da06..ef6cee454a87 100644 --- a/core/lib/multivm/src/versions/vm_latest/vm.rs +++ b/core/lib/multivm/src/versions/vm_latest/vm.rs @@ -186,8 +186,7 @@ impl VmInterface for Vm { } } - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { - let pubdata_builder = pubdata_builder.expect("`pubdata_builder` is required"); + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { let pubdata_tracer = Some(PubdataTracer::new( self.batch_env.clone(), VmExecutionMode::Batch, diff --git a/core/lib/multivm/src/versions/vm_m5/vm.rs b/core/lib/multivm/src/versions/vm_m5/vm.rs index a3d5f107bc68..55afeed17cd1 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm.rs @@ -115,10 +115,7 @@ impl VmInterface for Vm { ) } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { self.vm .execute_till_block_end( crate::vm_m5::vm_with_bootloader::BootloaderJobType::BlockPostprocessing, diff --git a/core/lib/multivm/src/versions/vm_m6/vm.rs b/core/lib/multivm/src/versions/vm_m6/vm.rs index 9456af1bc959..4c67a2184180 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm.rs @@ -207,10 +207,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { self.vm .execute_till_block_end( crate::vm_m6::vm_with_bootloader::BootloaderJobType::BlockPostprocessing, diff --git a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs index 36e22eaaa9a5..81b0c52cce5e 100644 --- a/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs +++ b/core/lib/multivm/src/versions/vm_refunds_enhancement/vm.rs @@ -125,10 +125,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner(&mut TracerDispatcher::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs index b7a5e5f6ba95..a2d18e10de44 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/vm.rs @@ -125,10 +125,7 @@ impl VmInterface for Vm { } } - fn finish_batch( - &mut self, - _pubdata_builder: Option>, - ) -> FinishedL1Batch { + fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { let result = self.inspect_inner(&mut TracerDispatcher::default(), VmExecutionMode::Batch); let execution_state = self.get_current_execution_state(); let bootloader_memory = self.bootloader_state.bootloader_memory(); diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs index bcfbd769062c..5ff27046377a 100644 --- a/core/lib/multivm/src/vm_instance.rs +++ b/core/lib/multivm/src/vm_instance.rs @@ -88,7 +88,7 @@ impl VmInterface for LegacyVmInstance { } /// Return the results of execution of all batch - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { dispatch_legacy_vm!(self.finish_batch(pubdata_builder)) } } @@ -293,7 +293,7 @@ impl VmInterface for FastVmInsta } } - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { dispatch_fast_vm!(self.finish_batch(pubdata_builder)) } } diff --git a/core/lib/tee_verifier/src/lib.rs b/core/lib/tee_verifier/src/lib.rs index e12e9f611dfb..140085dbb9fe 100644 --- a/core/lib/tee_verifier/src/lib.rs +++ b/core/lib/tee_verifier/src/lib.rs @@ -209,7 +209,7 @@ fn execute_vm( tracing::trace!("about to vm.finish_batch()"); - Ok(vm.finish_batch(Some(pubdata_params_to_builder(pubdata_params)))) + Ok(vm.finish_batch(pubdata_params_to_builder(pubdata_params))) } /// Map `LogQuery` and `TreeLogEntry` to a `TreeInstruction` diff --git a/core/lib/vm_executor/src/batch/factory.rs b/core/lib/vm_executor/src/batch/factory.rs index 75a35c91a42f..f974d17f4a75 100644 --- a/core/lib/vm_executor/src/batch/factory.rs +++ b/core/lib/vm_executor/src/batch/factory.rs @@ -138,7 +138,7 @@ impl BatchExecutorFactory storage, l1_batch_params, system_env, - Some(pubdata_params_to_builder(pubdata_params)), + pubdata_params_to_builder(pubdata_params), ) }); Box::new(MainBatchExecutor::new(handle, commands_sender)) @@ -192,7 +192,7 @@ impl BatchVm { dispatch_batch_vm!(self.start_new_l2_block(l2_block)); } - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { dispatch_batch_vm!(self.finish_batch(pubdata_builder)) } @@ -269,7 +269,7 @@ impl CommandReceiver { storage: S, l1_batch_params: L1BatchEnv, system_env: SystemEnv, - pubdata_builder: Option>, + pubdata_builder: Rc, ) -> anyhow::Result> { tracing::info!("Starting executing L1 batch #{}", &l1_batch_params.number); @@ -378,7 +378,7 @@ impl CommandReceiver { fn finish_batch( &self, vm: &mut BatchVm, - pubdata_builder: Option>, + pubdata_builder: Rc, ) -> anyhow::Result { // The vm execution was paused right after the last transaction was executed. // There is some post-processing work that the VM needs to do before the block is fully processed. diff --git a/core/lib/vm_interface/src/utils/dump.rs b/core/lib/vm_interface/src/utils/dump.rs index 4e60f166b608..19e847dae6c5 100644 --- a/core/lib/vm_interface/src/utils/dump.rs +++ b/core/lib/vm_interface/src/utils/dump.rs @@ -178,7 +178,7 @@ impl VmInterface for DumpingVm { .inspect_transaction_with_bytecode_compression(tracer, tx, with_compression) } - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { self.inner.finish_batch(pubdata_builder) } } diff --git a/core/lib/vm_interface/src/utils/shadow.rs b/core/lib/vm_interface/src/utils/shadow.rs index c343e61c4022..a8b84a338a9c 100644 --- a/core/lib/vm_interface/src/utils/shadow.rs +++ b/core/lib/vm_interface/src/utils/shadow.rs @@ -254,7 +254,7 @@ where (main_bytecodes_result, main_tx_result) } - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch { + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { let main_batch = self.main.finish_batch(pubdata_builder.clone()); if let Some(shadow) = self.shadow.get_mut() { let shadow_batch = shadow.vm.finish_batch(pubdata_builder.clone()); diff --git a/core/lib/vm_interface/src/vm.rs b/core/lib/vm_interface/src/vm.rs index 3e9afb412f7f..2c25d729e318 100644 --- a/core/lib/vm_interface/src/vm.rs +++ b/core/lib/vm_interface/src/vm.rs @@ -54,7 +54,7 @@ pub trait VmInterface { /// Execute batch till the end and return the result, with final execution state /// and bootloader memory. - fn finish_batch(&mut self, pubdata_builder: Option>) -> FinishedL1Batch; + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch; } /// Extension trait for [`VmInterface`] that provides some additional methods. diff --git a/core/node/commitment_generator/src/lib.rs b/core/node/commitment_generator/src/lib.rs index be14acd9fc46..3a36f3970da7 100644 --- a/core/node/commitment_generator/src/lib.rs +++ b/core/node/commitment_generator/src/lib.rs @@ -296,7 +296,11 @@ impl CommitmentGenerator { .connection_pool .connection_tagged("commitment_generator") .await?; - let aggregation_root = read_aggregation_root(&mut connection, l1_batch_number).await?; + let aggregation_root = if protocol_version.is_pre_gateway() { + read_aggregation_root(&mut connection, l1_batch_number).await? + } else { + H256::zero() + }; CommitmentInput::PostBoojum { common, @@ -384,9 +388,9 @@ impl CommitmentGenerator { // Do nothing } (L1BatchCommitmentMode::Validium, CommitmentInput::PostBoojum { blob_hashes, .. }) => { - blob_hashes - .iter_mut() - .for_each(|b| b.commitment = H256::zero()); + for hashes in blob_hashes { + hashes.commitment = H256::zero(); + } } (L1BatchCommitmentMode::Validium, _) => { /* Do nothing */ } } diff --git a/core/node/consensus/src/storage/store.rs b/core/node/consensus/src/storage/store.rs index 05a3bac0add6..53be2fc63c75 100644 --- a/core/node/consensus/src/storage/store.rs +++ b/core/node/consensus/src/storage/store.rs @@ -28,6 +28,13 @@ fn to_fetched_block( .context("Integer overflow converting block number")?, ); let payload = Payload::decode(payload).context("Payload::decode()")?; + let pubdata_params = if payload.protocol_version.is_pre_gateway() { + payload.pubdata_params.unwrap_or_default() + } else { + payload + .pubdata_params + .context("Missing `pubdata_params` for post-gateway payload")? + }; Ok(FetchedBlock { number, l1_batch_number: payload.l1_batch_number, @@ -38,7 +45,7 @@ fn to_fetched_block( l1_gas_price: payload.l1_gas_price, l2_fair_gas_price: payload.l2_fair_gas_price, fair_pubdata_price: payload.fair_pubdata_price, - pubdata_params: payload.pubdata_params.unwrap_or_default(), + pubdata_params, virtual_blocks: payload.virtual_blocks, operator_address: payload.operator_address, transactions: payload diff --git a/core/node/node_sync/src/fetcher.rs b/core/node/node_sync/src/fetcher.rs index 08e3d4262433..9c76d1d93ca3 100644 --- a/core/node/node_sync/src/fetcher.rs +++ b/core/node/node_sync/src/fetcher.rs @@ -1,3 +1,4 @@ +use anyhow::Context; use zksync_dal::{Connection, Core, CoreDal}; use zksync_shared_metrics::{TxStage, APP_METRICS}; use zksync_state_keeper::io::{common::IoCursor, L1BatchParams, L2BlockParams}; @@ -78,6 +79,14 @@ impl TryFrom for FetchedBlock { )); } + let pubdata_params = if block.protocol_version.is_pre_gateway() { + block.pubdata_params.unwrap_or_default() + } else { + block + .pubdata_params + .context("Missing `pubdata_params` for post-gateway payload")? + }; + Ok(Self { number: block.number, l1_batch_number: block.l1_batch_number, @@ -94,7 +103,7 @@ impl TryFrom for FetchedBlock { .into_iter() .map(FetchedTransaction::new) .collect(), - pubdata_params: block.pubdata_params.unwrap_or_default(), + pubdata_params, }) } } diff --git a/core/node/state_keeper/src/io/mempool.rs b/core/node/state_keeper/src/io/mempool.rs index fe1323bf56af..dfddd36aba71 100644 --- a/core/node/state_keeper/src/io/mempool.rs +++ b/core/node/state_keeper/src/io/mempool.rs @@ -165,19 +165,7 @@ impl StateKeeperIO for MempoolIO { { let protocol_version = unsealed_storage_batch .protocol_version - .expect("unsealed batch is missing protocol version"); - let pubdata_params = match ( - protocol_version.is_pre_gateway(), - self.l2_da_validator_address, - ) { - (true, _) => PubdataParams::default(), - (false, Some(l2_da_validator_address)) => PubdataParams { - l2_da_validator_address, - pubdata_type: self.pubdata_type, - }, - (false, None) => anyhow::bail!("L2 DA validator address not found"), - }; - + .context("unsealed batch is missing protocol version")?; return Ok(Some(L1BatchParams { protocol_version, validation_computational_gas_limit: self.validation_computational_gas_limit, @@ -188,7 +176,7 @@ impl StateKeeperIO for MempoolIO { // This value is effectively ignored by the protocol. virtual_blocks: 1, }, - pubdata_params, + pubdata_params: self.pubdata_params(protocol_version)?, })); } @@ -235,18 +223,6 @@ impl StateKeeperIO for MempoolIO { continue; } - let pubdata_params = match ( - protocol_version.is_pre_gateway(), - self.l2_da_validator_address, - ) { - (true, _) => PubdataParams::default(), - (false, Some(l2_da_validator_address)) => PubdataParams { - l2_da_validator_address, - pubdata_type: self.pubdata_type, - }, - (false, None) => anyhow::bail!("L2 DA validator address not found"), - }; - self.pool .connection_tagged("state_keeper") .await? @@ -270,7 +246,7 @@ impl StateKeeperIO for MempoolIO { // This value is effectively ignored by the protocol. virtual_blocks: 1, }, - pubdata_params, + pubdata_params: self.pubdata_params(protocol_version)?, })); } Ok(None) @@ -508,6 +484,22 @@ impl MempoolIO { pubdata_type, }) } + + fn pubdata_params(&self, protocol_version: ProtocolVersionId) -> anyhow::Result { + let pubdata_params = match ( + protocol_version.is_pre_gateway(), + self.l2_da_validator_address, + ) { + (true, _) => PubdataParams::default(), + (false, Some(l2_da_validator_address)) => PubdataParams { + l2_da_validator_address, + pubdata_type: self.pubdata_type, + }, + (false, None) => anyhow::bail!("L2 DA validator address not found"), + }; + + Ok(pubdata_params) + } } /// Getters required for testing the MempoolIO. diff --git a/core/node/state_keeper/src/io/persistence.rs b/core/node/state_keeper/src/io/persistence.rs index c01c67a3bbd2..06f1972a02aa 100644 --- a/core/node/state_keeper/src/io/persistence.rs +++ b/core/node/state_keeper/src/io/persistence.rs @@ -45,7 +45,7 @@ impl StateKeeperPersistence { pool: &ConnectionPool, l2_legacy_shared_bridge_addr: Option
, ) -> anyhow::Result<()> { - let mut connection = pool.connection().await.context("Get DB connection")?; + let mut connection = pool.connection_tagged("state_keeper").await?; if let Some(l2_block) = connection .blocks_dal() @@ -64,9 +64,7 @@ impl StateKeeperPersistence { .unwrap_or_else(ProtocolVersionId::last_potentially_undefined); if protocol_version.is_pre_gateway() && l2_legacy_shared_bridge_addr.is_none() { - anyhow::bail!( - "Missing `l2_legacy_shared_bridge_addr` for chain that was initialized before gateway upgrade".to_string() - ); + anyhow::bail!("Missing `l2_legacy_shared_bridge_addr` for chain that was initialized before gateway upgrade"); } }