Skip to content

Commit

Permalink
Merge pull request #574 from chainbound/proxy-err
Browse files Browse the repository at this point in the history
fix(bolt-sidecar): return error when no bids
  • Loading branch information
Jonas Bostoen authored Dec 16, 2024
2 parents a93583f + d118171 commit 5449ae4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 9 additions & 6 deletions bolt-sidecar/src/api/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ pub enum BuilderApiError {
FailedDelegating(ErrorResponse),
#[error("Failed to revoke constraint submission rights: {0:?}")]
FailedRevoking(ErrorResponse),
#[error("No bids found for slot {0}")]
NoBids(u64),
#[error("Failed to fetch local payload for slot {0}")]
FailedToFetchLocalPayload(u64),
#[error("Axum error: {0:?}")]
Expand All @@ -84,14 +86,15 @@ pub enum BuilderApiError {
impl IntoResponse for BuilderApiError {
fn into_response(self) -> Response {
match self {
Self::FailedRegisteringValidators(error) |
Self::FailedGettingHeader(error) |
Self::FailedGettingPayload(error) |
Self::FailedSubmittingConstraints(error) |
Self::FailedDelegating(error) |
Self::FailedRevoking(error) => {
Self::FailedRegisteringValidators(error)
| Self::FailedGettingHeader(error)
| Self::FailedGettingPayload(error)
| Self::FailedSubmittingConstraints(error)
| Self::FailedDelegating(error)
| Self::FailedRevoking(error) => {
(StatusCode::from_u16(error.code).unwrap(), Json(error)).into_response()
}
Self::NoBids(_) => (StatusCode::NO_CONTENT, self.to_string()).into_response(),
Self::AxumError(err) => (StatusCode::BAD_REQUEST, err.to_string()).into_response(),
Self::JsonError(err) => (StatusCode::BAD_REQUEST, err.to_string()).into_response(),
Self::FailedToFetchLocalPayload(_) => {
Expand Down
4 changes: 4 additions & 0 deletions bolt-sidecar/src/client/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ impl ConstraintsApi for ConstraintsClient {
.send()
.await?;

if response.status() != StatusCode::NO_CONTENT {
return Err(BuilderApiError::NoBids(params.slot));
}

if response.status() != StatusCode::OK {
let error = response.json::<ErrorResponse>().await?;
return Err(BuilderApiError::FailedGettingHeader(error));
Expand Down

0 comments on commit 5449ae4

Please sign in to comment.