Skip to content

Commit abeb358

Browse files
authored
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
1 parent 6f3af67 commit abeb358

File tree

3 files changed

+2
-101
lines changed

3 files changed

+2
-101
lines changed

beacon_node/http_api/src/lib.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4267,36 +4267,6 @@ pub fn serve<T: BeaconChainTypes>(
42674267
},
42684268
);
42694269

4270-
// GET lighthouse/beacon/states/{state_id}/ssz
4271-
let get_lighthouse_beacon_states_ssz = warp::path("lighthouse")
4272-
.and(warp::path("beacon"))
4273-
.and(warp::path("states"))
4274-
.and(warp::path::param::<StateId>())
4275-
.and(warp::path("ssz"))
4276-
.and(warp::path::end())
4277-
.and(task_spawner_filter.clone())
4278-
.and(chain_filter.clone())
4279-
.then(
4280-
|state_id: StateId,
4281-
task_spawner: TaskSpawner<T::EthSpec>,
4282-
chain: Arc<BeaconChain<T>>| {
4283-
task_spawner.blocking_response_task(Priority::P1, move || {
4284-
// This debug endpoint provides no indication of optimistic status.
4285-
let (state, _execution_optimistic, _finalized) = state_id.state(&chain)?;
4286-
Response::builder()
4287-
.status(200)
4288-
.body(state.as_ssz_bytes().into())
4289-
.map(|res: Response<Body>| add_ssz_content_type_header(res))
4290-
.map_err(|e| {
4291-
warp_utils::reject::custom_server_error(format!(
4292-
"failed to create response: {}",
4293-
e
4294-
))
4295-
})
4296-
})
4297-
},
4298-
);
4299-
43004270
// GET lighthouse/staking
43014271
let get_lighthouse_staking = warp::path("lighthouse")
43024272
.and(warp::path("staking"))
@@ -4631,7 +4601,6 @@ pub fn serve<T: BeaconChainTypes>(
46314601
.uor(get_lighthouse_eth1_syncing)
46324602
.uor(get_lighthouse_eth1_block_cache)
46334603
.uor(get_lighthouse_eth1_deposit_cache)
4634-
.uor(get_lighthouse_beacon_states_ssz)
46354604
.uor(get_lighthouse_staking)
46364605
.uor(get_lighthouse_database_info)
46374606
.uor(get_lighthouse_block_rewards)

beacon_node/http_api/tests/tests.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5057,26 +5057,6 @@ impl ApiTester {
50575057
self
50585058
}
50595059

5060-
pub async fn test_get_lighthouse_beacon_states_ssz(self) -> Self {
5061-
for state_id in self.interesting_state_ids() {
5062-
let result = self
5063-
.client
5064-
.get_lighthouse_beacon_states_ssz(&state_id.0, &self.chain.spec)
5065-
.await
5066-
.unwrap();
5067-
5068-
let mut expected = state_id
5069-
.state(&self.chain)
5070-
.ok()
5071-
.map(|(state, _execution_optimistic, _finalized)| state);
5072-
expected.as_mut().map(|state| state.drop_all_caches());
5073-
5074-
assert_eq!(result, expected, "{:?}", state_id);
5075-
}
5076-
5077-
self
5078-
}
5079-
50805060
pub async fn test_get_lighthouse_staking(self) -> Self {
50815061
let result = self.client.get_lighthouse_staking().await.unwrap();
50825062

@@ -6373,8 +6353,6 @@ async fn lighthouse_endpoints() {
63736353
.await
63746354
.test_get_lighthouse_eth1_deposit_cache()
63756355
.await
6376-
.test_get_lighthouse_beacon_states_ssz()
6377-
.await
63786356
.test_get_lighthouse_staking()
63796357
.await
63806358
.test_get_lighthouse_database_info()

common/eth2/src/lighthouse.rs

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ mod standard_block_rewards;
88
mod sync_committee_rewards;
99

1010
use crate::{
11-
ok_or_error,
1211
types::{
13-
BeaconState, ChainSpec, DepositTreeSnapshot, Epoch, EthSpec, FinalizedExecutionBlock,
14-
GenericResponse, ValidatorId,
12+
DepositTreeSnapshot, Epoch, EthSpec, FinalizedExecutionBlock, GenericResponse, ValidatorId,
1513
},
16-
BeaconNodeHttpClient, DepositData, Error, Eth1Data, Hash256, Slot, StateId, StatusCode,
14+
BeaconNodeHttpClient, DepositData, Error, Eth1Data, Hash256, Slot,
1715
};
1816
use proto_array::core::ProtoArray;
19-
use reqwest::IntoUrl;
2017
use serde::{Deserialize, Serialize};
2118
use ssz::four_byte_option_impl;
2219
use ssz_derive::{Decode, Encode};
@@ -371,27 +368,6 @@ pub struct DatabaseInfo {
371368
}
372369

373370
impl BeaconNodeHttpClient {
374-
/// Perform a HTTP GET request, returning `None` on a 404 error.
375-
async fn get_bytes_opt<U: IntoUrl>(&self, url: U) -> Result<Option<Vec<u8>>, Error> {
376-
let response = self.client.get(url).send().await.map_err(Error::from)?;
377-
match ok_or_error(response).await {
378-
Ok(resp) => Ok(Some(
379-
resp.bytes()
380-
.await
381-
.map_err(Error::from)?
382-
.into_iter()
383-
.collect::<Vec<_>>(),
384-
)),
385-
Err(err) => {
386-
if err.status() == Some(StatusCode::NOT_FOUND) {
387-
Ok(None)
388-
} else {
389-
Err(err)
390-
}
391-
}
392-
}
393-
}
394-
395371
/// `GET lighthouse/health`
396372
pub async fn get_lighthouse_health(&self) -> Result<GenericResponse<Health>, Error> {
397373
let mut path = self.server.full.clone();
@@ -516,28 +492,6 @@ impl BeaconNodeHttpClient {
516492
self.get(path).await
517493
}
518494

519-
/// `GET lighthouse/beacon/states/{state_id}/ssz`
520-
pub async fn get_lighthouse_beacon_states_ssz<E: EthSpec>(
521-
&self,
522-
state_id: &StateId,
523-
spec: &ChainSpec,
524-
) -> Result<Option<BeaconState<E>>, Error> {
525-
let mut path = self.server.full.clone();
526-
527-
path.path_segments_mut()
528-
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
529-
.push("lighthouse")
530-
.push("beacon")
531-
.push("states")
532-
.push(&state_id.to_string())
533-
.push("ssz");
534-
535-
self.get_bytes_opt(path)
536-
.await?
537-
.map(|bytes| BeaconState::from_ssz_bytes(&bytes, spec).map_err(Error::InvalidSsz))
538-
.transpose()
539-
}
540-
541495
/// `GET lighthouse/staking`
542496
pub async fn get_lighthouse_staking(&self) -> Result<bool, Error> {
543497
let mut path = self.server.full.clone();

0 commit comments

Comments
 (0)