From 39684f3ccf048d1924e7aea827d4686185dbaeba Mon Sep 17 00:00:00 2001 From: Asmaa Magdoub Date: Wed, 25 Dec 2024 08:43:25 +0200 Subject: [PATCH] feat(consensus): impl try_sync in sequencer context --- .../src/sequencer_consensus_context.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 d25b781808a..6090eadf9bf 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs @@ -97,7 +97,6 @@ enum HandledProposalPart { const BUILD_PROPOSAL_MARGIN: Duration = Duration::from_millis(1000); pub struct SequencerConsensusContext { - #[allow(dead_code)] state_sync_client: SharedStateSyncClient, batcher: Arc, validators: Vec, @@ -308,9 +307,13 @@ impl ConsensusContext for SequencerConsensusContext { Ok(()) } - async fn try_sync(&mut self, _height: BlockNumber) -> bool { - // TODO(Asmaa): Implement sync. - todo!() + async fn try_sync(&mut self, height: BlockNumber) -> bool { + let sync_block = self.state_sync_client.get_block(height).await; + if let Ok(Some(sync_block)) = sync_block { + self.batcher.add_sync_block(sync_block).await.unwrap(); + return true; + } + false } async fn set_height_and_round(&mut self, height: BlockNumber, round: Round) {