mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-25 21:17:17 +00:00
Remove unused errors from genesis crate
This commit is contained in:
parent
cb85fbcdb2
commit
dcb507ca18
@ -1,30 +1,12 @@
|
||||
use types::{BeaconState, ChainSpec, Crosslink, Fork};
|
||||
use validator_shuffling::{shard_and_committees_for_cycle, ValidatorAssignmentError};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {
|
||||
NoValidators,
|
||||
ValidationAssignmentError(ValidatorAssignmentError),
|
||||
NotImplemented,
|
||||
}
|
||||
|
||||
pub fn genesis_beacon_state(spec: &ChainSpec) -> Result<BeaconState, Error> {
|
||||
/*
|
||||
* Assign the validators to shards, using all zeros as the seed.
|
||||
*/
|
||||
let _shard_and_committee_for_slots = {
|
||||
let mut a = shard_and_committees_for_cycle(&[0; 32], &spec.initial_validators, 0, &spec)?;
|
||||
let mut b = a.clone();
|
||||
a.append(&mut b);
|
||||
a
|
||||
};
|
||||
|
||||
pub fn genesis_beacon_state(spec: &ChainSpec) -> BeaconState {
|
||||
let initial_crosslink = Crosslink {
|
||||
slot: spec.genesis_slot,
|
||||
shard_block_root: spec.zero_hash,
|
||||
};
|
||||
|
||||
Ok(BeaconState {
|
||||
BeaconState {
|
||||
/*
|
||||
* Misc
|
||||
*/
|
||||
@ -81,12 +63,6 @@ pub fn genesis_beacon_state(spec: &ChainSpec) -> Result<BeaconState, Error> {
|
||||
*/
|
||||
latest_eth1_data: spec.intial_eth1_data.clone(),
|
||||
eth1_data_votes: vec![],
|
||||
})
|
||||
}
|
||||
|
||||
impl From<ValidatorAssignmentError> for Error {
|
||||
fn from(e: ValidatorAssignmentError) -> Error {
|
||||
Error::ValidationAssignmentError(e)
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +75,7 @@ mod tests {
|
||||
fn test_genesis_state() {
|
||||
let spec = ChainSpec::foundation();
|
||||
|
||||
let state = genesis_beacon_state(&spec).unwrap();
|
||||
let state = genesis_beacon_state(&spec);
|
||||
|
||||
assert_eq!(
|
||||
state.validator_registry.len(),
|
||||
@ -111,7 +87,7 @@ mod tests {
|
||||
fn test_genesis_state_misc() {
|
||||
let spec = ChainSpec::foundation();
|
||||
|
||||
let state = genesis_beacon_state(&spec).unwrap();
|
||||
let state = genesis_beacon_state(&spec);
|
||||
|
||||
assert_eq!(state.slot, 0);
|
||||
assert_eq!(state.genesis_time, spec.genesis_time);
|
||||
@ -124,7 +100,7 @@ mod tests {
|
||||
fn test_genesis_state_validators() {
|
||||
let spec = ChainSpec::foundation();
|
||||
|
||||
let state = genesis_beacon_state(&spec).unwrap();
|
||||
let state = genesis_beacon_state(&spec);
|
||||
|
||||
assert_eq!(state.validator_registry, spec.initial_validators);
|
||||
assert_eq!(state.validator_balances, spec.initial_balances);
|
||||
@ -137,7 +113,7 @@ mod tests {
|
||||
fn test_genesis_state_randomness_committees() {
|
||||
let spec = ChainSpec::foundation();
|
||||
|
||||
let state = genesis_beacon_state(&spec).unwrap();
|
||||
let state = genesis_beacon_state(&spec);
|
||||
|
||||
// Array of size 8,192 each being zero_hash
|
||||
assert_eq!(state.latest_randao_mixes.len(), 8_192);
|
||||
@ -166,7 +142,7 @@ mod tests {
|
||||
fn test_genesis_state_finanilty() {
|
||||
let spec = ChainSpec::foundation();
|
||||
|
||||
let state = genesis_beacon_state(&spec).unwrap();
|
||||
let state = genesis_beacon_state(&spec);
|
||||
|
||||
assert_eq!(state.previous_justified_slot, 0);
|
||||
assert_eq!(state.justified_slot, 0);
|
||||
@ -178,7 +154,7 @@ mod tests {
|
||||
fn test_genesis_state_recent_state() {
|
||||
let spec = ChainSpec::foundation();
|
||||
|
||||
let state = genesis_beacon_state(&spec).unwrap();
|
||||
let state = genesis_beacon_state(&spec);
|
||||
|
||||
// Test latest_crosslinks
|
||||
assert_eq!(state.latest_crosslinks.len(), 1_024);
|
||||
@ -210,7 +186,7 @@ mod tests {
|
||||
fn test_genesis_state_deposit_root() {
|
||||
let spec = ChainSpec::foundation();
|
||||
|
||||
let state = genesis_beacon_state(&spec).unwrap();
|
||||
let state = genesis_beacon_state(&spec);
|
||||
|
||||
assert_eq!(&state.latest_eth1_data, &spec.intial_eth1_data);
|
||||
assert!(state.eth1_data_votes.is_empty());
|
||||
|
@ -2,4 +2,4 @@ mod beacon_block;
|
||||
mod beacon_state;
|
||||
|
||||
pub use crate::beacon_block::genesis_beacon_block;
|
||||
pub use crate::beacon_state::{genesis_beacon_state, Error as GenesisError};
|
||||
pub use crate::beacon_state::genesis_beacon_state;
|
||||
|
Loading…
Reference in New Issue
Block a user