commonware-glue 2026.9.0

Default constructions that span multiple primitives.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
use super::harness::{
    CommitteeSchedule, Registration, RegistrationRole, ValidatorState, final_height,
};
use crate::{
    dkg::{
        ReshareBlock,
        types::{EpochOutcome, Payload},
    },
    simulate::{
        exit::ExitCondition, processed::ProcessedHeight, property::Property,
        tracker::ProgressTracker,
    },
};
use commonware_codec::{Encode as _, FixedSize};
use commonware_consensus::types::{Epoch, Height};
use commonware_cryptography::{bls12381::primitives::variant::MinPk, ed25519, transcript::Summary};
use commonware_utils::sync::Mutex;
use std::{collections::BTreeMap, future::Future, pin::Pin, sync::Arc};

#[derive(Clone)]
pub(super) struct AllActiveProcessedHeight {
    required: Height,
    participants: usize,
}

impl AllActiveProcessedHeight {
    pub(super) const fn new(required: Height, participants: usize) -> Self {
        Self {
            required,
            participants,
        }
    }
}

impl ExitCondition<ed25519::PublicKey, ValidatorState> for AllActiveProcessedHeight {
    fn name(&self) -> &str {
        "all_active_processed_height"
    }

    fn requires_polling(&self) -> bool {
        true
    }

    fn reached<'a>(
        &'a self,
        _tracker: &'a ProgressTracker<ed25519::PublicKey>,
        states: &'a [&'a ValidatorState],
        _target_count: usize,
    ) -> Pin<Box<dyn Future<Output = Result<bool, String>> + Send + 'a>> {
        Box::pin(async move {
            if states.len() != self.participants {
                return Ok(false);
            }
            for state in states {
                if state.processed_height().await < self.required.get() {
                    return Ok(false);
                }
            }
            Ok(true)
        })
    }
}

#[derive(Clone)]
pub(super) struct SignerRegistered;

impl Property<ed25519::PublicKey, ValidatorState> for SignerRegistered {
    fn name(&self) -> &str {
        "signer_registered"
    }

    fn check<'a>(
        &'a self,
        _tracker: &'a ProgressTracker<ed25519::PublicKey>,
        states: &'a [&'a ValidatorState],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>> {
        Box::pin(async move {
            let found = states.iter().any(|state| {
                state
                    .registrations()
                    .iter()
                    .any(|registration| registration.role == RegistrationRole::Signer)
            });
            if found {
                Ok(())
            } else {
                Err("no node registered a signing scheme".to_string())
            }
        })
    }
}

#[derive(Clone)]
pub(super) struct BoundaryEpochInfos {
    epochs: u64,
    no_reveals: bool,
    min_successes: u64,
    expected_failures: Vec<u64>,
}

impl BoundaryEpochInfos {
    pub(super) const fn new(epochs: u64) -> Self {
        Self {
            epochs,
            no_reveals: false,
            min_successes: epochs,
            expected_failures: Vec::new(),
        }
    }

    pub(super) const fn with_no_reveals(mut self) -> Self {
        self.no_reveals = true;
        self
    }

    pub(super) const fn with_min_successes(mut self, min_successes: u64) -> Self {
        self.min_successes = min_successes;
        self
    }

    pub(super) fn with_expected_failures(
        mut self,
        failures: impl IntoIterator<Item = u64>,
    ) -> Self {
        self.expected_failures = failures.into_iter().collect();
        self
    }
}

impl Property<ed25519::PublicKey, ValidatorState> for BoundaryEpochInfos {
    fn name(&self) -> &str {
        "boundary_epoch_infos"
    }

    fn check<'a>(
        &'a self,
        _tracker: &'a ProgressTracker<ed25519::PublicKey>,
        states: &'a [&'a ValidatorState],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>> {
        Box::pin(async move {
            for state in states {
                let mut checked = 0;
                let mut successes = 0;
                let mut expected_failures = 0;
                let state_sync_height = state.state_sync_height();
                for epoch in 0..self.epochs {
                    let height = final_height(epoch);
                    if state_sync_height.is_some_and(|synced| height.get() < synced) {
                        continue;
                    }
                    checked += 1;
                    let expect_failure = self.expected_failures.contains(&epoch);
                    if expect_failure {
                        expected_failures += 1;
                    }
                    let Some(block) = state.marshal.get_block(height).await else {
                        return Err(format!(
                            "missing finalized boundary block at height {height}"
                        ));
                    };
                    match block.payload() {
                        Some(Payload::EpochInfo(info)) if info.epoch == Epoch::new(epoch + 1) => {
                            if info.outcome == EpochOutcome::Success {
                                if expect_failure {
                                    return Err(format!(
                                        "boundary at height {height} succeeded, expected failure"
                                    ));
                                }
                                successes += 1;
                                if self.no_reveals && !info.output.revealed().is_empty() {
                                    return Err(format!(
                                        "epoch {epoch} revealed {} shares",
                                        info.output.revealed().len()
                                    ));
                                }
                                continue;
                            }
                            if expect_failure {
                                continue;
                            }
                            if self.min_successes == self.epochs {
                                return Err(format!(
                                    "boundary at height {height} carried epoch info {:?}",
                                    info.outcome
                                ));
                            }
                        }
                        Some(Payload::EpochInfo(info)) => {
                            return Err(format!(
                                "boundary at height {height} carried epoch info for {}, expected {}",
                                info.epoch,
                                Epoch::new(epoch + 1)
                            ));
                        }
                        Some(_) => {
                            return Err(format!(
                                "boundary at height {height} carried non-epoch-info DKG payload"
                            ));
                        }
                        None => {
                            return Err(format!(
                                "boundary at height {height} carried no DKG payload"
                            ));
                        }
                    }
                }
                let required = if !self.expected_failures.is_empty() {
                    checked - expected_failures
                } else if self.min_successes == self.epochs {
                    checked
                } else {
                    self.min_successes.min(checked)
                };
                if successes < required {
                    return Err(format!(
                        "observed {successes} successful epochs, expected at least {required}"
                    ));
                }
            }
            Ok(())
        })
    }
}

#[derive(Clone)]
pub(super) struct EpochInfoContinuity {
    epochs: u64,
    schedule: Arc<CommitteeSchedule>,
}

impl EpochInfoContinuity {
    pub(super) const fn new(epochs: u64, schedule: Arc<CommitteeSchedule>) -> Self {
        Self { epochs, schedule }
    }
}

impl Property<ed25519::PublicKey, ValidatorState> for EpochInfoContinuity {
    fn name(&self) -> &str {
        "epoch_info_continuity"
    }

    fn check<'a>(
        &'a self,
        _tracker: &'a ProgressTracker<ed25519::PublicKey>,
        states: &'a [&'a ValidatorState],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>> {
        Box::pin(async move {
            for epoch in 0..self.epochs {
                let previous_height = Epoch::new(epoch)
                    .previous()
                    .map(|epoch| final_height(epoch.get()))
                    .unwrap_or(Height::zero());
                let previous = boundary_info(states, previous_height).await?;

                let height = final_height(epoch);
                let info = boundary_info(states, height).await?;
                let expected_epoch = Epoch::new(epoch + 1);
                if info.epoch != expected_epoch {
                    return Err(format!(
                        "boundary at height {height} carried epoch info for {}, expected {expected_epoch}",
                        info.epoch
                    ));
                }
                if info.players != previous.next_players {
                    return Err(format!(
                        "boundary at height {height} players did not match previous next players"
                    ));
                }
                let expected_next_players = self.schedule.players(expected_epoch.next());
                if info.next_players != expected_next_players {
                    return Err(format!(
                        "boundary at height {height} next players did not match schedule for {}",
                        expected_epoch.next()
                    ));
                }

                match info.outcome {
                    EpochOutcome::Success => {
                        if info.output.players() != &previous.players {
                            return Err(format!(
                                "successful boundary at height {height} output players did not match previous players"
                            ));
                        }
                    }
                    EpochOutcome::Failure => {
                        if info.output != previous.output {
                            return Err(format!(
                                "failed boundary at height {height} did not carry forward output"
                            ));
                        }
                    }
                }
            }
            Ok(())
        })
    }
}

async fn boundary_info(
    states: &[&ValidatorState],
    height: Height,
) -> Result<
    crate::dkg::types::EpochInfo<MinPk, ed25519::PublicKey, super::harness::TestDirectory>,
    String,
> {
    for state in states {
        let Some(block) = state.marshal.get_block(height).await else {
            continue;
        };
        let Some(Payload::EpochInfo(info)) = block.payload() else {
            return Err(format!(
                "boundary at height {height} did not carry epoch info"
            ));
        };
        return Ok(info);
    }
    Err(format!(
        "missing finalized boundary block at height {height}"
    ))
}

#[derive(Clone)]
pub(super) struct BoundaryOutputMode {
    epoch: Epoch,
    mode: u8,
}

impl BoundaryOutputMode {
    pub(super) const fn new(epoch: Epoch, mode: u8) -> Self {
        Self { epoch, mode }
    }
}

impl Property<ed25519::PublicKey, ValidatorState> for BoundaryOutputMode {
    fn name(&self) -> &str {
        "boundary_output_mode"
    }

    fn check<'a>(
        &'a self,
        _tracker: &'a ProgressTracker<ed25519::PublicKey>,
        states: &'a [&'a ValidatorState],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>> {
        Box::pin(async move {
            let height = final_height(self.epoch.get());
            let info = boundary_info(states, height).await?;

            let encoded = info.output.encode();
            let Some(mode) = encoded.get(<Summary as FixedSize>::SIZE).copied() else {
                return Err("encoded output missing sharing mode".to_string());
            };
            if mode != self.mode {
                return Err(format!(
                    "boundary at height {height} used sharing mode {mode}, expected {}",
                    self.mode
                ));
            }
            Ok(())
        })
    }
}

#[derive(Clone)]
pub(super) struct FailedCeremonyCarryOver {
    epoch: Epoch,
    schedule: CommitteeSchedule,
}

impl FailedCeremonyCarryOver {
    pub(super) const fn new(epoch: Epoch, schedule: CommitteeSchedule) -> Self {
        Self { epoch, schedule }
    }
}

impl Property<ed25519::PublicKey, ValidatorState> for FailedCeremonyCarryOver {
    fn name(&self) -> &str {
        "failed_ceremony_carry_over"
    }

    fn check<'a>(
        &'a self,
        _tracker: &'a ProgressTracker<ed25519::PublicKey>,
        states: &'a [&'a ValidatorState],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>> {
        Box::pin(async move {
            // The previous boundary may predate a node's state-sync floor and
            // be absent from its marshal, so read it from whichever node
            // retains it.
            let previous_height = self
                .epoch
                .previous()
                .map(|epoch| final_height(epoch.get()))
                .unwrap_or(Height::zero());
            let previous = boundary_info(states, previous_height).await?;

            // The carry-over boundary itself must be visible to a state-synced
            // node whose floor covers it: demand that node's view of the
            // boundary rather than falling back to a peer that retains it.
            let height = final_height(self.epoch.get());
            let synced = states.iter().find(|state| {
                state
                    .state_sync_height()
                    .is_some_and(|floor| floor <= height.get())
            });
            let info = match synced {
                Some(synced) => {
                    let Some(block) = synced.marshal.get_block(height).await else {
                        return Err(format!(
                            "state-synced node missing boundary block at height {height}"
                        ));
                    };
                    let Some(Payload::EpochInfo(info)) = block.payload() else {
                        return Err(format!(
                            "boundary at height {height} did not carry epoch info"
                        ));
                    };
                    info
                }
                None => boundary_info(states, height).await?,
            };

            let expected_epoch = self.epoch.next();
            if info.epoch != expected_epoch {
                return Err(format!(
                    "boundary at height {height} carried epoch info for {}, expected {expected_epoch}",
                    info.epoch
                ));
            }
            if info.outcome != EpochOutcome::Failure {
                return Err(format!(
                    "boundary at height {height} carried {:?}, expected failure",
                    info.outcome
                ));
            }
            if info.output != previous.output {
                return Err("failed ceremony did not carry forward output".to_string());
            }
            if info.players != previous.next_players {
                return Err("failed ceremony did not advance to previous next players".to_string());
            }
            let expected_next_players = self.schedule.players(expected_epoch.next());
            if info.next_players != expected_next_players {
                return Err(format!(
                    "failed ceremony did not refresh next players for {}",
                    expected_epoch.next()
                ));
            }

            for state in states {
                let expected = if previous
                    .output
                    .players()
                    .position(state.public_key())
                    .is_some()
                {
                    RegistrationRole::Signer
                } else {
                    RegistrationRole::Verifier
                };
                let registrations = state.registrations();
                let registered = registrations.iter().any(|registration| {
                    registration.epoch == expected_epoch && registration.role == expected
                });
                if !registered {
                    return Err(format!(
                        "node {} did not register {expected:?} for carried epoch {expected_epoch}: {registrations:?}",
                        state.public_key()
                    ));
                }
            }

            Ok(())
        })
    }
}

#[derive(Clone)]
pub(super) struct AllNodesRecovered {
    public_keys: Vec<ed25519::PublicKey>,
}

impl AllNodesRecovered {
    pub(super) fn new(public_keys: Vec<ed25519::PublicKey>) -> Self {
        Self { public_keys }
    }
}

impl Property<ed25519::PublicKey, ValidatorState> for AllNodesRecovered {
    fn name(&self) -> &str {
        "all_nodes_recovered"
    }

    fn check<'a>(
        &'a self,
        tracker: &'a ProgressTracker<ed25519::PublicKey>,
        states: &'a [&'a ValidatorState],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>> {
        Box::pin(async move {
            if states.len() != self.public_keys.len() {
                return Err(format!(
                    "active states {}, expected {}",
                    states.len(),
                    self.public_keys.len()
                ));
            }
            if tracker.tracked_count() != self.public_keys.len() {
                return Err(format!(
                    "tracker saw {} nodes, expected {}",
                    tracker.tracked_count(),
                    self.public_keys.len()
                ));
            }
            for public_key in &self.public_keys {
                let recovered = states.iter().any(|state| state.public_key() == public_key);
                if !recovered {
                    return Err(format!("node {public_key} was not active at shutdown"));
                }
            }
            Ok(())
        })
    }
}

#[derive(Clone)]
pub(super) struct SchemesRegistered {
    public_keys: Vec<ed25519::PublicKey>,
    epoch: Epoch,
}

impl SchemesRegistered {
    pub(super) fn new(public_keys: Vec<ed25519::PublicKey>, epoch: Epoch) -> Self {
        Self { public_keys, epoch }
    }
}

impl Property<ed25519::PublicKey, ValidatorState> for SchemesRegistered {
    fn name(&self) -> &str {
        "schemes_registered"
    }

    fn check<'a>(
        &'a self,
        _tracker: &'a ProgressTracker<ed25519::PublicKey>,
        states: &'a [&'a ValidatorState],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>> {
        Box::pin(async move {
            let Some(ceremony_epoch) = self.epoch.previous() else {
                return Err("epoch zero has no reshare output".to_string());
            };
            let height = final_height(ceremony_epoch.get());
            let Some(reference) = states.first() else {
                return Err("no active validator states".to_string());
            };
            let Some(block) = reference.marshal.get_block(height).await else {
                return Err(format!(
                    "missing finalized boundary block at height {height}"
                ));
            };
            let Some(Payload::EpochInfo(info)) = block.payload() else {
                return Err(format!(
                    "boundary at height {height} did not carry epoch info"
                ));
            };
            if info.epoch != self.epoch {
                return Err(format!(
                    "boundary at height {height} carried epoch info for {}, expected {}",
                    info.epoch, self.epoch
                ));
            }
            for public_key in &self.public_keys {
                let expected = if info.output.players().position(public_key).is_some() {
                    RegistrationRole::Signer
                } else {
                    RegistrationRole::Verifier
                };
                let Some(registrations) = states
                    .iter()
                    .find(|state| state.public_key() == public_key)
                    .map(|state| state.registrations())
                else {
                    return Err(format!("node {public_key} was not active at shutdown"));
                };
                let registered = registrations.iter().any(|registration| {
                    registration.epoch == self.epoch && registration.role == expected
                });
                if !registered {
                    return Err(format!(
                        "node {public_key} did not register {expected:?} for epoch {}: {registrations:?}",
                        self.epoch
                    ));
                }
            }
            Ok(())
        })
    }
}

#[derive(Clone)]
pub(super) struct StateSyncedSigner {
    public_key: ed25519::PublicKey,
    min_epoch: Epoch,
    registrations: Arc<Mutex<BTreeMap<ed25519::PublicKey, Vec<Registration>>>>,
    state_syncs: Arc<Mutex<BTreeMap<ed25519::PublicKey, u64>>>,
}

impl StateSyncedSigner {
    pub(super) fn new(
        public_key: ed25519::PublicKey,
        min_epoch: Epoch,
        registrations: Arc<Mutex<BTreeMap<ed25519::PublicKey, Vec<Registration>>>>,
        state_syncs: Arc<Mutex<BTreeMap<ed25519::PublicKey, u64>>>,
    ) -> Self {
        Self {
            public_key,
            min_epoch,
            registrations,
            state_syncs,
        }
    }
}

impl Property<ed25519::PublicKey, ValidatorState> for StateSyncedSigner {
    fn name(&self) -> &str {
        "state_synced_signer"
    }

    fn check<'a>(
        &'a self,
        _tracker: &'a ProgressTracker<ed25519::PublicKey>,
        _states: &'a [&'a ValidatorState],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>> {
        Box::pin(async move {
            let state_syncs = self.state_syncs.lock();
            let Some(height) = state_syncs.get(&self.public_key).copied() else {
                let keys = state_syncs.keys().cloned().collect::<Vec<_>>();
                return Err(format!(
                    "node {} did not state sync, recorded syncs: {keys:?}",
                    self.public_key
                ));
            };
            let signed = self
                .registrations
                .lock()
                .get(&self.public_key)
                .into_iter()
                .flatten()
                .any(|registration| {
                    registration.role == RegistrationRole::Signer
                        && registration.epoch >= self.min_epoch
                });
            if signed {
                Ok(())
            } else {
                Err(format!(
                    "node {} state synced at height {height} but never registered as signer at or after epoch {}",
                    self.public_key, self.min_epoch
                ))
            }
        })
    }
}

#[derive(Clone)]
pub(super) struct StateSyncedAtHeight {
    public_key: ed25519::PublicKey,
    min_height: Height,
    max_height: Height,
    state_syncs: Arc<Mutex<BTreeMap<ed25519::PublicKey, u64>>>,
}

impl StateSyncedAtHeight {
    pub(super) const fn new(
        public_key: ed25519::PublicKey,
        min_height: Height,
        max_height: Height,
        state_syncs: Arc<Mutex<BTreeMap<ed25519::PublicKey, u64>>>,
    ) -> Self {
        Self {
            public_key,
            min_height,
            max_height,
            state_syncs,
        }
    }
}

impl Property<ed25519::PublicKey, ValidatorState> for StateSyncedAtHeight {
    fn name(&self) -> &str {
        "state_synced_at_height"
    }

    fn check<'a>(
        &'a self,
        _tracker: &'a ProgressTracker<ed25519::PublicKey>,
        _states: &'a [&'a ValidatorState],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>> {
        Box::pin(async move {
            let state_syncs = self.state_syncs.lock();
            let Some(height) = state_syncs.get(&self.public_key).copied() else {
                return Err(format!("node {} did not state sync", self.public_key));
            };
            if height < self.min_height.get() || height > self.max_height.get() {
                return Err(format!(
                    "node {} state synced at height {height}, expected {}..={}",
                    self.public_key, self.min_height, self.max_height
                ));
            }
            Ok(())
        })
    }
}

#[derive(Clone)]
pub(super) struct StateSyncMembership {
    schedule: Arc<CommitteeSchedule>,
    public_key: ed25519::PublicKey,
    next_player_epoch: Epoch,
}

impl StateSyncMembership {
    pub(super) fn new(
        schedule: Arc<CommitteeSchedule>,
        public_key: ed25519::PublicKey,
        next_player_epoch: Epoch,
    ) -> Self {
        Self {
            schedule,
            public_key,
            next_player_epoch,
        }
    }
}

impl Property<ed25519::PublicKey, ValidatorState> for StateSyncMembership {
    fn name(&self) -> &str {
        "state_sync_membership"
    }

    fn check<'a>(
        &'a self,
        _tracker: &'a ProgressTracker<ed25519::PublicKey>,
        _states: &'a [&'a ValidatorState],
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>> {
        Box::pin(async move {
            let player_epoch = self.next_player_epoch.next();
            if let Some(previous) = self.next_player_epoch.previous()
                && self
                    .schedule
                    .players(previous)
                    .position(&self.public_key)
                    .is_some()
            {
                return Err(format!(
                    "node {} was present before state-sync epoch {}",
                    self.public_key, self.next_player_epoch
                ));
            }
            if self
                .schedule
                .players(self.next_player_epoch)
                .position(&self.public_key)
                .is_some()
            {
                return Err(format!(
                    "node {} was a player in state-sync epoch {}",
                    self.public_key, self.next_player_epoch
                ));
            }
            if self
                .schedule
                .players(player_epoch)
                .position(&self.public_key)
                .is_none()
            {
                return Err(format!(
                    "node {} was not a next player in epoch {}",
                    self.public_key, self.next_player_epoch
                ));
            }
            Ok(())
        })
    }
}