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

@@ -4,7 +4,7 @@ use bls::Signature;
use log::debug;
use slot_clock::TestingSlotClockError;
use types::{
beacon_state::CommitteesError,
beacon_state::SlotProcessingError,
readers::{BeaconBlockReader, BeaconStateReader},
BeaconBlock, BeaconBlockBody, BeaconState, Eth1Data, Hash256,
};
@@ -14,7 +14,7 @@ pub enum Error {
DBError(String),
StateTransitionError(TransitionError),
PresentSlotIsNone,
CommitteesError(CommitteesError),
SlotProcessingError(SlotProcessingError),
}
impl<T, U> BeaconChain<T, U>
@@ -116,8 +116,8 @@ impl From<TestingSlotClockError> for Error {
}
}
impl From<CommitteesError> for Error {
fn from(e: CommitteesError) -> Error {
Error::CommitteesError(e)
impl From<SlotProcessingError> for Error {
fn from(e: SlotProcessingError) -> Error {
Error::SlotProcessingError(e)
}
}

View File

@@ -1,11 +1,11 @@
use crate::{BeaconChain, CheckPoint, ClientDB, SlotClock};
use std::sync::RwLockReadGuard;
use types::{beacon_state::CommitteesError, BeaconBlock, BeaconState, Hash256};
use types::{beacon_state::SlotProcessingError, BeaconBlock, BeaconState, Hash256};
#[derive(Debug, PartialEq)]
pub enum Error {
PastSlot,
CommitteesError(CommitteesError),
SlotProcessingError(SlotProcessingError),
}
impl<T, U> BeaconChain<T, U>
@@ -64,8 +64,8 @@ where
}
}
impl From<CommitteesError> for Error {
fn from(e: CommitteesError) -> Error {
Error::CommitteesError(e)
impl From<SlotProcessingError> for Error {
fn from(e: SlotProcessingError) -> Error {
Error::SlotProcessingError(e)
}
}

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)
}
}