mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Remove VC response signing and fix HTTP error handling (#5529)
* and_then to then remove expect move convert_rejection to utils remove signer from vc api * remove key * remove auth header * revert * Merge branch 'unstable' of https://github.com/sigp/lighthouse into vc-api-fix * merge unstable * revert * Merge branch 'unstable' of https://github.com/sigp/lighthouse into vc-api-fix * Merge branch 'unstable' of https://github.com/sigp/lighthouse into vc-api-fix * refactor blocking json task * linting * revert logging * remove response signing checks in validtor http_api client * remove notion of public key, prefixes, and simplify token generation * fmt * Remove outdated comment on public key
This commit is contained in:
@@ -97,7 +97,7 @@ use warp::hyper::Body;
|
||||
use warp::sse::Event;
|
||||
use warp::Reply;
|
||||
use warp::{http::Response, Filter, Rejection};
|
||||
use warp_utils::{query::multi_key_query, uor::UnifyingOrFilter};
|
||||
use warp_utils::{query::multi_key_query, reject::convert_rejection, uor::UnifyingOrFilter};
|
||||
|
||||
const API_PREFIX: &str = "eth";
|
||||
|
||||
@@ -1802,7 +1802,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
)
|
||||
.await
|
||||
.map(|()| warp::reply::json(&()));
|
||||
task_spawner::convert_rejection(result).await
|
||||
convert_rejection(result).await
|
||||
},
|
||||
);
|
||||
|
||||
@@ -3817,12 +3817,12 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.await;
|
||||
|
||||
if initial_result.is_err() {
|
||||
return task_spawner::convert_rejection(initial_result).await;
|
||||
return convert_rejection(initial_result).await;
|
||||
}
|
||||
|
||||
// Await a response from the builder without blocking a
|
||||
// `BeaconProcessor` worker.
|
||||
task_spawner::convert_rejection(rx.await.unwrap_or_else(|_| {
|
||||
convert_rejection(rx.await.unwrap_or_else(|_| {
|
||||
Ok(warp::reply::with_status(
|
||||
warp::reply::json(&"No response from channel"),
|
||||
eth2::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
|
||||
@@ -4,6 +4,7 @@ use std::future::Future;
|
||||
use tokio::sync::{mpsc::error::TrySendError, oneshot};
|
||||
use types::EthSpec;
|
||||
use warp::reply::{Reply, Response};
|
||||
use warp_utils::reject::convert_rejection;
|
||||
|
||||
/// Maps a request to a queue in the `BeaconProcessor`.
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -35,24 +36,6 @@ pub struct TaskSpawner<E: EthSpec> {
|
||||
beacon_processor_send: Option<BeaconProcessorSend<E>>,
|
||||
}
|
||||
|
||||
/// Convert a warp `Rejection` into a `Response`.
|
||||
///
|
||||
/// This function should *always* be used to convert rejections into responses. This prevents warp
|
||||
/// from trying to backtrack in strange ways. See: https://github.com/sigp/lighthouse/issues/3404
|
||||
pub async fn convert_rejection<T: Reply>(res: Result<T, warp::Rejection>) -> Response {
|
||||
match res {
|
||||
Ok(response) => response.into_response(),
|
||||
Err(e) => match warp_utils::reject::handle_rejection(e).await {
|
||||
Ok(reply) => reply.into_response(),
|
||||
Err(_) => warp::reply::with_status(
|
||||
warp::reply::json(&"unhandled error"),
|
||||
eth2::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
.into_response(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> TaskSpawner<E> {
|
||||
pub fn new(beacon_processor_send: Option<BeaconProcessorSend<E>>) -> Self {
|
||||
Self {
|
||||
|
||||
Reference in New Issue
Block a user