Skip to content

Commit

Permalink
store view sync vote as action (#3798)
Browse files Browse the repository at this point in the history
* store view sync vote as action

* don't block view sync votes
  • Loading branch information
bfish713 authored Oct 28, 2024
1 parent 0172de1 commit 83d9684
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/task-impls/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,16 @@ impl<
consensus: Arc<RwLock<Consensus<TYPES>>>,
view: <TYPES as NodeType>::View,
) -> std::result::Result<(), ()> {
if let Some(action) = maybe_action {
if let Some(mut action) = maybe_action {
if !consensus.write().await.update_action(action, view) {
tracing::warn!("Already actioned {:?} in view {:?}", action, view);
return Err(());
}
// If the action was view sync record it as a vote, but we don't
// want to limit to 1 View sycn vote above so change the action here.
if matches!(action, HotShotAction::ViewSyncVote) {
action = HotShotAction::Vote;
}
match storage.write().await.record_action(view, action).await {
Ok(()) => Ok(()),
Err(e) => {
Expand Down Expand Up @@ -460,6 +465,7 @@ impl<
))
}
HotShotEvent::ViewSyncCommitVoteSend(vote) => {
*maybe_action = Some(HotShotAction::ViewSyncVote);
let view_number = vote.view_number() + vote.date().relay;
let leader = match self.quorum_membership.leader(view_number, self.epoch) {
Ok(l) => l,
Expand All @@ -482,6 +488,7 @@ impl<
))
}
HotShotEvent::ViewSyncFinalizeVoteSend(vote) => {
*maybe_action = Some(HotShotAction::ViewSyncVote);
let view_number = vote.view_number() + vote.date().relay;
let leader = match self.quorum_membership.leader(view_number, self.epoch) {
Ok(l) => l,
Expand Down
2 changes: 2 additions & 0 deletions crates/types/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ pub enum EventType<TYPES: NodeType> {
pub enum HotShotAction {
/// A quorum vote was sent
Vote,
/// View Sync Vote
ViewSyncVote,
/// A quorum proposal was sent
Propose,
/// DA proposal was sent
Expand Down

0 comments on commit 83d9684

Please sign in to comment.