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

@@ -5,6 +5,7 @@ use crate::decode::{ssz_decode_state, yaml_decode_file};
use crate::type_name;
use crate::type_name::TypeName;
use serde_derive::Deserialize;
use state_processing::per_epoch_processing::capella::process_historical_summaries_update;
use state_processing::per_epoch_processing::{
altair, base,
effective_balance_updates::process_effective_balance_updates,
@@ -57,6 +58,8 @@ pub struct RandaoMixesReset;
#[derive(Debug)]
pub struct HistoricalRootsUpdate;
#[derive(Debug)]
pub struct HistoricalSummariesUpdate;
#[derive(Debug)]
pub struct ParticipationRecordUpdates;
#[derive(Debug)]
pub struct SyncCommitteeUpdates;
@@ -77,6 +80,7 @@ type_name!(EffectiveBalanceUpdates, "effective_balance_updates");
type_name!(SlashingsReset, "slashings_reset");
type_name!(RandaoMixesReset, "randao_mixes_reset");
type_name!(HistoricalRootsUpdate, "historical_roots_update");
type_name!(HistoricalSummariesUpdate, "historical_summaries_update");
type_name!(ParticipationRecordUpdates, "participation_record_updates");
type_name!(SyncCommitteeUpdates, "sync_committee_updates");
type_name!(InactivityUpdates, "inactivity_updates");
@@ -194,7 +198,23 @@ impl<E: EthSpec> EpochTransition<E> for RandaoMixesReset {
impl<E: EthSpec> EpochTransition<E> for HistoricalRootsUpdate {
fn run(state: &mut BeaconState<E>, _spec: &ChainSpec) -> Result<(), EpochProcessingError> {
process_historical_roots_update(state)
match state {
BeaconState::Base(_) | BeaconState::Altair(_) | BeaconState::Merge(_) => {
process_historical_roots_update(state)
}
_ => Ok(()),
}
}
}
impl<E: EthSpec> EpochTransition<E> for HistoricalSummariesUpdate {
fn run(state: &mut BeaconState<E>, _spec: &ChainSpec) -> Result<(), EpochProcessingError> {
match state {
BeaconState::Capella(_) | BeaconState::Eip4844(_) => {
process_historical_summaries_update(state)
}
_ => Ok(()),
}
}
}
@@ -287,10 +307,16 @@ impl<E: EthSpec, T: EpochTransition<E>> Case for EpochProcessing<E, T> {
T::name() != "sync_committee_updates"
&& T::name() != "inactivity_updates"
&& T::name() != "participation_flag_updates"
&& T::name() != "historical_summaries_update"
}
// No phase0 tests for Altair and later.
ForkName::Altair | ForkName::Merge | ForkName::Capella => {
ForkName::Altair | ForkName::Merge => {
T::name() != "participation_record_updates"
&& T::name() != "historical_summaries_update"
}
ForkName::Capella => {
T::name() != "participation_record_updates"
&& T::name() != "historical_roots_update"
}
ForkName::Eip4844 => false, // TODO: revisit when tests are out
}