Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(starknet_batcher): add_sync_block on batcher client #2519

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

2 changes: 2 additions & 0 deletions crates/starknet_batcher/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ 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(())),
}
}
}
1 change: 1 addition & 0 deletions crates/starknet_batcher_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ papyrus_proc_macros.workspace = true
serde = { workspace = true, features = ["derive"] }
starknet_api.workspace = true
starknet_sequencer_infra.workspace = true
starknet_state_sync_types.workspace = true
thiserror.workspace = true


Expand Down
11 changes: 11 additions & 0 deletions crates/starknet_batcher_types/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use starknet_sequencer_infra::component_definitions::{
ComponentClient,
ComponentRequestAndResponseSender,
};
use starknet_state_sync_types::state_sync_types::SyncBlock;
use thiserror::Error;

use crate::batcher_types::{
Expand Down Expand Up @@ -68,6 +69,8 @@ pub trait BatcherClient: Send + Sync {
/// 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 All @@ -78,6 +81,7 @@ pub enum BatcherRequest {
SendProposalContent(SendProposalContentInput),
StartHeight(StartHeightInput),
DecisionReached(DecisionReachedInput),
AddSyncBlock(SyncBlock),
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand All @@ -88,6 +92,7 @@ pub enum BatcherResponse {
SendProposalContent(BatcherResult<SendProposalContentResponse>),
StartHeight(BatcherResult<()>),
DecisionReached(BatcherResult<()>),
AddSyncBlock(BatcherResult<()>),
}

#[derive(Clone, Debug, Error)]
Expand Down Expand Up @@ -159,4 +164,10 @@ where
BatcherError
)
}

async fn add_sync_block(&self, sync_block: SyncBlock) -> BatcherClientResult<()> {
let request = BatcherRequest::AddSyncBlock(sync_block);
let response = self.send(request).await;
handle_response_variants!(BatcherResponse, AddSyncBlock, BatcherClientError, BatcherError)
}
}
Loading