diff --git a/eth2/fork_choice/src/bitwise_lmd_ghost.rs b/eth2/fork_choice/src/bitwise_lmd_ghost.rs index 66100dbc12..7667b28b74 100644 --- a/eth2/fork_choice/src/bitwise_lmd_ghost.rs +++ b/eth2/fork_choice/src/bitwise_lmd_ghost.rs @@ -34,7 +34,7 @@ fn power_of_2_below(x: u64) -> u64 { } /// Stores the necessary data structures to run the optimised bitwise lmd ghost algorithm. -pub struct BitwiseLMDGhost { +pub struct BitwiseLMDGhost { /// A cache of known ancestors at given heights for a specific block. //TODO: Consider FnvHashMap cache: HashMap, Hash256>, diff --git a/eth2/fork_choice/src/optimized_lmd_ghost.rs b/eth2/fork_choice/src/optimized_lmd_ghost.rs index 3e43e2153b..d2663b2b64 100644 --- a/eth2/fork_choice/src/optimized_lmd_ghost.rs +++ b/eth2/fork_choice/src/optimized_lmd_ghost.rs @@ -34,7 +34,7 @@ fn power_of_2_below(x: u64) -> u64 { } /// Stores the necessary data structures to run the optimised lmd ghost algorithm. -pub struct OptimizedLMDGhost { +pub struct OptimizedLMDGhost { /// A cache of known ancestors at given heights for a specific block. //TODO: Consider FnvHashMap cache: HashMap, Hash256>, diff --git a/eth2/fork_choice/src/slow_lmd_ghost.rs b/eth2/fork_choice/src/slow_lmd_ghost.rs index c621870d15..68c4ac5a68 100644 --- a/eth2/fork_choice/src/slow_lmd_ghost.rs +++ b/eth2/fork_choice/src/slow_lmd_ghost.rs @@ -13,7 +13,7 @@ use types::{BeaconBlock, BeaconState, BeaconStateTypes, ChainSpec, Hash256, Slot //TODO: Pruning and syncing -pub struct SlowLMDGhost { +pub struct SlowLMDGhost { /// The latest attestation targets as a map of validator index to block hash. //TODO: Could this be a fixed size vec latest_attestation_targets: HashMap, diff --git a/eth2/fork_choice/tests/tests.rs b/eth2/fork_choice/tests/tests.rs index fb530ac434..3addb8c0aa 100644 --- a/eth2/fork_choice/tests/tests.rs +++ b/eth2/fork_choice/tests/tests.rs @@ -25,7 +25,10 @@ use std::collections::HashMap; use std::sync::Arc; use std::{fs::File, io::prelude::*, path::PathBuf}; use types::test_utils::TestingBeaconStateBuilder; -use types::{BeaconBlock, BeaconBlockBody, ChainSpec, Eth1Data, Hash256, Keypair, Slot}; +use types::{ + BeaconBlock, BeaconBlockBody, BeaconStateTypes, Eth1Data, FoundationStateTypes, Hash256, + Keypair, Slot, +}; use yaml_rust::yaml; // Note: We Assume the block Id's are hex-encoded. @@ -82,7 +85,7 @@ fn test_yaml_vectors( let test_cases = load_test_cases_from_yaml(yaml_file_path); // default vars - let spec = ChainSpec::foundation(); + let spec = FoundationStateTypes::spec(); let zero_hash = Hash256::zero(); let eth1_data = Eth1Data { deposit_root: zero_hash.clone(), @@ -227,23 +230,27 @@ fn setup_inital_state( // the fork choice instantiation let fork_choice: Box = match fork_choice_algo { - ForkChoiceAlgorithm::OptimizedLMDGhost => Box::new(OptimizedLMDGhost::new( - block_store.clone(), - state_store.clone(), - )), - ForkChoiceAlgorithm::BitwiseLMDGhost => Box::new(BitwiseLMDGhost::new( - block_store.clone(), - state_store.clone(), - )), + ForkChoiceAlgorithm::OptimizedLMDGhost => { + let f: OptimizedLMDGhost = + OptimizedLMDGhost::new(block_store.clone(), state_store.clone()); + Box::new(f) + } + ForkChoiceAlgorithm::BitwiseLMDGhost => { + let f: BitwiseLMDGhost = + BitwiseLMDGhost::new(block_store.clone(), state_store.clone()); + Box::new(f) + } ForkChoiceAlgorithm::SlowLMDGhost => { - Box::new(SlowLMDGhost::new(block_store.clone(), state_store.clone())) + let f: SlowLMDGhost = + SlowLMDGhost::new(block_store.clone(), state_store.clone()); + Box::new(f) } ForkChoiceAlgorithm::LongestChain => Box::new(LongestChain::new(block_store.clone())), }; - let spec = ChainSpec::foundation(); + let spec = FoundationStateTypes::spec(); - let mut state_builder = + let mut state_builder: TestingBeaconStateBuilder = TestingBeaconStateBuilder::from_single_keypair(num_validators, &Keypair::random(), &spec); state_builder.build_caches(&spec).unwrap(); let (state, _keypairs) = state_builder.build();