Skip to content

Commit

Permalink
chore(starknet_batcher): remove redundant mutex and sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Yael-Starkware committed Dec 2, 2024
1 parent 718c39b commit 32d3d7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions crates/starknet_batcher/src/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ use starknet_api::core::ContractAddress;
use starknet_api::executable_transaction::Transaction;
use starknet_api::transaction::TransactionHash;
use thiserror::Error;
use tokio::sync::Mutex;
use tracing::{debug, error, info, trace};

use crate::transaction_executor::TransactionExecutorTrait;
Expand Down Expand Up @@ -98,7 +97,7 @@ pub struct BlockBuilderExecutionParams {

pub struct BlockBuilder {
// TODO(Yael 14/10/2024): make the executor thread safe and delete this mutex.
executor: Mutex<Box<dyn TransactionExecutorTrait>>,
executor: Box<dyn TransactionExecutorTrait>,
tx_provider: Box<dyn TransactionProvider>,
output_content_sender: Option<tokio::sync::mpsc::UnboundedSender<Transaction>>,
abort_signal_receiver: tokio::sync::oneshot::Receiver<()>,
Expand All @@ -118,7 +117,7 @@ impl BlockBuilder {
execution_params: BlockBuilderExecutionParams,
) -> Self {
Self {
executor: Mutex::new(executor),
executor,
tx_provider,
output_content_sender,
abort_signal_receiver,
Expand Down Expand Up @@ -163,7 +162,7 @@ impl BlockBuilderTrait for BlockBuilder {
// TODO(yair): Avoid this clone.
executor_input_chunk.push(BlockifierTransaction::from(tx.clone()));
}
let results = self.executor.lock().await.add_txs_to_block(&executor_input_chunk);
let results = self.executor.add_txs_to_block(&executor_input_chunk);
trace!("Transaction execution results: {:?}", results);
block_is_full = collect_execution_results_and_stream_txs(
next_tx_chunk,
Expand All @@ -175,7 +174,7 @@ impl BlockBuilderTrait for BlockBuilder {
.await?;
}
let (commitment_state_diff, visited_segments_mapping, bouncer_weights) =
self.executor.lock().await.close_block()?;
self.executor.close_block()?;
Ok(BlockExecutionArtifacts {
execution_infos,
commitment_state_diff,
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_batcher/src/transaction_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum NextTxs {

#[cfg_attr(test, automock)]
#[async_trait]
pub trait TransactionProvider: Send + Sync {
pub trait TransactionProvider: Send {
async fn get_txs(&mut self, n_txs: usize) -> Result<NextTxs, TransactionProviderError>;
}

Expand Down

0 comments on commit 32d3d7c

Please sign in to comment.