mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Add beacon state test builder, tidy errors
This commit is contained in:
@@ -5,7 +5,7 @@ use ssz::TreeHash;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::iter::FromIterator;
|
||||
use types::{
|
||||
beacon_state::{AttestationParticipantsError, CommitteesError, InclusionError},
|
||||
beacon_state::{AttestationParticipantsError, BeaconStateError, InclusionError},
|
||||
validator_registry::get_active_validator_indices,
|
||||
BeaconState, ChainSpec, Crosslink, Epoch, Hash256, PendingAttestation,
|
||||
};
|
||||
@@ -27,7 +27,7 @@ pub enum Error {
|
||||
NoBlockRoots,
|
||||
BaseRewardQuotientIsZero,
|
||||
NoRandaoSeed,
|
||||
CommitteesError(CommitteesError),
|
||||
BeaconStateError(BeaconStateError),
|
||||
AttestationParticipantsError(AttestationParticipantsError),
|
||||
InclusionError(InclusionError),
|
||||
WinningRootError(WinningRootError),
|
||||
@@ -559,9 +559,7 @@ impl EpochProcessable for BeaconState {
|
||||
self.current_epoch_start_shard = (self.current_epoch_start_shard
|
||||
+ self.get_current_epoch_committee_count(spec) as u64)
|
||||
% spec.shard_count;
|
||||
self.current_epoch_seed = self
|
||||
.generate_seed(self.current_calculation_epoch, spec)
|
||||
.ok_or_else(|| Error::NoRandaoSeed)?;
|
||||
self.current_epoch_seed = self.generate_seed(self.current_calculation_epoch, spec)?
|
||||
} else {
|
||||
let epochs_since_last_registry_update =
|
||||
current_epoch - self.validator_registry_update_epoch;
|
||||
@@ -569,9 +567,8 @@ impl EpochProcessable for BeaconState {
|
||||
& epochs_since_last_registry_update.is_power_of_two()
|
||||
{
|
||||
self.current_calculation_epoch = next_epoch;
|
||||
self.current_epoch_seed = self
|
||||
.generate_seed(self.current_calculation_epoch, spec)
|
||||
.ok_or_else(|| Error::NoRandaoSeed)?;
|
||||
self.current_epoch_seed =
|
||||
self.generate_seed(self.current_calculation_epoch, spec)?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,9 +686,9 @@ impl From<InclusionError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CommitteesError> for Error {
|
||||
fn from(e: CommitteesError) -> Error {
|
||||
Error::CommitteesError(e)
|
||||
impl From<BeaconStateError> for Error {
|
||||
fn from(e: BeaconStateError) -> Error {
|
||||
Error::BeaconStateError(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user