From 50c67ff528b7692868032d7c54cd0d82df60a3b0 Mon Sep 17 00:00:00 2001 From: Michal Strug Date: Fri, 13 Dec 2024 13:50:49 +0100 Subject: [PATCH 01/10] Updated openapi definition --- crates/driver/openapi.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/driver/openapi.yml b/crates/driver/openapi.yml index 9b4a6bd812..f30f735d70 100644 --- a/crates/driver/openapi.yml +++ b/crates/driver/openapi.yml @@ -130,7 +130,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Solution" + $ref: "#/components/schemas/SolutionWithDeadline" responses: "200": description: Execution accepted. @@ -526,7 +526,19 @@ components: gas: type: integer Solution: - description: Request to the settle and reveal endpoint. + description: Request to the reveal endpoint. + type: object + properties: + solutionId: + description: Id of the solution that should be executed. + type: integer + example: 123 + auctionId: + description: Auction ID in which the specified solution ID is competing. + type: integer + example: 123 + SolutionWithDeadline: + description: Request to the settle endpoint. type: object properties: solutionId: From fbf141ead393fcfee4581d0b8e73671a437593c1 Mon Sep 17 00:00:00 2001 From: Michal Strug Date: Fri, 13 Dec 2024 21:51:41 +0100 Subject: [PATCH 02/10] Renamed dto module --- crates/driver/src/infra/api/routes/settle/dto/mod.rs | 4 ++-- .../settle/dto/{solution.rs => solution_with_deadline.rs} | 2 +- crates/driver/src/infra/api/routes/settle/mod.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename crates/driver/src/infra/api/routes/settle/dto/{solution.rs => solution_with_deadline.rs} (94%) diff --git a/crates/driver/src/infra/api/routes/settle/dto/mod.rs b/crates/driver/src/infra/api/routes/settle/dto/mod.rs index 563b0e3cb7..92db16a74e 100644 --- a/crates/driver/src/infra/api/routes/settle/dto/mod.rs +++ b/crates/driver/src/infra/api/routes/settle/dto/mod.rs @@ -1,3 +1,3 @@ -mod solution; +mod solution_with_deadline; -pub use solution::Solution; +pub use solution_with_deadline::SolutionWithDeadline; diff --git a/crates/driver/src/infra/api/routes/settle/dto/solution.rs b/crates/driver/src/infra/api/routes/settle/dto/solution_with_deadline.rs similarity index 94% rename from crates/driver/src/infra/api/routes/settle/dto/solution.rs rename to crates/driver/src/infra/api/routes/settle/dto/solution_with_deadline.rs index 6c62cd0cdd..0dc9cc41cd 100644 --- a/crates/driver/src/infra/api/routes/settle/dto/solution.rs +++ b/crates/driver/src/infra/api/routes/settle/dto/solution_with_deadline.rs @@ -3,7 +3,7 @@ use {super::super::super::deserialize_solution_id, serde::Deserialize, serde_wit #[serde_as] #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct Solution { +pub struct SolutionWithDeadline { /// Unique ID of the solution (per driver competition), to settle. #[serde(deserialize_with = "deserialize_solution_id")] pub solution_id: u64, diff --git a/crates/driver/src/infra/api/routes/settle/mod.rs b/crates/driver/src/infra/api/routes/settle/mod.rs index 6a169ce3b1..f027c282b0 100644 --- a/crates/driver/src/infra/api/routes/settle/mod.rs +++ b/crates/driver/src/infra/api/routes/settle/mod.rs @@ -17,7 +17,7 @@ pub(in crate::infra::api) fn settle(router: axum::Router) -> axum::Router async fn route( state: axum::extract::State, - req: axum::Json, + req: axum::Json, ) -> Result<(), (hyper::StatusCode, axum::Json)> { let auction_id = req.auction_id; let solver = state.solver().name().to_string(); From 1651c0c9d4fdb573c5b35c8ee47d7320e64796eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Strug?= <47604705+mstrug@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:59:20 +0100 Subject: [PATCH 03/10] Update crates/driver/openapi.yml Co-authored-by: Martin Magnus --- crates/driver/openapi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/driver/openapi.yml b/crates/driver/openapi.yml index f30f735d70..fe77e73004 100644 --- a/crates/driver/openapi.yml +++ b/crates/driver/openapi.yml @@ -526,7 +526,7 @@ components: gas: type: integer Solution: - description: Request to the reveal endpoint. + description: Request to the `/reveal` endpoint. type: object properties: solutionId: From ee517477b97835e949c7d87e7df966398cc37f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Strug?= <47604705+mstrug@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:59:27 +0100 Subject: [PATCH 04/10] Update crates/driver/openapi.yml Co-authored-by: Martin Magnus --- crates/driver/openapi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/driver/openapi.yml b/crates/driver/openapi.yml index fe77e73004..0cf5195386 100644 --- a/crates/driver/openapi.yml +++ b/crates/driver/openapi.yml @@ -538,7 +538,7 @@ components: type: integer example: 123 SolutionWithDeadline: - description: Request to the settle endpoint. + description: Request to the `/settle` endpoint. type: object properties: solutionId: From cbc7f9f67546f271537d7b0a9936d11c3770270e Mon Sep 17 00:00:00 2001 From: Michal Strug Date: Mon, 16 Dec 2024 13:57:09 +0100 Subject: [PATCH 05/10] Renamed driver reveal endpoint req/resp --- crates/driver/src/infra/api/routes/reveal/dto/mod.rs | 6 +++--- .../routes/reveal/dto/{solution.rs => reveal_request.rs} | 2 +- .../routes/reveal/dto/{revealed.rs => reveal_response.rs} | 4 ++-- crates/driver/src/infra/api/routes/reveal/mod.rs | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) rename crates/driver/src/infra/api/routes/reveal/dto/{solution.rs => reveal_request.rs} (94%) rename crates/driver/src/infra/api/routes/reveal/dto/{revealed.rs => reveal_response.rs} (93%) diff --git a/crates/driver/src/infra/api/routes/reveal/dto/mod.rs b/crates/driver/src/infra/api/routes/reveal/dto/mod.rs index 164d4534c4..75671089e4 100644 --- a/crates/driver/src/infra/api/routes/reveal/dto/mod.rs +++ b/crates/driver/src/infra/api/routes/reveal/dto/mod.rs @@ -1,4 +1,4 @@ -mod revealed; -mod solution; +mod reveal_request; +mod reveal_response; -pub use {revealed::Revealed, solution::Solution}; +pub use {reveal_request::RevealRequest, reveal_response::RevealResponse}; diff --git a/crates/driver/src/infra/api/routes/reveal/dto/solution.rs b/crates/driver/src/infra/api/routes/reveal/dto/reveal_request.rs similarity index 94% rename from crates/driver/src/infra/api/routes/reveal/dto/solution.rs rename to crates/driver/src/infra/api/routes/reveal/dto/reveal_request.rs index 0c8d55fa49..f298b55700 100644 --- a/crates/driver/src/infra/api/routes/reveal/dto/solution.rs +++ b/crates/driver/src/infra/api/routes/reveal/dto/reveal_request.rs @@ -3,7 +3,7 @@ use {super::super::super::deserialize_solution_id, serde::Deserialize, serde_wit #[serde_as] #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct Solution { +pub struct RevealRequest { /// Unique ID of the solution (per driver competition), to reveal. #[serde(deserialize_with = "deserialize_solution_id")] pub solution_id: u64, diff --git a/crates/driver/src/infra/api/routes/reveal/dto/revealed.rs b/crates/driver/src/infra/api/routes/reveal/dto/reveal_response.rs similarity index 93% rename from crates/driver/src/infra/api/routes/reveal/dto/revealed.rs rename to crates/driver/src/infra/api/routes/reveal/dto/reveal_response.rs index 1f256320b4..0f1d495042 100644 --- a/crates/driver/src/infra/api/routes/reveal/dto/revealed.rs +++ b/crates/driver/src/infra/api/routes/reveal/dto/reveal_response.rs @@ -4,7 +4,7 @@ use { serde_with::serde_as, }; -impl Revealed { +impl RevealResponse { pub fn new(reveal: competition::Revealed) -> Self { Self { calldata: Calldata { @@ -18,7 +18,7 @@ impl Revealed { #[serde_as] #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] -pub struct Revealed { +pub struct RevealResponse { calldata: Calldata, } diff --git a/crates/driver/src/infra/api/routes/reveal/mod.rs b/crates/driver/src/infra/api/routes/reveal/mod.rs index 750636cdaf..b96ce290f8 100644 --- a/crates/driver/src/infra/api/routes/reveal/mod.rs +++ b/crates/driver/src/infra/api/routes/reveal/mod.rs @@ -14,8 +14,8 @@ pub(in crate::infra::api) fn reveal(router: axum::Router) -> axum::Router async fn route( state: axum::extract::State, - req: axum::Json, -) -> Result, (hyper::StatusCode, axum::Json)> { + req: axum::Json, +) -> Result, (hyper::StatusCode, axum::Json)> { let handle_request = async { observe::revealing(); let result = state @@ -24,7 +24,7 @@ async fn route( .await; observe::revealed(state.solver().name(), &result); let result = result?; - Ok(axum::Json(dto::Revealed::new(result))) + Ok(axum::Json(dto::RevealResponse::new(result))) }; handle_request From 996af7ec1df48fb7c497422d4dfb974923b1a27d Mon Sep 17 00:00:00 2001 From: Michal Strug Date: Mon, 16 Dec 2024 13:57:39 +0100 Subject: [PATCH 06/10] Renamed driver settle endpoint req --- crates/driver/src/infra/api/routes/settle/dto/mod.rs | 4 ++-- .../dto/{solution_with_deadline.rs => settle_request.rs} | 2 +- crates/driver/src/infra/api/routes/settle/mod.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename crates/driver/src/infra/api/routes/settle/dto/{solution_with_deadline.rs => settle_request.rs} (94%) diff --git a/crates/driver/src/infra/api/routes/settle/dto/mod.rs b/crates/driver/src/infra/api/routes/settle/dto/mod.rs index 92db16a74e..0986792238 100644 --- a/crates/driver/src/infra/api/routes/settle/dto/mod.rs +++ b/crates/driver/src/infra/api/routes/settle/dto/mod.rs @@ -1,3 +1,3 @@ -mod solution_with_deadline; +mod settle_request; -pub use solution_with_deadline::SolutionWithDeadline; +pub use settle_request::SettleRequest; diff --git a/crates/driver/src/infra/api/routes/settle/dto/solution_with_deadline.rs b/crates/driver/src/infra/api/routes/settle/dto/settle_request.rs similarity index 94% rename from crates/driver/src/infra/api/routes/settle/dto/solution_with_deadline.rs rename to crates/driver/src/infra/api/routes/settle/dto/settle_request.rs index 0dc9cc41cd..478d0766f2 100644 --- a/crates/driver/src/infra/api/routes/settle/dto/solution_with_deadline.rs +++ b/crates/driver/src/infra/api/routes/settle/dto/settle_request.rs @@ -3,7 +3,7 @@ use {super::super::super::deserialize_solution_id, serde::Deserialize, serde_wit #[serde_as] #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct SolutionWithDeadline { +pub struct SettleRequest { /// Unique ID of the solution (per driver competition), to settle. #[serde(deserialize_with = "deserialize_solution_id")] pub solution_id: u64, diff --git a/crates/driver/src/infra/api/routes/settle/mod.rs b/crates/driver/src/infra/api/routes/settle/mod.rs index f027c282b0..f6d073e1c7 100644 --- a/crates/driver/src/infra/api/routes/settle/mod.rs +++ b/crates/driver/src/infra/api/routes/settle/mod.rs @@ -17,7 +17,7 @@ pub(in crate::infra::api) fn settle(router: axum::Router) -> axum::Router async fn route( state: axum::extract::State, - req: axum::Json, + req: axum::Json, ) -> Result<(), (hyper::StatusCode, axum::Json)> { let auction_id = req.auction_id; let solver = state.solver().name().to_string(); From 488b1588b0d41e6078d0d08cd77c61d3e4666667 Mon Sep 17 00:00:00 2001 From: Michal Strug Date: Mon, 16 Dec 2024 13:58:29 +0100 Subject: [PATCH 07/10] Renamed driver solve endpoint req/resp --- crates/driver/src/infra/api/routes/solve/dto/mod.rs | 8 ++++---- .../routes/solve/dto/{auction.rs => solve_request.rs} | 6 +++--- .../routes/solve/dto/{solved.rs => solve_response.rs} | 4 ++-- crates/driver/src/infra/api/routes/solve/mod.rs | 9 ++++++--- 4 files changed, 15 insertions(+), 12 deletions(-) rename crates/driver/src/infra/api/routes/solve/dto/{auction.rs => solve_request.rs} (99%) rename crates/driver/src/infra/api/routes/solve/dto/{solved.rs => solve_response.rs} (98%) diff --git a/crates/driver/src/infra/api/routes/solve/dto/mod.rs b/crates/driver/src/infra/api/routes/solve/dto/mod.rs index b7d9b72236..1fb6e69db5 100644 --- a/crates/driver/src/infra/api/routes/solve/dto/mod.rs +++ b/crates/driver/src/infra/api/routes/solve/dto/mod.rs @@ -1,7 +1,7 @@ -mod auction; -mod solved; +mod solve_request; +mod solve_response; pub use { - auction::{Auction, Error as AuctionError}, - solved::Solved, + solve_request::{Error as AuctionError, SolveRequest}, + solve_response::SolveResponse, }; diff --git a/crates/driver/src/infra/api/routes/solve/dto/auction.rs b/crates/driver/src/infra/api/routes/solve/dto/solve_request.rs similarity index 99% rename from crates/driver/src/infra/api/routes/solve/dto/auction.rs rename to crates/driver/src/infra/api/routes/solve/dto/solve_request.rs index 38138face1..b773387715 100644 --- a/crates/driver/src/infra/api/routes/solve/dto/auction.rs +++ b/crates/driver/src/infra/api/routes/solve/dto/solve_request.rs @@ -13,7 +13,7 @@ use { std::collections::HashSet, }; -impl Auction { +impl SolveRequest { pub async fn into_domain( self, eth: &Ethereum, @@ -198,7 +198,7 @@ impl From for Error { #[serde_as] #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct Auction { +pub struct SolveRequest { #[serde_as(as = "serde_with::DisplayFromStr")] id: i64, tokens: Vec, @@ -208,7 +208,7 @@ pub struct Auction { surplus_capturing_jit_order_owners: Vec, } -impl Auction { +impl SolveRequest { pub fn id(&self) -> i64 { self.id } diff --git a/crates/driver/src/infra/api/routes/solve/dto/solved.rs b/crates/driver/src/infra/api/routes/solve/dto/solve_response.rs similarity index 98% rename from crates/driver/src/infra/api/routes/solve/dto/solved.rs rename to crates/driver/src/infra/api/routes/solve/dto/solve_response.rs index 6b91523be0..892810f5f1 100644 --- a/crates/driver/src/infra/api/routes/solve/dto/solved.rs +++ b/crates/driver/src/infra/api/routes/solve/dto/solve_response.rs @@ -9,7 +9,7 @@ use { std::collections::HashMap, }; -impl Solved { +impl SolveResponse { pub fn new(solved: Option, solver: &Solver) -> Self { let solutions = solved .into_iter() @@ -22,7 +22,7 @@ impl Solved { #[serde_as] #[derive(Debug, Default, Serialize)] #[serde(rename_all = "camelCase")] -pub struct Solved { +pub struct SolveResponse { solutions: Vec, } diff --git a/crates/driver/src/infra/api/routes/solve/mod.rs b/crates/driver/src/infra/api/routes/solve/mod.rs index eccafb8ead..259425d979 100644 --- a/crates/driver/src/infra/api/routes/solve/mod.rs +++ b/crates/driver/src/infra/api/routes/solve/mod.rs @@ -17,8 +17,8 @@ pub(in crate::infra::api) fn solve(router: axum::Router) -> axum::Router< async fn route( state: axum::extract::State, - auction: axum::Json, -) -> Result, (hyper::StatusCode, axum::Json)> { + auction: axum::Json, +) -> Result, (hyper::StatusCode, axum::Json)> { let auction_id = auction.id(); let handle_request = async { observe::auction(auction_id); @@ -38,7 +38,10 @@ async fn route( .await; let result = competition.solve(&auction).await; observe::solved(state.solver().name(), &result); - Ok(axum::Json(dto::Solved::new(result?, &competition.solver))) + Ok(axum::Json(dto::SolveResponse::new( + result?, + &competition.solver, + ))) }; handle_request From eda01b489544df9289208f9318537f9983c5a0e9 Mon Sep 17 00:00:00 2001 From: Michal Strug Date: Mon, 16 Dec 2024 14:01:29 +0100 Subject: [PATCH 08/10] Updated OpenAPI definition file --- crates/driver/openapi.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/driver/openapi.yml b/crates/driver/openapi.yml index 0cf5195386..a8d43d199f 100644 --- a/crates/driver/openapi.yml +++ b/crates/driver/openapi.yml @@ -103,14 +103,14 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Solution" + $ref: "#/components/schemas/RevealRequest" responses: "200": description: Execution accepted. content: application/json: schema: - $ref: "#/components/schemas/RevealedResponse" + $ref: "#/components/schemas/RevealResponse" "400": $ref: "#/components/responses/BadRequest" "500": @@ -130,7 +130,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/SolutionWithDeadline" + $ref: "#/components/schemas/SettleRequest" responses: "200": description: Execution accepted. @@ -525,35 +525,35 @@ components: $ref: "#/components/schemas/BigUint" gas: type: integer - Solution: - description: Request to the `/reveal` endpoint. + SettleRequest: + description: Request to the `/settle` endpoint. type: object properties: solutionId: description: Id of the solution that should be executed. type: integer example: 123 + submissionDeadlineLatestBlock: + description: The last block number in which the solution TX can be included. + type: integer + example: 12345 auctionId: description: Auction ID in which the specified solution ID is competing. type: integer example: 123 - SolutionWithDeadline: - description: Request to the `/settle` endpoint. + RevealRequest: + description: Request to the `/reveal` endpoint. type: object properties: solutionId: description: Id of the solution that should be executed. type: integer example: 123 - submissionDeadlineLatestBlock: - description: The last block number in which the solution TX can be included. - type: integer - example: 12345 auctionId: description: Auction ID in which the specified solution ID is competing. type: integer example: 123 - RevealedResponse: + RevealResponse: description: Response of the reveal endpoint. type: object properties: From 07f998b2eabd42d814af86200b8ec57cef9c93e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Strug?= <47604705+mstrug@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:00:58 +0100 Subject: [PATCH 09/10] Update crates/driver/src/infra/api/routes/solve/mod.rs Co-authored-by: ilya --- crates/driver/src/infra/api/routes/solve/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/driver/src/infra/api/routes/solve/mod.rs b/crates/driver/src/infra/api/routes/solve/mod.rs index 259425d979..68031ea4d8 100644 --- a/crates/driver/src/infra/api/routes/solve/mod.rs +++ b/crates/driver/src/infra/api/routes/solve/mod.rs @@ -17,7 +17,7 @@ pub(in crate::infra::api) fn solve(router: axum::Router) -> axum::Router< async fn route( state: axum::extract::State, - auction: axum::Json, + req: axum::Json, ) -> Result, (hyper::StatusCode, axum::Json)> { let auction_id = auction.id(); let handle_request = async { From c1eae9534cf712bf3ee7d6ff122bca0806df6209 Mon Sep 17 00:00:00 2001 From: Michal Strug Date: Mon, 16 Dec 2024 17:06:19 +0100 Subject: [PATCH 10/10] Fixed compilation --- crates/driver/src/infra/api/routes/solve/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/driver/src/infra/api/routes/solve/mod.rs b/crates/driver/src/infra/api/routes/solve/mod.rs index 68031ea4d8..be9de73abe 100644 --- a/crates/driver/src/infra/api/routes/solve/mod.rs +++ b/crates/driver/src/infra/api/routes/solve/mod.rs @@ -19,11 +19,11 @@ async fn route( state: axum::extract::State, req: axum::Json, ) -> Result, (hyper::StatusCode, axum::Json)> { - let auction_id = auction.id(); + let auction_id = req.id(); let handle_request = async { observe::auction(auction_id); let start = Instant::now(); - let auction = auction + let auction = req .0 .into_domain(state.eth(), state.tokens(), state.timeouts()) .await