Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bolt-sidecar): return error when no bids #574

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading