add new beacon state variant for shanghai

This commit is contained in:
realbigsean
2022-02-20 15:27:22 -07:00
parent 203418ffc9
commit acaa340b41
10 changed files with 105 additions and 36 deletions

View File

@@ -97,7 +97,7 @@ impl<E: EthSpec> EpochTransition<E> for JustificationAndFinalization {
justification_and_finalization_state.apply_changes_to_state(state);
Ok(())
}
BeaconState::Altair(_) | BeaconState::Merge(_) => {
BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => {
let justification_and_finalization_state =
altair::process_justification_and_finalization(
state,
@@ -118,7 +118,7 @@ impl<E: EthSpec> EpochTransition<E> for RewardsAndPenalties {
validator_statuses.process_attestations(state)?;
base::process_rewards_and_penalties(state, &mut validator_statuses, spec)
}
BeaconState::Altair(_) | BeaconState::Merge(_) => {
BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => {
altair::process_rewards_and_penalties(
state,
&altair::ParticipationCache::new(state, spec).unwrap(),
@@ -147,7 +147,7 @@ impl<E: EthSpec> EpochTransition<E> for Slashings {
spec,
)?;
}
BeaconState::Altair(_) | BeaconState::Merge(_) => {
BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => {
process_slashings(
state,
altair::ParticipationCache::new(state, spec)
@@ -205,7 +205,7 @@ impl<E: EthSpec> EpochTransition<E> for SyncCommitteeUpdates {
fn run(state: &mut BeaconState<E>, spec: &ChainSpec) -> Result<(), EpochProcessingError> {
match state {
BeaconState::Base(_) => Ok(()),
BeaconState::Altair(_) | BeaconState::Merge(_) => {
BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => {
altair::process_sync_committee_updates(state, spec)
}
}
@@ -216,11 +216,13 @@ impl<E: EthSpec> EpochTransition<E> for InactivityUpdates {
fn run(state: &mut BeaconState<E>, spec: &ChainSpec) -> Result<(), EpochProcessingError> {
match state {
BeaconState::Base(_) => Ok(()),
BeaconState::Altair(_) | BeaconState::Merge(_) => altair::process_inactivity_updates(
state,
&altair::ParticipationCache::new(state, spec).unwrap(),
spec,
),
BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => {
altair::process_inactivity_updates(
state,
&altair::ParticipationCache::new(state, spec).unwrap(),
spec,
)
}
}
}
}
@@ -229,7 +231,7 @@ impl<E: EthSpec> EpochTransition<E> for ParticipationFlagUpdates {
fn run(state: &mut BeaconState<E>, _: &ChainSpec) -> Result<(), EpochProcessingError> {
match state {
BeaconState::Base(_) => Ok(()),
BeaconState::Altair(_) | BeaconState::Merge(_) => {
BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => {
altair::process_participation_flag_updates(state)
}
}

View File

@@ -81,14 +81,16 @@ impl<E: EthSpec> Operation<E> for Attestation<E> {
BeaconState::Base(_) => {
base::process_attestations(state, &[self.clone()], VerifySignatures::True, spec)
}
BeaconState::Altair(_) | BeaconState::Merge(_) => altair::process_attestation(
state,
self,
0,
proposer_index,
VerifySignatures::True,
spec,
),
BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => {
altair::process_attestation(
state,
self,
0,
proposer_index,
VerifySignatures::True,
spec,
)
}
}
}
}