diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index c8ad15e2e1..20dd3f049f 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -1504,7 +1504,14 @@ impl BeaconChain { let previous_slot = self.head_info().slot; let new_slot = beacon_block.slot; - let is_reorg = self.head_info().block_root != beacon_block.parent_root; + // Note: this will declare a re-org if we skip `SLOTS_PER_HISTORICAL_ROOT` blocks + // between calls to fork choice without swapping between chains. This seems like an + // extreme-enough scenario that a warning is fine. + let is_reorg = self.head_info().block_root + != beacon_state + .get_block_root(self.head_info().slot) + .map(|root| *root) + .unwrap_or_else(|_| Hash256::random()); // If we switched to a new chain (instead of building atop the present chain). if is_reorg { diff --git a/beacon_node/store/src/leveldb_store.rs b/beacon_node/store/src/leveldb_store.rs index b9ebd25d10..051d091706 100644 --- a/beacon_node/store/src/leveldb_store.rs +++ b/beacon_node/store/src/leveldb_store.rs @@ -69,17 +69,18 @@ impl Store for LevelDB { let column_key = Self::get_key_for_col(col, key); metrics::inc_counter(&metrics::DISK_DB_READ_COUNT); + let timer = metrics::start_timer(&metrics::DISK_DB_READ_TIMES); - let result = self - .db + self.db .get(self.read_options(), column_key) - .map_err(Into::into); - - if let Ok(Some(bytes)) = &result { - metrics::inc_counter_by(&metrics::DISK_DB_READ_BYTES, bytes.len() as i64) - } - - result + .map_err(Into::into) + .map(|opt| { + opt.map(|bytes| { + metrics::inc_counter_by(&metrics::DISK_DB_READ_BYTES, bytes.len() as i64); + metrics::stop_timer(timer); + bytes + }) + }) } /// Store some `value` in `column`, indexed with `key`. @@ -88,10 +89,14 @@ impl Store for LevelDB { metrics::inc_counter(&metrics::DISK_DB_WRITE_COUNT); metrics::inc_counter_by(&metrics::DISK_DB_WRITE_BYTES, val.len() as i64); + let timer = metrics::start_timer(&metrics::DISK_DB_WRITE_TIMES); self.db .put(self.write_options(), column_key, val) .map_err(Into::into) + .map(|()| { + metrics::stop_timer(timer); + }) } /// Return `true` if `key` exists in `column`. diff --git a/beacon_node/store/src/metrics.rs b/beacon_node/store/src/metrics.rs index 6f51c71ba3..022d814464 100644 --- a/beacon_node/store/src/metrics.rs +++ b/beacon_node/store/src/metrics.rs @@ -25,6 +25,14 @@ lazy_static! { "store_disk_db_write_count_total", "Total number of writes to the on-disk DB" ); + pub static ref DISK_DB_READ_TIMES: Result = try_create_histogram( + "store_disk_db_read_seconds", + "Time taken to write bytes to store." + ); + pub static ref DISK_DB_WRITE_TIMES: Result = try_create_histogram( + "store_disk_db_write_seconds", + "Time taken to write bytes to store." + ); pub static ref DISK_DB_EXISTS_COUNT: Result = try_create_int_counter( "store_disk_db_exists_count_total", "Total number of checks if a key is in the on-disk DB" diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 8ca5d49f67..d547594da4 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -2,7 +2,7 @@ * [Introduction](./intro.md) * [Become a Validator](./become-a-validator.md) -* [Introduction](./intro.md) +* [Installation](./installation.md) * [Docker](./docker.md) * [CLI](./cli.md) * [Testnets](./testnets.md) diff --git a/lcli/src/main.rs b/lcli/src/main.rs index 76811192a0..93100c01d6 100644 --- a/lcli/src/main.rs +++ b/lcli/src/main.rs @@ -25,6 +25,15 @@ fn main() { "Performs various testing-related tasks, modelled after zcli. \ by @protolambda.", ) + .arg( + Arg::with_name("spec") + .short("s") + .value_name("STRING") + .takes_value(true) + .required(true) + .possible_values(&["minimal", "mainnet"]) + .default_value("mainnet") + ) .subcommand( SubCommand::with_name("genesis_yaml") .about("Generates a genesis YAML file") @@ -44,16 +53,6 @@ fn main() { .required(false) .help("Eth2 genesis time (seconds since UNIX epoch)."), ) - .arg( - Arg::with_name("spec") - .short("s") - .value_name("STRING") - .takes_value(true) - .required(true) - .possible_values(&["minimal", "mainnet"]) - .default_value("mainnet") - .help("Eth2 genesis time (seconds since UNIX epoch)."), - ) .arg( Arg::with_name("output_file") .short("f")