Filter out outdated slots (#22450)

* Filter out outdated slots

* Fixup error
This commit is contained in:
carllin
2022-01-13 19:51:00 -05:00
committed by GitHub
parent eca8d21249
commit 4ab7d6c23e
6 changed files with 151 additions and 45 deletions

View File

@ -609,6 +609,9 @@ impl ClusterInfoVoteListener {
// The last vote slot, which is the greatest slot in the stack
// of votes in a vote transaction, qualifies for optimistic confirmation.
// We cannot count any other slots in this vote toward optimistic confirmation because:
// 1) There may have been a switch between the earlier vote and the last vote
// 2) We do not know the hash of the earlier slot
if slot == last_vote_slot {
let vote_accounts = epoch_stakes.stakes().vote_accounts();
let stake = vote_accounts

View File

@ -366,7 +366,7 @@ impl Tower {
last_voted_slot_in_bank: Option<Slot>,
) -> Vote {
let vote = Vote::new(vec![slot], hash);
local_vote_state.process_vote_unchecked(&vote);
local_vote_state.process_vote_unchecked(vote);
let slots = if let Some(last_voted_slot) = last_voted_slot_in_bank {
local_vote_state
.votes
@ -2276,7 +2276,7 @@ pub mod test {
hash: Hash::default(),
timestamp: None,
};
local.process_vote_unchecked(&vote);
local.process_vote_unchecked(vote);
assert_eq!(local.votes.len(), 1);
let vote =
Tower::apply_vote_and_generate_vote_diff(&mut local, 1, Hash::default(), Some(0));
@ -2292,7 +2292,7 @@ pub mod test {
hash: Hash::default(),
timestamp: None,
};
local.process_vote_unchecked(&vote);
local.process_vote_unchecked(vote);
assert_eq!(local.votes.len(), 1);
// First vote expired, so should be evicted from tower. Thus even with