From 097b23ab20ab041be2ad1bcaf4427d09d6cd63bf Mon Sep 17 00:00:00 2001 From: Yael Doweck Date: Thu, 28 Nov 2024 11:12:32 +0200 Subject: [PATCH] fix(batcher): assert when using the transaction_provider with n_txs=0 --- crates/starknet_batcher/src/transaction_provider.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/starknet_batcher/src/transaction_provider.rs b/crates/starknet_batcher/src/transaction_provider.rs index 50324a890b..672daed899 100644 --- a/crates/starknet_batcher/src/transaction_provider.rs +++ b/crates/starknet_batcher/src/transaction_provider.rs @@ -83,6 +83,7 @@ impl ProposeTransactionProvider { #[async_trait] impl TransactionProvider for ProposeTransactionProvider { async fn get_txs(&mut self, n_txs: usize) -> Result { + assert!(n_txs > 0, "The number of transactions requested must be greater than zero."); let mut txs = vec![]; if self.phase == TxProviderPhase::L1 { let n_l1handler_txs_to_get = @@ -118,6 +119,7 @@ pub struct ValidateTransactionProvider { #[async_trait] impl TransactionProvider for ValidateTransactionProvider { async fn get_txs(&mut self, n_txs: usize) -> Result { + assert!(n_txs > 0, "The number of transactions requested must be greater than zero."); let mut buffer = Vec::with_capacity(n_txs); self.tx_receiver.recv_many(&mut buffer, n_txs).await; // If the buffer is empty, it means that the stream was dropped, otherwise it would have