Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribe to the correct subnets for electra attestations #5782

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -816,9 +816,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,
Comment on lines +819 to 822
Copy link
Collaborator Author

@eserilev eserilev May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using the provided attestation, instead of the indexed_attestation here. is that ok?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't think of a reason to use indexed_attestation

&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 @@ -1168,8 +1168,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 @@ -146,8 +146,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
12 changes: 6 additions & 6 deletions consensus/types/src/subnet_id.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! 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 serde::{Deserialize, Serialize};
use std::ops::{Deref, DerefMut};
Expand Down Expand Up @@ -37,16 +37,16 @@ impl SubnetId {
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.
pub fn compute_subnet_for_attestation_data<E: EthSpec>(
attestation_data: &AttestationData,
pub fn compute_subnet_for_attestation<E: EthSpec>(
attestation: &AttestationRef<E>,
committee_count_per_slot: u64,
spec: &ChainSpec,
) -> Result<SubnetId, ArithError> {
Self::compute_subnet::<E>(
attestation_data.slot,
attestation_data.index,
attestation.data().slot,
attestation.committee_index(),
committee_count_per_slot,
spec,
)
Expand Down
Loading