mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 05:18:30 +00:00
Fix failing tests (#4423)
* Get tests passing * Get benchmarks compiling * Fix EF withdrawals test * Remove unused deps * Fix tree_hash panic in tests * Fix slasher compilation * Fix ssz_generic test * Get more tests passing * Fix EF tests for real * Fix local testnet scripts
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
|
||||
use criterion::Criterion;
|
||||
use criterion::{black_box, criterion_group, criterion_main, Benchmark};
|
||||
use milhouse::List;
|
||||
use rayon::prelude::*;
|
||||
use ssz::Encode;
|
||||
use std::sync::Arc;
|
||||
use types::{
|
||||
test_utils::generate_deterministic_keypair, BeaconState, Epoch, Eth1Data, EthSpec, Hash256,
|
||||
MainnetEthSpec, Validator,
|
||||
MainnetEthSpec, Validator, ValidatorMutable,
|
||||
};
|
||||
|
||||
fn get_state<E: EthSpec>(validator_count: usize) -> BeaconState<E> {
|
||||
@@ -27,21 +28,25 @@ fn get_state<E: EthSpec>(validator_count: usize) -> BeaconState<E> {
|
||||
.expect("should add balance");
|
||||
}
|
||||
|
||||
*state.validators_mut() = (0..validator_count)
|
||||
.collect::<Vec<_>>()
|
||||
.par_iter()
|
||||
.map(|&i| Validator {
|
||||
pubkey: generate_deterministic_keypair(i).pk.into(),
|
||||
withdrawal_credentials: Hash256::from_low_u64_le(i as u64),
|
||||
effective_balance: spec.max_effective_balance,
|
||||
slashed: false,
|
||||
activation_eligibility_epoch: Epoch::new(0),
|
||||
activation_epoch: Epoch::new(0),
|
||||
exit_epoch: Epoch::from(u64::max_value()),
|
||||
withdrawable_epoch: Epoch::from(u64::max_value()),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.into();
|
||||
*state.validators_mut() = List::new(
|
||||
(0..validator_count)
|
||||
.collect::<Vec<_>>()
|
||||
.par_iter()
|
||||
.map(|&i| Validator {
|
||||
pubkey: Arc::new(generate_deterministic_keypair(i).pk.compress()),
|
||||
mutable: ValidatorMutable {
|
||||
withdrawal_credentials: Hash256::from_low_u64_le(i as u64),
|
||||
effective_balance: spec.max_effective_balance,
|
||||
slashed: false,
|
||||
activation_eligibility_epoch: Epoch::new(0),
|
||||
activation_epoch: Epoch::new(0),
|
||||
exit_epoch: Epoch::from(u64::max_value()),
|
||||
withdrawable_epoch: Epoch::from(u64::max_value()),
|
||||
},
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
state
|
||||
}
|
||||
@@ -96,19 +101,6 @@ fn all_benches(c: &mut Criterion) {
|
||||
.sample_size(10),
|
||||
);
|
||||
|
||||
let inner_state = state.clone();
|
||||
c.bench(
|
||||
&format!("{}_validators", validator_count),
|
||||
Benchmark::new("clone/tree_hash_cache", move |b| {
|
||||
b.iter_batched_ref(
|
||||
|| inner_state.clone(),
|
||||
|state| black_box(state.tree_hash_cache().clone()),
|
||||
criterion::BatchSize::SmallInput,
|
||||
)
|
||||
})
|
||||
.sample_size(10),
|
||||
);
|
||||
|
||||
let inner_state = state.clone();
|
||||
c.bench(
|
||||
&format!("{}_validators", validator_count),
|
||||
|
||||
@@ -336,11 +336,14 @@ where
|
||||
pub slashings: FixedVector<u64, T::EpochsPerSlashingsVector>,
|
||||
|
||||
// Attestations (genesis fork only)
|
||||
// FIXME(sproul): excluded from tree lists due to ResetListDiff
|
||||
#[superstruct(only(Base))]
|
||||
#[test_random(default)]
|
||||
#[metastruct(exclude_from(tree_lists))]
|
||||
pub previous_epoch_attestations: VList<PendingAttestation<T>, T::MaxPendingAttestations>,
|
||||
#[superstruct(only(Base))]
|
||||
#[test_random(default)]
|
||||
#[metastruct(exclude_from(tree_lists))]
|
||||
pub current_epoch_attestations: VList<PendingAttestation<T>, T::MaxPendingAttestations>,
|
||||
|
||||
// Participation (Altair and later)
|
||||
@@ -1899,6 +1902,8 @@ impl<T: EthSpec, GenericValidator: ValidatorTrait> BeaconState<T, GenericValidat
|
||||
pub fn apply_pending_mutations(&mut self) -> Result<(), Error> {
|
||||
match self {
|
||||
Self::Base(inner) => {
|
||||
inner.previous_epoch_attestations.apply_updates()?;
|
||||
inner.current_epoch_attestations.apply_updates()?;
|
||||
map_beacon_state_base_tree_list_fields!(inner, |_, x| { x.apply_updates() })
|
||||
}
|
||||
Self::Altair(inner) => {
|
||||
|
||||
Reference in New Issue
Block a user