Optimisations and bug fixes for state advance

This commit is reasonably performant on Prater!
This commit is contained in:
Michael Sproul
2022-02-17 14:00:57 +11:00
parent f5dae9106e
commit 1db0e32bfb
13 changed files with 171 additions and 56 deletions

View File

@@ -1729,12 +1729,10 @@ impl<T: EthSpec> BeaconState<T> {
self.clone_with(CloneConfig::committee_caches_only())
}
pub fn is_eligible_validator(&self, val_index: usize) -> Result<bool, Error> {
pub fn is_eligible_validator(&self, val: &Validator) -> bool {
let previous_epoch = self.previous_epoch();
self.get_validator(val_index).map(|val| {
val.is_active_at(previous_epoch)
|| (val.slashed && previous_epoch + Epoch::new(1) < val.withdrawable_epoch)
})
val.is_active_at(previous_epoch)
|| (val.slashed && previous_epoch + Epoch::new(1) < val.withdrawable_epoch)
}
pub fn is_in_inactivity_leak(&self, spec: &ChainSpec) -> bool {