Add Fulu boilerplate (#6695)

* Add Fulu boilerplate

* Add more boilerplate

* Change fulu_time to osaka_time

* Merge branch 'unstable' into fulu-boilerplate

* Fix tests

* Merge branch 'unstable' into fulu-boilerplate

* More test fixes

* Apply suggestions

* Remove `get_payload` boilerplate

* Add lightclient fulu types and fix beacon-chain-tests

* Disable Fulu in ef-tests

* Reduce boilerplate for future forks

* Small fixes

* One more fix

* Apply suggestions

* Merge branch 'unstable' into fulu-boilerplate

* Fix lints
This commit is contained in:
Mac L
2025-01-10 09:25:23 +04:00
committed by GitHub
parent 722573f7ed
commit ecdf2d891f
91 changed files with 2365 additions and 674 deletions

View File

@@ -98,29 +98,24 @@ impl<E: EthSpec> Operation<E> for Attestation<E> {
) -> Result<(), BlockProcessingError> {
initialize_epoch_cache(state, spec)?;
let mut ctxt = ConsensusContext::new(state.slot());
match state {
BeaconState::Base(_) => base::process_attestations(
if state.fork_name_unchecked().altair_enabled() {
initialize_progressive_balances_cache(state, spec)?;
altair_deneb::process_attestation(
state,
self.to_ref(),
0,
&mut ctxt,
VerifySignatures::True,
spec,
)
} else {
base::process_attestations(
state,
[self.clone().to_ref()].into_iter(),
VerifySignatures::True,
&mut ctxt,
spec,
),
BeaconState::Altair(_)
| BeaconState::Bellatrix(_)
| BeaconState::Capella(_)
| BeaconState::Deneb(_)
| BeaconState::Electra(_) => {
initialize_progressive_balances_cache(state, spec)?;
altair_deneb::process_attestation(
state,
self.to_ref(),
0,
&mut ctxt,
VerifySignatures::True,
spec,
)
}
)
}
}
}
@@ -131,14 +126,11 @@ impl<E: EthSpec> Operation<E> for AttesterSlashing<E> {
}
fn decode(path: &Path, fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> {
Ok(match fork_name {
ForkName::Base
| ForkName::Altair
| ForkName::Bellatrix
| ForkName::Capella
| ForkName::Deneb => Self::Base(ssz_decode_file(path)?),
ForkName::Electra => Self::Electra(ssz_decode_file(path)?),
})
if fork_name.electra_enabled() {
Ok(Self::Electra(ssz_decode_file(path)?))
} else {
Ok(Self::Base(ssz_decode_file(path)?))
}
}
fn apply_to(
@@ -308,6 +300,7 @@ impl<E: EthSpec> Operation<E> for BeaconBlockBody<E, FullPayload<E>> {
ForkName::Capella => BeaconBlockBody::Capella(<_>::from_ssz_bytes(bytes)?),
ForkName::Deneb => BeaconBlockBody::Deneb(<_>::from_ssz_bytes(bytes)?),
ForkName::Electra => BeaconBlockBody::Electra(<_>::from_ssz_bytes(bytes)?),
ForkName::Fulu => BeaconBlockBody::Fulu(<_>::from_ssz_bytes(bytes)?),
_ => panic!(),
})
})
@@ -363,6 +356,10 @@ impl<E: EthSpec> Operation<E> for BeaconBlockBody<E, BlindedPayload<E>> {
let inner = <BeaconBlockBodyElectra<E, FullPayload<E>>>::from_ssz_bytes(bytes)?;
BeaconBlockBody::Electra(inner.clone_as_blinded())
}
ForkName::Fulu => {
let inner = <BeaconBlockBodyElectra<E, FullPayload<E>>>::from_ssz_bytes(bytes)?;
BeaconBlockBody::Electra(inner.clone_as_blinded())
}
_ => panic!(),
})
})