mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
Merge branch 'release-v7.0.0' into unstable
This commit is contained in:
@@ -27,6 +27,7 @@ use http_api::{
|
||||
};
|
||||
use lighthouse_network::{types::SyncState, Enr, EnrExt, PeerId};
|
||||
use network::NetworkReceivers;
|
||||
use operation_pool::attestation_storage::CheckpointKey;
|
||||
use proto_array::ExecutionStatus;
|
||||
use sensitive_url::SensitiveUrl;
|
||||
use slot_clock::SlotClock;
|
||||
@@ -1241,6 +1242,33 @@ impl ApiTester {
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_beacon_states_pending_consolidations(self) -> Self {
|
||||
for state_id in self.interesting_state_ids() {
|
||||
let mut state_opt = state_id
|
||||
.state(&self.chain)
|
||||
.ok()
|
||||
.map(|(state, _execution_optimistic, _finalized)| state);
|
||||
|
||||
let result = self
|
||||
.client
|
||||
.get_beacon_states_pending_consolidations(state_id.0)
|
||||
.await
|
||||
.unwrap()
|
||||
.map(|res| res.data);
|
||||
|
||||
if result.is_none() && state_opt.is_none() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let state = state_opt.as_mut().expect("result should be none");
|
||||
let expected = state.pending_consolidations().unwrap();
|
||||
|
||||
assert_eq!(result.unwrap(), expected.to_vec());
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_beacon_headers_all_slots(self) -> Self {
|
||||
for slot in 0..CHAIN_LENGTH {
|
||||
let slot = Slot::from(slot);
|
||||
@@ -2087,7 +2115,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)
|
||||
@@ -2106,9 +2134,80 @@ impl ApiTester {
|
||||
.await
|
||||
.unwrap()
|
||||
.data;
|
||||
|
||||
assert_eq!(result, expected);
|
||||
|
||||
self
|
||||
let result_committee_index_filtered = self
|
||||
.client
|
||||
.get_beacon_pool_attestations_v1(None, Some(0))
|
||||
.await
|
||||
.unwrap()
|
||||
.data;
|
||||
|
||||
let expected_committee_index_filtered = expected
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter(|att| att.get_committee_indices_map().contains(&0))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(
|
||||
result_committee_index_filtered,
|
||||
expected_committee_index_filtered
|
||||
);
|
||||
|
||||
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.get_committee_indices_map().contains(&1))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(
|
||||
result_committee_index_filtered,
|
||||
expected_committee_index_filtered
|
||||
);
|
||||
|
||||
let fork_name = self
|
||||
.harness
|
||||
.chain
|
||||
.spec
|
||||
.fork_name_at_slot::<E>(self.harness.chain.slot().unwrap());
|
||||
|
||||
// aggregate electra attestations
|
||||
if fork_name.electra_enabled() {
|
||||
// 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))
|
||||
.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::<Vec<_>>();
|
||||
assert_eq!(
|
||||
result_committee_index_filtered,
|
||||
expected_committee_index_filtered
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn test_post_beacon_pool_attester_slashings_valid_v1(mut self) -> Self {
|
||||
@@ -6386,6 +6485,8 @@ async fn beacon_get_state_info_electra() {
|
||||
.test_beacon_states_pending_deposits()
|
||||
.await
|
||||
.test_beacon_states_pending_partial_withdrawals()
|
||||
.await
|
||||
.test_beacon_states_pending_consolidations()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -6416,10 +6517,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
|
||||
|
||||
Reference in New Issue
Block a user