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

@@ -14,7 +14,7 @@ use types::*;
///
/// Utilises lazy-loading from separate storage for its vector fields.
#[superstruct(
variants(Base, Altair, Merge),
variants(Base, Altair, Merge, Shanghai),
variant_attributes(derive(Debug, PartialEq, Clone, Encode, Decode))
)]
#[derive(Debug, PartialEq, Clone, Encode)]
@@ -66,9 +66,9 @@ where
pub current_epoch_attestations: VariableList<PendingAttestation<T>, T::MaxPendingAttestations>,
// Participation (Altair and later)
#[superstruct(only(Altair, Merge))]
#[superstruct(only(Altair, Merge, Shanghai))]
pub previous_epoch_participation: VariableList<ParticipationFlags, T::ValidatorRegistryLimit>,
#[superstruct(only(Altair, Merge))]
#[superstruct(only(Altair, Merge, Shanghai))]
pub current_epoch_participation: VariableList<ParticipationFlags, T::ValidatorRegistryLimit>,
// Finality
@@ -78,17 +78,17 @@ where
pub finalized_checkpoint: Checkpoint,
// Inactivity
#[superstruct(only(Altair, Merge))]
#[superstruct(only(Altair, Merge, Shanghai))]
pub inactivity_scores: VariableList<u64, T::ValidatorRegistryLimit>,
// Light-client sync committees
#[superstruct(only(Altair, Merge))]
#[superstruct(only(Altair, Merge, Shanghai))]
pub current_sync_committee: Arc<SyncCommittee<T>>,
#[superstruct(only(Altair, Merge))]
#[superstruct(only(Altair, Merge, Shanghai))]
pub next_sync_committee: Arc<SyncCommittee<T>>,
// Execution
#[superstruct(only(Merge))]
#[superstruct(only(Merge, Shanghai))]
pub latest_execution_payload_header: ExecutionPayloadHeader<T>,
}
@@ -178,6 +178,20 @@ impl<T: EthSpec> PartialBeaconState<T> {
latest_execution_payload_header
]
),
BeaconState::Shanghai(s) => impl_from_state_forgetful!(
s,
outer,
Shanghai,
PartialBeaconStateShanghai,
[
previous_epoch_participation,
current_epoch_participation,
current_sync_committee,
next_sync_committee,
inactivity_scores,
latest_execution_payload_header
]
),
}
}
@@ -365,6 +379,19 @@ impl<E: EthSpec> TryInto<BeaconState<E>> for PartialBeaconState<E> {
latest_execution_payload_header
]
),
PartialBeaconState::Shanghai(inner) => impl_try_into_beacon_state!(
inner,
Shanghai,
BeaconStateShanghai,
[
previous_epoch_participation,
current_epoch_participation,
current_sync_committee,
next_sync_committee,
inactivity_scores,
latest_execution_payload_header
]
),
};
Ok(state)
}