Implemented detailed state eqs in ef_tests

This commit is contained in:
Paul Hauner
2019-05-22 18:00:21 +10:00
parent 7a99654f89
commit b2666d700c
4 changed files with 73 additions and 4 deletions

View File

@@ -762,6 +762,16 @@ impl<T: EthSpec> BeaconState<T> {
Ok(())
}
/// Drop all caches on the state.
pub fn drop_all_caches(&mut self) {
self.drop_committee_cache(RelativeEpoch::Previous);
self.drop_committee_cache(RelativeEpoch::Current);
self.drop_committee_cache(RelativeEpoch::Next);
self.drop_pubkey_cache();
self.drop_tree_hash_cache();
self.exit_cache = ExitCache::default();
}
/// Build an epoch cache, unless it is has already been built.
pub fn build_committee_cache(
&mut self,
@@ -824,7 +834,7 @@ impl<T: EthSpec> BeaconState<T> {
}
/// Drops the cache, leaving it in an uninitialized state.
fn drop_cache(&mut self, relative_epoch: RelativeEpoch) {
fn drop_committee_cache(&mut self, relative_epoch: RelativeEpoch) {
self.committee_caches[Self::cache_index(relative_epoch)] = CommitteeCache::default();
}
@@ -887,6 +897,11 @@ impl<T: EthSpec> BeaconState<T> {
.and_then(|b| Ok(Hash256::from_slice(b)))
.map_err(Into::into)
}
/// Completely drops the tree hash cache, replacing it with a new, empty cache.
pub fn drop_tree_hash_cache(&mut self) {
self.tree_hash_cache = TreeHashCache::default()
}
}
impl From<RelativeEpochError> for Error {