Skip to content

Commit

Permalink
feat(starknet_batcher): communication for sync block request (#2603)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware authored Dec 16, 2024
1 parent 127a796 commit 901111f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/starknet_batcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions crates/starknet_batcher/src/batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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::{
Expand Down Expand Up @@ -343,6 +344,11 @@ impl Batcher {
Ok(GetProposalContentResponse { content: GetProposalContent::Finished(commitment) })
}

// 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;
Expand Down
5 changes: 3 additions & 2 deletions crates/starknet_batcher/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ impl ComponentRequestHandler<BatcherRequest, BatcherResponse> 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)
}
}
}
}
5 changes: 3 additions & 2 deletions crates/starknet_batcher_types/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()>;
/// Adds a block from the state sync. Updates the batcher's state and commits 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)]
Expand Down

0 comments on commit 901111f

Please sign in to comment.