Skip to content

Commit 8506fb0

Browse files
eserilevrealbigsean
authored andcommitted
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
1 parent 8468937 commit 8506fb0

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

beacon_node/beacon_chain/src/attestation_verification.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,9 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
795795
committees_per_slot: u64,
796796
subnet_id: Option<SubnetId>,
797797
chain: &BeaconChain<T>,
798-
) -> Result<(u64, SubnetId), Error> {
799-
let expected_subnet_id = SubnetId::compute_subnet_for_attestation_data::<T::EthSpec>(
800-
indexed_attestation.data(),
798+
) -> Result<(u64, SubnetId), Error> {
799+
let expected_subnet_id = SubnetId::compute_subnet_for_attestation::<T::EthSpec>(
800+
&attestation,
801801
committees_per_slot,
802802
&chain.spec,
803803
)

beacon_node/beacon_chain/src/test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,8 +1168,8 @@ where
11681168
agg_sig
11691169
};
11701170

1171-
let subnet_id = SubnetId::compute_subnet_for_attestation_data::<E>(
1172-
attestation.data(),
1171+
let subnet_id = SubnetId::compute_subnet_for_attestation::<E>(
1172+
&attestation.to_ref(),
11731173
committee_count,
11741174
&self.chain.spec,
11751175
)

beacon_node/beacon_chain/tests/attestation_verification.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ fn get_valid_unaggregated_attestation<T: BeaconChainTypes>(
146146
)
147147
.expect("should sign attestation");
148148

149-
let subnet_id = SubnetId::compute_subnet_for_attestation_data::<E>(
150-
valid_attestation.data(),
149+
let subnet_id = SubnetId::compute_subnet_for_attestation::<E>(
150+
&valid_attestation.to_ref(),
151151
head.beacon_state
152152
.get_committee_count_at_slot(current_slot)
153153
.expect("should get committee count"),

consensus/types/src/subnet_id.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Identifies each shard by an integer identifier.
2-
use crate::{AttestationData, ChainSpec, CommitteeIndex, Epoch, EthSpec, Slot};
2+
use crate::{AttestationRef, ChainSpec, CommitteeIndex, Epoch, EthSpec, Slot};
33
use safe_arith::{ArithError, SafeArith};
44
use serde::{Deserialize, Serialize};
55
use std::ops::{Deref, DerefMut};
@@ -37,16 +37,16 @@ impl SubnetId {
3737
id.into()
3838
}
3939

40-
/// Compute the subnet for an attestation with `attestation_data` where each slot in the
40+
/// Compute the subnet for an attestation where each slot in the
4141
/// attestation epoch contains `committee_count_per_slot` committees.
42-
pub fn compute_subnet_for_attestation_data<E: EthSpec>(
43-
attestation_data: &AttestationData,
42+
pub fn compute_subnet_for_attestation<E: EthSpec>(
43+
attestation: &AttestationRef<E>,
4444
committee_count_per_slot: u64,
4545
spec: &ChainSpec,
4646
) -> Result<SubnetId, ArithError> {
4747
Self::compute_subnet::<E>(
48-
attestation_data.slot,
49-
attestation_data.index,
48+
attestation.data().slot,
49+
attestation.committee_index(),
5050
committee_count_per_slot,
5151
spec,
5252
)

0 commit comments

Comments
 (0)