mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Add Electra fork boilerplate (#5122)
* Add Electra fork boilerplate * Remove electra from spec tests * Fix tests * Remove sneaky log file * Fix more tests * Fix even more tests and add suggestions * Remove unrelated lcli addition * Update more tests * Merge branch 'unstable' into electra * Add comment for test-suite lcli override * Merge branch 'unstable' into electra * Cleanup * Merge branch 'unstable' into electra * Apply suggestions * Merge branch 'unstable' into electra * Merge sigp/unstable into electra * Merge branch 'unstable' into electra
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::{DBColumn, Error, StoreItem};
|
||||
use ssz::{Decode, Encode};
|
||||
use types::{
|
||||
BlobSidecarList, EthSpec, ExecutionPayload, ExecutionPayloadCapella, ExecutionPayloadDeneb,
|
||||
ExecutionPayloadMerge,
|
||||
ExecutionPayloadElectra, ExecutionPayloadMerge,
|
||||
};
|
||||
|
||||
macro_rules! impl_store_item {
|
||||
@@ -25,6 +25,7 @@ macro_rules! impl_store_item {
|
||||
impl_store_item!(ExecutionPayloadMerge);
|
||||
impl_store_item!(ExecutionPayloadCapella);
|
||||
impl_store_item!(ExecutionPayloadDeneb);
|
||||
impl_store_item!(ExecutionPayloadElectra);
|
||||
impl_store_item!(BlobSidecarList);
|
||||
|
||||
/// This fork-agnostic implementation should be only used for writing.
|
||||
@@ -41,12 +42,18 @@ impl<E: EthSpec> StoreItem for ExecutionPayload<E> {
|
||||
}
|
||||
|
||||
fn from_store_bytes(bytes: &[u8]) -> Result<Self, Error> {
|
||||
ExecutionPayloadDeneb::from_ssz_bytes(bytes)
|
||||
.map(Self::Deneb)
|
||||
ExecutionPayloadElectra::from_ssz_bytes(bytes)
|
||||
.map(Self::Electra)
|
||||
.or_else(|_| {
|
||||
ExecutionPayloadCapella::from_ssz_bytes(bytes)
|
||||
.map(Self::Capella)
|
||||
.or_else(|_| ExecutionPayloadMerge::from_ssz_bytes(bytes).map(Self::Merge))
|
||||
ExecutionPayloadDeneb::from_ssz_bytes(bytes)
|
||||
.map(Self::Deneb)
|
||||
.or_else(|_| {
|
||||
ExecutionPayloadCapella::from_ssz_bytes(bytes)
|
||||
.map(Self::Capella)
|
||||
.or_else(|_| {
|
||||
ExecutionPayloadMerge::from_ssz_bytes(bytes).map(Self::Merge)
|
||||
})
|
||||
})
|
||||
})
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use types::*;
|
||||
///
|
||||
/// Utilises lazy-loading from separate storage for its vector fields.
|
||||
#[superstruct(
|
||||
variants(Base, Altair, Merge, Capella, Deneb),
|
||||
variants(Base, Altair, Merge, Capella, Deneb, Electra),
|
||||
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, Capella, Deneb))]
|
||||
#[superstruct(only(Altair, Merge, Capella, Deneb, Electra))]
|
||||
pub previous_epoch_participation: VariableList<ParticipationFlags, T::ValidatorRegistryLimit>,
|
||||
#[superstruct(only(Altair, Merge, Capella, Deneb))]
|
||||
#[superstruct(only(Altair, Merge, Capella, Deneb, Electra))]
|
||||
pub current_epoch_participation: VariableList<ParticipationFlags, T::ValidatorRegistryLimit>,
|
||||
|
||||
// Finality
|
||||
@@ -78,13 +78,13 @@ where
|
||||
pub finalized_checkpoint: Checkpoint,
|
||||
|
||||
// Inactivity
|
||||
#[superstruct(only(Altair, Merge, Capella, Deneb))]
|
||||
#[superstruct(only(Altair, Merge, Capella, Deneb, Electra))]
|
||||
pub inactivity_scores: VariableList<u64, T::ValidatorRegistryLimit>,
|
||||
|
||||
// Light-client sync committees
|
||||
#[superstruct(only(Altair, Merge, Capella, Deneb))]
|
||||
#[superstruct(only(Altair, Merge, Capella, Deneb, Electra))]
|
||||
pub current_sync_committee: Arc<SyncCommittee<T>>,
|
||||
#[superstruct(only(Altair, Merge, Capella, Deneb))]
|
||||
#[superstruct(only(Altair, Merge, Capella, Deneb, Electra))]
|
||||
pub next_sync_committee: Arc<SyncCommittee<T>>,
|
||||
|
||||
// Execution
|
||||
@@ -103,15 +103,20 @@ where
|
||||
partial_getter(rename = "latest_execution_payload_header_deneb")
|
||||
)]
|
||||
pub latest_execution_payload_header: ExecutionPayloadHeaderDeneb<T>,
|
||||
#[superstruct(
|
||||
only(Electra),
|
||||
partial_getter(rename = "latest_execution_payload_header_electra")
|
||||
)]
|
||||
pub latest_execution_payload_header: ExecutionPayloadHeaderElectra<T>,
|
||||
|
||||
// Capella
|
||||
#[superstruct(only(Capella, Deneb))]
|
||||
#[superstruct(only(Capella, Deneb, Electra))]
|
||||
pub next_withdrawal_index: u64,
|
||||
#[superstruct(only(Capella, Deneb))]
|
||||
#[superstruct(only(Capella, Deneb, Electra))]
|
||||
pub next_withdrawal_validator_index: u64,
|
||||
|
||||
#[ssz(skip_serializing, skip_deserializing)]
|
||||
#[superstruct(only(Capella, Deneb))]
|
||||
#[superstruct(only(Capella, Deneb, Electra))]
|
||||
pub historical_summaries: Option<VariableList<HistoricalSummary, T::HistoricalRootsLimit>>,
|
||||
}
|
||||
|
||||
@@ -243,6 +248,23 @@ impl<T: EthSpec> PartialBeaconState<T> {
|
||||
],
|
||||
[historical_summaries]
|
||||
),
|
||||
BeaconState::Electra(s) => impl_from_state_forgetful!(
|
||||
s,
|
||||
outer,
|
||||
Electra,
|
||||
PartialBeaconStateElectra,
|
||||
[
|
||||
previous_epoch_participation,
|
||||
current_epoch_participation,
|
||||
current_sync_committee,
|
||||
next_sync_committee,
|
||||
inactivity_scores,
|
||||
latest_execution_payload_header,
|
||||
next_withdrawal_index,
|
||||
next_withdrawal_validator_index
|
||||
],
|
||||
[historical_summaries]
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,6 +510,22 @@ impl<E: EthSpec> TryInto<BeaconState<E>> for PartialBeaconState<E> {
|
||||
],
|
||||
[historical_summaries]
|
||||
),
|
||||
PartialBeaconState::Electra(inner) => impl_try_into_beacon_state!(
|
||||
inner,
|
||||
Electra,
|
||||
BeaconStateElectra,
|
||||
[
|
||||
previous_epoch_participation,
|
||||
current_epoch_participation,
|
||||
current_sync_committee,
|
||||
next_sync_committee,
|
||||
inactivity_scores,
|
||||
latest_execution_payload_header,
|
||||
next_withdrawal_index,
|
||||
next_withdrawal_validator_index
|
||||
],
|
||||
[historical_summaries]
|
||||
),
|
||||
};
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user