diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 3c3fa99ff6..92ee529d62 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -10,7 +10,7 @@ use lmd_ghost::LmdGhost; use operation_pool::DepositInsertStatus; use operation_pool::{OperationPool, PersistedOperationPool}; use parking_lot::RwLock; -use slog::{crit, debug, error, info, trace, warn, Logger}; +use slog::{debug, error, info, trace, warn, Logger}; use slot_clock::SlotClock; use ssz::Encode; use state_processing::per_block_processing::{ @@ -355,9 +355,9 @@ impl BeaconChain { // We log warnings or simply fail if there are too many skip slots. This is a // protection against DoS attacks. if slot > head_state.slot + BLOCK_SKIPPING_FAILURE_THRESHOLD { - crit!( + error!( self.log, - "Refusing to skip more than {} blocks", BLOCK_SKIPPING_LOGGING_THRESHOLD; + "Refusing to skip more than {} blocks", BLOCK_SKIPPING_FAILURE_THRESHOLD; "head_slot" => head_state.slot, "request_slot" => slot ); diff --git a/beacon_node/eth1/src/http.rs b/beacon_node/eth1/src/http.rs index b0de6542db..1aedfcdd2f 100644 --- a/beacon_node/eth1/src/http.rs +++ b/beacon_node/eth1/src/http.rs @@ -137,19 +137,21 @@ pub fn get_deposit_count( block_number, timeout, ) - .and_then(|result| result.ok_or_else(|| "No response to deposit count".to_string())) - .and_then(|bytes| { - if bytes.is_empty() { - Ok(None) - } else if bytes.len() == DEPOSIT_COUNT_RESPONSE_BYTES { - let mut array = [0; 8]; - array.copy_from_slice(&bytes[32 + 32..32 + 32 + 8]); - Ok(Some(u64::from_le_bytes(array))) - } else { - Err(format!( - "Deposit count response was not {} bytes: {:?}", - DEPOSIT_COUNT_RESPONSE_BYTES, bytes - )) + .and_then(|result| match result { + None => Ok(None), + Some(bytes) => { + if bytes.is_empty() { + Ok(None) + } else if bytes.len() == DEPOSIT_COUNT_RESPONSE_BYTES { + let mut array = [0; 8]; + array.copy_from_slice(&bytes[32 + 32..32 + 32 + 8]); + Ok(Some(u64::from_le_bytes(array))) + } else { + Err(format!( + "Deposit count response was not {} bytes: {:?}", + DEPOSIT_COUNT_RESPONSE_BYTES, bytes + )) + } } }) } @@ -172,17 +174,19 @@ pub fn get_deposit_root( block_number, timeout, ) - .and_then(|result| result.ok_or_else(|| "No response to deposit root".to_string())) - .and_then(|bytes| { - if bytes.is_empty() { - Ok(None) - } else if bytes.len() == DEPOSIT_ROOT_BYTES { - Ok(Some(Hash256::from_slice(&bytes))) - } else { - Err(format!( - "Deposit root response was not {} bytes: {:?}", - DEPOSIT_ROOT_BYTES, bytes - )) + .and_then(|result| match result { + None => Ok(None), + Some(bytes) => { + if bytes.is_empty() { + Ok(None) + } else if bytes.len() == DEPOSIT_ROOT_BYTES { + Ok(Some(Hash256::from_slice(&bytes))) + } else { + Err(format!( + "Deposit root response was not {} bytes: {:?}", + DEPOSIT_ROOT_BYTES, bytes + )) + } } }) } diff --git a/beacon_node/eth1/src/service.rs b/beacon_node/eth1/src/service.rs index 5ec89d3bf2..8a9be6b896 100644 --- a/beacon_node/eth1/src/service.rs +++ b/beacon_node/eth1/src/service.rs @@ -121,7 +121,7 @@ impl Default for Config { lowest_cached_block_number: 0, follow_distance: 128, block_cache_truncation: Some(4_096), - auto_update_interval_millis: 500, + auto_update_interval_millis: 7_000, blocks_per_log_query: 1_000, max_log_requests_per_update: None, max_blocks_per_update: None, diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index df56084765..f89a517482 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -268,7 +268,6 @@ fn process_testnet_subcommand( spec.max_effective_balance = 3_200_000_000; spec.ejection_balance = 1_600_000_000; spec.effective_balance_increment = 100_000_000; - spec.min_genesis_time = 0; spec.genesis_fork = Fork { previous_version: [0; 4], current_version: [0, 0, 0, 42], @@ -276,11 +275,19 @@ fn process_testnet_subcommand( }; client_config.eth1.deposit_contract_address = - format!("{}", eth2_testnet_dir.deposit_contract_address()?); + format!("{:?}", eth2_testnet_dir.deposit_contract_address()?); client_config.eth1.deposit_contract_deploy_block = eth2_testnet_dir.deposit_contract_deploy_block; + spec.min_genesis_time = eth2_testnet_dir.min_genesis_time; + + // Note: these constants _should_ only be used during genesis to determine the genesis + // time. This allows the testnet to start shortly after the time + validator count + // conditions are satisified, not 1-2 days. + spec.seconds_per_day = 60; + client_config.eth1.follow_distance = 16; client_config.dummy_eth1_backend = false; + client_config.sync_eth1_chain = true; builder.set_genesis(ClientGenesis::DepositContract) } diff --git a/validator_client/src/config.rs b/validator_client/src/config.rs index 2e16752d67..f1c0cbe701 100644 --- a/validator_client/src/config.rs +++ b/validator_client/src/config.rs @@ -3,6 +3,7 @@ use serde_derive::{Deserialize, Serialize}; use std::path::PathBuf; pub const DEFAULT_HTTP_SERVER: &str = "http://localhost:5052/"; +pub const DEFAULT_DATA_DIR: &str = ".lighthouse/validators"; /// Specifies a method for obtaining validator keypairs. #[derive(Clone)] @@ -37,7 +38,7 @@ impl Default for Config { /// Build a new configuration from defaults. fn default() -> Self { Self { - data_dir: PathBuf::from(".lighthouse/validators"), + data_dir: PathBuf::from(DEFAULT_DATA_DIR), key_source: <_>::default(), http_server: DEFAULT_HTTP_SERVER.to_string(), } @@ -50,6 +51,21 @@ impl Config { pub fn from_cli(cli_args: &ArgMatches) -> Result { let mut config = Config::default(); + // Read the `--datadir` flag. + // + // If it's not present, try and find the home directory (`~`) and push the default data + // directory onto it. + config.data_dir = cli_args + .value_of("datadir") + .map(PathBuf::from) + .or_else(|| { + dirs::home_dir().map(|mut home| { + home.push(DEFAULT_DATA_DIR); + home + }) + }) + .ok_or_else(|| "Unable to find a home directory for the datadir".to_string())?; + if let Some(server) = cli_args.value_of("server") { config.http_server = server.to_string(); } diff --git a/validator_client/src/validator_store.rs b/validator_client/src/validator_store.rs index 4256ce4939..96c945729e 100644 --- a/validator_client/src/validator_store.rs +++ b/validator_client/src/validator_store.rs @@ -34,7 +34,7 @@ impl ValidatorStore { log: Logger, ) -> Result { let validator_iter = read_dir(&base_dir) - .map_err(|e| format!("Failed to read base directory: {:?}", e))? + .map_err(|e| format!("Failed to read base directory {:?}: {:?}", base_dir, e))? .filter_map(|validator_dir| { let path = validator_dir.ok()?.path();