patches flaky test_rpc_slot_updates (#26593)

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.
This commit is contained in:
behzad nouri 2022-07-14 12:33:54 +00:00 committed by GitHub
parent 4dea32e8e5
commit 1bc2cc7f76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 9 deletions

View File

@ -195,17 +195,23 @@ 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))
@ -213,17 +219,16 @@ fn test_rpc_slot_updates() {
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());
}
}
}