From 12d382bddf30d75492c0dcd5ee95bc3fdf4442f5 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Wed, 9 Apr 2025 11:11:26 -0700 Subject: [PATCH 01/10] fix beacon pool attestation endpoint --- beacon_node/http_api/src/lib.rs | 20 +++++++---- beacon_node/http_api/tests/tests.rs | 33 +++++++++++++++++++ .../operation_pool/src/attestation_storage.rs | 21 +++++++++++- beacon_node/operation_pool/src/lib.rs | 4 +-- consensus/types/src/attestation.rs | 6 +++- 5 files changed, 73 insertions(+), 11 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index a33508dde96..5f05ca9b906 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -68,6 +68,7 @@ use slog::{crit, debug, error, info, warn, Logger}; use slot_clock::SlotClock; use ssz::Encode; pub use state_id::StateId; +use types::AttestationData; use std::future::Future; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::path::PathBuf; @@ -86,7 +87,7 @@ use tokio_stream::{ StreamExt, }; use types::{ - fork_versioned_response::EmptyMetadata, Attestation, AttestationData, AttestationShufflingId, + fork_versioned_response::EmptyMetadata, Attestation, AttestationShufflingId, AttesterSlashing, BeaconStateError, ChainSpec, Checkpoint, CommitteeCache, ConfigAndPreset, Epoch, EthSpec, ForkName, ForkVersionedResponse, Hash256, ProposerPreparationData, ProposerSlashing, RelativeEpoch, SignedAggregateAndProof, SignedBlindedBeaconBlock, @@ -1999,11 +2000,16 @@ pub fn serve( chain: Arc>, query: api_types::AttestationPoolQuery| { task_spawner.blocking_response_task(Priority::P1, move || { - let query_filter = |data: &AttestationData| { - query.slot.is_none_or(|slot| slot == data.slot) - && query - .committee_index - .is_none_or(|index| index == data.index) + let query_filter = |data: &AttestationData, committee_index: Option| { + query + .slot + .is_none_or(|slot| slot == data.slot) + && query.committee_index.is_none_or(|index| { + if let Some(committee_index) = committee_index { + return index == committee_index; + } + false + }) }; let mut attestations = chain.op_pool.get_filtered_attestations(query_filter); @@ -2012,7 +2018,7 @@ pub fn serve( .naive_aggregation_pool .read() .iter() - .filter(|&att| query_filter(att.data())) + .filter(|&att| query_filter(att.data(), att.committee_index())) .cloned(), ); // Use the current slot to find the fork version, and convert all messages to the diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 6ddd49bfd93..be4630df955 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -2111,8 +2111,41 @@ impl ApiTester { .await .unwrap() .data; + assert_eq!(result, expected); + let result_committee_index_filtered = self + .client + .get_beacon_pool_attestations_v1(None, Some(1)) + .await + .unwrap() + .data; + + let expected_committee_index_filtered = expected + .clone() + .into_iter() + .filter(|att| att.committee_index() == Some(1)) + .collect::>(); + + assert_eq!(result_committee_index_filtered, expected_committee_index_filtered); + assert_ne!(result_committee_index_filtered, expected); + + let result_committee_index_filtered = self + .client + .get_beacon_pool_attestations_v2(None, Some(2)) + .await + .unwrap() + .data; + + let expected_committee_index_filtered = expected + .clone() + .into_iter() + .filter(|att| att.committee_index() == Some(2)) + .collect::>(); + + assert_eq!(result_committee_index_filtered, expected_committee_index_filtered); + assert_ne!(result_committee_index_filtered, expected); + self } diff --git a/beacon_node/operation_pool/src/attestation_storage.rs b/beacon_node/operation_pool/src/attestation_storage.rs index 49ef5c279c5..9acbd7d4aed 100644 --- a/beacon_node/operation_pool/src/attestation_storage.rs +++ b/beacon_node/operation_pool/src/attestation_storage.rs @@ -119,6 +119,21 @@ impl CompactAttestationRef<'_, E> { } } + pub fn committee_index(&self) -> Option { + match self.indexed { + CompactIndexedAttestation::Base(_) => { + Some(self.data.index) + } + CompactIndexedAttestation::Electra(indexed_att) => { + indexed_att.committee_bits + .iter() + .enumerate() + .find(|&(_, bit)| bit) + .map(|(index, _)| index as u64) + } + } + } + pub fn clone_as_attestation(&self) -> Attestation { match self.indexed { CompactIndexedAttestation::Base(indexed_att) => Attestation::Base(AttestationBase { @@ -268,7 +283,11 @@ impl CompactIndexedAttestationElectra { } pub fn committee_index(&self) -> Option { - self.get_committee_indices().first().copied() + self.committee_bits + .iter() + .enumerate() + .find(|&(_, bit)| bit) + .map(|(index, _)| index as u64) } pub fn get_committee_indices(&self) -> Vec { diff --git a/beacon_node/operation_pool/src/lib.rs b/beacon_node/operation_pool/src/lib.rs index 584a5f9f323..afcc371eb2b 100644 --- a/beacon_node/operation_pool/src/lib.rs +++ b/beacon_node/operation_pool/src/lib.rs @@ -673,12 +673,12 @@ impl OperationPool { /// This method may return objects that are invalid for block inclusion. pub fn get_filtered_attestations(&self, filter: F) -> Vec> where - F: Fn(&AttestationData) -> bool, + F: Fn(&AttestationData, Option) -> bool, { self.attestations .read() .iter() - .filter(|att| filter(&att.attestation_data())) + .filter(|att| filter(&att.attestation_data(), att.committee_index())) .map(|att| att.clone_as_attestation()) .collect() } diff --git a/consensus/types/src/attestation.rs b/consensus/types/src/attestation.rs index 1485842edbd..370b0516465 100644 --- a/consensus/types/src/attestation.rs +++ b/consensus/types/src/attestation.rs @@ -292,7 +292,11 @@ impl AttestationRef<'_, E> { impl AttestationElectra { pub fn committee_index(&self) -> Option { - self.get_committee_indices().first().cloned() + self.committee_bits + .iter() + .enumerate() + .find(|&(_, bit)| bit) + .map(|(index, _)| index as u64) } pub fn get_aggregation_bits(&self) -> Vec { From 9e592c225d866d014b0c06afe6577ec009a13264 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Wed, 9 Apr 2025 11:13:57 -0700 Subject: [PATCH 02/10] rerun --- beacon_node/operation_pool/src/attestation_storage.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/beacon_node/operation_pool/src/attestation_storage.rs b/beacon_node/operation_pool/src/attestation_storage.rs index 9acbd7d4aed..6b44ea8d15d 100644 --- a/beacon_node/operation_pool/src/attestation_storage.rs +++ b/beacon_node/operation_pool/src/attestation_storage.rs @@ -289,6 +289,7 @@ impl CompactIndexedAttestationElectra { .find(|&(_, bit)| bit) .map(|(index, _)| index as u64) } + pub fn get_committee_indices(&self) -> Vec { self.committee_bits From ac6fb34d7ff3837d126b5db981545cb384ce1e67 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Wed, 9 Apr 2025 11:14:06 -0700 Subject: [PATCH 03/10] rerun --- beacon_node/operation_pool/src/attestation_storage.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/beacon_node/operation_pool/src/attestation_storage.rs b/beacon_node/operation_pool/src/attestation_storage.rs index 6b44ea8d15d..9acbd7d4aed 100644 --- a/beacon_node/operation_pool/src/attestation_storage.rs +++ b/beacon_node/operation_pool/src/attestation_storage.rs @@ -289,7 +289,6 @@ impl CompactIndexedAttestationElectra { .find(|&(_, bit)| bit) .map(|(index, _)| index as u64) } - pub fn get_committee_indices(&self) -> Vec { self.committee_bits From 0c788271e1e05560f93a92ed83126ebc75c81680 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Wed, 9 Apr 2025 11:14:27 -0700 Subject: [PATCH 04/10] fmt --- beacon_node/http_api/src/lib.rs | 18 ++++++++---------- beacon_node/http_api/tests/tests.rs | 10 ++++++++-- .../operation_pool/src/attestation_storage.rs | 17 +++++++---------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 5f05ca9b906..3a979d63972 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -68,7 +68,6 @@ use slog::{crit, debug, error, info, warn, Logger}; use slot_clock::SlotClock; use ssz::Encode; pub use state_id::StateId; -use types::AttestationData; use std::future::Future; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::path::PathBuf; @@ -86,13 +85,14 @@ use tokio_stream::{ wrappers::{errors::BroadcastStreamRecvError, BroadcastStream}, StreamExt, }; +use types::AttestationData; use types::{ - fork_versioned_response::EmptyMetadata, Attestation, AttestationShufflingId, - AttesterSlashing, BeaconStateError, ChainSpec, Checkpoint, CommitteeCache, ConfigAndPreset, - Epoch, EthSpec, ForkName, ForkVersionedResponse, Hash256, ProposerPreparationData, - ProposerSlashing, RelativeEpoch, SignedAggregateAndProof, SignedBlindedBeaconBlock, - SignedBlsToExecutionChange, SignedContributionAndProof, SignedValidatorRegistrationData, - SignedVoluntaryExit, Slot, SyncCommitteeMessage, SyncContributionData, + fork_versioned_response::EmptyMetadata, Attestation, AttestationShufflingId, AttesterSlashing, + BeaconStateError, ChainSpec, Checkpoint, CommitteeCache, ConfigAndPreset, Epoch, EthSpec, + ForkName, ForkVersionedResponse, Hash256, ProposerPreparationData, ProposerSlashing, + RelativeEpoch, SignedAggregateAndProof, SignedBlindedBeaconBlock, SignedBlsToExecutionChange, + SignedContributionAndProof, SignedValidatorRegistrationData, SignedVoluntaryExit, Slot, + SyncCommitteeMessage, SyncContributionData, }; use validator::pubkey_to_validator_index; use version::{ @@ -2001,9 +2001,7 @@ pub fn serve( query: api_types::AttestationPoolQuery| { task_spawner.blocking_response_task(Priority::P1, move || { let query_filter = |data: &AttestationData, committee_index: Option| { - query - .slot - .is_none_or(|slot| slot == data.slot) + query.slot.is_none_or(|slot| slot == data.slot) && query.committee_index.is_none_or(|index| { if let Some(committee_index) = committee_index { return index == committee_index; diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index be4630df955..d0824246200 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -2127,7 +2127,10 @@ impl ApiTester { .filter(|att| att.committee_index() == Some(1)) .collect::>(); - assert_eq!(result_committee_index_filtered, expected_committee_index_filtered); + assert_eq!( + result_committee_index_filtered, + expected_committee_index_filtered + ); assert_ne!(result_committee_index_filtered, expected); let result_committee_index_filtered = self @@ -2143,7 +2146,10 @@ impl ApiTester { .filter(|att| att.committee_index() == Some(2)) .collect::>(); - assert_eq!(result_committee_index_filtered, expected_committee_index_filtered); + assert_eq!( + result_committee_index_filtered, + expected_committee_index_filtered + ); assert_ne!(result_committee_index_filtered, expected); self diff --git a/beacon_node/operation_pool/src/attestation_storage.rs b/beacon_node/operation_pool/src/attestation_storage.rs index 9acbd7d4aed..9c3c3cd0c04 100644 --- a/beacon_node/operation_pool/src/attestation_storage.rs +++ b/beacon_node/operation_pool/src/attestation_storage.rs @@ -121,16 +121,13 @@ impl CompactAttestationRef<'_, E> { pub fn committee_index(&self) -> Option { match self.indexed { - CompactIndexedAttestation::Base(_) => { - Some(self.data.index) - } - CompactIndexedAttestation::Electra(indexed_att) => { - indexed_att.committee_bits - .iter() - .enumerate() - .find(|&(_, bit)| bit) - .map(|(index, _)| index as u64) - } + CompactIndexedAttestation::Base(_) => Some(self.data.index), + CompactIndexedAttestation::Electra(indexed_att) => indexed_att + .committee_bits + .iter() + .enumerate() + .find(|&(_, bit)| bit) + .map(|(index, _)| index as u64), } } From 75c27c841f9d7e12ea8a9ab06e88f3bce75e96d9 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 10 Apr 2025 16:02:19 -0700 Subject: [PATCH 05/10] fixes --- beacon_node/http_api/src/lib.rs | 16 ++--- beacon_node/http_api/tests/tests.rs | 69 ++++++++++++++++--- .../operation_pool/src/attestation_storage.rs | 10 +-- beacon_node/operation_pool/src/lib.rs | 8 +-- consensus/types/src/attestation.rs | 8 +++ 5 files changed, 85 insertions(+), 26 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 3a979d63972..c8c8ff2868e 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -68,6 +68,7 @@ use slog::{crit, debug, error, info, warn, Logger}; use slot_clock::SlotClock; use ssz::Encode; pub use state_id::StateId; +use std::collections::HashSet; use std::future::Future; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::path::PathBuf; @@ -2000,14 +2001,11 @@ pub fn serve( chain: Arc>, query: api_types::AttestationPoolQuery| { task_spawner.blocking_response_task(Priority::P1, move || { - let query_filter = |data: &AttestationData, committee_index: Option| { + let query_filter = |data: &AttestationData, committee_indices: HashSet| { query.slot.is_none_or(|slot| slot == data.slot) - && query.committee_index.is_none_or(|index| { - if let Some(committee_index) = committee_index { - return index == committee_index; - } - false - }) + && query + .committee_index + .is_none_or(|index| committee_indices.contains(&index)) }; let mut attestations = chain.op_pool.get_filtered_attestations(query_filter); @@ -2016,7 +2014,9 @@ pub fn serve( .naive_aggregation_pool .read() .iter() - .filter(|&att| query_filter(att.data(), att.committee_index())) + .filter(|&att| { + query_filter(att.data(), att.get_committee_indices_map()) + }) .cloned(), ); // Use the current slot to find the fork version, and convert all messages to the diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index d0824246200..52205120945 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -28,6 +28,7 @@ use http_api::{ use lighthouse_network::{types::SyncState, Enr, EnrExt, PeerId}; use logging::test_logger; use network::NetworkReceivers; +use operation_pool::attestation_storage::CheckpointKey; use proto_array::ExecutionStatus; use sensitive_url::SensitiveUrl; use slot_clock::SlotClock; @@ -2092,7 +2093,7 @@ impl ApiTester { self } - pub async fn test_get_beacon_pool_attestations(self) -> Self { + pub async fn test_get_beacon_pool_attestations(self) { let result = self .client .get_beacon_pool_attestations_v1(None, None) @@ -2116,7 +2117,7 @@ impl ApiTester { let result_committee_index_filtered = self .client - .get_beacon_pool_attestations_v1(None, Some(1)) + .get_beacon_pool_attestations_v1(None, Some(0)) .await .unwrap() .data; @@ -2124,18 +2125,17 @@ impl ApiTester { let expected_committee_index_filtered = expected .clone() .into_iter() - .filter(|att| att.committee_index() == Some(1)) + .filter(|att| att.get_committee_indices_map().contains(&0)) .collect::>(); assert_eq!( result_committee_index_filtered, expected_committee_index_filtered ); - assert_ne!(result_committee_index_filtered, expected); let result_committee_index_filtered = self .client - .get_beacon_pool_attestations_v2(None, Some(2)) + .get_beacon_pool_attestations_v1(None, Some(1)) .await .unwrap() .data; @@ -2143,16 +2143,47 @@ impl ApiTester { let expected_committee_index_filtered = expected .clone() .into_iter() - .filter(|att| att.committee_index() == Some(2)) + .filter(|att| att.get_committee_indices_map().contains(&1)) .collect::>(); assert_eq!( result_committee_index_filtered, expected_committee_index_filtered ); - assert_ne!(result_committee_index_filtered, expected); - self + let fork_name = self + .harness + .chain + .spec + .fork_name_at_slot::(self.harness.chain.slot().unwrap()); + + // aggregate electra attestations + if fork_name.electra_enabled() { + let mut all_attestations = self.chain.op_pool.attestations.write(); + let (prev_epoch_key, curr_epoch_key) = + CheckpointKey::keys_for_state(&self.harness.get_current_state()); + all_attestations.aggregate_across_committees(prev_epoch_key); + all_attestations.aggregate_across_committees(curr_epoch_key); + drop(all_attestations); + let result_committee_index_filtered = self + .client + .get_beacon_pool_attestations_v2(None, Some(0)) + .await + .unwrap() + .data; + let mut expected = self.chain.op_pool.get_all_attestations(); + expected.extend(self.chain.naive_aggregation_pool.read().iter().cloned()); + let expected_committee_index_filtered = expected + .clone() + .into_iter() + .filter(|att| att.get_committee_indices_map().contains(&0)) + .collect::>(); + assert!(expected_committee_index_filtered.len() > 0); + assert_eq!( + result_committee_index_filtered, + expected_committee_index_filtered + ); + } } pub async fn test_post_beacon_pool_attester_slashings_valid_v1(mut self) -> Self { @@ -6473,10 +6504,30 @@ async fn beacon_get_blocks() { } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn beacon_get_pools() { +async fn test_beacon_pool_attestations_electra() { + let mut config = ApiTesterConfig::default(); + config.spec.altair_fork_epoch = Some(Epoch::new(0)); + config.spec.bellatrix_fork_epoch = Some(Epoch::new(0)); + config.spec.capella_fork_epoch = Some(Epoch::new(0)); + config.spec.deneb_fork_epoch = Some(Epoch::new(0)); + config.spec.electra_fork_epoch = Some(Epoch::new(0)); + ApiTester::new_from_config(config) + .await + .test_get_beacon_pool_attestations() + .await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_beacon_pool_attestations_base() { ApiTester::new() .await .test_get_beacon_pool_attestations() + .await; +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn beacon_get_pools() { + ApiTester::new() .await .test_get_beacon_pool_attester_slashings() .await diff --git a/beacon_node/operation_pool/src/attestation_storage.rs b/beacon_node/operation_pool/src/attestation_storage.rs index 9c3c3cd0c04..67c24b9c7a1 100644 --- a/beacon_node/operation_pool/src/attestation_storage.rs +++ b/beacon_node/operation_pool/src/attestation_storage.rs @@ -1,6 +1,6 @@ use crate::AttestationStats; use itertools::Itertools; -use std::collections::{BTreeMap, HashMap}; +use std::collections::{BTreeMap, HashMap, HashSet}; use types::{ attestation::{AttestationBase, AttestationElectra}, superstruct, AggregateSignature, Attestation, AttestationData, BeaconState, BitList, BitVector, @@ -119,15 +119,15 @@ impl CompactAttestationRef<'_, E> { } } - pub fn committee_index(&self) -> Option { + pub fn get_committee_indices_map(&self) -> HashSet { match self.indexed { - CompactIndexedAttestation::Base(_) => Some(self.data.index), + CompactIndexedAttestation::Base(_) => HashSet::from([self.data.index]), CompactIndexedAttestation::Electra(indexed_att) => indexed_att .committee_bits .iter() .enumerate() - .find(|&(_, bit)| bit) - .map(|(index, _)| index as u64), + .filter_map(|(index, bit)| if bit { Some(index as u64) } else { None }) + .collect(), } } diff --git a/beacon_node/operation_pool/src/lib.rs b/beacon_node/operation_pool/src/lib.rs index afcc371eb2b..ec8c6640b1d 100644 --- a/beacon_node/operation_pool/src/lib.rs +++ b/beacon_node/operation_pool/src/lib.rs @@ -1,5 +1,5 @@ mod attestation; -mod attestation_storage; +pub mod attestation_storage; mod attester_slashing; mod bls_to_execution_changes; mod max_cover; @@ -47,7 +47,7 @@ type SyncContributions = RwLock { /// Map from attestation ID (see below) to vectors of attestations. - attestations: RwLock>, + pub attestations: RwLock>, /// Map from sync aggregate ID to the best `SyncCommitteeContribution`s seen for that ID. sync_contributions: SyncContributions, /// Set of attester slashings, and the fork version they were verified against. @@ -673,12 +673,12 @@ impl OperationPool { /// This method may return objects that are invalid for block inclusion. pub fn get_filtered_attestations(&self, filter: F) -> Vec> where - F: Fn(&AttestationData, Option) -> bool, + F: Fn(&AttestationData, HashSet) -> bool, { self.attestations .read() .iter() - .filter(|att| filter(&att.attestation_data(), att.committee_index())) + .filter(|att| filter(&att.attestation_data(), att.get_committee_indices_map())) .map(|att| att.clone_as_attestation()) .collect() } diff --git a/consensus/types/src/attestation.rs b/consensus/types/src/attestation.rs index 370b0516465..08953770637 100644 --- a/consensus/types/src/attestation.rs +++ b/consensus/types/src/attestation.rs @@ -5,6 +5,7 @@ use derivative::Derivative; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use ssz_types::BitVector; +use std::collections::HashSet; use std::hash::{Hash, Hasher}; use superstruct::superstruct; use test_random_derive::TestRandom; @@ -209,6 +210,13 @@ impl Attestation { } } + pub fn get_committee_indices_map(&self) -> HashSet { + match self { + Attestation::Base(att) => HashSet::from([att.data.index]), + Attestation::Electra(att) => att.get_committee_indices().into_iter().collect(), + } + } + pub fn is_aggregation_bits_zero(&self) -> bool { match self { Attestation::Base(att) => att.aggregation_bits.is_zero(), From 3feefad49994d1f5d438dce69c206cc2ed0651ef Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Thu, 10 Apr 2025 16:27:21 -0700 Subject: [PATCH 06/10] update --- beacon_node/http_api/tests/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 52205120945..ac150aad10f 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -2178,7 +2178,7 @@ impl ApiTester { .into_iter() .filter(|att| att.get_committee_indices_map().contains(&0)) .collect::>(); - assert!(expected_committee_index_filtered.len() > 0); + assert!(expected_committee_index_filtered.is_empty()); assert_eq!( result_committee_index_filtered, expected_committee_index_filtered From 0b7e0b5766002fb1d9e10ce0a4c41e46840dfad0 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Thu, 10 Apr 2025 17:15:48 -0700 Subject: [PATCH 07/10] lint --- beacon_node/http_api/tests/tests.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index ac150aad10f..bf1696c525c 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -2159,12 +2159,15 @@ impl ApiTester { // aggregate electra attestations if fork_name.electra_enabled() { - let mut all_attestations = self.chain.op_pool.attestations.write(); - let (prev_epoch_key, curr_epoch_key) = - CheckpointKey::keys_for_state(&self.harness.get_current_state()); - all_attestations.aggregate_across_committees(prev_epoch_key); - all_attestations.aggregate_across_committees(curr_epoch_key); - drop(all_attestations); + // Take and drop the lock in a block to avoid clippy complaining + // about taking locks across await points + { + let mut all_attestations = self.chain.op_pool.attestations.write(); + let (prev_epoch_key, curr_epoch_key) = + CheckpointKey::keys_for_state(&self.harness.get_current_state()); + all_attestations.aggregate_across_committees(prev_epoch_key); + all_attestations.aggregate_across_committees(curr_epoch_key); + } let result_committee_index_filtered = self .client .get_beacon_pool_attestations_v2(None, Some(0)) From 0c53c520cacd65c237b40640d73779bbfcffc649 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Thu, 10 Apr 2025 17:39:43 -0700 Subject: [PATCH 08/10] Update crossbeam to silence audit failures --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d1ceb2dbaf9..eee67a413e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1696,9 +1696,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.14" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" dependencies = [ "crossbeam-utils", ] From 6fc92029ac516b8bca3756006847fa8c80d486de Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Thu, 10 Apr 2025 18:53:01 -0700 Subject: [PATCH 09/10] Fix test --- beacon_node/http_api/tests/tests.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index bf1696c525c..9a700b8049b 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -2181,7 +2181,6 @@ impl ApiTester { .into_iter() .filter(|att| att.get_committee_indices_map().contains(&0)) .collect::>(); - assert!(expected_committee_index_filtered.is_empty()); assert_eq!( result_committee_index_filtered, expected_committee_index_filtered From b3d116ce7e6d00cb9549f6e635e704c940178263 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Thu, 10 Apr 2025 18:53:20 -0700 Subject: [PATCH 10/10] Revert "Update crossbeam to silence audit failures" This reverts commit 0c53c520cacd65c237b40640d73779bbfcffc649. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eee67a413e8..d1ceb2dbaf9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1696,9 +1696,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.15" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" dependencies = [ "crossbeam-utils", ]