Improve logging for eth1

This commit is contained in:
Paul Hauner
2019-11-25 18:19:26 +11:00
parent b8bc548aaa
commit ae535ea33a
3 changed files with 28 additions and 13 deletions

View File

@@ -205,20 +205,31 @@ impl<T: EthSpec, S: Store> Eth1ChainBackend<T> for CachingEth1Backend<T, S> {
let blocks = self.core.blocks().read();
let eth1_data = eth1_data_sets(blocks.iter(), state, prev_eth1_hash, spec)
.map(|(new_eth1_data, all_eth1_data)| {
collect_valid_votes(state, new_eth1_data, all_eth1_data)
})
.and_then(find_winning_vote)
.unwrap_or_else(|| {
let (new_eth1_data, all_eth1_data) =
if let Some(sets) = eth1_data_sets(blocks.iter(), state, prev_eth1_hash, spec) {
sets
} else {
crit!(
self.log,
"Unable to cast valid vote for Eth1Data";
"hint" => "check connection to eth1 node",
"reason" => "no votes",
"Unable to find eth1 data sets";
"outcome" => "casting random eth1 vote"
);
random_eth1_data()
});
return Ok(random_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) {
eth1_data
} else {
crit!(
self.log,
"Unable to find a winning eth1 vote";
"outcome" => "casting random eth1 vote"
);
return Ok(random_eth1_data());
};
Ok(eth1_data)
}

View File

@@ -220,6 +220,8 @@ impl Service {
{
let log_a = self.log.clone();
let log_b = self.log.clone();
let inner_1 = self.inner.clone();
let inner_2 = self.inner.clone();
let deposit_future = self
.update_deposit_cache()
@@ -229,6 +231,7 @@ impl Service {
Ok(DepositCacheUpdateOutcome::Success { logs_imported }) => trace!(
log_a,
"Updated eth1 deposit cache";
"cached_deposits" => inner_1.deposit_cache.read().cache.len(),
"logs_imported" => logs_imported,
),
Err(e) => error!(
@@ -252,6 +255,7 @@ impl Service {
}) => trace!(
log_b,
"Updated eth1 block cache";
"cached_blocks" => inner_2.block_cache.read().len(),
"blocks_imported" => blocks_imported,
"head_block" => head_block_number,
),

View File

@@ -154,7 +154,7 @@ pub fn route<T: BeaconChainTypes>(
// (e.g., a response with a 404 or 500 status).
request_result.then(move |result| match result {
Ok(response) => {
debug!(local_log, "Request successful: {:?}", path);
debug!(local_log, "HTTP API request successful"; "path" => path);
metrics::inc_counter(&metrics::SUCCESS_COUNT);
metrics::stop_timer(timer);
@@ -163,7 +163,7 @@ pub fn route<T: BeaconChainTypes>(
Err(e) => {
let error_response = e.into();
debug!(local_log, "Request failure: {:?}", path);
debug!(local_log, "HTTP API request failure"; "path" => path);
metrics::stop_timer(timer);
Ok(error_response)