add electra fork enabled fn to ForkName impl (#36)

* add electra fork enabled fn to ForkName impl

* remove inadvertent file
This commit is contained in:
Eitan Seri-Levi
2024-06-18 22:50:07 +02:00
committed by dapplion
parent 9e84779522
commit 7af3f2eb35
13 changed files with 31 additions and 21 deletions

View File

@@ -1341,7 +1341,10 @@ pub fn verify_committee_index<E: EthSpec>(
attestation: AttestationRef<E>,
spec: &ChainSpec,
) -> Result<(), Error> {
if spec.fork_name_at_slot::<E>(attestation.data().slot) >= ForkName::Electra {
if spec
.fork_name_at_slot::<E>(attestation.data().slot)
.electra_enabled()
{
// Check to ensure that the attestation is for a single committee.
let num_committee_bits = get_committee_indices::<E>(
attestation

View File

@@ -1994,7 +1994,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
};
drop(cache_timer);
if self.spec.fork_name_at_slot::<T::EthSpec>(request_slot) >= ForkName::Electra {
if self
.spec
.fork_name_at_slot::<T::EthSpec>(request_slot)
.electra_enabled()
{
let mut committee_bits = BitVector::default();
if committee_len > 0 {
committee_bits.set(request_index as usize, true)?;

View File

@@ -123,7 +123,7 @@ impl<E: EthSpec> EarlyAttesterCache<E> {
item.committee_lengths
.get_committee_length::<E>(request_slot, request_index, spec)?;
let attestation = if spec.fork_name_at_slot::<E>(request_slot) >= ForkName::Electra {
let attestation = if spec.fork_name_at_slot::<E>(request_slot).electra_enabled() {
let mut committee_bits = BitVector::default();
if committee_len > 0 {
committee_bits

View File

@@ -1033,7 +1033,7 @@ where
*state.get_block_root(target_slot)?
};
if self.spec.fork_name_at_slot::<E>(slot) >= ForkName::Electra {
if self.spec.fork_name_at_slot::<E>(slot).electra_enabled() {
let mut committee_bits = BitVector::default();
committee_bits.set(index as usize, true)?;
Ok(Attestation::Electra(AttestationElectra {
@@ -1376,7 +1376,7 @@ where
let fork_name = self.spec.fork_name_at_slot::<E>(slot);
let aggregate = if fork_name >= ForkName::Electra {
let aggregate = if fork_name.electra_enabled() {
self.chain
.get_aggregated_attestation_electra(
slot,
@@ -1541,7 +1541,7 @@ where
let fork_name = self.spec.fork_name_at_slot::<E>(Slot::new(0));
let mut attestation_1 = if fork_name >= ForkName::Electra {
let mut attestation_1 = if fork_name.electra_enabled() {
IndexedAttestation::Electra(IndexedAttestationElectra {
attesting_indices: VariableList::new(validator_indices).unwrap(),
data: AttestationData {
@@ -1623,7 +1623,7 @@ where
}
}
if fork_name >= ForkName::Electra {
if fork_name.electra_enabled() {
AttesterSlashing::Electra(AttesterSlashingElectra {
attestation_1: attestation_1.as_electra().unwrap().clone(),
attestation_2: attestation_2.as_electra().unwrap().clone(),
@@ -1657,7 +1657,7 @@ where
},
};
let (mut attestation_1, mut attestation_2) = if fork_name >= ForkName::Electra {
let (mut attestation_1, mut attestation_2) = if fork_name.electra_enabled() {
let attestation_1 = IndexedAttestationElectra {
attesting_indices: VariableList::new(validator_indices_1).unwrap(),
data: data.clone(),
@@ -1735,7 +1735,7 @@ where
}
}
if fork_name >= ForkName::Electra {
if fork_name.electra_enabled() {
AttesterSlashing::Electra(AttesterSlashingElectra {
attestation_1: attestation_1.as_electra().unwrap().clone(),
attestation_2: attestation_2.as_electra().unwrap().clone(),