Skip to content

Commit

Permalink
Fix flaky test test_fork_choice_refresh_old_votes (solana-labs#19278)
Browse files Browse the repository at this point in the history
* Fix flaky test test_fork_choice_refresh_old_votes

* Wait for latest voted block to arrive in blockstore

* Wait for block to be full
  • Loading branch information
AshwinSekar authored Aug 20, 2021
1 parent 17978c2 commit 05e7d10
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions local-cluster/tests/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,9 @@ fn test_kill_partition_switch_threshold_progress() {
\-------- 4 (38%, heavier fork)
*/
// where the 2% that voted on slot 1 don't see their votes land in a block
// and thus without integrating votes from gossip into fork choice, will
// deem slot 4 the heavier fork and try to switch to slot 4, which doesn't pass the
// switch threshold. This stalls the network.
// due to blockhash expiration, and thus without resigning their votes with
// a newer blockhash, will deem slot 4 the heavier fork and try to switch to
// slot 4, which doesn't pass the switch threshold. This stalls the network.

// We do this by:
// 1) Creating a partition so all three nodes don't see each other
Expand Down Expand Up @@ -1137,14 +1137,21 @@ fn test_fork_choice_refresh_old_votes() {

info!("Opened blockstores");

// Get latest votes
// Get latest votes. We additionally check to make sure the vote has landed in
// blockstore. This is important because if we were the leader for the block there
// is a possibility of voting before broadcast has inserted in blockstore.
let (lighter_fork_latest_vote, _) = last_vote_in_tower(
&lighter_fork_ledger_path,
&context.lighter_fork_validator_key,
)
.unwrap();
let (heaviest_fork_latest_vote, _) =
last_vote_in_tower(&heaviest_ledger_path, &context.heaviest_validator_key).unwrap();
while !lighter_fork_blockstore.is_full(lighter_fork_latest_vote)
|| !heaviest_blockstore.is_full(heaviest_fork_latest_vote)
{
sleep(Duration::from_millis(100));
}

// Find the first slot on the smaller fork
let lighter_ancestors: BTreeSet<Slot> = std::iter::once(lighter_fork_latest_vote)
Expand Down

0 comments on commit 05e7d10

Please sign in to comment.