mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Electra attestation changes from Lions review (#5971)
* dedup/cleanup and remove unneeded hashset use * remove irrelevant TODOs
This commit is contained in:
@@ -1397,8 +1397,7 @@ pub fn obtain_indexed_attestation_and_committees_per_slot<T: BeaconChainTypes>(
|
|||||||
attesting_indices_electra::get_indexed_attestation(&committees, att)
|
attesting_indices_electra::get_indexed_attestation(&committees, att)
|
||||||
.map(|attestation| (attestation, committees_per_slot))
|
.map(|attestation| (attestation, committees_per_slot))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
let index = att.committee_index().unwrap_or(0);
|
if let BlockOperationError::BeaconStateError(NoCommitteeFound(index)) = e {
|
||||||
if e == BlockOperationError::BeaconStateError(NoCommitteeFound(index)) {
|
|
||||||
Error::NoCommitteeForSlotAndIndex {
|
Error::NoCommitteeForSlotAndIndex {
|
||||||
slot: att.data.slot,
|
slot: att.data.slot,
|
||||||
index,
|
index,
|
||||||
|
|||||||
@@ -241,24 +241,12 @@ impl<E: EthSpec> AggregateMap for AggregatedAttestationMap<E> {
|
|||||||
fn insert(&mut self, a: AttestationRef<E>) -> Result<InsertOutcome, Error> {
|
fn insert(&mut self, a: AttestationRef<E>) -> Result<InsertOutcome, Error> {
|
||||||
let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_CORE_INSERT);
|
let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_CORE_INSERT);
|
||||||
|
|
||||||
let aggregation_bit = match a {
|
let aggregation_bit = *a
|
||||||
AttestationRef::Base(att) => att
|
.set_aggregation_bits()
|
||||||
.aggregation_bits
|
.iter()
|
||||||
.iter()
|
.at_most_one()
|
||||||
.enumerate()
|
.map_err(|iter| Error::MoreThanOneAggregationBitSet(iter.count()))?
|
||||||
.filter_map(|(i, bit)| if bit { Some(i) } else { None })
|
.ok_or(Error::NoAggregationBitsSet)?;
|
||||||
.at_most_one()
|
|
||||||
.map_err(|iter| Error::MoreThanOneAggregationBitSet(iter.count()))?
|
|
||||||
.ok_or(Error::NoAggregationBitsSet)?,
|
|
||||||
AttestationRef::Electra(att) => att
|
|
||||||
.aggregation_bits
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.filter_map(|(i, bit)| if bit { Some(i) } else { None })
|
|
||||||
.at_most_one()
|
|
||||||
.map_err(|iter| Error::MoreThanOneAggregationBitSet(iter.count()))?
|
|
||||||
.ok_or(Error::NoAggregationBitsSet)?,
|
|
||||||
};
|
|
||||||
|
|
||||||
let attestation_key = AttestationKey::from_attestation_ref(a)?;
|
let attestation_key = AttestationKey::from_attestation_ref(a)?;
|
||||||
let attestation_key_root = attestation_key.tree_hash_root();
|
let attestation_key_root = attestation_key.tree_hash_root();
|
||||||
|
|||||||
@@ -233,7 +233,6 @@ fn get_non_aggregator<T: BeaconChainTypes>(
|
|||||||
let state = &head.beacon_state;
|
let state = &head.beacon_state;
|
||||||
let current_slot = chain.slot().expect("should get slot");
|
let current_slot = chain.slot().expect("should get slot");
|
||||||
|
|
||||||
// TODO(electra) make fork-agnostic
|
|
||||||
let committee = state
|
let committee = state
|
||||||
.get_beacon_committee(
|
.get_beacon_committee(
|
||||||
current_slot,
|
current_slot,
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ pub mod attesting_indices_electra {
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use crate::per_block_processing::errors::{AttestationInvalid as Invalid, BlockOperationError};
|
use crate::per_block_processing::errors::{AttestationInvalid as Invalid, BlockOperationError};
|
||||||
use itertools::Itertools;
|
|
||||||
use safe_arith::SafeArith;
|
use safe_arith::SafeArith;
|
||||||
use types::*;
|
use types::*;
|
||||||
|
|
||||||
@@ -96,7 +95,7 @@ pub mod attesting_indices_electra {
|
|||||||
aggregation_bits: &BitList<E::MaxValidatorsPerSlot>,
|
aggregation_bits: &BitList<E::MaxValidatorsPerSlot>,
|
||||||
committee_bits: &BitVector<E::MaxCommitteesPerSlot>,
|
committee_bits: &BitVector<E::MaxCommitteesPerSlot>,
|
||||||
) -> Result<Vec<u64>, BeaconStateError> {
|
) -> Result<Vec<u64>, BeaconStateError> {
|
||||||
let mut output: HashSet<u64> = HashSet::new();
|
let mut attesting_indices = vec![];
|
||||||
|
|
||||||
let committee_indices = get_committee_indices::<E>(committee_bits);
|
let committee_indices = get_committee_indices::<E>(committee_bits);
|
||||||
|
|
||||||
@@ -128,8 +127,7 @@ pub mod attesting_indices_electra {
|
|||||||
})
|
})
|
||||||
.collect::<HashSet<u64>>();
|
.collect::<HashSet<u64>>();
|
||||||
|
|
||||||
output.extend(committee_attesters);
|
attesting_indices.extend(committee_attesters);
|
||||||
|
|
||||||
committee_offset.safe_add_assign(beacon_committee.committee.len())?;
|
committee_offset.safe_add_assign(beacon_committee.committee.len())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,10 +136,9 @@ pub mod attesting_indices_electra {
|
|||||||
return Err(BeaconStateError::InvalidBitfield);
|
return Err(BeaconStateError::InvalidBitfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut indices = output.into_iter().collect_vec();
|
attesting_indices.sort_unstable();
|
||||||
indices.sort_unstable();
|
|
||||||
|
|
||||||
Ok(indices)
|
Ok(attesting_indices)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_committee_indices<E: EthSpec>(
|
pub fn get_committee_indices<E: EthSpec>(
|
||||||
|
|||||||
@@ -326,7 +326,6 @@ where
|
|||||||
genesis_validators_root,
|
genesis_validators_root,
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO(electra), signing root isnt unique in the case of electra
|
|
||||||
let message = indexed_attestation.data().signing_root(domain);
|
let message = indexed_attestation.data().signing_root(domain);
|
||||||
|
|
||||||
Ok(SignatureSet::multiple_pubkeys(signature, pubkeys, message))
|
Ok(SignatureSet::multiple_pubkeys(signature, pubkeys, message))
|
||||||
|
|||||||
Reference in New Issue
Block a user