mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Add more logging for validator duties
This commit is contained in:
@@ -3,7 +3,7 @@ use environment::RuntimeContext;
|
|||||||
use exit_future::Signal;
|
use exit_future::Signal;
|
||||||
use futures::{stream, Future, IntoFuture, Stream};
|
use futures::{stream, Future, IntoFuture, Stream};
|
||||||
use remote_beacon_node::{PublishStatus, RemoteBeaconNode};
|
use remote_beacon_node::{PublishStatus, RemoteBeaconNode};
|
||||||
use slog::{crit, info};
|
use slog::{crit, error, info, trace};
|
||||||
use slot_clock::SlotClock;
|
use slot_clock::SlotClock;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -159,17 +159,34 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockService<T, E> {
|
|||||||
/// Attempt to produce a block for any block producers in the `ValidatorStore`.
|
/// Attempt to produce a block for any block producers in the `ValidatorStore`.
|
||||||
fn do_update(self) -> impl Future<Item = (), Error = ()> {
|
fn do_update(self) -> impl Future<Item = (), Error = ()> {
|
||||||
let service = self.clone();
|
let service = self.clone();
|
||||||
let log = self.context.log.clone();
|
let log_1 = self.context.log.clone();
|
||||||
|
let log_2 = self.context.log.clone();
|
||||||
|
|
||||||
self.slot_clock
|
self.slot_clock
|
||||||
.now()
|
.now()
|
||||||
.ok_or_else(move || {
|
.ok_or_else(move || {
|
||||||
crit!(log, "Duties manager failed to read slot clock");
|
crit!(log_1, "Duties manager failed to read slot clock");
|
||||||
})
|
})
|
||||||
.into_future()
|
.into_future()
|
||||||
.and_then(move |slot| {
|
.and_then(move |slot| {
|
||||||
let iter = service.duties_service.block_producers(slot).into_iter();
|
let iter = service.duties_service.block_producers(slot).into_iter();
|
||||||
|
|
||||||
|
if iter.len() == 0 {
|
||||||
|
trace!(
|
||||||
|
log_2,
|
||||||
|
"No local block proposers for this slot";
|
||||||
|
"slot" => slot.as_u64()
|
||||||
|
)
|
||||||
|
} else if iter.len() > 1 {
|
||||||
|
error!(
|
||||||
|
log_2,
|
||||||
|
"Multiple block proposers for this slot";
|
||||||
|
"action" => "producing blocks for all proposers",
|
||||||
|
"num_proposers" => iter.len(),
|
||||||
|
"slot" => slot.as_u64(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
stream::unfold(iter, move |mut block_producers| {
|
stream::unfold(iter, move |mut block_producers| {
|
||||||
let log_1 = service.context.log.clone();
|
let log_1 = service.context.log.clone();
|
||||||
let log_2 = service.context.log.clone();
|
let log_2 = service.context.log.clone();
|
||||||
|
|||||||
@@ -23,8 +23,10 @@ type BaseHashMap = HashMap<PublicKey, HashMap<Epoch, ValidatorDuty>>;
|
|||||||
|
|
||||||
/// The outcome of inserting some `ValidatorDuty` into the `DutiesStore`.
|
/// The outcome of inserting some `ValidatorDuty` into the `DutiesStore`.
|
||||||
enum InsertOutcome {
|
enum InsertOutcome {
|
||||||
/// The duties were previously unknown and have been stored.
|
/// These are the first duties received for this validator.
|
||||||
New,
|
NewValidator,
|
||||||
|
/// The duties for this given epoch were previously unknown and have been stored.
|
||||||
|
NewEpoch,
|
||||||
/// The duties were identical to some already in the store.
|
/// The duties were identical to some already in the store.
|
||||||
Identical,
|
Identical,
|
||||||
/// There were duties for this validator and epoch in the store that were different to the ones
|
/// There were duties for this validator and epoch in the store that were different to the ones
|
||||||
@@ -107,7 +109,7 @@ impl DutiesStore {
|
|||||||
} else {
|
} else {
|
||||||
validator_map.insert(epoch, duties);
|
validator_map.insert(epoch, duties);
|
||||||
|
|
||||||
InsertOutcome::New
|
InsertOutcome::NewEpoch
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let validator_pubkey = duties.validator_pubkey.clone();
|
let validator_pubkey = duties.validator_pubkey.clone();
|
||||||
@@ -117,7 +119,7 @@ impl DutiesStore {
|
|||||||
|
|
||||||
store.insert(validator_pubkey, validator_map);
|
store.insert(validator_pubkey, validator_map);
|
||||||
|
|
||||||
InsertOutcome::New
|
InsertOutcome::NewValidator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,14 +356,30 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
|
|||||||
.map(move |all_duties| (epoch, all_duties))
|
.map(move |all_duties| (epoch, all_duties))
|
||||||
.map_err(move |e| format!("Failed to get duties for epoch {}: {:?}", epoch, e))
|
.map_err(move |e| format!("Failed to get duties for epoch {}: {:?}", epoch, e))
|
||||||
.map(move |(epoch, all_duties)| {
|
.map(move |(epoch, all_duties)| {
|
||||||
let mut new = 0;
|
let log = service_2.context.log.clone();
|
||||||
|
|
||||||
|
let mut new_validator = 0;
|
||||||
|
let mut new_epoch = 0;
|
||||||
let mut identical = 0;
|
let mut identical = 0;
|
||||||
let mut replaced = 0;
|
let mut replaced = 0;
|
||||||
let mut invalid = 0;
|
let mut invalid = 0;
|
||||||
|
|
||||||
all_duties.into_iter().for_each(|duties| {
|
all_duties.into_iter().for_each(|duties| {
|
||||||
match service_2.store.insert(epoch, duties, E::slots_per_epoch()) {
|
match service_2
|
||||||
InsertOutcome::New => new += 1,
|
.store
|
||||||
|
.insert(epoch, duties.clone(), E::slots_per_epoch())
|
||||||
|
{
|
||||||
|
InsertOutcome::NewValidator => {
|
||||||
|
info!(
|
||||||
|
log,
|
||||||
|
"First duty assignment for validator";
|
||||||
|
"proposal_slot" => format!("{:?}", &duties.block_proposal_slot),
|
||||||
|
"attestation_slot" => format!("{:?}", &duties.attestation_slot),
|
||||||
|
"validator" => format!("{:?}", &duties.validator_pubkey)
|
||||||
|
);
|
||||||
|
new_validator += 1
|
||||||
|
}
|
||||||
|
InsertOutcome::NewEpoch => new_epoch += 1,
|
||||||
InsertOutcome::Identical => identical += 1,
|
InsertOutcome::Identical => identical += 1,
|
||||||
InsertOutcome::Replaced => replaced += 1,
|
InsertOutcome::Replaced => replaced += 1,
|
||||||
InsertOutcome::Invalid => invalid += 1,
|
InsertOutcome::Invalid => invalid += 1,
|
||||||
@@ -370,7 +388,7 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
|
|||||||
|
|
||||||
if invalid > 0 {
|
if invalid > 0 {
|
||||||
error!(
|
error!(
|
||||||
service_2.context.log,
|
log,
|
||||||
"Received invalid duties from beacon node";
|
"Received invalid duties from beacon node";
|
||||||
"bad_duty_count" => invalid,
|
"bad_duty_count" => invalid,
|
||||||
"info" => "Duties are from wrong epoch."
|
"info" => "Duties are from wrong epoch."
|
||||||
@@ -378,17 +396,18 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trace!(
|
trace!(
|
||||||
service_2.context.log,
|
log,
|
||||||
"Performed duties update";
|
"Performed duties update";
|
||||||
"replaced_duties" => replaced,
|
"identical" => identical,
|
||||||
"identical_duties" => identical,
|
"new_epoch" => new_epoch,
|
||||||
"new_duties" => new,
|
"new_validator" => new_validator,
|
||||||
|
"replaced" => replaced,
|
||||||
"epoch" => format!("{}", epoch)
|
"epoch" => format!("{}", epoch)
|
||||||
);
|
);
|
||||||
|
|
||||||
if replaced > 0 {
|
if replaced > 0 {
|
||||||
warn!(
|
warn!(
|
||||||
service_2.context.log,
|
log,
|
||||||
"Duties changed during routine update";
|
"Duties changed during routine update";
|
||||||
"info" => "Chain re-org likely occurred."
|
"info" => "Chain re-org likely occurred."
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user