Skip to content

Commit

Permalink
refactor(consensus): rename notify_decision to decision_reached (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
matan-starkware authored Aug 18, 2024
1 parent 32e3859 commit c45b4e5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/sequencing/papyrus_consensus/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ where
tokio::select! {
decision = run_height => {
let decision = decision?;
context.notify_decision(decision.block, decision.precommits).await?;
context.decision_reached(decision.block, decision.precommits).await?;
current_height = current_height.unchecked_next();
},
sync_height = sync_height(current_height, &mut sync_receiver) => {
Expand Down
6 changes: 3 additions & 3 deletions crates/sequencing/papyrus_consensus/src/manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ mock! {
fin_receiver: oneshot::Receiver<BlockHash>,
) -> Result<(), ConsensusError>;

async fn notify_decision(
async fn decision_reached(
&mut self,
block: TestBlock,
precommits: Vec<Vote>,
Expand Down Expand Up @@ -184,7 +184,7 @@ async fn run_consensus_sync() {
context.expect_validators().returning(move |_| vec![*PROPOSER_ID, *VALIDATOR_ID]);
context.expect_proposer().returning(move |_, _| *PROPOSER_ID);
context.expect_broadcast().returning(move |_| Ok(()));
context.expect_notify_decision().return_once(move |block, votes| {
context.expect_decision_reached().return_once(move |block, votes| {
assert_eq!(block.id(), BlockHash(Felt::TWO));
assert_eq!(votes[0].height, 2);
decision_tx.send(()).unwrap();
Expand Down Expand Up @@ -247,7 +247,7 @@ async fn run_consensus_sync_cancellation_safety() {
Ok(())
});
context.expect_broadcast().returning(move |_| Ok(()));
context.expect_notify_decision().return_once(|block, votes| {
context.expect_decision_reached().return_once(|block, votes| {
assert_eq!(block.id(), BlockHash(Felt::ONE));
assert_eq!(votes[0].height, 1);
decision_tx.send(()).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl ConsensusContext for PapyrusConsensusContext {
Ok(())
}

async fn notify_decision(
async fn decision_reached(
&mut self,
block: Self::Block,
precommits: Vec<Vote>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async fn decision() {
let (_, mut papyrus_context, _, mut sync_network) = test_setup();
let block = PapyrusConsensusBlock::default();
let precommit = Vote::default();
papyrus_context.notify_decision(block, vec![precommit.clone()]).await.unwrap();
papyrus_context.decision_reached(block, vec![precommit.clone()]).await.unwrap();
assert_eq!(sync_network.messages_to_broadcast_receiver.next().await.unwrap(), precommit);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/sequencing/papyrus_consensus/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mock! {
fin_receiver: oneshot::Receiver<BlockHash>,
) -> Result<(), ConsensusError>;

async fn notify_decision(
async fn decision_reached(
&mut self,
block: TestBlock,
precommits: Vec<Vote>,
Expand Down
2 changes: 1 addition & 1 deletion crates/sequencing/papyrus_consensus/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub trait ConsensusContext {
/// - `block` identifies the decision.
/// - `precommits` - All precommits must be for the same `(block.id(), height, round)` and form
/// a quorum (>2/3 of the voting power) for this height.
async fn notify_decision(
async fn decision_reached(
&mut self,
block: Self::Block,
precommits: Vec<Vote>,
Expand Down

0 comments on commit c45b4e5

Please sign in to comment.