Skip to content

Commit

Permalink
Subscribe to the correct subnets for electra attestations (sigp#5782)
Browse files Browse the repository at this point in the history
* subscribe to the correct att subnets for electra

* subscribe to the correct att subnets for electra
  • Loading branch information
eserilev authored and realbigsean committed Jun 25, 2024
1 parent 0435842 commit d785f96
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions beacon_node/beacon_chain/src/attestation_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,9 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
committees_per_slot: u64,
subnet_id: Option<SubnetId>,
chain: &BeaconChain<T>,
) -> Result<(u64, SubnetId), Error> {
let expected_subnet_id = SubnetId::compute_subnet_for_attestation_data::<T::EthSpec>(
indexed_attestation.data(),
) -> Result<(u64, SubnetId), Error> {
let expected_subnet_id = SubnetId::compute_subnet_for_attestation::<T::EthSpec>(
&attestation,
committees_per_slot,
&chain.spec,
)
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,8 @@ where
agg_sig
};

let subnet_id = SubnetId::compute_subnet_for_attestation_data::<E>(
attestation.data(),
let subnet_id = SubnetId::compute_subnet_for_attestation::<E>(
&attestation.to_ref(),
committee_count,
&self.chain.spec,
)
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/tests/attestation_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ fn get_valid_unaggregated_attestation<T: BeaconChainTypes>(
)
.expect("should sign attestation");

let subnet_id = SubnetId::compute_subnet_for_attestation_data::<E>(
valid_attestation.data(),
let subnet_id = SubnetId::compute_subnet_for_attestation::<E>(
&valid_attestation.to_ref(),
head.beacon_state
.get_committee_count_at_slot(current_slot)
.expect("should get committee count"),
Expand Down
5 changes: 2 additions & 3 deletions consensus/types/src/subnet_id.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Identifies each shard by an integer identifier.
use crate::{AttestationRef, ChainSpec, CommitteeIndex, Epoch, EthSpec, Slot};
use lazy_static::lazy_static;
use safe_arith::{ArithError, SafeArith};
use serde::{Deserialize, Serialize};
use std::ops::{Deref, DerefMut};
Expand Down Expand Up @@ -41,15 +40,15 @@ impl SubnetId {
/// Compute the subnet for an attestation where each slot in the
/// attestation epoch contains `committee_count_per_slot` committees.
pub fn compute_subnet_for_attestation<E: EthSpec>(
attestation: AttestationRef<E>,
attestation: &AttestationRef<E>,
committee_count_per_slot: u64,
spec: &ChainSpec,
) -> Result<SubnetId, ArithError> {
let committee_index = attestation.committee_index().ok_or(ArithError::Overflow)?;

Self::compute_subnet::<E>(
attestation.data().slot,
committee_index,
attestation.committee_index(),
committee_count_per_slot,
spec,
)
Expand Down

0 comments on commit d785f96

Please sign in to comment.