Bump warp and begin axum migration (#9001)

- Bump `warp` to 0.4. This unifies `warp` and `axum` onto the same `http`, `hyper`, `h2`, `rustls`, etc versions.
- Create `axum_utils` which contain common functions and types
- Begins migration of all HTTP API servers from warp to axum


Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
Mac L
2026-06-25 18:19:29 +04:00
committed by GitHub
parent a4c4cccf04
commit 8c2a909061
41 changed files with 1333 additions and 543 deletions

View File

@@ -13,8 +13,8 @@ use std::sync::Arc;
use types::{EthSpec, ForkName, Hash256, LightClientBootstrap};
use warp::{
Rejection,
hyper::{Body, Response},
reply::Reply,
http::response::Builder,
reply::{Reply, Response},
};
const MAX_REQUEST_LIGHT_CLIENT_UPDATES: u64 = 128;
@@ -23,7 +23,7 @@ pub fn get_light_client_updates<T: BeaconChainTypes>(
chain: Arc<BeaconChain<T>>,
query: LightClientUpdatesQuery,
accept_header: Option<api_types::Accept>,
) -> Result<Response<Body>, Rejection> {
) -> Result<Response, Rejection> {
validate_light_client_updates_request(&chain, &query)?;
let light_client_updates = chain
@@ -34,17 +34,17 @@ pub fn get_light_client_updates<T: BeaconChainTypes>(
match accept_header {
Some(api_types::Accept::Ssz) => {
let response_chunks = light_client_updates
let response_chunks: Vec<u8> = light_client_updates
.into_iter()
.flat_map(|update| {
map_light_client_update_to_response_chunk::<T>(&chain, update).as_ssz_bytes()
})
.collect();
Response::builder()
Builder::new()
.status(200)
.body(response_chunks)
.map(|res: Response<Vec<u8>>| add_ssz_content_type_header(res))
.map(add_ssz_content_type_header)
.map_err(|e| {
warp_utils::reject::custom_server_error(format!(
"failed to create response: {}",
@@ -66,7 +66,7 @@ pub fn get_light_client_bootstrap<T: BeaconChainTypes>(
chain: Arc<BeaconChain<T>>,
block_root: &Hash256,
accept_header: Option<api_types::Accept>,
) -> Result<Response<Body>, Rejection> {
) -> Result<Response, Rejection> {
let (light_client_bootstrap, fork_name) = chain
.get_light_client_bootstrap(block_root)
.map_err(|err| {
@@ -83,11 +83,11 @@ pub fn get_light_client_bootstrap<T: BeaconChainTypes>(
))?;
match accept_header {
Some(api_types::Accept::Ssz) => Response::builder()
Some(api_types::Accept::Ssz) => Builder::new()
.status(200)
.body(light_client_bootstrap.as_ssz_bytes().into())
.map(|res: Response<Body>| add_consensus_version_header(res, fork_name))
.map(|res: Response<Body>| add_ssz_content_type_header(res))
.body(light_client_bootstrap.as_ssz_bytes())
.map(|res| add_consensus_version_header(res, fork_name))
.map(add_ssz_content_type_header)
.map_err(|e| {
warp_utils::reject::custom_server_error(format!("failed to create response: {}", e))
}),