Skip to content
Draft
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
20 changes: 0 additions & 20 deletions crates/autopilot/src/domain/competition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ pub struct TradedOrder {
pub struct Score(eth::Ether);

impl Score {
pub fn try_new(score: eth::Ether) -> Result<Self, ZeroScore> {
if score.0.is_zero() {
Err(ZeroScore)
} else {
Ok(Self(score))
}
}

pub fn get(&self) -> &eth::Ether {
&self.0
}
Expand All @@ -112,15 +104,3 @@ impl num::CheckedSub for Score {
self.0.checked_sub(&v.0).map(Score)
}
}

#[derive(Debug, thiserror::Error)]
#[error("the solver proposed a 0-score solution")]
pub struct ZeroScore;

#[derive(Debug, thiserror::Error)]
pub enum SolutionError {
#[error(transparent)]
ZeroScore(#[from] ZeroScore),
#[error("the solver got deny listed")]
SolverDenyListed,
}
12 changes: 4 additions & 8 deletions crates/autopilot/src/infra/solvers/dto/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ impl InjectIntoHttpRequest for Request {
}

impl Response {
pub fn into_domain(
self,
) -> Vec<Result<domain::competition::Solution, domain::competition::SolutionError>> {
pub fn into_domain(self) -> Vec<domain::competition::Solution> {
for solution in &self.solutions {
if !solution.clearing_prices.is_empty() {
tracing::debug!(
Expand Down Expand Up @@ -197,17 +195,15 @@ pub struct Token {
}

impl Solution {
pub fn into_domain(
self,
) -> Result<domain::competition::Solution, domain::competition::SolutionError> {
Ok(domain::competition::Solution::new(
pub fn into_domain(self) -> domain::competition::Solution {
domain::competition::Solution::new(
self.solution_id,
self.submission_address,
self.orders
.into_iter()
.map(|(o, amounts)| (o.into(), amounts.into_domain()))
.collect(),
))
)
}
}

Expand Down
28 changes: 4 additions & 24 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use {
competition::{
self,
Solution,
SolutionError,
Unscored,
winner_selection::{self, Ranking},
},
Expand Down Expand Up @@ -640,16 +639,9 @@ impl RunLoop {

solutions
.into_iter()
.filter_map(|solution| match solution {
Ok(solution) => {
Metrics::solution_ok(&driver);
Some(competition::Bid::new(solution, driver.clone()))
}
Err(err) => {
Metrics::solution_err(&driver, &err);
tracing::debug!(?err, driver = %driver.name, "invalid proposed solution");
None
}
.map(|solution| {
Metrics::solution_ok(&driver);
competition::Bid::new(solution, driver.clone())
})
.collect()
}
Expand All @@ -659,8 +651,7 @@ impl RunLoop {
&self,
driver: Arc<infra::Driver>,
request: solve::Request,
) -> Result<Vec<Result<competition::Solution, domain::competition::SolutionError>>, SolveError>
{
) -> Result<Vec<competition::Solution>, SolveError> {
let (can_participate, response) = {
let driver = driver.clone();
let eth = self.eth.clone();
Expand Down Expand Up @@ -1012,17 +1003,6 @@ impl Metrics {
.inc();
}

fn solution_err(driver: &infra::Driver, err: &SolutionError) {
let label = match err {
SolutionError::ZeroScore(_) => "zero_score",
SolutionError::SolverDenyListed => "solver_deny_listed",
};
Self::get()
.solutions
.with_label_values(&[driver.name.as_str(), label])
.inc();
}

fn settle_ok(driver: &infra::Driver, settled_order_count: usize, elapsed: Duration) {
Self::get()
.settle
Expand Down
6 changes: 0 additions & 6 deletions crates/autopilot/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use {
anyhow::Context,
eth_domain_types::WrappedNativeToken,
ethrpc::block_stream::CurrentBlockWatcher,
itertools::Itertools,
num::{CheckedSub, Saturating},
shared::token_list::AutoUpdatingTokenList,
std::{num::NonZeroUsize, sync::Arc, time::Duration},
Expand Down Expand Up @@ -227,11 +226,6 @@ impl RunLoop {
}
};

let (solutions, errs): (Vec<_>, Vec<_>) = solutions.into_iter().partition_result();
if !errs.is_empty() {
tracing::debug!(len = errs.len(), ?errs, "dropping solutions with errors");
}

futures::future::join_all(solutions.iter().map(|s| async {
let response = driver.reveal(reveal::Request {
solution_id: s.id(),
Expand Down
Loading