mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +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:
@@ -488,7 +488,7 @@ impl<E: EthSpec> Tester<E> {
|
||||
let since_genesis = tick
|
||||
.checked_sub(genesis_time)
|
||||
.ok_or_else(|| Error::FailedToParseTest("tick is prior to genesis".into()))?;
|
||||
let slots_since_genesis = since_genesis / self.spec.seconds_per_slot;
|
||||
let slots_since_genesis = since_genesis / self.spec.get_slot_duration().as_secs();
|
||||
Ok(self.spec.genesis_slot + slots_since_genesis)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ use rayon::prelude::*;
|
||||
use std::cmp::max;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use environment::tracing_common;
|
||||
use tracing_subscriber::prelude::*;
|
||||
@@ -175,8 +174,11 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
let latest_fork_version = spec.electra_fork_version;
|
||||
let latest_fork_start_epoch = ELECTRA_FORK_EPOCH;
|
||||
|
||||
spec.seconds_per_slot /= speed_up_factor;
|
||||
spec.seconds_per_slot = max(1, spec.seconds_per_slot);
|
||||
let mut slot_duration_ms = spec.get_slot_duration().as_millis() as u64;
|
||||
slot_duration_ms /= speed_up_factor;
|
||||
slot_duration_ms = max(1_000, slot_duration_ms);
|
||||
spec = spec.set_slot_duration_ms::<MinimalEthSpec>(slot_duration_ms);
|
||||
|
||||
spec.genesis_delay = genesis_delay;
|
||||
spec.min_genesis_time = 0;
|
||||
spec.min_genesis_active_validator_count = total_validator_count as u64;
|
||||
@@ -188,7 +190,7 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
let spec = Arc::new(spec);
|
||||
env.eth2_config.spec = spec.clone();
|
||||
|
||||
let slot_duration = Duration::from_secs(spec.seconds_per_slot);
|
||||
let slot_duration = spec.get_slot_duration();
|
||||
let slots_per_epoch = MinimalEthSpec::slots_per_epoch();
|
||||
let initial_validator_count = spec.min_genesis_active_validator_count as usize;
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ use rayon::prelude::*;
|
||||
use std::cmp::max;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tokio::time::sleep;
|
||||
use tracing::Level;
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};
|
||||
use types::{Epoch, EthSpec, MinimalEthSpec};
|
||||
|
||||
const END_EPOCH: u64 = 16;
|
||||
const GENESIS_DELAY: u64 = 38;
|
||||
const ALTAIR_FORK_EPOCH: u64 = 0;
|
||||
@@ -179,8 +179,11 @@ pub fn run_fallback_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
|
||||
let genesis_delay = GENESIS_DELAY;
|
||||
|
||||
spec.seconds_per_slot /= speed_up_factor;
|
||||
spec.seconds_per_slot = max(1, spec.seconds_per_slot);
|
||||
let mut slot_duration_ms = spec.get_slot_duration().as_millis() as u64;
|
||||
slot_duration_ms /= speed_up_factor;
|
||||
slot_duration_ms = max(1_000, slot_duration_ms);
|
||||
spec = spec.set_slot_duration_ms::<MinimalEthSpec>(slot_duration_ms);
|
||||
|
||||
spec.genesis_delay = genesis_delay;
|
||||
spec.min_genesis_time = 0;
|
||||
spec.min_genesis_active_validator_count = total_validator_count as u64;
|
||||
@@ -193,7 +196,7 @@ pub fn run_fallback_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
let spec = Arc::new(spec);
|
||||
env.eth2_config.spec = spec.clone();
|
||||
|
||||
let slot_duration = Duration::from_secs(spec.seconds_per_slot);
|
||||
let slot_duration = spec.get_slot_duration();
|
||||
let slots_per_epoch = MinimalEthSpec::slots_per_epoch();
|
||||
|
||||
let disconnection_epoch = 1;
|
||||
|
||||
@@ -73,23 +73,33 @@ fn default_mock_execution_config<E: EthSpec>(
|
||||
if let Some(capella_fork_epoch) = spec.capella_fork_epoch {
|
||||
mock_execution_config.shanghai_time = Some(
|
||||
genesis_time
|
||||
+ spec.seconds_per_slot * E::slots_per_epoch() * capella_fork_epoch.as_u64(),
|
||||
+ (spec.get_slot_duration().as_secs())
|
||||
* E::slots_per_epoch()
|
||||
* capella_fork_epoch.as_u64(),
|
||||
)
|
||||
}
|
||||
if let Some(deneb_fork_epoch) = spec.deneb_fork_epoch {
|
||||
mock_execution_config.cancun_time = Some(
|
||||
genesis_time + spec.seconds_per_slot * E::slots_per_epoch() * deneb_fork_epoch.as_u64(),
|
||||
genesis_time
|
||||
+ (spec.get_slot_duration().as_secs())
|
||||
* E::slots_per_epoch()
|
||||
* deneb_fork_epoch.as_u64(),
|
||||
)
|
||||
}
|
||||
if let Some(electra_fork_epoch) = spec.electra_fork_epoch {
|
||||
mock_execution_config.prague_time = Some(
|
||||
genesis_time
|
||||
+ spec.seconds_per_slot * E::slots_per_epoch() * electra_fork_epoch.as_u64(),
|
||||
+ (spec.get_slot_duration().as_secs())
|
||||
* E::slots_per_epoch()
|
||||
* electra_fork_epoch.as_u64(),
|
||||
)
|
||||
}
|
||||
if let Some(fulu_fork_epoch) = spec.fulu_fork_epoch {
|
||||
mock_execution_config.osaka_time = Some(
|
||||
genesis_time + spec.seconds_per_slot * E::slots_per_epoch() * fulu_fork_epoch.as_u64(),
|
||||
genesis_time
|
||||
+ (spec.get_slot_duration().as_secs())
|
||||
* E::slots_per_epoch()
|
||||
* fulu_fork_epoch.as_u64(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user