Subscribe to the correct subnets for electra attestations (#5782)

* subscribe to the correct att subnets for electra

* subscribe to the correct att subnets for electra
This commit is contained in:
Eitan Seri-Levi
2024-05-15 08:37:20 +03:00
committed by realbigsean
parent 3b1fb0ad81
commit 79a5f2556f
4 changed files with 13 additions and 13 deletions

View File

@@ -795,9 +795,9 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
committees_per_slot: u64, committees_per_slot: u64,
subnet_id: Option<SubnetId>, subnet_id: Option<SubnetId>,
chain: &BeaconChain<T>, chain: &BeaconChain<T>,
) -> Result<(u64, SubnetId), Error> { ) -> Result<(u64, SubnetId), Error> {
let expected_subnet_id = SubnetId::compute_subnet_for_attestation_data::<T::EthSpec>( let expected_subnet_id = SubnetId::compute_subnet_for_attestation::<T::EthSpec>(
indexed_attestation.data(), &attestation,
committees_per_slot, committees_per_slot,
&chain.spec, &chain.spec,
) )

View File

@@ -1168,8 +1168,8 @@ where
agg_sig agg_sig
}; };
let subnet_id = SubnetId::compute_subnet_for_attestation_data::<E>( let subnet_id = SubnetId::compute_subnet_for_attestation::<E>(
attestation.data(), &attestation.to_ref(),
committee_count, committee_count,
&self.chain.spec, &self.chain.spec,
) )

View File

@@ -146,8 +146,8 @@ fn get_valid_unaggregated_attestation<T: BeaconChainTypes>(
) )
.expect("should sign attestation"); .expect("should sign attestation");
let subnet_id = SubnetId::compute_subnet_for_attestation_data::<E>( let subnet_id = SubnetId::compute_subnet_for_attestation::<E>(
valid_attestation.data(), &valid_attestation.to_ref(),
head.beacon_state head.beacon_state
.get_committee_count_at_slot(current_slot) .get_committee_count_at_slot(current_slot)
.expect("should get committee count"), .expect("should get committee count"),

View File

@@ -1,5 +1,5 @@
//! Identifies each shard by an integer identifier. //! Identifies each shard by an integer identifier.
use crate::{AttestationData, ChainSpec, CommitteeIndex, Epoch, EthSpec, Slot}; use crate::{AttestationRef, ChainSpec, CommitteeIndex, Epoch, EthSpec, Slot};
use safe_arith::{ArithError, SafeArith}; use safe_arith::{ArithError, SafeArith};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
@@ -37,16 +37,16 @@ impl SubnetId {
id.into() id.into()
} }
/// Compute the subnet for an attestation with `attestation_data` where each slot in the /// Compute the subnet for an attestation where each slot in the
/// attestation epoch contains `committee_count_per_slot` committees. /// attestation epoch contains `committee_count_per_slot` committees.
pub fn compute_subnet_for_attestation_data<E: EthSpec>( pub fn compute_subnet_for_attestation<E: EthSpec>(
attestation_data: &AttestationData, attestation: &AttestationRef<E>,
committee_count_per_slot: u64, committee_count_per_slot: u64,
spec: &ChainSpec, spec: &ChainSpec,
) -> Result<SubnetId, ArithError> { ) -> Result<SubnetId, ArithError> {
Self::compute_subnet::<E>( Self::compute_subnet::<E>(
attestation_data.slot, attestation.data().slot,
attestation_data.index, attestation.committee_index(),
committee_count_per_slot, committee_count_per_slot,
spec, spec,
) )