mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 12:58:31 +00:00
Do project-wide s/epoch_length/slots_per_epoch/g
This commit is contained in:
@@ -13,7 +13,7 @@ pub struct Config {
|
||||
/// Initial validators.
|
||||
pub deposits_for_chain_start: usize,
|
||||
/// Number of slots in an epoch.
|
||||
pub epoch_length: Option<u64>,
|
||||
pub slots_per_epoch: Option<u64>,
|
||||
/// Number of slots to build before ending execution.
|
||||
pub num_slots: u64,
|
||||
/// Number of slots that should be skipped due to inactive validator.
|
||||
@@ -34,7 +34,7 @@ impl Config {
|
||||
Self {
|
||||
deposits_for_chain_start: as_usize(&yaml, "deposits_for_chain_start")
|
||||
.expect("Must specify validator count"),
|
||||
epoch_length: as_u64(&yaml, "epoch_length"),
|
||||
slots_per_epoch: as_u64(&yaml, "slots_per_epoch"),
|
||||
num_slots: as_u64(&yaml, "num_slots").expect("Must specify `config.num_slots`"),
|
||||
skip_slots: as_vec_u64(yaml, "skip_slots"),
|
||||
deposits: parse_deposits(&yaml),
|
||||
|
||||
@@ -54,12 +54,12 @@ impl TestCase {
|
||||
|
||||
/// Return a `ChainSpec::foundation()`.
|
||||
///
|
||||
/// If specified in `config`, returns it with a modified `epoch_length`.
|
||||
/// If specified in `config`, returns it with a modified `slots_per_epoch`.
|
||||
fn spec(&self) -> ChainSpec {
|
||||
let mut spec = ChainSpec::foundation();
|
||||
|
||||
if let Some(n) = self.config.epoch_length {
|
||||
spec.epoch_length = n;
|
||||
if let Some(n) = self.config.slots_per_epoch {
|
||||
spec.slots_per_epoch = n;
|
||||
}
|
||||
|
||||
spec
|
||||
@@ -174,7 +174,7 @@ impl TestCase {
|
||||
|
||||
for state_check in state_checks {
|
||||
let adjusted_state_slot =
|
||||
state.slot - spec.genesis_epoch.start_slot(spec.epoch_length);
|
||||
state.slot - spec.genesis_epoch.start_slot(spec.slots_per_epoch);
|
||||
|
||||
if state_check.slot == adjusted_state_slot {
|
||||
state_check.assert_valid(state, spec);
|
||||
|
||||
@@ -36,13 +36,13 @@ impl StateCheck {
|
||||
///
|
||||
/// Panics with an error message if any test fails.
|
||||
pub fn assert_valid(&self, state: &BeaconState, spec: &ChainSpec) {
|
||||
let state_epoch = state.slot.epoch(spec.epoch_length);
|
||||
let state_epoch = state.slot.epoch(spec.slots_per_epoch);
|
||||
|
||||
info!("Running state check for slot height {}.", self.slot);
|
||||
|
||||
assert_eq!(
|
||||
self.slot,
|
||||
state.slot - spec.genesis_epoch.start_slot(spec.epoch_length),
|
||||
state.slot - spec.genesis_epoch.start_slot(spec.slots_per_epoch),
|
||||
"State slot is invalid."
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user