mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 04:37:13 +00:00
self review
This commit is contained in:
@@ -3289,7 +3289,7 @@ impl ApiTester {
|
||||
.chain
|
||||
.spec
|
||||
.fork_name_at_slot::<E>(self.chain.slot().unwrap())
|
||||
>= ForkName::Electra
|
||||
.electra_enabled()
|
||||
{
|
||||
for attestation in self.chain.naive_aggregation_pool.read().iter() {
|
||||
let result = self
|
||||
|
||||
@@ -346,7 +346,7 @@ impl BeaconNodeHttpClient {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Perform a HTTP POST request with a custom timeout.
|
||||
/// Perform a HTTP POST request with a custom timeout and consensus header.
|
||||
async fn post_with_timeout_and_consensus_header<T: Serialize, U: IntoUrl>(
|
||||
&self,
|
||||
url: U,
|
||||
@@ -410,6 +410,7 @@ impl BeaconNodeHttpClient {
|
||||
|
||||
/// Generic POST function supporting arbitrary responses and timeouts.
|
||||
/// Does not include Content-Type application/json in the request header.
|
||||
/// Does include Eth-Consensus-Version in the request header.
|
||||
async fn post_generic_json_without_content_type_header_but_with_consensus_header<
|
||||
T: Serialize,
|
||||
U: IntoUrl,
|
||||
@@ -2358,7 +2359,7 @@ impl BeaconNodeHttpClient {
|
||||
slot: Slot,
|
||||
attestation_data_root: Hash256,
|
||||
committee_index: CommitteeIndex,
|
||||
) -> Result<Option<GenericResponse<Attestation<E>>>, Error> {
|
||||
) -> Result<Option<ForkVersionedResponse<Attestation<E>>>, Error> {
|
||||
let mut path = self.eth_path(V2)?;
|
||||
|
||||
path.path_segments_mut()
|
||||
|
||||
@@ -487,6 +487,23 @@ impl<'a, E: EthSpec> From<AttestationRefOnDisk<'a, E>> for AttestationRef<'a, E>
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> ForkVersionDeserialize for Attestation<E> {
|
||||
fn deserialize_by_fork<'de, D: serde::Deserializer<'de>>(
|
||||
value: serde_json::Value,
|
||||
fork_name: crate::ForkName,
|
||||
) -> Result<Self, D::Error> {
|
||||
if fork_name.electra_enabled() {
|
||||
let attestation: AttestationElectra<E> =
|
||||
serde_json::from_value(value).map_err(serde::de::Error::custom)?;
|
||||
Ok(Attestation::Electra(attestation))
|
||||
} else {
|
||||
let attestation: AttestationBase<E> =
|
||||
serde_json::from_value(value).map_err(serde::de::Error::custom)?;
|
||||
Ok(Attestation::Base(attestation))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> ForkVersionDeserialize for Vec<Attestation<E>> {
|
||||
fn deserialize_by_fork<'de, D: serde::Deserializer<'de>>(
|
||||
value: serde_json::Value,
|
||||
|
||||
@@ -548,7 +548,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
|
||||
&metrics::ATTESTATION_SERVICE_TIMES,
|
||||
&[metrics::AGGREGATES_HTTP_GET],
|
||||
);
|
||||
let aggregate_attestation_result = if fork_name.electra_enabled() {
|
||||
if fork_name.electra_enabled() {
|
||||
beacon_node
|
||||
.get_validator_aggregate_attestation_v2(
|
||||
attestation_data.slot,
|
||||
@@ -556,6 +556,13 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
|
||||
committee_index,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
format!("Failed to produce an aggregate attestation: {:?}", e)
|
||||
})?
|
||||
.ok_or_else(|| {
|
||||
format!("No aggregate available for {:?}", attestation_data)
|
||||
})
|
||||
.map(|result| result.data)
|
||||
} else {
|
||||
beacon_node
|
||||
.get_validator_aggregate_attestation_v1(
|
||||
@@ -563,14 +570,14 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
|
||||
attestation_data.tree_hash_root(),
|
||||
)
|
||||
.await
|
||||
};
|
||||
|
||||
aggregate_attestation_result
|
||||
.map_err(|e| {
|
||||
format!("Failed to produce an aggregate attestation: {:?}", e)
|
||||
})?
|
||||
.ok_or_else(|| format!("No aggregate available for {:?}", attestation_data))
|
||||
.map(|result| result.data)
|
||||
.map_err(|e| {
|
||||
format!("Failed to produce an aggregate attestation: {:?}", e)
|
||||
})?
|
||||
.ok_or_else(|| {
|
||||
format!("No aggregate available for {:?}", attestation_data)
|
||||
})
|
||||
.map(|result| result.data)
|
||||
}
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user