Merge branch 'electra_attestation_changes' of https://github.com/sigp/lighthouse into block-processing-electra

This commit is contained in:
realbigsean
2024-05-09 21:29:53 -04:00
2 changed files with 12 additions and 9 deletions

View File

@@ -1625,14 +1625,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
} }
} }
// TODO(electra): call this function from the new beacon API method
pub fn get_aggregated_attestation_electra( pub fn get_aggregated_attestation_electra(
&self, &self,
data: &AttestationData, slot: Slot,
attestation_data_root: &Hash256,
committee_index: CommitteeIndex, committee_index: CommitteeIndex,
) -> Result<Option<Attestation<T::EthSpec>>, Error> { ) -> Result<Option<Attestation<T::EthSpec>>, Error> {
let attestation_key = let attestation_key = crate::naive_aggregation_pool::AttestationKey::new_electra(
crate::naive_aggregation_pool::AttestationKey::new_electra(data, committee_index); slot,
*attestation_data_root,
committee_index,
);
if let Some(attestation) = self.naive_aggregation_pool.read().get(&attestation_key) { if let Some(attestation) = self.naive_aggregation_pool.read().get(&attestation_key) {
self.filter_optimistic_attestation(attestation) self.filter_optimistic_attestation(attestation)
.map(Option::Some) .map(Option::Some)

View File

@@ -8,7 +8,8 @@ use types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT;
use types::slot_data::SlotData; use types::slot_data::SlotData;
use types::sync_committee_contribution::SyncContributionData; use types::sync_committee_contribution::SyncContributionData;
use types::{ use types::{
Attestation, AttestationData, AttestationRef, EthSpec, Hash256, Slot, SyncCommitteeContribution, Attestation, AttestationData, AttestationRef, CommitteeIndex, EthSpec, Hash256, Slot,
SyncCommitteeContribution,
}; };
type AttestationKeyRoot = Hash256; type AttestationKeyRoot = Hash256;
@@ -18,7 +19,7 @@ type SyncDataRoot = Hash256;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct AttestationKey { pub struct AttestationKey {
data_root: Hash256, data_root: Hash256,
committee_index: Option<u64>, committee_index: Option<CommitteeIndex>,
slot: Slot, slot: Slot,
} }
@@ -95,10 +96,9 @@ impl AttestationKey {
} }
} }
pub fn new_electra(data: &AttestationData, committee_index: u64) -> Self { pub fn new_electra(slot: Slot, data_root: Hash256, committee_index: CommitteeIndex) -> Self {
let slot = data.slot;
Self { Self {
data_root: data.tree_hash_root(), data_root,
committee_index: Some(committee_index), committee_index: Some(committee_index),
slot, slot,
} }