Skip to content

Commit

Permalink
Fix attestation validations before publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Tumas committed May 15, 2024
1 parent 9b98c04 commit f59bcb9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
9 changes: 3 additions & 6 deletions fork_choice_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,12 +1333,9 @@ impl<P: Preset> Store<P> {
}
}

let AttestationData {
slot,
index,
target,
..
} = attestation.data();
let index = misc::committee_index(&attestation);

let AttestationData { slot, target, .. } = attestation.data();

// TODO(feature/deneb): Figure out why this validation is split over 2 methods.
// TODO(feature/deneb): This appears to be unfinished.
Expand Down
12 changes: 11 additions & 1 deletion helper_functions/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use typenum::Unsigned as _;
use types::{
altair::{consts::SyncCommitteeSubnetCount, primitives::SyncCommitteePeriod},
cache::PackedIndices,
combined::SignedBeaconBlock,
combined::{Attestation, SignedBeaconBlock},
config::Config,
deneb::{
consts::{BlobCommitmentTreeDepth, BlobSidecarSubnetCount, VERSIONED_HASH_VERSION_KZG},
Expand Down Expand Up @@ -506,6 +506,16 @@ pub fn construct_blob_sidecars<P: Preset>(
.collect()
}

#[must_use]
pub fn committee_index<P: Preset>(attestation: &Attestation<P>) -> CommitteeIndex {
match attestation {
Attestation::Phase0(attestation) => attestation.data.index,
Attestation::Electra(attestation) => get_committee_indices::<P>(attestation.committee_bits)
.next()
.unwrap_or_default(),
}
}

#[must_use]
pub fn get_committee_indices<P: Preset>(
committee_bits: BitVector<P::MaxCommitteesPerSlot>,
Expand Down
4 changes: 2 additions & 2 deletions validator/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,7 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
..
} = own_attestation;

let committee_index = committee_index(attestation);
let committee_index = misc::committee_index(attestation);

debug!(
"validator {} of committee {} ({:?}) attesting in slot {}: {:?}",
Expand Down Expand Up @@ -1794,7 +1794,7 @@ impl<P: Preset, W: Wait + Sync> Validator<P, W> {
self.own_aggregators = accepted_attestations
.into_iter()
.filter_map(|own_attestation| {
let committee_index = committee_index(&own_attestation.attestation);
let committee_index = misc::committee_index(&own_attestation.attestation);

let member =
own_members.get(&(committee_index, own_attestation.validator_index))?;
Expand Down

0 comments on commit f59bcb9

Please sign in to comment.