mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-25 13:07:18 +00:00
Fix various compile errors and warnings
This commit is contained in:
parent
ab12787610
commit
a662c3a940
@ -2,11 +2,10 @@ extern crate slog;
|
|||||||
|
|
||||||
mod run;
|
mod run;
|
||||||
|
|
||||||
use clap::{App, Arg, ArgMatches};
|
use clap::{App, Arg};
|
||||||
use client::{ClientConfig, Eth2Config};
|
use client::{ClientConfig, Eth2Config};
|
||||||
use eth2_config::{get_data_dir, read_from_file, write_to_file};
|
use eth2_config::{get_data_dir, read_from_file, write_to_file};
|
||||||
use slog::{crit, o, Drain};
|
use slog::{crit, o, Drain};
|
||||||
use std::fs;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub const DEFAULT_DATA_DIR: &str = ".lighthouse";
|
pub const DEFAULT_DATA_DIR: &str = ".lighthouse";
|
||||||
@ -119,7 +118,7 @@ fn main() {
|
|||||||
)
|
)
|
||||||
.get_matches();
|
.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,
|
Ok(dir) => dir,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
crit!(logger, "Failed to initialize data dir"; "error" => format!("{:?}", e));
|
crit!(logger, "Failed to initialize data dir"; "error" => format!("{:?}", e));
|
||||||
|
@ -724,14 +724,14 @@ mod tests {
|
|||||||
let spec = E::default_spec();
|
let spec = E::default_spec();
|
||||||
|
|
||||||
let num_validators =
|
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(
|
let mut state_builder = TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(
|
||||||
num_validators,
|
num_validators,
|
||||||
&spec,
|
&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;
|
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();
|
state_builder.build_caches(&spec).unwrap();
|
||||||
let (state, keypairs) = state_builder.build();
|
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
|
// But once we advance to more than an epoch after the attestation, it should prune it
|
||||||
// out of existence.
|
// out of existence.
|
||||||
state.slot += 2 * T::slots_per_epoch();
|
state.slot += 2 * MainnetEthSpec::slots_per_epoch();
|
||||||
op_pool.prune_attestations(state);
|
op_pool.prune_attestations(state);
|
||||||
assert_eq!(op_pool.num_attestations(), 0);
|
assert_eq!(op_pool.num_attestations(), 0);
|
||||||
}
|
}
|
||||||
|
@ -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.
|
// Set the state and block to be in the last slot of the 4th epoch.
|
||||||
let last_slot_of_epoch =
|
let last_slot_of_epoch =
|
||||||
(MainnetEthSpec::genesis_epoch() + 4).end_slot(MainnetEthSpec::slots_per_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.build_caches(&spec);
|
||||||
|
|
||||||
(builder)
|
(builder)
|
||||||
|
@ -42,7 +42,7 @@ pub fn per_epoch_processing<T: EthSpec>(
|
|||||||
validator_statuses.process_attestations(&state, spec)?;
|
validator_statuses.process_attestations(&state, spec)?;
|
||||||
|
|
||||||
// Justification and finalization.
|
// Justification and finalization.
|
||||||
process_justification_and_finalization(state, &validator_statuses.total_balances, spec)?;
|
process_justification_and_finalization(state, &validator_statuses.total_balances)?;
|
||||||
|
|
||||||
// Crosslinks.
|
// Crosslinks.
|
||||||
let winning_root_for_shards = process_crosslinks(state, spec)?;
|
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>(
|
pub fn process_justification_and_finalization<T: EthSpec>(
|
||||||
state: &mut BeaconState<T>,
|
state: &mut BeaconState<T>,
|
||||||
total_balances: &TotalBalances,
|
total_balances: &TotalBalances,
|
||||||
spec: &ChainSpec,
|
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
if state.current_epoch() == T::genesis_epoch() {
|
if state.current_epoch() == T::genesis_epoch() {
|
||||||
return Ok(());
|
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 {
|
if total_balances.previous_epoch_target_attesters * 3 >= total_balances.previous_epoch * 2 {
|
||||||
state.current_justified_epoch = previous_epoch;
|
state.current_justified_epoch = previous_epoch;
|
||||||
state.current_justified_root =
|
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;
|
state.justification_bitfield |= 2;
|
||||||
}
|
}
|
||||||
// If the current epoch gets justified, fill the last bit.
|
// If the current epoch gets justified, fill the last bit.
|
||||||
if total_balances.current_epoch_target_attesters * 3 >= total_balances.current_epoch * 2 {
|
if total_balances.current_epoch_target_attesters * 3 >= total_balances.current_epoch * 2 {
|
||||||
state.current_justified_epoch = current_epoch;
|
state.current_justified_epoch = current_epoch;
|
||||||
state.current_justified_root =
|
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;
|
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.
|
// 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 {
|
if (bitfield >> 1) % 8 == 0b111 && old_previous_justified_epoch == current_epoch - 3 {
|
||||||
state.finalized_epoch = old_previous_justified_epoch;
|
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.
|
// 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 {
|
if (bitfield >> 1) % 4 == 0b11 && state.previous_justified_epoch == current_epoch - 2 {
|
||||||
state.finalized_epoch = old_previous_justified_epoch;
|
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.
|
// 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 {
|
if bitfield % 8 == 0b111 && state.current_justified_epoch == current_epoch - 2 {
|
||||||
state.finalized_epoch = old_current_justified_epoch;
|
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.
|
// 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 {
|
if bitfield % 4 == 0b11 && state.current_justified_epoch == current_epoch - 1 {
|
||||||
state.finalized_epoch = old_current_justified_epoch;
|
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(())
|
Ok(())
|
||||||
|
@ -15,7 +15,7 @@ fn runs_without_error() {
|
|||||||
|
|
||||||
let target_slot =
|
let target_slot =
|
||||||
(MinimalEthSpec::genesis_epoch() + 4).end_slot(MinimalEthSpec::slots_per_epoch());
|
(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();
|
let (mut state, _keypairs) = builder.build();
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ fn new_state<T: EthSpec>(validator_count: usize, slot: Slot) -> BeaconState<T> {
|
|||||||
let mut builder =
|
let mut builder =
|
||||||
TestingBeaconStateBuilder::from_single_keypair(validator_count, &Keypair::random(), spec);
|
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();
|
let (state, _keypairs) = builder.build();
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ mod committees {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let slot = state_epoch.start_slot(T::slots_per_epoch());
|
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();
|
let (mut state, _keypairs): (BeaconState<T>, _) = builder.build();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user