Skip to content

Commit

Permalink
feat(batcher): add validate flow request handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Yael-Starkware committed Nov 4, 2024
1 parent bd3fad8 commit a399828
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
19 changes: 19 additions & 0 deletions crates/batcher/src/batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use starknet_batcher_types::batcher_types::{
GetProposalContentInput,
GetProposalContentResponse,
ProposalId,
SendProposalContentInput,
SendProposalContentResponse,
StartHeightInput,
ValidateProposalInput,
};
use starknet_batcher_types::errors::BatcherError;
use starknet_mempool_types::communication::SharedMempoolClient;
Expand Down Expand Up @@ -99,6 +102,22 @@ impl Batcher {
Ok(())
}

#[instrument(skip(self), err)]
pub async fn validate_proposal(
&mut self,
validate_proposal_input: ValidateProposalInput,
) -> BatcherResult<()> {
todo!();
}

#[instrument(skip(self), err)]
pub async fn send_proposal_content(
&mut self,
send_proposal_content_input: SendProposalContentInput,
) -> BatcherResult<SendProposalContentResponse> {
todo!();
}

#[instrument(skip(self), err)]
pub async fn get_proposal_content(
&mut self,
Expand Down
7 changes: 6 additions & 1 deletion crates/batcher/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ impl ComponentRequestHandler<BatcherRequest, BatcherResponse> for Batcher {
BatcherRequest::DecisionReached(input) => {
BatcherResponse::DecisionReached(self.decision_reached(input).await)
}
_ => unimplemented!(),
BatcherRequest::ValidateProposal(input) => {
BatcherResponse::ValidateProposal(self.validate_proposal(input).await)
}
BatcherRequest::SendProposalContent(input) => {
BatcherResponse::SendProposalContent(self.send_proposal_content(input).await)
}
}
}
}
1 change: 1 addition & 0 deletions crates/batcher_types/src/batcher_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub enum GetProposalContent {
pub struct ValidateProposalInput {
pub proposal_id: ProposalId,
pub deadline: chrono::DateTime<Utc>,
pub retrospective_block_hash: Option<BlockHashAndNumber>,
}

impl BuildProposalInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,15 @@ impl ConsensusContext for SequencerConsensusContext {

let chrono_timeout =
chrono::Duration::from_std(timeout).expect("Can't convert timeout to chrono::Duration");
let input =
ValidateProposalInput { proposal_id, deadline: chrono::Utc::now() + chrono_timeout };
let input = ValidateProposalInput {
proposal_id,
deadline: chrono::Utc::now() + chrono_timeout,
// TODO(Matan 3/11/2024): Add the real value of the retrospective block hash.
retrospective_block_hash: Some(BlockHashAndNumber {
number: BlockNumber::default(),
hash: BlockHash::default(),
}),
};
self.maybe_start_height(height).await;
batcher.validate_proposal(input).await.expect("Failed to initiate proposal validation");
tokio::spawn(
Expand Down

0 comments on commit a399828

Please sign in to comment.