mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-31 21:27:12 +00:00
Unify EthSpecs in Mainnet and Minimal
This commit is contained in:
@@ -3,10 +3,10 @@ use criterion::{criterion_group, criterion_main, Benchmark};
|
||||
use fork_choice::{test_utils::TestingForkChoiceBuilder, ForkChoice, OptimizedLMDGhost};
|
||||
use std::sync::Arc;
|
||||
use store::MemoryStore;
|
||||
use types::{ChainSpec, EthSpec, FoundationEthSpec};
|
||||
use types::{ChainSpec, EthSpec, MainnetEthSpec};
|
||||
|
||||
pub type TestedForkChoice<T, U> = OptimizedLMDGhost<T, U>;
|
||||
pub type TestedEthSpec = FoundationEthSpec;
|
||||
pub type TestedEthSpec = MainnetEthSpec;
|
||||
|
||||
/// Helper function to setup a builder and spec.
|
||||
fn setup(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use fork_choice::{test_utils::TestingForkChoiceBuilder, ForkChoice, OptimizedLMDGhost};
|
||||
use std::sync::Arc;
|
||||
use store::{MemoryStore, Store};
|
||||
use types::{BeaconBlock, ChainSpec, EthSpec, FoundationEthSpec, Hash256};
|
||||
use types::{BeaconBlock, ChainSpec, EthSpec, Hash256, MainnetEthSpec};
|
||||
|
||||
fn main() {
|
||||
let validator_count = 16;
|
||||
@@ -9,15 +9,15 @@ fn main() {
|
||||
let repetitions = 50;
|
||||
|
||||
let store = MemoryStore::open();
|
||||
let builder: TestingForkChoiceBuilder<MemoryStore, FoundationEthSpec> =
|
||||
let builder: TestingForkChoiceBuilder<MemoryStore, MainnetEthSpec> =
|
||||
TestingForkChoiceBuilder::new(validator_count, chain_length, Arc::new(store));
|
||||
|
||||
let fork_choosers: Vec<OptimizedLMDGhost<MemoryStore, FoundationEthSpec>> = (0..repetitions)
|
||||
let fork_choosers: Vec<OptimizedLMDGhost<MemoryStore, MainnetEthSpec>> = (0..repetitions)
|
||||
.into_iter()
|
||||
.map(|_| builder.build())
|
||||
.collect();
|
||||
|
||||
let spec = &FoundationEthSpec::default_spec();
|
||||
let spec = &MainnetEthSpec::default_spec();
|
||||
|
||||
println!("Running {} times...", repetitions);
|
||||
for fc in fork_choosers {
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||
use store::Store;
|
||||
use types::{
|
||||
test_utils::{SeedableRng, TestRandom, TestingBeaconStateBuilder, XorShiftRng},
|
||||
BeaconBlock, BeaconState, EthSpec, FoundationEthSpec, Hash256, Keypair,
|
||||
BeaconBlock, BeaconState, EthSpec, Hash256, Keypair, MainnetEthSpec,
|
||||
};
|
||||
|
||||
/// Creates a chain of blocks and produces `ForkChoice` instances with pre-filled stores.
|
||||
@@ -16,11 +16,8 @@ pub struct TestingForkChoiceBuilder<S, E> {
|
||||
|
||||
impl<S: Store, E: EthSpec> TestingForkChoiceBuilder<S, E> {
|
||||
pub fn new(validator_count: usize, chain_length: usize, store: Arc<S>) -> Self {
|
||||
let chain = get_chain_of_blocks::<FoundationEthSpec, S>(
|
||||
chain_length,
|
||||
validator_count,
|
||||
store.clone(),
|
||||
);
|
||||
let chain =
|
||||
get_chain_of_blocks::<MainnetEthSpec, S>(chain_length, validator_count, store.clone());
|
||||
|
||||
Self {
|
||||
store,
|
||||
|
||||
@@ -11,7 +11,7 @@ use std::sync::Arc;
|
||||
use std::{fs::File, io::prelude::*, path::PathBuf};
|
||||
use types::test_utils::TestingBeaconStateBuilder;
|
||||
use types::{
|
||||
BeaconBlock, BeaconBlockBody, Eth1Data, EthSpec, FoundationEthSpec, Hash256, Keypair, Slot,
|
||||
BeaconBlock, BeaconBlockBody, Eth1Data, EthSpec, Hash256, Keypair, MainnetEthSpec, Slot,
|
||||
};
|
||||
use yaml_rust::yaml;
|
||||
|
||||
@@ -22,7 +22,7 @@ fn test_optimized_lmd_ghost() {
|
||||
// set up logging
|
||||
// Builder::from_env(Env::default().default_filter_or("trace")).init();
|
||||
|
||||
test_yaml_vectors::<OptimizedLMDGhost<MemoryStore, FoundationEthSpec>>(
|
||||
test_yaml_vectors::<OptimizedLMDGhost<MemoryStore, MainnetEthSpec>>(
|
||||
"tests/lmd_ghost_test_vectors.yaml",
|
||||
100,
|
||||
);
|
||||
@@ -33,7 +33,7 @@ fn test_bitwise_lmd_ghost() {
|
||||
// set up logging
|
||||
//Builder::from_env(Env::default().default_filter_or("trace")).init();
|
||||
|
||||
test_yaml_vectors::<BitwiseLMDGhost<MemoryStore, FoundationEthSpec>>(
|
||||
test_yaml_vectors::<BitwiseLMDGhost<MemoryStore, MainnetEthSpec>>(
|
||||
"tests/bitwise_lmd_ghost_test_vectors.yaml",
|
||||
100,
|
||||
);
|
||||
@@ -41,7 +41,7 @@ fn test_bitwise_lmd_ghost() {
|
||||
|
||||
#[test]
|
||||
fn test_slow_lmd_ghost() {
|
||||
test_yaml_vectors::<SlowLMDGhost<MemoryStore, FoundationEthSpec>>(
|
||||
test_yaml_vectors::<SlowLMDGhost<MemoryStore, MainnetEthSpec>>(
|
||||
"tests/lmd_ghost_test_vectors.yaml",
|
||||
100,
|
||||
);
|
||||
@@ -61,7 +61,7 @@ fn test_yaml_vectors<T: ForkChoice<MemoryStore>>(
|
||||
let test_cases = load_test_cases_from_yaml(yaml_file_path);
|
||||
|
||||
// default vars
|
||||
let spec = FoundationEthSpec::default_spec();
|
||||
let spec = MainnetEthSpec::default_spec();
|
||||
let zero_hash = Hash256::zero();
|
||||
let eth1_data = Eth1Data {
|
||||
deposit_count: 0,
|
||||
@@ -204,9 +204,9 @@ where
|
||||
let store = Arc::new(MemoryStore::open());
|
||||
|
||||
let fork_choice = ForkChoice::new(store.clone());
|
||||
let spec = FoundationEthSpec::default_spec();
|
||||
let spec = MainnetEthSpec::default_spec();
|
||||
|
||||
let mut state_builder: TestingBeaconStateBuilder<FoundationEthSpec> =
|
||||
let mut state_builder: TestingBeaconStateBuilder<MainnetEthSpec> =
|
||||
TestingBeaconStateBuilder::from_single_keypair(num_validators, &Keypair::random(), &spec);
|
||||
state_builder.build_caches(&spec).unwrap();
|
||||
let (state, _keypairs) = state_builder.build();
|
||||
|
||||
Reference in New Issue
Block a user