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