Remove genesis_epoch from ChainSpec

This commit is contained in:
Paul Hauner
2019-06-08 08:17:42 -04:00
parent e74d49fc8a
commit caddeba81b
16 changed files with 34 additions and 38 deletions

View File

@@ -23,7 +23,7 @@ pub fn bench_epoch_processing_n_validators(c: &mut Criterion, validator_count: u
TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(validator_count, &spec);
// Set the state to be just before an epoch transition.
let target_slot = (spec.genesis_epoch + 4).end_slot(T::slots_per_epoch());
let target_slot = (T::genesis_epoch() + 4).end_slot(T::slots_per_epoch());
builder.teleport_to_slot(target_slot, &spec);
// Builds all caches; benches will not contain shuffling/committee building times.

View File

@@ -34,7 +34,7 @@ pub fn block_processing_worst_case(c: &mut Criterion) {
bench_builder.maximize_block_operations(&spec);
// Set the state and block to be in the last slot of the 4th epoch.
let last_slot_of_epoch = (spec.genesis_epoch + 4).end_slot(T::slots_per_epoch());
let last_slot_of_epoch = (T::genesis_epoch() + 4).end_slot(T::slots_per_epoch());
bench_builder.set_slot(last_slot_of_epoch, &spec);
// Build all the state caches so the build times aren't included in the benches.
@@ -73,7 +73,7 @@ pub fn block_processing_reasonable_case(c: &mut Criterion) {
bench_builder.num_transfers = 2;
// Set the state and block to be in the last slot of the 4th epoch.
let last_slot_of_epoch = (spec.genesis_epoch + 4).end_slot(T::slots_per_epoch());
let last_slot_of_epoch = (T::genesis_epoch() + 4).end_slot(T::slots_per_epoch());
bench_builder.set_slot(last_slot_of_epoch, &spec);
// Build all the state caches so the build times aren't included in the benches.

View File

@@ -25,8 +25,8 @@ pub fn get_genesis_beacon_state<T: EthSpec>(
// Process genesis activations.
for validator in &mut state.validator_registry {
if validator.effective_balance >= spec.max_effective_balance {
validator.activation_eligibility_epoch = spec.genesis_epoch;
validator.activation_epoch = spec.genesis_epoch;
validator.activation_eligibility_epoch = T::genesis_epoch();
validator.activation_epoch = T::genesis_epoch();
}
}

View File

@@ -105,7 +105,7 @@ fn get_builder(spec: &ChainSpec) -> (BlockProcessingBuilder<FoundationEthSpec>)
// Set the state and block to be in the last slot of the 4th epoch.
let last_slot_of_epoch =
(spec.genesis_epoch + 4).end_slot(FoundationEthSpec::slots_per_epoch());
(FoundationEthSpec::genesis_epoch() + 4).end_slot(FoundationEthSpec::slots_per_epoch());
builder.set_slot(last_slot_of_epoch, &spec);
builder.build_caches(&spec);

View File

@@ -86,7 +86,7 @@ pub fn process_justification_and_finalization<T: EthSpec>(
total_balances: &TotalBalances,
spec: &ChainSpec,
) -> Result<(), Error> {
if state.current_epoch() == spec.genesis_epoch {
if state.current_epoch() == T::genesis_epoch() {
return Ok(());
}

View File

@@ -39,7 +39,7 @@ pub fn process_rewards_and_penalties<T: EthSpec>(
winning_root_for_shards: &WinningRootHashSet,
spec: &ChainSpec,
) -> Result<(), Error> {
if state.current_epoch() == spec.genesis_epoch {
if state.current_epoch() == T::genesis_epoch() {
return Ok(());
}

View File

@@ -13,7 +13,8 @@ fn runs_without_error() {
let mut builder: TestingBeaconStateBuilder<FewValidatorsEthSpec> =
TestingBeaconStateBuilder::from_deterministic_keypairs(8, &spec);
let target_slot = (spec.genesis_epoch + 4).end_slot(FewValidatorsEthSpec::slots_per_epoch());
let target_slot = (FewValidatorsEthSpec::genesis_epoch() + 4)
.end_slot(FewValidatorsEthSpec::slots_per_epoch());
builder.teleport_to_slot(target_slot, &spec);
let (mut state, _keypairs) = builder.build();