mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Implement /eth/v1/beacon/blobs endpoint (#8103)
* #8085 Co-Authored-By: Tan Chee Keong <tanck@sigmaprime.io> Co-Authored-By: chonghe <44791194+chong-he@users.noreply.github.com>
This commit is contained in:
@@ -214,6 +214,7 @@ pub fn prometheus_metrics() -> warp::filters::log::Log<impl Fn(warp::filters::lo
|
||||
equals("v1/beacon/blocks")
|
||||
.or_else(|| starts_with("v2/beacon/blocks"))
|
||||
.or_else(|| starts_with("v1/beacon/blob_sidecars"))
|
||||
.or_else(|| starts_with("v1/beacon/blobs"))
|
||||
.or_else(|| starts_with("v1/beacon/blocks/head/root"))
|
||||
.or_else(|| starts_with("v1/beacon/blinded_blocks"))
|
||||
.or_else(|| starts_with("v2/beacon/blinded_blocks"))
|
||||
@@ -1897,7 +1898,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
*/
|
||||
|
||||
// GET beacon/blob_sidecars/{block_id}
|
||||
let get_blobs = eth_v1
|
||||
let get_blob_sidecars = eth_v1
|
||||
.and(warp::path("beacon"))
|
||||
.and(warp::path("blob_sidecars"))
|
||||
.and(block_id_or_err)
|
||||
@@ -1947,6 +1948,52 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
},
|
||||
);
|
||||
|
||||
// GET beacon/blobs/{block_id}
|
||||
let get_blobs = eth_v1
|
||||
.and(warp::path("beacon"))
|
||||
.and(warp::path("blobs"))
|
||||
.and(block_id_or_err)
|
||||
.and(warp::path::end())
|
||||
.and(multi_key_query::<api_types::BlobsVersionedHashesQuery>())
|
||||
.and(task_spawner_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.and(warp::header::optional::<api_types::Accept>("accept"))
|
||||
.then(
|
||||
|block_id: BlockId,
|
||||
version_hashes_res: Result<api_types::BlobsVersionedHashesQuery, warp::Rejection>,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
accept_header: Option<api_types::Accept>| {
|
||||
task_spawner.blocking_response_task(Priority::P1, move || {
|
||||
let versioned_hashes = version_hashes_res?;
|
||||
let response =
|
||||
block_id.get_blobs_by_versioned_hashes(versioned_hashes, &chain)?;
|
||||
|
||||
match accept_header {
|
||||
Some(api_types::Accept::Ssz) => Response::builder()
|
||||
.status(200)
|
||||
.body(response.data.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
|
||||
))
|
||||
}),
|
||||
_ => {
|
||||
let res = execution_optimistic_finalized_beacon_response(
|
||||
ResponseIncludesVersion::No,
|
||||
response.metadata.execution_optimistic.unwrap_or(false),
|
||||
response.metadata.finalized.unwrap_or(false),
|
||||
response.data,
|
||||
)?;
|
||||
Ok(warp::reply::json(&res).into_response())
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
/*
|
||||
* beacon/pool
|
||||
*/
|
||||
@@ -4794,6 +4841,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.uor(get_beacon_block_attestations)
|
||||
.uor(get_beacon_blinded_block)
|
||||
.uor(get_beacon_block_root)
|
||||
.uor(get_blob_sidecars)
|
||||
.uor(get_blobs)
|
||||
.uor(get_beacon_pool_attestations)
|
||||
.uor(get_beacon_pool_attester_slashings)
|
||||
|
||||
Reference in New Issue
Block a user