diff --git a/crates/driver/src/domain/competition/auction.rs b/crates/driver/src/domain/competition/auction.rs index 3178c25848..5b54b10709 100644 --- a/crates/driver/src/domain/competition/auction.rs +++ b/crates/driver/src/domain/competition/auction.rs @@ -10,9 +10,8 @@ use { infra::{self, blockchain, config::file::OrderPriorityStrategy, observe, Ethereum}, util::{self, Bytes}, }, - app_data::ValidatedAppData, chrono::{Duration, Utc}, - futures::future::{join_all, try_join, try_join_all, BoxFuture, FutureExt, Shared}, + futures::future::{join, join_all, BoxFuture, FutureExt, Shared}, itertools::Itertools, model::{order::OrderKind, signature::Signature}, shared::signature_validator::{Contracts, SignatureValidating}, @@ -150,40 +149,52 @@ impl AuctionProcessor { /// Process the auction by prioritizing the orders and filtering out /// unfillable orders. Fetches full app data for each order and returns an /// auction with updated orders. - pub async fn process(&self, auction: Auction, solver: ð::H160) -> Result { - let (app_data_by_order, mut prioritized_orders) = try_join( + pub async fn process(&self, auction: Auction, solver: ð::H160) -> Auction { + let (app_data_by_order, mut prioritized_orders) = join( self.collect_orders_app_data(&auction), - self.prioritize_orders(&auction, solver).map(Ok), + self.prioritize_orders(&auction, solver), ) - .await?; - - for order in &mut prioritized_orders { - if let Some(Some(app_data)) = app_data_by_order.get(&order.uid) { - order.app_data = app_data.clone().into(); - } - } + .await; + + // Filter out orders that failed to fetch app data. + prioritized_orders.retain_mut(|order| { + app_data_by_order.get(&order.uid).map_or(true, |result| { + match result { + Err(err) => { + tracing::warn!(order_uid=?order.uid, ?err, "failed to fetch app data for order, excluding from auction"); + false + } + Ok(Some(app_data)) => { + order.app_data = app_data.clone().into(); + true + } + Ok(None) => true + } + }) + }); - Ok(Auction { + Auction { orders: prioritized_orders, ..auction - }) + } } /// Fetches the app data for all orders in the auction. + /// Returns a map from order UIDs to the result of fetching the app data. async fn collect_orders_app_data( &self, auction: &Auction, - ) -> Result>, Error> { - Ok(try_join_all(auction.orders.iter().map(|order| async { - self.app_data_retriever - .get(order.app_data.hash()) - .await - .map(|app_data| (order.uid, app_data)) - .map_err(|err| Error::AppDataFetching(order.uid, err)) + ) -> HashMap< + order::Uid, + Result, order::app_data::FetchingError>, + > { + join_all(auction.orders.iter().map(|order| async { + let result = self.app_data_retriever.get(order.app_data.hash()).await; + (order.uid, result) })) - .await? + .await .into_iter() - .collect::>()) + .collect::>() } /// Prioritize well priced and filter out unfillable orders from the given @@ -672,6 +683,4 @@ pub enum Error { InvalidAmounts, #[error("blockchain error: {0:?}")] Blockchain(#[from] blockchain::Error), - #[error("order {0:?} app data fetching error: {1}")] - AppDataFetching(order::Uid, order::app_data::FetchingError), } diff --git a/crates/driver/src/domain/quote.rs b/crates/driver/src/domain/quote.rs index 67ceeac155..75aa0aecf7 100644 --- a/crates/driver/src/domain/quote.rs +++ b/crates/driver/src/domain/quote.rs @@ -15,7 +15,6 @@ use { }, util, }, - anyhow::anyhow, chrono::Utc, std::{ collections::{HashMap, HashSet}, @@ -183,7 +182,6 @@ impl Order { auction::Error::InvalidTokens => panic!("fake auction with invalid tokens"), auction::Error::InvalidAmounts => panic!("fake auction with invalid amounts"), auction::Error::Blockchain(e) => e.into(), - auction::Error::AppDataFetching(_, e) => Error::Boundary(anyhow!("{}", e)), }) } diff --git a/crates/driver/src/infra/api/error.rs b/crates/driver/src/infra/api/error.rs index 5693e125be..e788bbe5bf 100644 --- a/crates/driver/src/infra/api/error.rs +++ b/crates/driver/src/infra/api/error.rs @@ -99,7 +99,6 @@ impl From for (hyper::StatusCode, axum::Json) api::routes::AuctionError::InvalidTokens => Kind::InvalidTokens, api::routes::AuctionError::InvalidAmounts => Kind::InvalidAmounts, api::routes::AuctionError::Blockchain(_) => Kind::Unknown, - api::routes::AuctionError::Internal => Kind::Unknown, }; error.into() } diff --git a/crates/driver/src/infra/api/routes/solve/dto/solve_request.rs b/crates/driver/src/infra/api/routes/solve/dto/solve_request.rs index 04ff2cf473..b773387715 100644 --- a/crates/driver/src/infra/api/routes/solve/dto/solve_request.rs +++ b/crates/driver/src/infra/api/routes/solve/dto/solve_request.rs @@ -177,8 +177,6 @@ pub enum Error { InvalidAmounts, #[error("blockchain error: {0:?}")] Blockchain(#[source] crate::infra::blockchain::Error), - #[error("internal error")] - Internal, } impl From for Error { @@ -193,7 +191,6 @@ impl From for Error { auction::Error::InvalidTokens => Self::InvalidTokens, auction::Error::InvalidAmounts => Self::InvalidAmounts, auction::Error::Blockchain(err) => Self::Blockchain(err), - auction::Error::AppDataFetching(_, _) => Self::Internal, } } } diff --git a/crates/driver/src/infra/api/routes/solve/mod.rs b/crates/driver/src/infra/api/routes/solve/mod.rs index 507168d44f..d72f635b3f 100644 --- a/crates/driver/src/infra/api/routes/solve/mod.rs +++ b/crates/driver/src/infra/api/routes/solve/mod.rs @@ -35,11 +35,7 @@ async fn route( let auction = state .pre_processor() .process(auction, &competition.solver.account().address()) - .await - .map_err(|err| { - tracing::error!(?err, "unable to pre-process the auction"); - Into::::into(err) - })?; + .await; let result = competition.solve(auction).await; competition.ensure_settle_queue_capacity()?; observe::solved(state.solver().name(), &result);