Skip to content

Commit 1bd4ac2

Browse files
authored
Fix flaky reconstruction test (#8321)
FIx flaky tests that depends on timing. Previously the test processes all 128 columns and expect reconstruction to happen after all columns are processed. There is a race here, and reconstruction could be triggered before all columns are processed. I've updated the tests to process 64 columns, just enough for reconstruction and wait for 50ms for reconstruction to be triggered. This PR requires the change made in #8194 for the test to pass consistently (blob count set to 1 for all blocks instead of random blob count between 0..max) Co-Authored-By: Jimmy Chen <[email protected]> Co-Authored-By: Jimmy Chen <[email protected]>
1 parent 2c1f1c1 commit 1bd4ac2

File tree

1 file changed

+13
-20
lines changed
  • beacon_node/network/src/network_beacon_processor

1 file changed

+13
-20
lines changed

beacon_node/network/src/network_beacon_processor/tests.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -916,36 +916,29 @@ async fn data_column_reconstruction_at_deadline() {
916916
.start_of(rig.next_block.slot())
917917
.unwrap();
918918

919-
rig.chain
920-
.slot_clock
921-
.set_current_time(slot_start - rig.chain.spec.maximum_gossip_clock_disparity());
922-
923-
assert_eq!(
924-
rig.chain.slot().unwrap(),
925-
rig.next_block.slot() - 1,
926-
"chain should be at the correct slot"
927-
);
928-
929919
// We push the slot clock to 3 seconds into the slot, this is the deadline to trigger reconstruction.
920+
let slot_duration = rig.chain.slot_clock.slot_duration().as_millis() as u64;
921+
let reconstruction_deadline_millis =
922+
(slot_duration * RECONSTRUCTION_DEADLINE.0) / RECONSTRUCTION_DEADLINE.1;
930923
rig.chain
931924
.slot_clock
932-
.set_current_time(slot_start + Duration::from_secs(3));
925+
.set_current_time(slot_start + Duration::from_millis(reconstruction_deadline_millis));
933926

934-
let num_data_columns = rig.next_data_columns.as_ref().map(|c| c.len()).unwrap_or(0);
935-
for i in 0..num_data_columns {
927+
let min_columns_for_reconstruction = E::number_of_columns() / 2;
928+
for i in 0..min_columns_for_reconstruction {
936929
rig.enqueue_gossip_data_columns(i);
937930
rig.assert_event_journal_completes(&[WorkType::GossipDataColumnSidecar])
938931
.await;
939932
}
940933

941934
// Since we're at the reconstruction deadline, reconstruction should be triggered immediately
942-
if num_data_columns > 0 {
943-
rig.assert_event_journal_completes_with_timeout(
944-
&[WorkType::ColumnReconstruction],
945-
Duration::from_millis(50),
946-
)
947-
.await;
948-
}
935+
rig.assert_event_journal_with_timeout(
936+
&[WorkType::ColumnReconstruction.into()],
937+
Duration::from_millis(50),
938+
false,
939+
false,
940+
)
941+
.await;
949942
}
950943

951944
// Test the column reconstruction is delayed for columns that arrive for a previous slot.

0 commit comments

Comments
 (0)