Skip considering banks older than the latest vote slot (#6037)

automerge
This commit is contained in:
Sagar Dhawan 2019-09-23 19:40:03 -07:00 committed by Grimes
parent 4f59077318
commit 84f74807d4
2 changed files with 10 additions and 9 deletions

View File

@ -253,10 +253,10 @@ impl Tower {
sum
}
// a slot is not recent if its older than the oldest lockout we have
pub fn is_recent(&self, slot: u64) -> bool {
if let Some(oldest_vote) = self.lockouts.votes.front() {
if slot < oldest_vote.slot {
// a slot is not recent if it's older than the newest vote we have
fn is_recent(&self, slot: u64) -> bool {
if let Some(last_vote) = self.lockouts.votes.back() {
if slot <= last_vote.slot {
return false;
}
}
@ -275,6 +275,11 @@ impl Tower {
pub fn is_locked_out(&self, slot: u64, ancestors: &HashMap<u64, HashSet<u64>>) -> bool {
assert!(ancestors.contains_key(&slot));
if !self.is_recent(slot) {
trace!("slot is not recent: {}", slot);
return true;
}
let mut lockouts = self.lockouts.clone();
lockouts.process_slot_vote_unchecked(slot);
for vote in &lockouts.votes {
@ -610,6 +615,7 @@ mod test {
}
assert!(!tower.is_recent(0));
assert!(!tower.is_recent(32));
assert!(!tower.is_recent(63));
assert!(tower.is_recent(65));
}

View File

@ -574,11 +574,6 @@ impl ReplayStage {
trace!("bank is votable: {} {}", b.slot(), is_votable);
is_votable
})
.filter(|b| {
let is_recent = tower.is_recent(b.slot());
trace!("tower is recent: {} {}", b.slot(), is_recent);
is_recent
})
.filter(|b| {
let has_voted = tower.has_voted(b.slot());
trace!("bank has_voted: {} {}", b.slot(), has_voted);