Fix various compile errors and warnings

This commit is contained in:
Paul Hauner 2019-06-09 06:26:34 -04:00
parent ab12787610
commit a662c3a940
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
7 changed files with 17 additions and 19 deletions

View File

@ -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));

View File

@ -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);
}

View File

@ -106,7 +106,7 @@ fn get_builder(spec: &ChainSpec) -> (BlockProcessingBuilder<MainnetEthSpec>) {
// 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)

View File

@ -42,7 +42,7 @@ pub fn per_epoch_processing<T: EthSpec>(
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<T: EthSpec>(
pub fn process_justification_and_finalization<T: EthSpec>(
state: &mut BeaconState<T>,
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<T: EthSpec>(
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<T: EthSpec>(
// 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(())

View File

@ -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();

View File

@ -25,7 +25,7 @@ fn new_state<T: EthSpec>(validator_count: usize, slot: Slot) -> BeaconState<T> {
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();

View File

@ -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<T>, _) = builder.build();