diff --git a/crates/driver/src/infra/solver/dto/solution.rs b/crates/driver/src/infra/solver/dto/solution.rs index 3d344780c0..d916296867 100644 --- a/crates/driver/src/infra/solver/dto/solution.rs +++ b/crates/driver/src/infra/solver/dto/solution.rs @@ -197,7 +197,9 @@ impl Solutions { .try_collect()?, solver.clone(), match solution.score { - Score::Solver(score) => competition::solution::SolverScore::Solver(score), + Score::Solver { score } => { + competition::solution::SolverScore::Solver(score) + } Score::RiskAdjusted(success_probability) => { competition::solution::SolverScore::RiskAdjusted(success_probability) } @@ -373,9 +375,13 @@ enum SigningScheme { Eip1271, } +#[serde_as] #[derive(Debug, Deserialize)] #[serde(rename_all = "lowercase", deny_unknown_fields)] pub enum Score { - Solver(eth::U256), + Solver { + #[serde_as(as = "serialize::U256")] + score: eth::U256, + }, RiskAdjusted(f64), } diff --git a/crates/driver/src/tests/cases/score_competition.rs b/crates/driver/src/tests/cases/score_competition.rs index 4c06082187..dbee014190 100644 --- a/crates/driver/src/tests/cases/score_competition.rs +++ b/crates/driver/src/tests/cases/score_competition.rs @@ -11,7 +11,7 @@ async fn solver_score_winner() { let test = setup() .pool(ab_pool()) .order(ab_order()) - .solution(ab_solution().score(Score::Solver(2902421280589416499u128.into()))) // not higher than objective value + .solution(ab_solution().score(Score::Solver { score: 2902421280589416499u128.into()})) // higher than objective value .solution(ab_solution().score(Score::RiskAdjusted(0.4))) .done() .await; @@ -29,7 +29,9 @@ async fn risk_adjusted_score_winner() { let test = setup() .pool(ab_pool()) .order(ab_order()) - .solution(ab_solution().score(Score::Solver(DEFAULT_SCORE_MIN.into()))) + .solution(ab_solution().score(Score::Solver { + score: DEFAULT_SCORE_MIN.into(), + })) .solution(ab_solution().score(Score::RiskAdjusted(0.9))) .done() .await; diff --git a/crates/driver/src/tests/setup/mod.rs b/crates/driver/src/tests/setup/mod.rs index 113996967e..09eef9c4d7 100644 --- a/crates/driver/src/tests/setup/mod.rs +++ b/crates/driver/src/tests/setup/mod.rs @@ -20,12 +20,13 @@ use { }, setup::blockchain::Blockchain, }, - util, + util::{self, serialize}, }, ethcontract::BlockId, hyper::StatusCode, itertools::Itertools, secp256k1::SecretKey, + serde_with::serde_as, std::{ collections::{HashMap, HashSet}, path::PathBuf, @@ -54,10 +55,14 @@ pub enum Partial { }, } +#[serde_as] #[derive(Debug, Clone, serde::Serialize)] #[serde(rename_all = "lowercase")] pub enum Score { - Solver(eth::U256), + Solver { + #[serde_as(as = "serialize::U256")] + score: eth::U256, + }, RiskAdjusted(f64), } diff --git a/crates/solvers/src/api/routes/solve/dto/solution.rs b/crates/solvers/src/api/routes/solve/dto/solution.rs index b80f6b52bc..8476716a95 100644 --- a/crates/solvers/src/api/routes/solve/dto/solution.rs +++ b/crates/solvers/src/api/routes/solve/dto/solution.rs @@ -133,7 +133,7 @@ impl Solutions { }) .collect(), score: match solution.score.clone() { - solution::Score::Solver(score) => Score::Solver(score), + solution::Score::Solver(score) => Score::Solver { score }, solution::Score::RiskAdjusted(score) => Score::RiskAdjusted(score.0), }, }) @@ -319,9 +319,13 @@ enum SigningScheme { } /// A score for a solution. The score is used to rank solutions. +#[serde_as] #[derive(Debug, Serialize)] #[serde(rename_all = "lowercase")] pub enum Score { - Solver(U256), + Solver { + #[serde_as(as = "serialize::U256")] + score: U256, + }, RiskAdjusted(f64), }