Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
squadgazzz committed Dec 2, 2024
1 parent 84592a4 commit c1ca8fb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
36 changes: 19 additions & 17 deletions crates/driver/src/domain/competition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Competition {
pub async fn solve(&self, auction: &Auction) -> Result<Option<Solved>, Error> {
if self.settle_queue.capacity() == 0 {
tracing::warn!("settlement queue is full; auction is rejected");
return Err(Error::SubmissionError);
return Err(Error::SettlementQueueIsFull);
}

let liquidity = match self.solver.liquidity() {
Expand Down Expand Up @@ -369,30 +369,30 @@ impl Competition {
submission_deadline,
response_sender,
} = request;
if self.eth.current_block().borrow().number >= submission_deadline {
if let Err(err) = response_sender.send(Err(DeadlineExceeded.into())) {
tracing::error!(
?err,
"settle deadline exceeded. unable to return a response"
);
let solver = self.solver.name().as_str();
async {
if self.eth.current_block().borrow().number >= submission_deadline {
if let Err(err) = response_sender.send(Err(DeadlineExceeded.into())) {
tracing::warn!(
?err,
"settle deadline exceeded. unable to return a response"
);
}
return;
}
continue;
}
let solver = self.solver.name().to_string();
let result = async {

observe::settling();
let result = self
.process_settle_request(auction_id, solution_id, submission_deadline)
.await;
observe::settled(self.solver.name(), &result);
result
}
.instrument(tracing::info_span!("/settle", solver, auction_id))
.await;

if let Err(err) = response_sender.send(result) {
tracing::error!(?err, "Failed to send /settle response");
if let Err(err) = response_sender.send(result) {
tracing::error!(?err, "Failed to send /settle response");
}
}
.instrument(tracing::info_span!("/settle", solver, auction_id))
.await
}
}

Expand Down Expand Up @@ -586,4 +586,6 @@ pub enum Error {
Solver(#[from] solver::Error),
#[error("failed to submit the solution")]
SubmissionError,
#[error("too many pending settlements for the same solver")]
SettlementQueueIsFull,
}
1 change: 1 addition & 0 deletions crates/driver/src/infra/api/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl From<competition::Error> for (hyper::StatusCode, axum::Json<Error>) {
competition::Error::DeadlineExceeded(_) => Kind::DeadlineExceeded,
competition::Error::Solver(_) => Kind::SolverFailed,
competition::Error::SubmissionError => Kind::FailedToSubmit,
competition::Error::SettlementQueueIsFull => Kind::SolverFailed,
};
error.into()
}
Expand Down
1 change: 1 addition & 0 deletions crates/driver/src/infra/observe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ fn competition_error(err: &competition::Error) -> &'static str {
competition::Error::Solver(solver::Error::Deserialize(_)) => "SolverDeserializeError",
competition::Error::Solver(solver::Error::Dto(_)) => "SolverDtoError",
competition::Error::SubmissionError => "SubmissionError",
competition::Error::SettlementQueueIsFull => "SettlementQueueIsFull",
}
}

Expand Down

0 comments on commit c1ca8fb

Please sign in to comment.