mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Replace INTERVALS_PER_SLOT with explicit slot component times (#7944)
https://github.com/ethereum/consensus-specs/pull/4476 Co-Authored-By: Barnabas Busa <barnabas.busa@ethereum.org> Co-Authored-By: Eitan Seri- Levi <eserilev@gmail.com> Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu> Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com> Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -315,7 +315,7 @@ where
|
||||
let deneb_time = genesis_time
|
||||
+ (deneb_fork_epoch.as_u64()
|
||||
* E::slots_per_epoch()
|
||||
* spec.seconds_per_slot);
|
||||
* spec.get_slot_duration().as_secs());
|
||||
|
||||
// Shrink the blob availability window so users don't start
|
||||
// a sync right before blobs start to disappear from the P2P
|
||||
@@ -325,7 +325,7 @@ where
|
||||
.saturating_sub(BLOB_AVAILABILITY_REDUCTION_EPOCHS);
|
||||
let blob_availability_window = reduced_p2p_availability_epochs
|
||||
* E::slots_per_epoch()
|
||||
* spec.seconds_per_slot;
|
||||
* spec.get_slot_duration().as_secs();
|
||||
|
||||
if now > deneb_time + blob_availability_window {
|
||||
return Err(
|
||||
@@ -592,17 +592,17 @@ where
|
||||
.network_globals
|
||||
.clone()
|
||||
.ok_or("slot_notifier requires a libp2p network")?;
|
||||
let seconds_per_slot = self
|
||||
let slot_duration = self
|
||||
.chain_spec
|
||||
.as_ref()
|
||||
.ok_or("slot_notifier requires a chain spec")?
|
||||
.seconds_per_slot;
|
||||
.get_slot_duration();
|
||||
|
||||
spawn_notifier(
|
||||
context.executor,
|
||||
beacon_chain,
|
||||
network_globals,
|
||||
seconds_per_slot,
|
||||
slot_duration,
|
||||
)
|
||||
.map_err(|e| format!("Unable to start slot notifier: {}", e))?;
|
||||
|
||||
@@ -906,7 +906,7 @@ where
|
||||
let slot_clock = SystemTimeSlotClock::new(
|
||||
spec.genesis_slot,
|
||||
Duration::from_secs(genesis_time),
|
||||
Duration::from_secs(spec.seconds_per_slot),
|
||||
spec.get_slot_duration(),
|
||||
);
|
||||
|
||||
self.slot_clock = Some(slot_clock);
|
||||
|
||||
@@ -44,10 +44,8 @@ pub fn spawn_notifier<T: BeaconChainTypes>(
|
||||
executor: task_executor::TaskExecutor,
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
network: Arc<NetworkGlobals<T::EthSpec>>,
|
||||
seconds_per_slot: u64,
|
||||
slot_duration: Duration,
|
||||
) -> Result<(), String> {
|
||||
let slot_duration = Duration::from_secs(seconds_per_slot);
|
||||
|
||||
let speedo = Mutex::new(Speedo::default());
|
||||
|
||||
// Keep track of sync state and reset the speedo on specific sync state changes.
|
||||
@@ -568,8 +566,8 @@ fn find_next_fork_to_prepare<T: BeaconChainTypes>(
|
||||
// Find the first fork that is scheduled and close to happen
|
||||
if let Some(fork_epoch) = fork_epoch {
|
||||
let fork_slot = fork_epoch.start_slot(T::EthSpec::slots_per_epoch());
|
||||
let preparation_slots =
|
||||
FORK_READINESS_PREPARATION_SECONDS / beacon_chain.spec.seconds_per_slot;
|
||||
let preparation_slots = FORK_READINESS_PREPARATION_SECONDS
|
||||
/ beacon_chain.spec.get_slot_duration().as_secs();
|
||||
let in_fork_preparation_period = current_slot + preparation_slots > fork_slot;
|
||||
if in_fork_preparation_period {
|
||||
return Some(*fork);
|
||||
|
||||
Reference in New Issue
Block a user