-
Notifications
You must be signed in to change notification settings - Fork 186
(fast1) Thread solution_id through price-estimation #4855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -184,6 +184,7 @@ impl From<dto::LegacyQuote> for LegacyTrade { | |||||||||||||
| solver: quote.solver, | ||||||||||||||
| tx_origin: quote.tx_origin, | ||||||||||||||
| supports_fast_path: quote.supports_fast_path, | ||||||||||||||
| solution_id: quote.solution_id, | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -215,6 +216,7 @@ impl From<dto::Quote> for Trade { | |||||||||||||
| tx_origin: quote.tx_origin, | ||||||||||||||
| jit_orders: quote.jit_orders, | ||||||||||||||
| supports_fast_path: quote.supports_fast_path, | ||||||||||||||
| solution_id: quote.solution_id, | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -363,6 +365,7 @@ impl TradeFinding for ExternalTradeFinder { | |||||||||||||
| gas_estimate, | ||||||||||||||
| solver: trade.solver(), | ||||||||||||||
| supports_fast_path: trade.supports_fast_path(), | ||||||||||||||
| solution_id: trade.solution_id(), | ||||||||||||||
| execution: QuoteExecution { | ||||||||||||||
| interactions: map_interactions_data(trade.interactions()), | ||||||||||||||
| pre_interactions: map_interactions_data(trade.pre_interactions()), | ||||||||||||||
|
|
@@ -402,7 +405,12 @@ pub mod dto { | |||||||||||||
| pub amount: U256, | ||||||||||||||
| pub kind: OrderKind, | ||||||||||||||
| pub deadline: chrono::DateTime<chrono::Utc>, | ||||||||||||||
| #[serde(default, skip_serializing_if = "std::ops::Not::not")] | ||||||||||||||
| // Renamed to match the driver's `enableFastPath` field name. | ||||||||||||||
| #[serde( | ||||||||||||||
| rename = "enableFastPath", | ||||||||||||||
|
Comment on lines
+408
to
+410
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nano nit:
Suggested change
|
||||||||||||||
| default, | ||||||||||||||
| skip_serializing_if = "std::ops::Not::not" | ||||||||||||||
| )] | ||||||||||||||
| pub fast_path: bool, | ||||||||||||||
| #[serde(skip_serializing_if = "Option::is_none")] | ||||||||||||||
| pub auction_id: Option<i64>, | ||||||||||||||
|
|
@@ -429,6 +437,11 @@ pub mod dto { | |||||||||||||
| pub tx_origin: Option<Address>, | ||||||||||||||
| #[serde(default)] | ||||||||||||||
| pub supports_fast_path: bool, | ||||||||||||||
| /// Solver-assigned solution id for this quote. Threaded through to | ||||||||||||||
| /// `QuoteResponse.solution_id` and, ultimately, into | ||||||||||||||
| /// `proposed_solutions.id` when a fast-path quote is persisted. | ||||||||||||||
| #[serde(default)] | ||||||||||||||
| pub solution_id: Option<u64>, | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer if we gave every quote request a unique id (not just the winning one) and send it as part of the request to solvers. This way they could later on see which specific call caused the winning quote and we could properly index every single quote response in our data infra as well. That fast path quote request id could later serve as a solution id.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Together with the quote request we already send a unique auction id. Later on we send the auction_id together with the solver's solution_id like we do with settle requests today.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but why don't we simply create a unique quote request ID that we send to each solver (and the winning one becomes the actual quote ID)? This way we don't need them to also come up with a solution id (which may not be unique across solvers) and create this compound primary key (fake auction id + solution id). This would also generalize for non fast path quotes, which currently are hard to identify in clickhouse and allow solvers to map which of the many quote request we send them ended up being used on the final order.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm bringing this up now, because changing it later on will be much more expensive. If we see a benefit in having globally unique quote IDs, I think now is the moment to introduce them (and reuse them for fast path solution identification). I also don't think the change would be that expensive to implement.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For streamed quotes for instance, we probably need a unique ID for each response, so the client can place an order from any of the responses (and not wait for some final ID to arrive at the end). |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| #[serde_as] | ||||||||||||||
|
|
@@ -448,6 +461,11 @@ pub mod dto { | |||||||||||||
| pub jit_orders: Vec<JitOrder>, | ||||||||||||||
| #[serde(default)] | ||||||||||||||
| pub supports_fast_path: bool, | ||||||||||||||
| /// Solver-assigned solution id for this quote. Threaded through to | ||||||||||||||
| /// `QuoteResponse.solution_id` and, ultimately, into | ||||||||||||||
| /// `proposed_solutions.id` when a fast-path quote is persisted. | ||||||||||||||
| #[serde(default)] | ||||||||||||||
| pub solution_id: Option<u64>, | ||||||||||||||
|
Comment on lines
+464
to
+468
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "threaded through" can rot and we can always use editor functions to follow, I'd say a description of the systems it needs to go through would be better |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| #[serde_as] | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,6 +37,9 @@ pub struct Quote { | |||||||||
| pub solver: Address, | ||||||||||
| /// Whether the quoting solver supports fast-path execution. | ||||||||||
| pub supports_fast_path: bool, | ||||||||||
| /// Solver-assigned solution id, when the underlying quote response | ||||||||||
| /// carries one. | ||||||||||
| pub solution_id: Option<u64>, | ||||||||||
| #[debug(ignore)] | ||||||||||
| pub execution: QuoteExecution, | ||||||||||
| } | ||||||||||
|
|
@@ -90,6 +93,13 @@ impl TradeKind { | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| pub fn solution_id(&self) -> Option<u64> { | ||||||||||
| match self { | ||||||||||
| TradeKind::Legacy(trade) => trade.solution_id, | ||||||||||
| TradeKind::Regular(trade) => trade.solution_id, | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| pub fn simulation_solver_address(&self) -> Address { | ||||||||||
| self.tx_origin().unwrap_or(self.solver()) | ||||||||||
| } | ||||||||||
|
|
@@ -148,6 +158,9 @@ pub struct LegacyTrade { | |||||||||
| pub tx_origin: Option<Address>, | ||||||||||
| /// Whether the quoting solver supports fast-path execution. | ||||||||||
| pub supports_fast_path: bool, | ||||||||||
| /// Solver-assigned solution id for this trade, if the response carried | ||||||||||
| /// one. | ||||||||||
|
Comment on lines
+161
to
+162
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nano-nit (apply to others if you take this suggestion):
Suggested change
|
||||||||||
| pub solution_id: Option<u64>, | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// A trade with JIT orders. | ||||||||||
|
|
@@ -169,6 +182,9 @@ pub struct Trade { | |||||||||
| pub jit_orders: Vec<dto::JitOrder>, | ||||||||||
| /// Whether the quoting solver supports fast-path execution. | ||||||||||
| pub supports_fast_path: bool, | ||||||||||
| /// Solver-assigned solution id for this trade, if the response carried | ||||||||||
| /// one. | ||||||||||
| pub solution_id: Option<u64>, | ||||||||||
| } | ||||||||||
|
|
||||||||||
| impl Trade { | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment about the threading applies here too