Duplication of validator polls are no longer fatal

This commit is contained in:
Age Manning 2019-08-07 16:33:21 +10:00
parent b3e0aad7bf
commit 107f32642f
No known key found for this signature in database
GPG Key ID: 05EED64B79E06A93

View File

@ -23,7 +23,7 @@ use protos::services_grpc::{
AttestationServiceClient, BeaconBlockServiceClient, BeaconNodeServiceClient, AttestationServiceClient, BeaconBlockServiceClient, BeaconNodeServiceClient,
ValidatorServiceClient, ValidatorServiceClient,
}; };
use slog::{error, info, warn}; use slog::{crit, error, info, warn};
use slot_clock::{SlotClock, SystemTimeSlotClock}; use slot_clock::{SlotClock, SystemTimeSlotClock};
use std::marker::PhantomData; use std::marker::PhantomData;
use std::sync::Arc; use std::sync::Arc;
@ -37,7 +37,7 @@ use types::{ChainSpec, Epoch, EthSpec, Fork, Slot};
/// A fixed amount of time after a slot to perform operations. This gives the node time to complete /// A fixed amount of time after a slot to perform operations. This gives the node time to complete
/// per-slot processes. /// per-slot processes.
const TIME_DELAY_FROM_SLOT: Duration = Duration::from_millis(200); const TIME_DELAY_FROM_SLOT: Duration = Duration::from_millis(100);
/// The validator service. This is the main thread that executes and maintains validator /// The validator service. This is the main thread that executes and maintains validator
/// duties. /// duties.
@ -106,7 +106,7 @@ impl<B: BeaconNodeDuties + 'static, S: Signer + 'static, E: EthSpec> Service<B,
); );
return Err("Genesis time in the future".into()); return Err("Genesis time in the future".into());
} }
// verify the node's chain id // verify the node's network id
if eth2_config.spec.network_id != info.network_id as u8 { if eth2_config.spec.network_id != info.network_id as u8 {
error!( error!(
log, log,
@ -303,12 +303,16 @@ impl<B: BeaconNodeDuties + 'static, S: Signer + 'static, E: EthSpec> Service<B,
let current_epoch = current_slot.epoch(self.slots_per_epoch); let current_epoch = current_slot.epoch(self.slots_per_epoch);
// this is a fatal error. If the slot clock repeats, there is something wrong with // this is a non-fatal error. If the slot clock repeats, the node could
// the timer, terminate immediately. // have been slow to process the previous slot and is now duplicating tasks.
assert!( // We ignore duplicated but raise a critical error.
current_slot > self.current_slot, if current_slot <= self.current_slot {
"The Timer should poll a new slot" crit!(
); self.log,
"The validator tried to duplicate a slot. Likely missed the previous slot"
);
return Err("Duplicate slot".into());
}
self.current_slot = current_slot; self.current_slot = current_slot;
info!(self.log, "Processing"; "slot" => current_slot.as_u64(), "epoch" => current_epoch.as_u64()); info!(self.log, "Processing"; "slot" => current_slot.as_u64(), "epoch" => current_epoch.as_u64());
Ok(()) Ok(())