Skip to content

Commit ab9e58a

Browse files
Get electra_op_pool up to date (sigp#5756)
* fix get attesting indices (sigp#5742) * fix get attesting indices * better errors * fix compile * only get committee index once * Ef test fixes (sigp#5753) * attestation related ef test fixes * delete commented out stuff * Fix Aggregation Pool for Electra (sigp#5754) * Fix Aggregation Pool for Electra * Remove Outdated Interface * fix ssz (sigp#5755) --------- Co-authored-by: realbigsean <[email protected]>
1 parent 7cb7653 commit ab9e58a

File tree

12 files changed

+307
-108
lines changed

12 files changed

+307
-108
lines changed

beacon_node/beacon_chain/src/attestation_verification.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,10 +1309,11 @@ pub fn obtain_indexed_attestation_and_committees_per_slot<T: BeaconChainTypes>(
13091309
attesting_indices_electra::get_indexed_attestation(&committees, att)
13101310
.map(|attestation| (attestation, committees_per_slot))
13111311
.map_err(|e| {
1312-
if e == BlockOperationError::BeaconStateError(NoCommitteeFound) {
1312+
let index = att.committee_index();
1313+
if e == BlockOperationError::BeaconStateError(NoCommitteeFound(index)) {
13131314
Error::NoCommitteeForSlotAndIndex {
13141315
slot: att.data.slot,
1315-
index: att.committee_index(),
1316+
index,
13161317
}
13171318
} else {
13181319
Error::Invalid(e)

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,11 +1612,28 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
16121612
/// Returns an aggregated `Attestation`, if any, that has a matching `attestation.data`.
16131613
///
16141614
/// The attestation will be obtained from `self.naive_aggregation_pool`.
1615-
pub fn get_aggregated_attestation(
1615+
pub fn get_aggregated_attestation_base(
16161616
&self,
16171617
data: &AttestationData,
16181618
) -> Result<Option<Attestation<T::EthSpec>>, Error> {
1619-
if let Some(attestation) = self.naive_aggregation_pool.read().get(data) {
1619+
let attestation_key = crate::naive_aggregation_pool::AttestationKey::new_base(data);
1620+
if let Some(attestation) = self.naive_aggregation_pool.read().get(&attestation_key) {
1621+
self.filter_optimistic_attestation(attestation)
1622+
.map(Option::Some)
1623+
} else {
1624+
Ok(None)
1625+
}
1626+
}
1627+
1628+
// TODO(electra): call this function from the new beacon API method
1629+
pub fn get_aggregated_attestation_electra(
1630+
&self,
1631+
data: &AttestationData,
1632+
committee_index: CommitteeIndex,
1633+
) -> Result<Option<Attestation<T::EthSpec>>, Error> {
1634+
let attestation_key =
1635+
crate::naive_aggregation_pool::AttestationKey::new_electra(data, committee_index);
1636+
if let Some(attestation) = self.naive_aggregation_pool.read().get(&attestation_key) {
16201637
self.filter_optimistic_attestation(attestation)
16211638
.map(Option::Some)
16221639
} else {
@@ -1628,16 +1645,21 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
16281645
/// `attestation.data.tree_hash_root()`.
16291646
///
16301647
/// The attestation will be obtained from `self.naive_aggregation_pool`.
1631-
pub fn get_aggregated_attestation_by_slot_and_root(
1648+
///
1649+
/// NOTE: This function will *only* work with pre-electra attestations and it only
1650+
/// exists to support the pre-electra validator API method.
1651+
pub fn get_pre_electra_aggregated_attestation_by_slot_and_root(
16321652
&self,
16331653
slot: Slot,
16341654
attestation_data_root: &Hash256,
16351655
) -> Result<Option<Attestation<T::EthSpec>>, Error> {
1636-
if let Some(attestation) = self
1637-
.naive_aggregation_pool
1638-
.read()
1639-
.get_by_slot_and_root(slot, attestation_data_root)
1640-
{
1656+
let attestation_key =
1657+
crate::naive_aggregation_pool::AttestationKey::new_base_from_slot_and_root(
1658+
slot,
1659+
*attestation_data_root,
1660+
);
1661+
1662+
if let Some(attestation) = self.naive_aggregation_pool.read().get(&attestation_key) {
16411663
self.filter_optimistic_attestation(attestation)
16421664
.map(Option::Some)
16431665
} else {

0 commit comments

Comments
 (0)