From bd860eb3e155177ca47714e6f9356d42c39eb960 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sun, 31 Mar 2019 15:30:09 +1100 Subject: [PATCH] Fixes bug in epoch processing. - Was using the wrong slot to determine relative epoch. - Added a non-related test I build during the search --- .../src/per_epoch_processing/validator_statuses.rs | 2 +- eth2/types/src/slot_epoch.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/eth2/state_processing/src/per_epoch_processing/validator_statuses.rs b/eth2/state_processing/src/per_epoch_processing/validator_statuses.rs index 50f3ec372..02149cc5a 100644 --- a/eth2/state_processing/src/per_epoch_processing/validator_statuses.rs +++ b/eth2/state_processing/src/per_epoch_processing/validator_statuses.rs @@ -227,7 +227,7 @@ impl ValidatorStatuses { status.is_previous_epoch_attester = true; // The inclusion slot and distance are only required for previous epoch attesters. - let relative_epoch = RelativeEpoch::from_slot(state.slot, a.data.slot, spec)?; + let relative_epoch = RelativeEpoch::from_slot(state.slot, a.inclusion_slot, spec)?; status.inclusion_info = Some(InclusionInfo { slot: a.inclusion_slot, distance: inclusion_distance(a), diff --git a/eth2/types/src/slot_epoch.rs b/eth2/types/src/slot_epoch.rs index c40b6badf..a8c32ef85 100644 --- a/eth2/types/src/slot_epoch.rs +++ b/eth2/types/src/slot_epoch.rs @@ -113,6 +113,16 @@ mod epoch_tests { all_tests!(Epoch); + #[test] + fn epoch_start_end() { + let slots_per_epoch = 8; + + let epoch = Epoch::new(0); + + assert_eq!(epoch.start_slot(slots_per_epoch), Slot::new(0)); + assert_eq!(epoch.end_slot(slots_per_epoch), Slot::new(7)); + } + #[test] fn slot_iter() { let slots_per_epoch = 8;