Unify EthSpecs in Mainnet and Minimal

This commit is contained in:
Paul Hauner
2019-06-08 08:49:04 -04:00
parent caddeba81b
commit 749f2fcb5f
27 changed files with 119 additions and 186 deletions

View File

@@ -82,7 +82,7 @@ impl<T: EthSpec, U: Store> Iterator for BlockRootsIterator<T, U> {
mod test {
use super::*;
use store::MemoryStore;
use types::{test_utils::TestingBeaconStateBuilder, FoundationEthSpec, Keypair};
use types::{test_utils::TestingBeaconStateBuilder, Keypair, MainnetEthSpec};
fn get_state<T: EthSpec>() -> BeaconState<T> {
let builder = TestingBeaconStateBuilder::from_single_keypair(
@@ -97,10 +97,10 @@ mod test {
#[test]
fn root_iter() {
let store = Arc::new(MemoryStore::open());
let slots_per_historical_root = FoundationEthSpec::slots_per_historical_root();
let slots_per_historical_root = MainnetEthSpec::slots_per_historical_root();
let mut state_a: BeaconState<FoundationEthSpec> = get_state();
let mut state_b: BeaconState<FoundationEthSpec> = get_state();
let mut state_a: BeaconState<MainnetEthSpec> = get_state();
let mut state_b: BeaconState<MainnetEthSpec> = get_state();
state_a.slot = Slot::from(slots_per_historical_root);
state_b.slot = Slot::from(slots_per_historical_root * 2);
@@ -122,7 +122,7 @@ mod test {
let mut collected: Vec<Hash256> = iter.collect();
collected.reverse();
let expected_len = 2 * FoundationEthSpec::slots_per_historical_root() - 1;
let expected_len = 2 * MainnetEthSpec::slots_per_historical_root() - 1;
assert_eq!(collected.len(), expected_len);

View File

@@ -11,10 +11,10 @@ use std::sync::Arc;
use tree_hash::TreeHash;
use types::{
test_utils::TestingBeaconStateBuilder, BeaconBlock, ChainSpec, EthSpec, Hash256,
LighthouseTestnetEthSpec,
MinimalEthSpec,
};
/// The number initial validators when starting the `LighthouseTestnet`.
/// The number initial validators when starting the `Minimal`.
const TESTNET_VALIDATOR_COUNT: usize = 16;
/// Provides a new, initialized `BeaconChain`
@@ -35,7 +35,7 @@ impl BeaconChainTypes for TestnetMemoryBeaconChainTypes {
type Store = MemoryStore;
type SlotClock = SystemTimeSlotClock;
type ForkChoice = OptimizedLMDGhost<Self::Store, Self::EthSpec>;
type EthSpec = LighthouseTestnetEthSpec;
type EthSpec = MinimalEthSpec;
}
impl<T: BeaconChainTypes> InitialiseBeaconChain<T> for TestnetMemoryBeaconChainTypes {}
@@ -46,7 +46,7 @@ impl BeaconChainTypes for TestnetDiskBeaconChainTypes {
type Store = DiskStore;
type SlotClock = SystemTimeSlotClock;
type ForkChoice = OptimizedLMDGhost<Self::Store, Self::EthSpec>;
type EthSpec = LighthouseTestnetEthSpec;
type EthSpec = MinimalEthSpec;
}
impl<T: BeaconChainTypes> InitialiseBeaconChain<T> for TestnetDiskBeaconChainTypes {}

View File

@@ -31,7 +31,7 @@ impl Default for ClientConfig {
network: NetworkConfig::new(vec![]),
rpc: rpc::RPCConfig::default(),
http: HttpServerConfig::default(),
spec: ChainSpec::lighthouse_testnet(),
spec: ChainSpec::minimal(),
}
}
}

View File

@@ -261,7 +261,7 @@ mod test {
#[test]
fn ssz_encoding() {
let original = PubsubMessage::Block(BeaconBlock::empty(&FoundationEthSpec::default_spec()));
let original = PubsubMessage::Block(BeaconBlock::empty(&MainnetEthSpec::default_spec()));
let encoded = ssz_encode(&original);

View File

@@ -61,7 +61,7 @@ mod tests {
#[test]
fn read_slot() {
let spec = FewValidatorsEthSpec::default_spec();
let spec = MinimalEthSpec::default_spec();
let test_slot = |slot: Slot| {
let mut block = BeaconBlock::empty(&spec);
@@ -85,7 +85,7 @@ mod tests {
#[test]
fn read_previous_block_root() {
let spec = FewValidatorsEthSpec::default_spec();
let spec = MinimalEthSpec::default_spec();
let test_root = |root: Hash256| {
let mut block = BeaconBlock::empty(&spec);
@@ -130,7 +130,7 @@ mod tests {
fn chain_without_skips() {
let n: usize = 10;
let store = MemoryStore::open();
let spec = FewValidatorsEthSpec::default_spec();
let spec = MinimalEthSpec::default_spec();
let slots: Vec<usize> = (0..n).collect();
let blocks_and_roots = build_chain(&store, &slots, &spec);
@@ -154,7 +154,7 @@ mod tests {
#[test]
fn chain_with_skips() {
let store = MemoryStore::open();
let spec = FewValidatorsEthSpec::default_spec();
let spec = MinimalEthSpec::default_spec();
let slots = vec![0, 1, 2, 5];