From dcb507ca18fa96792570c2ebae94efaa448d6968 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 5 Feb 2019 03:51:24 +1100 Subject: [PATCH] Remove unused errors from genesis crate --- eth2/genesis/src/beacon_state.rs | 42 +++++++------------------------- eth2/genesis/src/lib.rs | 2 +- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/eth2/genesis/src/beacon_state.rs b/eth2/genesis/src/beacon_state.rs index 7d7cc7665..4ccb32e54 100644 --- a/eth2/genesis/src/beacon_state.rs +++ b/eth2/genesis/src/beacon_state.rs @@ -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 { - /* - * 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 { */ latest_eth1_data: spec.intial_eth1_data.clone(), eth1_data_votes: vec![], - }) -} - -impl From 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()); diff --git a/eth2/genesis/src/lib.rs b/eth2/genesis/src/lib.rs index 003e66959..295bdbd3c 100644 --- a/eth2/genesis/src/lib.rs +++ b/eth2/genesis/src/lib.rs @@ -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;