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:
@@ -66,6 +66,7 @@ pub fn previous_fork(fork_name: ForkName) -> ForkName {
|
||||
ForkName::Merge => ForkName::Altair,
|
||||
ForkName::Capella => ForkName::Merge,
|
||||
ForkName::Deneb => ForkName::Capella,
|
||||
ForkName::Electra => ForkName::Deneb,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,8 @@ impl<E: EthSpec> EpochTransition<E> for JustificationAndFinalization {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => {
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => {
|
||||
let justification_and_finalization_state =
|
||||
altair::process_justification_and_finalization(
|
||||
state,
|
||||
@@ -126,7 +127,8 @@ impl<E: EthSpec> EpochTransition<E> for RewardsAndPenalties {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => altair::process_rewards_and_penalties(
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => altair::process_rewards_and_penalties(
|
||||
state,
|
||||
&altair::ParticipationCache::new(state, spec).unwrap(),
|
||||
spec,
|
||||
@@ -156,7 +158,8 @@ impl<E: EthSpec> EpochTransition<E> for Slashings {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => {
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => {
|
||||
process_slashings(
|
||||
state,
|
||||
altair::ParticipationCache::new(state, spec)
|
||||
@@ -208,7 +211,7 @@ impl<E: EthSpec> EpochTransition<E> for HistoricalRootsUpdate {
|
||||
impl<E: EthSpec> EpochTransition<E> for HistoricalSummariesUpdate {
|
||||
fn run(state: &mut BeaconState<E>, _spec: &ChainSpec) -> Result<(), EpochProcessingError> {
|
||||
match state {
|
||||
BeaconState::Capella(_) | BeaconState::Deneb(_) => {
|
||||
BeaconState::Capella(_) | BeaconState::Deneb(_) | BeaconState::Electra(_) => {
|
||||
process_historical_summaries_update(state)
|
||||
}
|
||||
_ => Ok(()),
|
||||
@@ -233,7 +236,8 @@ impl<E: EthSpec> EpochTransition<E> for SyncCommitteeUpdates {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => altair::process_sync_committee_updates(state, spec),
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => altair::process_sync_committee_updates(state, spec),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,7 +249,8 @@ impl<E: EthSpec> EpochTransition<E> for InactivityUpdates {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => altair::process_inactivity_updates(
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => altair::process_inactivity_updates(
|
||||
state,
|
||||
&altair::ParticipationCache::new(state, spec).unwrap(),
|
||||
spec,
|
||||
@@ -261,7 +266,8 @@ impl<E: EthSpec> EpochTransition<E> for ParticipationFlagUpdates {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => altair::process_participation_flag_updates(state),
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => altair::process_participation_flag_updates(state),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,7 +318,7 @@ impl<E: EthSpec, T: EpochTransition<E>> Case for EpochProcessing<E, T> {
|
||||
T::name() != "participation_record_updates"
|
||||
&& T::name() != "historical_summaries_update"
|
||||
}
|
||||
ForkName::Capella | ForkName::Deneb => {
|
||||
ForkName::Capella | ForkName::Deneb | ForkName::Electra => {
|
||||
T::name() != "participation_record_updates"
|
||||
&& T::name() != "historical_roots_update"
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use crate::decode::{ssz_decode_state, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use state_processing::upgrade::{
|
||||
upgrade_to_altair, upgrade_to_bellatrix, upgrade_to_capella, upgrade_to_deneb,
|
||||
upgrade_to_electra,
|
||||
};
|
||||
use types::BeaconState;
|
||||
|
||||
@@ -65,6 +66,7 @@ impl<E: EthSpec> Case for ForkTest<E> {
|
||||
ForkName::Merge => upgrade_to_bellatrix(&mut result_state, spec).map(|_| result_state),
|
||||
ForkName::Capella => upgrade_to_capella(&mut result_state, spec).map(|_| result_state),
|
||||
ForkName::Deneb => upgrade_to_deneb(&mut result_state, spec).map(|_| result_state),
|
||||
ForkName::Electra => upgrade_to_electra(&mut result_state, spec).map(|_| result_state),
|
||||
};
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
|
||||
@@ -2,7 +2,9 @@ use super::*;
|
||||
use crate::decode::{ssz_decode_file, ssz_decode_state, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use tree_hash::Hash256;
|
||||
use types::{BeaconBlockBody, BeaconBlockBodyDeneb, BeaconState};
|
||||
use types::{
|
||||
BeaconBlockBody, BeaconBlockBodyDeneb, BeaconBlockBodyElectra, BeaconState, FullPayload,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Metadata {
|
||||
@@ -92,7 +94,7 @@ pub struct KzgInclusionMerkleProofValidity<E: EthSpec> {
|
||||
|
||||
impl<E: EthSpec> LoadCase for KzgInclusionMerkleProofValidity<E> {
|
||||
fn load_from_dir(path: &Path, fork_name: ForkName) -> Result<Self, Error> {
|
||||
let block = match fork_name {
|
||||
let block: BeaconBlockBody<E, FullPayload<E>> = match fork_name {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => {
|
||||
return Err(Error::InternalError(format!(
|
||||
"KZG inclusion merkle proof validity test skipped for {:?}",
|
||||
@@ -100,7 +102,11 @@ impl<E: EthSpec> LoadCase for KzgInclusionMerkleProofValidity<E> {
|
||||
)))
|
||||
}
|
||||
ForkName::Deneb => {
|
||||
ssz_decode_file::<BeaconBlockBodyDeneb<E>>(&path.join("object.ssz_snappy"))?
|
||||
ssz_decode_file::<BeaconBlockBodyDeneb<E>>(&path.join("object.ssz_snappy"))?.into()
|
||||
}
|
||||
ForkName::Electra => {
|
||||
ssz_decode_file::<BeaconBlockBodyElectra<E>>(&path.join("object.ssz_snappy"))?
|
||||
.into()
|
||||
}
|
||||
};
|
||||
let merkle_proof = yaml_decode_file(&path.join("proof.yaml"))?;
|
||||
@@ -114,7 +120,7 @@ impl<E: EthSpec> LoadCase for KzgInclusionMerkleProofValidity<E> {
|
||||
|
||||
Ok(Self {
|
||||
metadata,
|
||||
block: block.into(),
|
||||
block,
|
||||
merkle_proof,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -99,7 +99,8 @@ impl<E: EthSpec> Operation<E> for Attestation<E> {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => {
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => {
|
||||
initialize_progressive_balances_cache(state, None, spec)?;
|
||||
altair_deneb::process_attestation(
|
||||
state,
|
||||
|
||||
@@ -53,6 +53,13 @@ impl<E: EthSpec> LoadCase for TransitionTest<E> {
|
||||
spec.capella_fork_epoch = Some(Epoch::new(0));
|
||||
spec.deneb_fork_epoch = Some(metadata.fork_epoch);
|
||||
}
|
||||
ForkName::Electra => {
|
||||
spec.altair_fork_epoch = Some(Epoch::new(0));
|
||||
spec.bellatrix_fork_epoch = Some(Epoch::new(0));
|
||||
spec.capella_fork_epoch = Some(Epoch::new(0));
|
||||
spec.deneb_fork_epoch = Some(Epoch::new(0));
|
||||
spec.electra_fork_epoch = Some(metadata.fork_epoch);
|
||||
}
|
||||
}
|
||||
|
||||
// Load blocks
|
||||
|
||||
@@ -18,13 +18,20 @@ pub trait Handler {
|
||||
|
||||
fn handler_name(&self) -> String;
|
||||
|
||||
// Add forks here to exclude them from EF spec testing. Helpful for adding future or
|
||||
// unspecified forks.
|
||||
// TODO(electra): Enable Electra once spec tests are available.
|
||||
fn disabled_forks(&self) -> Vec<ForkName> {
|
||||
vec![ForkName::Electra]
|
||||
}
|
||||
|
||||
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
|
||||
Self::Case::is_enabled_for_fork(fork_name)
|
||||
}
|
||||
|
||||
fn run(&self) {
|
||||
for fork_name in ForkName::list_all() {
|
||||
if self.is_enabled_for_fork(fork_name) {
|
||||
if !self.disabled_forks().contains(&fork_name) && self.is_enabled_for_fork(fork_name) {
|
||||
self.run_for_fork(fork_name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user