diff --git a/Cargo.lock b/Cargo.lock index d57ab8f4f91..bde79e64c65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10255,6 +10255,7 @@ dependencies = [ "starknet_batcher_types", "starknet_mempool_types", "starknet_sequencer_infra", + "starknet_state_sync_types", "thiserror", "tokio", "tracing", diff --git a/crates/starknet_batcher/Cargo.toml b/crates/starknet_batcher/Cargo.toml index 7f14eb059da..ad23321bc98 100644 --- a/crates/starknet_batcher/Cargo.toml +++ b/crates/starknet_batcher/Cargo.toml @@ -21,6 +21,7 @@ starknet_api.workspace = true starknet_batcher_types.workspace = true starknet_mempool_types.workspace = true starknet_sequencer_infra.workspace = true +starknet_state_sync_types.workspace = true thiserror.workspace = true tokio.workspace = true tracing.workspace = true diff --git a/crates/starknet_batcher/src/batcher.rs b/crates/starknet_batcher/src/batcher.rs index c6d034a3ff1..2ab68759dc4 100644 --- a/crates/starknet_batcher/src/batcher.rs +++ b/crates/starknet_batcher/src/batcher.rs @@ -30,6 +30,7 @@ use starknet_batcher_types::errors::BatcherError; use starknet_mempool_types::communication::SharedMempoolClient; use starknet_mempool_types::mempool_types::CommitBlockArgs; use starknet_sequencer_infra::component_definitions::ComponentStarter; +use starknet_state_sync_types::state_sync_types::SyncBlock; use tracing::{debug, error, info, instrument, trace}; use crate::block_builder::{ @@ -344,6 +345,11 @@ impl Batcher { }) } + // TODO(Arni): Impl add sync block + pub async fn add_sync_block(&mut self, _sync_block: SyncBlock) -> BatcherResult<()> { + todo!("Implement add sync block"); + } + #[instrument(skip(self), err)] pub async fn decision_reached(&mut self, input: DecisionReachedInput) -> BatcherResult<()> { let proposal_id = input.proposal_id; diff --git a/crates/starknet_batcher/src/communication.rs b/crates/starknet_batcher/src/communication.rs index cf13381c85c..45451e25d44 100644 --- a/crates/starknet_batcher/src/communication.rs +++ b/crates/starknet_batcher/src/communication.rs @@ -33,8 +33,9 @@ impl ComponentRequestHandler for Batcher { BatcherRequest::SendProposalContent(input) => { BatcherResponse::SendProposalContent(self.send_proposal_content(input).await) } - // TODO(alonh): fill this - BatcherRequest::AddSyncBlock(_sync_block) => BatcherResponse::AddSyncBlock(Ok(())), + BatcherRequest::AddSyncBlock(sync_block) => { + BatcherResponse::AddSyncBlock(self.add_sync_block(sync_block).await) + } } } } diff --git a/crates/starknet_batcher_types/src/communication.rs b/crates/starknet_batcher_types/src/communication.rs index 0dbca627b51..6f60a2b9fd6 100644 --- a/crates/starknet_batcher_types/src/communication.rs +++ b/crates/starknet_batcher_types/src/communication.rs @@ -69,11 +69,12 @@ pub trait BatcherClient: Send + Sync { /// From this point onwards, the batcher will accept requests only for proposals associated /// with this height. async fn start_height(&self, input: StartHeightInput) -> BatcherClientResult<()>; + /// Add a block that came from the state sync. Update the batcher's state and commit the + /// transactions to the mempool. + async fn add_sync_block(&self, sync_block: SyncBlock) -> BatcherClientResult<()>; /// Notifies the batcher that a decision has been reached. /// This closes the process of the given height, and the accepted proposal is committed. async fn decision_reached(&self, input: DecisionReachedInput) -> BatcherClientResult<()>; - - async fn add_sync_block(&self, sync_block: SyncBlock) -> BatcherClientResult<()>; } #[derive(Debug, Serialize, Deserialize, Clone)]