mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Merge branch 'beacon-api-electra' of https://github.com/sigp/lighthouse into p2p-electra
This commit is contained in:
@@ -1625,14 +1625,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(electra): call this function from the new beacon API method
|
|
||||||
pub fn get_aggregated_attestation_electra(
|
pub fn get_aggregated_attestation_electra(
|
||||||
&self,
|
&self,
|
||||||
data: &AttestationData,
|
slot: Slot,
|
||||||
|
attestation_data_root: &Hash256,
|
||||||
committee_index: CommitteeIndex,
|
committee_index: CommitteeIndex,
|
||||||
) -> Result<Option<Attestation<T::EthSpec>>, Error> {
|
) -> Result<Option<Attestation<T::EthSpec>>, Error> {
|
||||||
let attestation_key =
|
let attestation_key = crate::naive_aggregation_pool::AttestationKey::new_electra(
|
||||||
crate::naive_aggregation_pool::AttestationKey::new_electra(data, committee_index);
|
slot,
|
||||||
|
*attestation_data_root,
|
||||||
|
committee_index,
|
||||||
|
);
|
||||||
if let Some(attestation) = self.naive_aggregation_pool.read().get(&attestation_key) {
|
if let Some(attestation) = self.naive_aggregation_pool.read().get(&attestation_key) {
|
||||||
self.filter_optimistic_attestation(attestation)
|
self.filter_optimistic_attestation(attestation)
|
||||||
.map(Option::Some)
|
.map(Option::Some)
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ use types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT;
|
|||||||
use types::slot_data::SlotData;
|
use types::slot_data::SlotData;
|
||||||
use types::sync_committee_contribution::SyncContributionData;
|
use types::sync_committee_contribution::SyncContributionData;
|
||||||
use types::{
|
use types::{
|
||||||
Attestation, AttestationData, AttestationRef, EthSpec, Hash256, Slot, SyncCommitteeContribution,
|
Attestation, AttestationData, AttestationRef, CommitteeIndex, EthSpec, Hash256, Slot,
|
||||||
|
SyncCommitteeContribution,
|
||||||
};
|
};
|
||||||
|
|
||||||
type AttestationKeyRoot = Hash256;
|
type AttestationKeyRoot = Hash256;
|
||||||
@@ -18,7 +19,7 @@ type SyncDataRoot = Hash256;
|
|||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct AttestationKey {
|
pub struct AttestationKey {
|
||||||
data_root: Hash256,
|
data_root: Hash256,
|
||||||
committee_index: Option<u64>,
|
committee_index: Option<CommitteeIndex>,
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,10 +96,9 @@ impl AttestationKey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_electra(data: &AttestationData, committee_index: u64) -> Self {
|
pub fn new_electra(slot: Slot, data_root: Hash256, committee_index: CommitteeIndex) -> Self {
|
||||||
let slot = data.slot;
|
|
||||||
Self {
|
Self {
|
||||||
data_root: data.tree_hash_root(),
|
data_root,
|
||||||
committee_index: Some(committee_index),
|
committee_index: Some(committee_index),
|
||||||
slot,
|
slot,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -644,7 +644,7 @@ impl<E: EthSpec> ExecutionPayloadBodyV1<E> {
|
|||||||
"block {} is post-electra but payload body doesn't have withdrawals/deposit_receipts/withdrawal_requests \
|
"block {} is post-electra but payload body doesn't have withdrawals/deposit_receipts/withdrawal_requests \
|
||||||
Check that ELs are returning receipts and withdrawal_requests in getPayloadBody requests",
|
Check that ELs are returning receipts and withdrawal_requests in getPayloadBody requests",
|
||||||
header.block_hash
|
header.block_hash
|
||||||
))
|
));
|
||||||
};
|
};
|
||||||
Ok(ExecutionPayload::Electra(ExecutionPayloadElectra {
|
Ok(ExecutionPayload::Electra(ExecutionPayloadElectra {
|
||||||
parent_hash: header.parent_hash,
|
parent_hash: header.parent_hash,
|
||||||
|
|||||||
@@ -3191,36 +3191,39 @@ pub fn serve<T: BeaconChainTypes>(
|
|||||||
task_spawner: TaskSpawner<T::EthSpec>,
|
task_spawner: TaskSpawner<T::EthSpec>,
|
||||||
chain: Arc<BeaconChain<T>>| {
|
chain: Arc<BeaconChain<T>>| {
|
||||||
task_spawner.blocking_json_task(Priority::P0, move || {
|
task_spawner.blocking_json_task(Priority::P0, move || {
|
||||||
if endpoint_version == V2 {
|
not_synced_filter?;
|
||||||
if query.committee_index.is_none() {
|
let res = if endpoint_version == V2 {
|
||||||
|
let Some(committee_index) = query.committee_index else {
|
||||||
return Err(warp_utils::reject::custom_bad_request(
|
return Err(warp_utils::reject::custom_bad_request(
|
||||||
"missing committee index".to_string(),
|
"missing committee index".to_string(),
|
||||||
));
|
));
|
||||||
}
|
};
|
||||||
|
chain.get_aggregated_attestation_electra(
|
||||||
|
query.slot,
|
||||||
|
&query.attestation_data_root,
|
||||||
|
committee_index,
|
||||||
|
)
|
||||||
} else if endpoint_version == V1 {
|
} else if endpoint_version == V1 {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
} else {
|
chain.get_pre_electra_aggregated_attestation_by_slot_and_root(
|
||||||
return Err(unsupported_version_rejection(endpoint_version));
|
|
||||||
}
|
|
||||||
//TODO(electra) pass the index into the next method.
|
|
||||||
not_synced_filter?;
|
|
||||||
chain
|
|
||||||
.get_pre_electra_aggregated_attestation_by_slot_and_root(
|
|
||||||
query.slot,
|
query.slot,
|
||||||
&query.attestation_data_root,
|
&query.attestation_data_root,
|
||||||
)
|
)
|
||||||
.map_err(|e| {
|
} else {
|
||||||
warp_utils::reject::custom_bad_request(format!(
|
return Err(unsupported_version_rejection(endpoint_version));
|
||||||
"unable to fetch aggregate: {:?}",
|
};
|
||||||
e
|
res.map_err(|e| {
|
||||||
))
|
warp_utils::reject::custom_bad_request(format!(
|
||||||
})?
|
"unable to fetch aggregate: {:?}",
|
||||||
.map(api_types::GenericResponse::from)
|
e
|
||||||
.ok_or_else(|| {
|
))
|
||||||
warp_utils::reject::custom_not_found(
|
})?
|
||||||
"no matching aggregate found".to_string(),
|
.map(api_types::GenericResponse::from)
|
||||||
)
|
.ok_or_else(|| {
|
||||||
})
|
warp_utils::reject::custom_not_found(
|
||||||
|
"no matching aggregate found".to_string(),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user