diff --git a/beacon_node/src/main.rs b/beacon_node/src/main.rs index 7827f7d26..ef70dd300 100644 --- a/beacon_node/src/main.rs +++ b/beacon_node/src/main.rs @@ -2,11 +2,10 @@ extern crate slog; mod run; -use clap::{App, Arg, ArgMatches}; +use clap::{App, Arg}; use client::{ClientConfig, Eth2Config}; use eth2_config::{get_data_dir, read_from_file, write_to_file}; use slog::{crit, o, Drain}; -use std::fs; use std::path::PathBuf; pub const DEFAULT_DATA_DIR: &str = ".lighthouse"; @@ -119,7 +118,7 @@ fn main() { ) .get_matches(); - let data_dir = match get_data_dir(&matches) { + let data_dir = match get_data_dir(&matches, PathBuf::from(DEFAULT_DATA_DIR)) { Ok(dir) => dir, Err(e) => { crit!(logger, "Failed to initialize data dir"; "error" => format!("{:?}", e)); diff --git a/eth2/operation_pool/src/lib.rs b/eth2/operation_pool/src/lib.rs index 0afd72918..ec7d5aa90 100644 --- a/eth2/operation_pool/src/lib.rs +++ b/eth2/operation_pool/src/lib.rs @@ -724,14 +724,14 @@ mod tests { let spec = E::default_spec(); let num_validators = - num_committees * T::slots_per_epoch() as usize * spec.target_committee_size; + num_committees * E::slots_per_epoch() as usize * spec.target_committee_size; let mut state_builder = TestingBeaconStateBuilder::from_default_keypairs_file_if_exists( num_validators, &spec, ); - let slot_offset = 1000 * T::slots_per_epoch() + T::slots_per_epoch() / 2; + let slot_offset = 1000 * E::slots_per_epoch() + E::slots_per_epoch() / 2; let slot = spec.genesis_slot + slot_offset; - state_builder.teleport_to_slot(slot, &spec); + state_builder.teleport_to_slot(slot); state_builder.build_caches(&spec).unwrap(); let (state, keypairs) = state_builder.build(); @@ -852,7 +852,7 @@ mod tests { // But once we advance to more than an epoch after the attestation, it should prune it // out of existence. - state.slot += 2 * T::slots_per_epoch(); + state.slot += 2 * MainnetEthSpec::slots_per_epoch(); op_pool.prune_attestations(state); assert_eq!(op_pool.num_attestations(), 0); } diff --git a/eth2/state_processing/src/per_block_processing/tests.rs b/eth2/state_processing/src/per_block_processing/tests.rs index 525637fea..6c9593c49 100644 --- a/eth2/state_processing/src/per_block_processing/tests.rs +++ b/eth2/state_processing/src/per_block_processing/tests.rs @@ -106,7 +106,7 @@ fn get_builder(spec: &ChainSpec) -> (BlockProcessingBuilder) { // Set the state and block to be in the last slot of the 4th epoch. let last_slot_of_epoch = (MainnetEthSpec::genesis_epoch() + 4).end_slot(MainnetEthSpec::slots_per_epoch()); - builder.set_slot(last_slot_of_epoch, &spec); + builder.set_slot(last_slot_of_epoch); builder.build_caches(&spec); (builder) diff --git a/eth2/state_processing/src/per_epoch_processing.rs b/eth2/state_processing/src/per_epoch_processing.rs index 2d76577e1..f7a4a1c50 100644 --- a/eth2/state_processing/src/per_epoch_processing.rs +++ b/eth2/state_processing/src/per_epoch_processing.rs @@ -42,7 +42,7 @@ pub fn per_epoch_processing( validator_statuses.process_attestations(&state, spec)?; // Justification and finalization. - process_justification_and_finalization(state, &validator_statuses.total_balances, spec)?; + process_justification_and_finalization(state, &validator_statuses.total_balances)?; // Crosslinks. let winning_root_for_shards = process_crosslinks(state, spec)?; @@ -84,7 +84,6 @@ pub fn per_epoch_processing( pub fn process_justification_and_finalization( state: &mut BeaconState, total_balances: &TotalBalances, - spec: &ChainSpec, ) -> Result<(), Error> { if state.current_epoch() == T::genesis_epoch() { return Ok(()); @@ -104,14 +103,14 @@ pub fn process_justification_and_finalization( if total_balances.previous_epoch_target_attesters * 3 >= total_balances.previous_epoch * 2 { state.current_justified_epoch = previous_epoch; state.current_justified_root = - *state.get_block_root_at_epoch(state.current_justified_epoch, spec)?; + *state.get_block_root_at_epoch(state.current_justified_epoch)?; state.justification_bitfield |= 2; } // If the current epoch gets justified, fill the last bit. if total_balances.current_epoch_target_attesters * 3 >= total_balances.current_epoch * 2 { state.current_justified_epoch = current_epoch; state.current_justified_root = - *state.get_block_root_at_epoch(state.current_justified_epoch, spec)?; + *state.get_block_root_at_epoch(state.current_justified_epoch)?; state.justification_bitfield |= 1; } @@ -120,22 +119,22 @@ pub fn process_justification_and_finalization( // The 2nd/3rd/4th most recent epochs are all justified, the 2nd using the 4th as source. if (bitfield >> 1) % 8 == 0b111 && old_previous_justified_epoch == current_epoch - 3 { state.finalized_epoch = old_previous_justified_epoch; - state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch, spec)?; + state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch)?; } // The 2nd/3rd most recent epochs are both justified, the 2nd using the 3rd as source. if (bitfield >> 1) % 4 == 0b11 && state.previous_justified_epoch == current_epoch - 2 { state.finalized_epoch = old_previous_justified_epoch; - state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch, spec)?; + state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch)?; } // The 1st/2nd/3rd most recent epochs are all justified, the 1st using the 2nd as source. if bitfield % 8 == 0b111 && state.current_justified_epoch == current_epoch - 2 { state.finalized_epoch = old_current_justified_epoch; - state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch, spec)?; + state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch)?; } // The 1st/2nd most recent epochs are both justified, the 1st using the 2nd as source. if bitfield % 4 == 0b11 && state.current_justified_epoch == current_epoch - 1 { state.finalized_epoch = old_current_justified_epoch; - state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch, spec)?; + state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch)?; } Ok(()) diff --git a/eth2/state_processing/src/per_epoch_processing/tests.rs b/eth2/state_processing/src/per_epoch_processing/tests.rs index 306acb7ee..9fdc82c6f 100644 --- a/eth2/state_processing/src/per_epoch_processing/tests.rs +++ b/eth2/state_processing/src/per_epoch_processing/tests.rs @@ -15,7 +15,7 @@ fn runs_without_error() { let target_slot = (MinimalEthSpec::genesis_epoch() + 4).end_slot(MinimalEthSpec::slots_per_epoch()); - builder.teleport_to_slot(target_slot, &spec); + builder.teleport_to_slot(target_slot); let (mut state, _keypairs) = builder.build(); diff --git a/eth2/types/src/beacon_state/committee_cache/tests.rs b/eth2/types/src/beacon_state/committee_cache/tests.rs index d30d0724d..ca58f8926 100644 --- a/eth2/types/src/beacon_state/committee_cache/tests.rs +++ b/eth2/types/src/beacon_state/committee_cache/tests.rs @@ -25,7 +25,7 @@ fn new_state(validator_count: usize, slot: Slot) -> BeaconState { let mut builder = TestingBeaconStateBuilder::from_single_keypair(validator_count, &Keypair::random(), spec); - builder.teleport_to_slot(slot, spec); + builder.teleport_to_slot(slot); let (state, _keypairs) = builder.build(); diff --git a/eth2/types/src/beacon_state/tests.rs b/eth2/types/src/beacon_state/tests.rs index b3c641f61..316a90151 100644 --- a/eth2/types/src/beacon_state/tests.rs +++ b/eth2/types/src/beacon_state/tests.rs @@ -300,7 +300,7 @@ mod committees { ); let slot = state_epoch.start_slot(T::slots_per_epoch()); - builder.teleport_to_slot(slot, spec); + builder.teleport_to_slot(slot); let (mut state, _keypairs): (BeaconState, _) = builder.build();