Skip to content

Commit

Permalink
patches flaky test_rpc_slot_updates (#26593)
Browse files Browse the repository at this point in the history
test_rpc_slot_updates fails if SlotUpdate::Completed is received after
SlotUpdate::Frozen:
https://github.com/solana-labs/solana/blob/dcfd823ca/rpc-test/tests/rpc.rs#L198-L228

However, SlotUpdate::Completed is sent asynchronous to banking-stage and
replay when shreds are inserted into blockstore. When the leader
generates blocks, replay may freeze the bank before shreds are all
inserted into blockstore; and so SlotUpdate::Completed may be received
_after_ SlotUpdate::Frozen.

The commit removes the ordering check for SlotUpdate::Completed.
  • Loading branch information
behzadnouri authored Jul 14, 2022
1 parent 4dea32e commit 1bc2cc7
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions rpc-test/tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,35 +195,40 @@ fn test_rpc_slot_updates() {

// Verify that updates are received in order for an upcoming slot
let verify_slot = first_update.slot() + 2;
let mut expected_update_index = 0;
let expected_updates = vec![
"CreatedBank",
"Completed",
"Frozen",
"OptimisticConfirmation",
"Root", // TODO: debug why root signal is sent twice.
"Root",
];
let mut expected_updates = expected_updates.into_iter().peekable();
// SlotUpdate::Completed is sent asynchronous to banking-stage and replay
// when shreds are inserted into blockstore. When the leader generates
// blocks, replay may freeze the bank before shreds are all inserted into
// blockstore; and so SlotUpdate::Completed may be received _after_
// SlotUpdate::Frozen.
let mut slot_update_completed = false;

let test_start = Instant::now();
loop {
while expected_updates.peek().is_some() || !slot_update_completed {
assert!(test_start.elapsed() < Duration::from_secs(30));
let update = update_receiver
.recv_timeout(Duration::from_secs(2))
.unwrap();
if update.slot() == verify_slot {
let update_name = match update {
SlotUpdate::CreatedBank { .. } => "CreatedBank",
SlotUpdate::Completed { .. } => "Completed",
SlotUpdate::Completed { .. } => {
slot_update_completed = true;
continue;
}
SlotUpdate::Frozen { .. } => "Frozen",
SlotUpdate::OptimisticConfirmation { .. } => "OptimisticConfirmation",
SlotUpdate::Root { .. } => "Root",
_ => continue,
};
assert_eq!(update_name, expected_updates[expected_update_index]);
expected_update_index += 1;
if expected_update_index == expected_updates.len() {
break;
}
assert_eq!(Some(update_name), expected_updates.next());
}
}
}
Expand Down

0 comments on commit 1bc2cc7

Please sign in to comment.