Remove custom SSZ beacon states route (#5065)
* Remove SSZ state root route * Remove SSZ states route from client impl * Patch tests * Merge branch 'unstable' into 5063-delete-ssz-state-route * Further remove dead code
This commit is contained in:
parent
6f3af67362
commit
abeb358f0b
@ -4267,36 +4267,6 @@ pub fn serve<T: BeaconChainTypes>(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// GET lighthouse/beacon/states/{state_id}/ssz
|
|
||||||
let get_lighthouse_beacon_states_ssz = warp::path("lighthouse")
|
|
||||||
.and(warp::path("beacon"))
|
|
||||||
.and(warp::path("states"))
|
|
||||||
.and(warp::path::param::<StateId>())
|
|
||||||
.and(warp::path("ssz"))
|
|
||||||
.and(warp::path::end())
|
|
||||||
.and(task_spawner_filter.clone())
|
|
||||||
.and(chain_filter.clone())
|
|
||||||
.then(
|
|
||||||
|state_id: StateId,
|
|
||||||
task_spawner: TaskSpawner<T::EthSpec>,
|
|
||||||
chain: Arc<BeaconChain<T>>| {
|
|
||||||
task_spawner.blocking_response_task(Priority::P1, move || {
|
|
||||||
// This debug endpoint provides no indication of optimistic status.
|
|
||||||
let (state, _execution_optimistic, _finalized) = state_id.state(&chain)?;
|
|
||||||
Response::builder()
|
|
||||||
.status(200)
|
|
||||||
.body(state.as_ssz_bytes().into())
|
|
||||||
.map(|res: Response<Body>| add_ssz_content_type_header(res))
|
|
||||||
.map_err(|e| {
|
|
||||||
warp_utils::reject::custom_server_error(format!(
|
|
||||||
"failed to create response: {}",
|
|
||||||
e
|
|
||||||
))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// GET lighthouse/staking
|
// GET lighthouse/staking
|
||||||
let get_lighthouse_staking = warp::path("lighthouse")
|
let get_lighthouse_staking = warp::path("lighthouse")
|
||||||
.and(warp::path("staking"))
|
.and(warp::path("staking"))
|
||||||
@ -4631,7 +4601,6 @@ pub fn serve<T: BeaconChainTypes>(
|
|||||||
.uor(get_lighthouse_eth1_syncing)
|
.uor(get_lighthouse_eth1_syncing)
|
||||||
.uor(get_lighthouse_eth1_block_cache)
|
.uor(get_lighthouse_eth1_block_cache)
|
||||||
.uor(get_lighthouse_eth1_deposit_cache)
|
.uor(get_lighthouse_eth1_deposit_cache)
|
||||||
.uor(get_lighthouse_beacon_states_ssz)
|
|
||||||
.uor(get_lighthouse_staking)
|
.uor(get_lighthouse_staking)
|
||||||
.uor(get_lighthouse_database_info)
|
.uor(get_lighthouse_database_info)
|
||||||
.uor(get_lighthouse_block_rewards)
|
.uor(get_lighthouse_block_rewards)
|
||||||
|
@ -5057,26 +5057,6 @@ impl ApiTester {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn test_get_lighthouse_beacon_states_ssz(self) -> Self {
|
|
||||||
for state_id in self.interesting_state_ids() {
|
|
||||||
let result = self
|
|
||||||
.client
|
|
||||||
.get_lighthouse_beacon_states_ssz(&state_id.0, &self.chain.spec)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut expected = state_id
|
|
||||||
.state(&self.chain)
|
|
||||||
.ok()
|
|
||||||
.map(|(state, _execution_optimistic, _finalized)| state);
|
|
||||||
expected.as_mut().map(|state| state.drop_all_caches());
|
|
||||||
|
|
||||||
assert_eq!(result, expected, "{:?}", state_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn test_get_lighthouse_staking(self) -> Self {
|
pub async fn test_get_lighthouse_staking(self) -> Self {
|
||||||
let result = self.client.get_lighthouse_staking().await.unwrap();
|
let result = self.client.get_lighthouse_staking().await.unwrap();
|
||||||
|
|
||||||
@ -6373,8 +6353,6 @@ async fn lighthouse_endpoints() {
|
|||||||
.await
|
.await
|
||||||
.test_get_lighthouse_eth1_deposit_cache()
|
.test_get_lighthouse_eth1_deposit_cache()
|
||||||
.await
|
.await
|
||||||
.test_get_lighthouse_beacon_states_ssz()
|
|
||||||
.await
|
|
||||||
.test_get_lighthouse_staking()
|
.test_get_lighthouse_staking()
|
||||||
.await
|
.await
|
||||||
.test_get_lighthouse_database_info()
|
.test_get_lighthouse_database_info()
|
||||||
|
@ -8,15 +8,12 @@ mod standard_block_rewards;
|
|||||||
mod sync_committee_rewards;
|
mod sync_committee_rewards;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ok_or_error,
|
|
||||||
types::{
|
types::{
|
||||||
BeaconState, ChainSpec, DepositTreeSnapshot, Epoch, EthSpec, FinalizedExecutionBlock,
|
DepositTreeSnapshot, Epoch, EthSpec, FinalizedExecutionBlock, GenericResponse, ValidatorId,
|
||||||
GenericResponse, ValidatorId,
|
|
||||||
},
|
},
|
||||||
BeaconNodeHttpClient, DepositData, Error, Eth1Data, Hash256, Slot, StateId, StatusCode,
|
BeaconNodeHttpClient, DepositData, Error, Eth1Data, Hash256, Slot,
|
||||||
};
|
};
|
||||||
use proto_array::core::ProtoArray;
|
use proto_array::core::ProtoArray;
|
||||||
use reqwest::IntoUrl;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use ssz::four_byte_option_impl;
|
use ssz::four_byte_option_impl;
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
@ -371,27 +368,6 @@ pub struct DatabaseInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BeaconNodeHttpClient {
|
impl BeaconNodeHttpClient {
|
||||||
/// Perform a HTTP GET request, returning `None` on a 404 error.
|
|
||||||
async fn get_bytes_opt<U: IntoUrl>(&self, url: U) -> Result<Option<Vec<u8>>, Error> {
|
|
||||||
let response = self.client.get(url).send().await.map_err(Error::from)?;
|
|
||||||
match ok_or_error(response).await {
|
|
||||||
Ok(resp) => Ok(Some(
|
|
||||||
resp.bytes()
|
|
||||||
.await
|
|
||||||
.map_err(Error::from)?
|
|
||||||
.into_iter()
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
)),
|
|
||||||
Err(err) => {
|
|
||||||
if err.status() == Some(StatusCode::NOT_FOUND) {
|
|
||||||
Ok(None)
|
|
||||||
} else {
|
|
||||||
Err(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `GET lighthouse/health`
|
/// `GET lighthouse/health`
|
||||||
pub async fn get_lighthouse_health(&self) -> Result<GenericResponse<Health>, Error> {
|
pub async fn get_lighthouse_health(&self) -> Result<GenericResponse<Health>, Error> {
|
||||||
let mut path = self.server.full.clone();
|
let mut path = self.server.full.clone();
|
||||||
@ -516,28 +492,6 @@ impl BeaconNodeHttpClient {
|
|||||||
self.get(path).await
|
self.get(path).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `GET lighthouse/beacon/states/{state_id}/ssz`
|
|
||||||
pub async fn get_lighthouse_beacon_states_ssz<E: EthSpec>(
|
|
||||||
&self,
|
|
||||||
state_id: &StateId,
|
|
||||||
spec: &ChainSpec,
|
|
||||||
) -> Result<Option<BeaconState<E>>, Error> {
|
|
||||||
let mut path = self.server.full.clone();
|
|
||||||
|
|
||||||
path.path_segments_mut()
|
|
||||||
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
|
|
||||||
.push("lighthouse")
|
|
||||||
.push("beacon")
|
|
||||||
.push("states")
|
|
||||||
.push(&state_id.to_string())
|
|
||||||
.push("ssz");
|
|
||||||
|
|
||||||
self.get_bytes_opt(path)
|
|
||||||
.await?
|
|
||||||
.map(|bytes| BeaconState::from_ssz_bytes(&bytes, spec).map_err(Error::InvalidSsz))
|
|
||||||
.transpose()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `GET lighthouse/staking`
|
/// `GET lighthouse/staking`
|
||||||
pub async fn get_lighthouse_staking(&self) -> Result<bool, Error> {
|
pub async fn get_lighthouse_staking(&self) -> Result<bool, Error> {
|
||||||
let mut path = self.server.full.clone();
|
let mut path = self.server.full.clone();
|
||||||
|
Loading…
Reference in New Issue
Block a user