mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
ContextDeserialize and Beacon API Improvements (#7372)
* #7286 * BeaconAPI is not returning a versioned response when it should for some V1 endpoints * these [strange functions with vX in the name that still accept `endpoint_version` arguments](https://github.com/sigp/lighthouse/blob/stable/beacon_node/http_api/src/produce_block.rs#L192) This refactor is a prerequisite to get the fulu EF tests running.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use eth2::types::beacon_response::EmptyMetadata;
|
||||
use eth2::types::builder_bid::SignedBuilderBid;
|
||||
use eth2::types::fork_versioned_response::EmptyMetadata;
|
||||
use eth2::types::{
|
||||
ContentType, EthSpec, ExecutionBlockHash, ForkName, ForkVersionDecode, ForkVersionDeserialize,
|
||||
ContentType, ContextDeserialize, EthSpec, ExecutionBlockHash, ForkName, ForkVersionDecode,
|
||||
ForkVersionedResponse, PublicKeyBytes, SignedValidatorRegistrationData, Slot,
|
||||
};
|
||||
use eth2::types::{FullPayloadContents, SignedBlindedBeaconBlock};
|
||||
@@ -119,7 +119,7 @@ impl BuilderHttpClient {
|
||||
}
|
||||
|
||||
async fn get_with_header<
|
||||
T: DeserializeOwned + ForkVersionDecode + ForkVersionDeserialize,
|
||||
T: DeserializeOwned + ForkVersionDecode + for<'de> ContextDeserialize<'de, ForkName>,
|
||||
U: IntoUrl,
|
||||
>(
|
||||
&self,
|
||||
@@ -147,7 +147,7 @@ impl BuilderHttpClient {
|
||||
self.ssz_available.store(true, Ordering::SeqCst);
|
||||
T::from_ssz_bytes_by_fork(&response_bytes, fork_name)
|
||||
.map(|data| ForkVersionedResponse {
|
||||
version: Some(fork_name),
|
||||
version: fork_name,
|
||||
metadata: EmptyMetadata {},
|
||||
data,
|
||||
})
|
||||
@@ -155,7 +155,15 @@ impl BuilderHttpClient {
|
||||
}
|
||||
ContentType::Json => {
|
||||
self.ssz_available.store(false, Ordering::SeqCst);
|
||||
serde_json::from_slice(&response_bytes).map_err(Error::InvalidJson)
|
||||
let mut de = serde_json::Deserializer::from_slice(&response_bytes);
|
||||
let data =
|
||||
T::context_deserialize(&mut de, fork_name).map_err(Error::InvalidJson)?;
|
||||
|
||||
Ok(ForkVersionedResponse {
|
||||
version: fork_name,
|
||||
metadata: EmptyMetadata {},
|
||||
data,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user