Fix bad predicate with malformed gossip votes (#12072)

This commit is contained in:
Ryo Onodera 2020-09-06 13:27:50 +09:00 committed by GitHub
parent 69e7e0129e
commit eabc63cdcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 8 deletions

View File

@ -641,11 +641,11 @@ impl ClusterInfoVoteListener {
let mut new_optimistic_confirmed_slots = vec![]; let mut new_optimistic_confirmed_slots = vec![];
// Process votes from gossip and ReplayStage // Process votes from gossip and ReplayStage
for (i, (vote_pubkey, vote, _)) in gossip_vote_txs for (is_gossip, (vote_pubkey, vote, _)) in gossip_vote_txs
.iter() .iter()
.filter_map(|gossip_tx| { .filter_map(|gossip_tx| {
vote_transaction::parse_vote_transaction(gossip_tx).filter( vote_transaction::parse_vote_transaction(gossip_tx)
|(vote_pubkey, vote, _)| { .filter(|(vote_pubkey, vote, _)| {
if vote.slots.is_empty() { if vote.slots.is_empty() {
return false; return false;
} }
@ -671,11 +671,10 @@ impl ClusterInfoVoteListener {
} }
true true
}, })
) .map(|v| (true, v))
}) })
.chain(replayed_votes) .chain(replayed_votes.into_iter().map(|v| (false, v)))
.enumerate()
{ {
Self::update_new_votes( Self::update_new_votes(
vote, vote,
@ -686,7 +685,7 @@ impl ClusterInfoVoteListener {
verified_vote_sender, verified_vote_sender,
&mut diff, &mut diff,
&mut new_optimistic_confirmed_slots, &mut new_optimistic_confirmed_slots,
i < gossip_vote_txs.len(), is_gossip,
); );
} }