mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-04 13:24:39 +00:00
Improve eth1 logging
This commit is contained in:
@@ -4,7 +4,7 @@ use exit_future::Exit;
|
|||||||
use futures::Future;
|
use futures::Future;
|
||||||
use integer_sqrt::IntegerSquareRoot;
|
use integer_sqrt::IntegerSquareRoot;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use slog::{crit, Logger};
|
use slog::{crit, trace, Logger};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::iter::DoubleEndedIterator;
|
use std::iter::DoubleEndedIterator;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
@@ -33,7 +33,7 @@ pub enum Error {
|
|||||||
/// voting period.
|
/// voting period.
|
||||||
UnableToGetPreviousStateRoot(BeaconStateError),
|
UnableToGetPreviousStateRoot(BeaconStateError),
|
||||||
/// The state required to find the previous eth1 block was not found in the store.
|
/// The state required to find the previous eth1 block was not found in the store.
|
||||||
PreviousStateNotInDB,
|
PreviousStateNotInDB(Hash256),
|
||||||
/// There was an error accessing an object in the database.
|
/// There was an error accessing an object in the database.
|
||||||
StoreError(StoreError),
|
StoreError(StoreError),
|
||||||
/// The eth1 head block at the start of the eth1 voting period is unknown.
|
/// The eth1 head block at the start of the eth1 voting period is unknown.
|
||||||
@@ -212,11 +212,20 @@ impl<T: EthSpec, S: Store> Eth1ChainBackend<T> for CachingEth1Backend<T, S> {
|
|||||||
crit!(
|
crit!(
|
||||||
self.log,
|
self.log,
|
||||||
"Unable to find eth1 data sets";
|
"Unable to find eth1 data sets";
|
||||||
|
"earliest_cached_block" => self.core.earliest_block_timestamp(),
|
||||||
|
"genesis_time" => state.genesis_time,
|
||||||
"outcome" => "casting random eth1 vote"
|
"outcome" => "casting random eth1 vote"
|
||||||
);
|
);
|
||||||
return Ok(random_eth1_data());
|
return Ok(random_eth1_data());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
trace!(
|
||||||
|
self.log,
|
||||||
|
"Found eth1 data sets";
|
||||||
|
"all_eth1_data" => all_eth1_data.len(),
|
||||||
|
"new_eth1_data" => new_eth1_data.len(),
|
||||||
|
);
|
||||||
|
|
||||||
let valid_votes = collect_valid_votes(state, new_eth1_data, all_eth1_data);
|
let valid_votes = collect_valid_votes(state, new_eth1_data, all_eth1_data);
|
||||||
|
|
||||||
let eth1_data = if let Some(eth1_data) = find_winning_vote(valid_votes) {
|
let eth1_data = if let Some(eth1_data) = find_winning_vote(valid_votes) {
|
||||||
@@ -307,7 +316,7 @@ fn eth1_block_hash_at_start_of_voting_period<T: EthSpec, S: Store>(
|
|||||||
.get::<BeaconState<T>>(&prev_state_root)
|
.get::<BeaconState<T>>(&prev_state_root)
|
||||||
.map_err(|e| Error::StoreError(e))?
|
.map_err(|e| Error::StoreError(e))?
|
||||||
.map(|state| state.eth1_data.block_hash)
|
.map(|state| state.eth1_data.block_hash)
|
||||||
.ok_or_else(|| Error::PreviousStateNotInDB)
|
.ok_or_else(|| Error::PreviousStateNotInDB(*prev_state_root))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ impl BlockCache {
|
|||||||
self.blocks.is_empty()
|
self.blocks.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the timestamp of the earliest block in the cache (if any).
|
||||||
|
pub fn earliest_block_timestamp(&self) -> Option<u64> {
|
||||||
|
self.blocks.first().map(|block| block.timestamp)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the highest block number stored.
|
/// Returns the highest block number stored.
|
||||||
pub fn highest_block_number(&self) -> Option<u64> {
|
pub fn highest_block_number(&self) -> Option<u64> {
|
||||||
self.blocks.last().map(|block| block.number)
|
self.blocks.last().map(|block| block.number)
|
||||||
|
|||||||
@@ -168,6 +168,11 @@ impl Service {
|
|||||||
*(self.inner.block_cache.write()) = BlockCache::default();
|
*(self.inner.block_cache.write()) = BlockCache::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the timestamp of the earliest block in the cache (if any).
|
||||||
|
pub fn earliest_block_timestamp(&self) -> Option<u64> {
|
||||||
|
self.inner.block_cache.read().earliest_block_timestamp()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the number of currently cached blocks.
|
/// Returns the number of currently cached blocks.
|
||||||
pub fn block_cache_len(&self) -> usize {
|
pub fn block_cache_len(&self) -> usize {
|
||||||
self.blocks().read().len()
|
self.blocks().read().len()
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ fn process_testnet_subcommand(
|
|||||||
// Note: these constants _should_ only be used during genesis to determine the genesis
|
// 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
|
// time. This allows the testnet to start shortly after the time + validator count
|
||||||
// conditions are satisfied, not 1-2 days.
|
// conditions are satisfied, not 1-2 days.
|
||||||
spec.seconds_per_day = 1800;
|
spec.seconds_per_day = 60;
|
||||||
|
|
||||||
client_config.eth1.follow_distance = 16;
|
client_config.eth1.follow_distance = 16;
|
||||||
client_config.dummy_eth1_backend = false;
|
client_config.dummy_eth1_backend = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user