Electra attestation changes from Lions review (#5971)

* dedup/cleanup and remove unneeded hashset use

* remove irrelevant TODOs
This commit is contained in:
Eitan Seri-Levi
2024-06-20 15:36:43 +02:00
committed by GitHub
parent 0e2add2daa
commit f85a124362
5 changed files with 11 additions and 29 deletions

View File

@@ -1397,8 +1397,7 @@ pub fn obtain_indexed_attestation_and_committees_per_slot<T: BeaconChainTypes>(
attesting_indices_electra::get_indexed_attestation(&committees, att)
.map(|attestation| (attestation, committees_per_slot))
.map_err(|e| {
let index = att.committee_index().unwrap_or(0);
if e == BlockOperationError::BeaconStateError(NoCommitteeFound(index)) {
if let BlockOperationError::BeaconStateError(NoCommitteeFound(index)) = e {
Error::NoCommitteeForSlotAndIndex {
slot: att.data.slot,
index,

View File

@@ -241,24 +241,12 @@ impl<E: EthSpec> AggregateMap for AggregatedAttestationMap<E> {
fn insert(&mut self, a: AttestationRef<E>) -> Result<InsertOutcome, Error> {
let _timer = metrics::start_timer(&metrics::ATTESTATION_PROCESSING_AGG_POOL_CORE_INSERT);
let aggregation_bit = match a {
AttestationRef::Base(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)?,
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 aggregation_bit = *a
.set_aggregation_bits()
.iter()
.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_root = attestation_key.tree_hash_root();