add historical summaries (#3865)

* add historical summaries

* fix tree hash caching, disable the sanity slots test with fake crypto

* add ssz static HistoricalSummary

* only store historical summaries after capella

* Teach `UpdatePattern` about Capella

* Tidy EF tests

* Clippy

Co-authored-by: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
realbigsean
2023-01-10 20:40:21 -05:00
committed by GitHub
parent 87c44697d0
commit 98b11bbd3f
21 changed files with 424 additions and 50 deletions

View File

@@ -0,0 +1,23 @@
use crate::EpochProcessingError;
use safe_arith::SafeArith;
use types::historical_summary::HistoricalSummary;
use types::{BeaconState, EthSpec};
pub fn process_historical_summaries_update<T: EthSpec>(
state: &mut BeaconState<T>,
) -> Result<(), EpochProcessingError> {
// Set historical block root accumulator.
let next_epoch = state.next_epoch()?;
if next_epoch
.as_u64()
.safe_rem((T::slots_per_historical_root() as u64).safe_div(T::slots_per_epoch())?)?
== 0
{
let summary = HistoricalSummary::new(state);
return state
.historical_summaries_mut()?
.push(summary)
.map_err(Into::into);
}
Ok(())
}