fix clock drift for assignments issued before the block (#3851)

* fix clock drift for assignments issued before the block

* always broadcast tranche 0 assignments

* Update tests

* Change from min to max

* Remove erronious print statement

* guide: require fixed approval delay

* prevent approval by very recent assignments

* fix approval-checking tests

* fix main approval tests

* Fix tests

* Fix looked over test

* fix test

Co-authored-by: Lldenaurois <Ljdenaurois@gmail.com>
This commit is contained in:
Robert Habermeier
2021-10-03 21:41:06 +02:00
committed by GitHub
parent 6d83b59944
commit a19ef45e5e
2 changed files with 38 additions and 28 deletions
+12 -13
View File
@@ -1609,7 +1609,7 @@ fn subsystem_process_wakeup_schedules_wakeup() {
futures_timer::Delay::new(Duration::from_millis(100)).await;
// The wakeup should have been rescheduled.
assert!(clock.inner.lock().current_wakeup_is(20));
assert!(clock.inner.lock().current_wakeup_is(30));
virtual_overseer
});
@@ -2234,8 +2234,8 @@ fn subsystem_process_wakeup_trigger_assignment_launch_approval() {
futures_timer::Delay::new(Duration::from_millis(200)).await;
assert!(clock.inner.lock().current_wakeup_is(slot_to_tick(slot + 1)));
clock.inner.lock().wakeup_all(slot_to_tick(slot + 1));
assert!(clock.inner.lock().current_wakeup_is(slot_to_tick(slot + 2)));
clock.inner.lock().wakeup_all(slot_to_tick(slot + 2));
assert_matches!(
overseer_recv(&mut virtual_overseer).await,
@@ -2467,7 +2467,7 @@ fn subsystem_assignment_triggered_by_all_with_less_than_threshold() {
approvals_to_import: vec![2, 4],
ticks: vec![
2, // APPROVAL_DELAY
20, // Check for no shows
21, // Check for no shows
],
should_be_triggered: |t| t == 20,
});
@@ -2483,7 +2483,7 @@ fn subsystem_assignment_not_triggered_by_all_with_threshold() {
approvals_to_import: vec![1, 3, 5],
ticks: vec![
2, // APPROVAL_DELAY
20, // Check no shows
21, // Check no shows
],
should_be_triggered: |_| false,
});
@@ -2498,8 +2498,8 @@ fn subsystem_assignment_triggered_if_below_maximum_and_clock_is_equal() {
assignments_to_import: vec![1],
approvals_to_import: vec![],
ticks: vec![
20, // Check no shows
21, // Alice wakeup, assignment triggered
21, // Check no shows
23, // Alice wakeup, assignment triggered
],
should_be_triggered: |tick| tick >= 21,
});
@@ -2516,7 +2516,7 @@ fn subsystem_assignment_not_triggered_more_than_maximum() {
ticks: vec![
2, // APPROVAL_DELAY
13, // Alice wakeup
20, // Check no shows
30, // Check no shows
],
should_be_triggered: |_| false,
});
@@ -2524,16 +2524,15 @@ fn subsystem_assignment_not_triggered_more_than_maximum() {
#[test]
fn subsystem_assignment_triggered_if_at_maximum() {
// TODO(ladi): is this possible?
triggers_assignment_test(TriggersAssignmentConfig {
our_assigned_tranche: 11,
our_assigned_tranche: 21,
assign_validator_tranche: |_| Ok(2),
no_show_slots: 2,
assignments_to_import: vec![1],
approvals_to_import: vec![],
ticks: vec![
12, // Bob wakeup
20, // Check no shows
30, // Check no shows
],
should_be_triggered: |_| false,
});
@@ -2583,7 +2582,7 @@ fn subsystem_assignment_not_triggered_if_at_maximum_but_clock_is_before_with_dri
12, // Charlie wakeup
13, // Dave wakeup
15, // Alice wakeup, noop
20, // Check no shows
30, // Check no shows
34, // Eve wakeup
],
should_be_triggered: |_| false,
@@ -2755,7 +2754,7 @@ fn pre_covers_dont_stall_approval() {
// Wait for the no-show timer to observe the approval from
// tranche 0 and set a wakeup for tranche 1.
clock.inner.lock().set_tick(20);
clock.inner.lock().set_tick(30);
// Sleep to ensure we get a consistent read on the database.
futures_timer::Delay::new(Duration::from_millis(100)).await;