Skip to content

Commit

Permalink
feat(consensus): add try_sync to context API
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaastarkware committed Dec 25, 2024
1 parent 47282a4 commit a4bd794
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/sequencing/papyrus_consensus/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ mock! {
precommits: Vec<Vote>,
) -> Result<(), ConsensusError>;

async fn try_sync(&mut self, height: BlockNumber) -> bool;

async fn set_height_and_round(&mut self, height: BlockNumber, round: Round);
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/sequencing/papyrus_consensus/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ pub trait ConsensusContext {
precommits: Vec<Vote>,
) -> Result<(), ConsensusError>;

/// Attempt to learn of a decision from the sync protocol.
/// Returns true if a decision was learned so consensus can proceed.
async fn try_sync(&mut self, height: BlockNumber) -> bool;

/// Update the context with the current height and round.
/// Must be called at the beginning of each height.
async fn set_height_and_round(&mut self, height: BlockNumber, round: Round);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ impl ConsensusContext for PapyrusConsensusContext {
Ok(())
}

async fn try_sync(&mut self, _height: BlockNumber) -> bool {
// TODO(Asmaa): Implement this.
todo!()
}

async fn set_height_and_round(&mut self, _height: BlockNumber, _round: Round) {
// No-op
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ impl ConsensusContext for SequencerConsensusContext {
Ok(())
}

async fn try_sync(&mut self, _height: BlockNumber) -> bool {
// TODO(Asmaa): Implement sync.
todo!()
}

async fn set_height_and_round(&mut self, height: BlockNumber, round: Round) {
if self.current_height.map(|h| height > h).unwrap_or(true) {
self.current_height = Some(height);
Expand Down

0 comments on commit a4bd794

Please sign in to comment.