Ensure per_epoch processing always runs.

Previously, it was running _after_ a state transition, not before it
with the slot processing.
This commit is contained in:
Paul Hauner
2019-01-31 16:39:44 +11:00
parent ae39a24e71
commit 8073296f5d
5 changed files with 44 additions and 21 deletions

View File

@@ -5,7 +5,7 @@ use log::debug;
use slot_clock::{SystemTimeSlotClockError, TestingSlotClockError};
use ssz::{ssz_encode, TreeHash};
use types::{
beacon_state::{AttestationValidationError, CommitteesError, EpochProcessingError},
beacon_state::{AttestationValidationError, CommitteesError, SlotProcessingError},
readers::BeaconBlockReader,
BeaconBlock, BeaconState, Exit, Fork, Hash256, PendingAttestation,
};
@@ -52,7 +52,7 @@ pub enum Error {
BadCustodyResponses,
SlotClockError(SystemTimeSlotClockError),
CommitteesError(CommitteesError),
EpochProcessingError(EpochProcessingError),
SlotProcessingError(SlotProcessingError),
}
impl<T, U> BeaconChain<T, U>
@@ -309,10 +309,6 @@ where
Error::BadCustodyResponses
);
if state.slot % self.spec.epoch_length == 0 {
state.per_epoch_processing(&self.spec)?;
}
debug!("State transition complete.");
Ok(state)
@@ -367,8 +363,8 @@ impl From<CommitteesError> for Error {
}
}
impl From<EpochProcessingError> for Error {
fn from(e: EpochProcessingError) -> Error {
Error::EpochProcessingError(e)
impl From<SlotProcessingError> for Error {
fn from(e: SlotProcessingError) -> Error {
Error::SlotProcessingError(e)
}
}