From a399828cf918b9592cd2186e1ce5abdc1cb54fd6 Mon Sep 17 00:00:00 2001
From: Yael Doweck <yael@starkware.co>
Date: Sun, 3 Nov 2024 11:46:18 +0200
Subject: [PATCH] feat(batcher): add validate flow request handlers

---
 crates/batcher/src/batcher.rs                 | 19 +++++++++++++++++++
 crates/batcher/src/communication.rs           |  7 ++++++-
 crates/batcher_types/src/batcher_types.rs     |  1 +
 .../src/sequencer_consensus_context.rs        | 11 +++++++++--
 4 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/crates/batcher/src/batcher.rs b/crates/batcher/src/batcher.rs
index d8086e31d5..f878d69e9a 100644
--- a/crates/batcher/src/batcher.rs
+++ b/crates/batcher/src/batcher.rs
@@ -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;
@@ -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,
diff --git a/crates/batcher/src/communication.rs b/crates/batcher/src/communication.rs
index 4a0ee89148..d82b984318 100644
--- a/crates/batcher/src/communication.rs
+++ b/crates/batcher/src/communication.rs
@@ -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)
+            }
         }
     }
 }
diff --git a/crates/batcher_types/src/batcher_types.rs b/crates/batcher_types/src/batcher_types.rs
index 994a631bb0..49b3f3f1af 100644
--- a/crates/batcher_types/src/batcher_types.rs
+++ b/crates/batcher_types/src/batcher_types.rs
@@ -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 {
diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
index 148ee8e4ce..0e8f237027 100644
--- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
+++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs
@@ -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(