From d9467a8ebb2f8535659b8728e49a92f5a6352bd0 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 18 Nov 2019 12:12:03 +1100 Subject: [PATCH] Fix incorrect cache drops in `advance_caches` --- eth2/types/src/beacon_state.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/eth2/types/src/beacon_state.rs b/eth2/types/src/beacon_state.rs index 54939843e1..f87e140adf 100644 --- a/eth2/types/src/beacon_state.rs +++ b/eth2/types/src/beacon_state.rs @@ -799,13 +799,11 @@ impl BeaconState { /// /// Note: whilst this function will preserve already-built caches, it will not build any. pub fn advance_caches(&mut self) { - let next = Self::committee_cache_index(RelativeEpoch::Previous); - let current = Self::committee_cache_index(RelativeEpoch::Current); - let caches = &mut self.committee_caches[..]; caches.rotate_left(1); + + let next = Self::committee_cache_index(RelativeEpoch::Next); caches[next] = CommitteeCache::default(); - caches[current] = CommitteeCache::default(); } fn committee_cache_index(relative_epoch: RelativeEpoch) -> usize {