mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
Represent slots in secs instead of millisecs (#2163)
## Issue Addressed NA ## Proposed Changes Copied from #2083, changes the config milliseconds_per_slot to seconds_per_slot to avoid errors when slot duration is not a multiple of a second. To avoid deserializing old serialized data (with milliseconds instead of seconds) the Serialize and Deserialize derive got removed from the Spec struct (isn't currently used anyway). This PR replaces #2083 for the purpose of fixing a merge conflict without requiring the input of @blacktemplar. ## Additional Info NA Co-authored-by: blacktemplar <blacktemplar@a1.net>
This commit is contained in:
@@ -126,7 +126,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
|
||||
pub fn start_update_service(self, spec: &ChainSpec) -> Result<(), String> {
|
||||
let log = self.context.log().clone();
|
||||
|
||||
let slot_duration = Duration::from_millis(spec.milliseconds_per_slot);
|
||||
let slot_duration = Duration::from_secs(spec.seconds_per_slot);
|
||||
let duration_to_next_slot = self
|
||||
.slot_clock
|
||||
.duration_to_next_slot()
|
||||
|
||||
@@ -466,7 +466,7 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
|
||||
.ok_or("Unable to determine duration to next slot")?;
|
||||
|
||||
let mut interval = {
|
||||
let slot_duration = Duration::from_millis(spec.milliseconds_per_slot);
|
||||
let slot_duration = Duration::from_secs(spec.seconds_per_slot);
|
||||
// Note: `interval_at` panics if `slot_duration` is 0
|
||||
interval_at(
|
||||
Instant::now() + duration_to_next_slot + TIME_DELAY_FROM_SLOT,
|
||||
|
||||
@@ -148,7 +148,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ForkService<T, E> {
|
||||
.ok_or("Unable to determine duration to next epoch")?;
|
||||
|
||||
let mut interval = {
|
||||
let slot_duration = Duration::from_millis(spec.milliseconds_per_slot);
|
||||
let slot_duration = Duration::from_secs(spec.seconds_per_slot);
|
||||
// Note: interval_at panics if `slot_duration * E::slots_per_epoch()` = 0
|
||||
interval_at(
|
||||
Instant::now() + duration_to_next_epoch + TIME_DELAY_FROM_SLOT,
|
||||
|
||||
@@ -248,7 +248,7 @@ impl<T: EthSpec> ProductionValidatorClient<T> {
|
||||
let slot_clock = SystemTimeSlotClock::new(
|
||||
context.eth2_config.spec.genesis_slot,
|
||||
Duration::from_secs(genesis_time),
|
||||
Duration::from_millis(context.eth2_config.spec.milliseconds_per_slot),
|
||||
Duration::from_secs(context.eth2_config.spec.seconds_per_slot),
|
||||
);
|
||||
|
||||
beacon_nodes.set_slot_clock(slot_clock.clone());
|
||||
|
||||
@@ -11,7 +11,7 @@ pub fn spawn_notifier<T: EthSpec>(client: &ProductionValidatorClient<T>) -> Resu
|
||||
let executor = context.executor.clone();
|
||||
let duties_service = client.duties_service.clone();
|
||||
|
||||
let slot_duration = Duration::from_millis(context.eth2_config.spec.milliseconds_per_slot);
|
||||
let slot_duration = Duration::from_secs(context.eth2_config.spec.seconds_per_slot);
|
||||
let duration_to_next_slot = duties_service
|
||||
.slot_clock
|
||||
.duration_to_next_slot()
|
||||
|
||||
Reference in New Issue
Block a user