Skip to content

Commit

Permalink
fix(batcher): assert when using the transaction_provider with n_txs=0
Browse files Browse the repository at this point in the history
  • Loading branch information
Yael-Starkware committed Nov 28, 2024
1 parent be65c40 commit 097b23a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/starknet_batcher/src/transaction_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl ProposeTransactionProvider {
#[async_trait]
impl TransactionProvider for ProposeTransactionProvider {
async fn get_txs(&mut self, n_txs: usize) -> Result<NextTxs, TransactionProviderError> {
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 =
Expand Down Expand Up @@ -118,6 +119,7 @@ pub struct ValidateTransactionProvider {
#[async_trait]
impl TransactionProvider for ValidateTransactionProvider {
async fn get_txs(&mut self, n_txs: usize) -> Result<NextTxs, TransactionProviderError> {
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
Expand Down

0 comments on commit 097b23a

Please sign in to comment.