Skip to content
Open
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
17 changes: 2 additions & 15 deletions crates/autopilot/src/domain/competition/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
super::auction::order,
crate::domain::{self, auction},
crate::domain,
alloy::primitives::Address,
derive_more::Display,
eth_domain_types as eth,
Expand All @@ -21,22 +21,15 @@ pub struct Solution {
id: SolutionId,
solver: Address,
orders: HashMap<domain::OrderUid, TradedOrder>,
prices: auction::Prices,
}

impl Solution {
pub fn new(
id: SolutionId,
solver: Address,
orders: HashMap<domain::OrderUid, TradedOrder>,
prices: auction::Prices,
) -> Self {
Self {
id,
solver,
orders,
prices,
}
Self { id, solver, orders }
}
}

Expand All @@ -56,10 +49,6 @@ impl Solution {
pub fn orders(&self) -> &HashMap<domain::OrderUid, TradedOrder> {
&self.orders
}

pub fn prices(&self) -> &HashMap<eth::TokenAddress, auction::Price> {
&self.prices
}
}

#[derive(Debug, Copy, Clone)]
Expand Down Expand Up @@ -132,8 +121,6 @@ pub struct ZeroScore;
pub enum SolutionError {
#[error(transparent)]
ZeroScore(#[from] ZeroScore),
#[error(transparent)]
InvalidPrice(#[from] auction::InvalidPrice),
#[error("the solver got deny listed")]
SolverDenyListed,
}
16 changes: 2 additions & 14 deletions crates/autopilot/src/domain/competition/winner_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ mod tests {
let solution_uid = hash(solution_id);
solution_map.insert(
solution_id,
create_bid(solution_uid, solver_address, trades, None).await,
create_bid(solution_uid, solver_address, trades).await,
);
}

Expand Down Expand Up @@ -1195,22 +1195,10 @@ mod tests {
solution_id: u64,
solver_address: Address,
trades: Vec<(OrderUid, TradedOrder)>,
prices: Option<HashMap<TokenAddress, Price>>,
) -> Bid<Unscored> {
// The prices of the tokens do not affect the result but they keys must exist
// for every token of every trade
let prices = prices.unwrap_or({
let mut res = HashMap::new();
for (_, trade) in &trades {
res.insert(trade.buy.token, create_price(eth::U256::ONE));
res.insert(trade.sell.token, create_price(eth::U256::ONE));
}
res
});

let trade_order_map: HashMap<OrderUid, TradedOrder> = trades.into_iter().collect();

let solution = Solution::new(solution_id, solver_address, trade_order_map, prices);
let solution = Solution::new(solution_id, solver_address, trade_order_map);

let driver = Driver::try_new(
url::Url::parse("http://localhost").unwrap(),
Expand Down
14 changes: 2 additions & 12 deletions crates/autopilot/src/infra/persistence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,8 @@ impl Persistence {
side: order.side.into(),
})
.collect(),
price_tokens: bid
.solution()
.prices()
.keys()
.map(|token| ByteArray(token.into_array()))
.collect(),
price_values: bid
.solution()
.prices()
.values()
.map(|price| u256_to_big_decimal(&price.get().0))
.collect(),
price_tokens: vec![],
price_values: vec![],
};
Ok::<_, DatabaseError>(solution)
})
Expand Down
21 changes: 15 additions & 6 deletions crates/autopilot/src/infra/solvers/dto/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ impl Response {
pub fn into_domain(
self,
) -> Vec<Result<domain::competition::Solution, domain::competition::SolutionError>> {
for solution in &self.solutions {
if !solution.clearing_prices.is_empty() {
tracing::debug!(
solution_id = solution.solution_id,
submission_address = %solution.submission_address,
num_prices = solution.clearing_prices.len(),
"driver sent deprecated clearingPrices field"
);
}
}
self.solutions
.into_iter()
.map(Solution::into_domain)
Expand Down Expand Up @@ -197,12 +207,6 @@ impl Solution {
.into_iter()
.map(|(o, amounts)| (o.into(), amounts.into_domain()))
.collect(),
self.clearing_prices
.into_iter()
.map(|(token, price)| {
domain::auction::Price::try_new(price.into()).map(|price| (token.into(), price))
})
.collect::<Result<_, _>>()?,
))
}
}
Expand Down Expand Up @@ -271,6 +275,11 @@ pub struct Solution {
/// Address used by the driver to submit the settlement onchain.
pub submission_address: Address,
pub orders: HashMap<boundary::OrderUid, TradedOrder>,
/// Deprecated: uniform clearing prices are no longer used by the
/// autopilot. Kept here purely so we can detect and log drivers that
/// still send them, in order to chase them down before the field is
/// removed entirely.
#[serde(default)]
#[serde_as(as = "HashMap<_, HexOrDecimalU256>")]
pub clearing_prices: HashMap<Address, U256>,
pub gas: Option<u64>,
Expand Down
1 change: 0 additions & 1 deletion crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,6 @@ impl Metrics {
fn solution_err(driver: &infra::Driver, err: &SolutionError) {
let label = match err {
SolutionError::ZeroScore(_) => "zero_score",
SolutionError::InvalidPrice(_) => "invalid_price",
SolutionError::SolverDenyListed => "solver_deny_listed",
};
Self::get()
Expand Down
12 changes: 9 additions & 3 deletions crates/driver/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,17 @@ components:
type: string
description: The effective amount the user received after all fees.
clearingPrices:
deprecated: true
description: >
Mapping of hex token address to price.
Deprecated. The autopilot no longer consumes uniform clearing
prices from the `/solve` response and ignores this field if
present. It is still emitted by drivers for backward
compatibility with autopilots running the previous code, and
will be removed in a follow-up release.

The prices of tokens for settled user orders as passed to the
settlement contract.

Mapping of hex token address to price. The prices of tokens
for settled user orders as passed to the settlement contract.
type: object
additionalProperties:
$ref: "#/components/schemas/BigUint"
Expand Down
5 changes: 5 additions & 0 deletions crates/driver/src/domain/competition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,11 @@ pub struct Solved {
pub id: solution::Id,
pub score: eth::Ether,
pub trades: HashMap<order::Uid, Amounts>,
/// Deprecated: uniform clearing prices are no longer consumed by the
/// autopilot. Still emitted on the `/solve` response so that autopilots
/// running the previous code can deserialise it during a rolling deploy.
/// Remove together with the response field once the new autopilot is
/// fully rolled out.
pub prices: HashMap<eth::TokenAddress, eth::TokenAmount>,
pub gas: Option<eth::Gas>,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,10 @@ impl Settlement {
acc
}

/// The uniform price vector this settlement proposes
/// The uniform price vector this settlement proposes.
///
/// Deprecated: only emitted on the `/solve` response so that autopilots
/// running the previous code can deserialise it during a rolling deploy.
pub fn prices(&self) -> HashMap<eth::TokenAddress, eth::TokenAmount> {
self.solution
.clearing_prices()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ pub struct Solution {
score: eth::U256,
#[serde_as(as = "HashMap<serde_ext::Hex, _>")]
orders: HashMap<OrderId, TradedOrder>,
/// Deprecated: kept only for backward compatibility with autopilots
/// running the previous code during a rolling deploy. Will be removed in
/// a follow-up once the new autopilot is fully rolled out.
#[serde_as(as = "HashMap<_, serde_ext::U256>")]
clearing_prices: HashMap<eth::Address, eth::U256>,
}
Expand Down
7 changes: 7 additions & 0 deletions crates/orderbook/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2137,10 +2137,17 @@ components:
Transaction in which the solution was executed onchain (if available).
nullable: true
clearingPrices:
deprecated: true
type: object
additionalProperties:
$ref: "#/components/schemas/BigUint"
description: >
Deprecated. The autopilot no longer persists per-solution uniform
clearing prices, so this field will be empty for solutions of
auctions produced by recent autopilots. Solutions stored before
this change keep their original values.


The prices of tokens for settled user orders as passed to the
settlement contract.
orders:
Expand Down
Loading