Skip to content

Commit

Permalink
v2.0: replay: do not refresh votes for hot spare validators (backport…
Browse files Browse the repository at this point in the history
… of #2770) (#2779)

replay: do not refresh votes for hot spare validators (#2770)

(cherry picked from commit 726a14f)

Co-authored-by: Ashwin Sekar <[email protected]>
  • Loading branch information
mergify[bot] and AshwinSekar authored Aug 29, 2024
1 parent 2f2d7ec commit 3853b5d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ pub(crate) enum BlockhashStatus {
Uninitialized,
/// Non voting validator
NonVoting,
/// Hot spare validator
HotSpare,
/// Successfully generated vote tx with blockhash
Blockhash(Hash),
}
Expand Down Expand Up @@ -587,6 +589,10 @@ impl Tower {
self.last_vote_tx_blockhash = BlockhashStatus::NonVoting;
}

pub(crate) fn mark_last_vote_tx_blockhash_hot_spare(&mut self) {
self.last_vote_tx_blockhash = BlockhashStatus::HotSpare;
}

pub fn last_voted_slot_in_bank(bank: &Bank, vote_account_pubkey: &Pubkey) -> Option<Slot> {
let vote_account = bank.get_vote_account(vote_account_pubkey)?;
let vote_state = vote_account.vote_state();
Expand Down
16 changes: 13 additions & 3 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ enum ConfirmationType {

enum GenerateVoteTxResult {
// non voting validator, not eligible for refresh
// until authorized keypair is overriden
NonVoting,
// hot spare validator, not eligble for refresh
// until set identity is invoked
HotSpare,
// failed generation, eligible for refresh
Failed,
Tx(Transaction),
Expand All @@ -145,6 +149,10 @@ impl GenerateVoteTxResult {
fn is_non_voting(&self) -> bool {
matches!(self, Self::NonVoting)
}

fn is_hot_spare(&self) -> bool {
matches!(self, Self::HotSpare)
}
}

#[derive(PartialEq, Eq, Debug)]
Expand Down Expand Up @@ -2532,7 +2540,7 @@ impl ReplayStage {
vote_state.node_pubkey,
node_keypair.pubkey()
);
return GenerateVoteTxResult::Failed;
return GenerateVoteTxResult::HotSpare;
}

let Some(authorized_voter_pubkey) = vote_state.get_authorized_voter(bank.epoch()) else {
Expand Down Expand Up @@ -2627,9 +2635,9 @@ impl ReplayStage {
// If we are a non voting validator or have an incorrect setup preventing us from
// generating vote txs, no need to refresh
let last_vote_tx_blockhash = match tower.last_vote_tx_blockhash() {
// Since the checks in vote generation are deterministic, if we were non voting
// Since the checks in vote generation are deterministic, if we were non voting or hot spare
// on the original vote, the refresh will also fail. No reason to refresh.
BlockhashStatus::NonVoting => return,
BlockhashStatus::NonVoting | BlockhashStatus::HotSpare => return,
// In this case we have not voted since restart, it is unclear if we are non voting.
// Attempt to refresh.
BlockhashStatus::Uninitialized => None,
Expand Down Expand Up @@ -2692,6 +2700,8 @@ impl ReplayStage {
last_vote_refresh_time.last_refresh_time = Instant::now();
} else if vote_tx_result.is_non_voting() {
tower.mark_last_vote_tx_blockhash_non_voting();
} else if vote_tx_result.is_hot_spare() {
tower.mark_last_vote_tx_blockhash_hot_spare();
}
}

Expand Down

0 comments on commit 3853b5d

Please sign in to comment.