From e2ebf21f3fa5c319995d6456f721ce9db41b45d6 Mon Sep 17 00:00:00 2001 From: Devan Non Date: Mon, 19 Feb 2024 19:06:37 +0100 Subject: [PATCH 1/4] allow baseline to run alongside external solver --- crates/e2e/src/setup/services.rs | 143 +++++++++++++++++++++++++------ 1 file changed, 118 insertions(+), 25 deletions(-) diff --git a/crates/e2e/src/setup/services.rs b/crates/e2e/src/setup/services.rs index 41a8072a12..1b71241c2a 100644 --- a/crates/e2e/src/setup/services.rs +++ b/crates/e2e/src/setup/services.rs @@ -193,13 +193,14 @@ impl<'a> Services<'a> { } /// Starts a basic version of the protocol with a single legacy solver and - /// quoter. + /// quoter. Optionally starts a baseline solver and uses it for price estimation. pub async fn start_protocol_legacy_solver( &self, solver: TestAccount, solver_endpoint: Option, quoter_endpoint: Option, chain_id: Option, + run_baseline: bool, ) { let external_solver_endpoint = solver_endpoint.unwrap_or("http://localhost:8000/solve".parse().unwrap()); @@ -211,33 +212,125 @@ impl<'a> Services<'a> { let colocated_quoter_endpoint = start_legacy_solver(external_quoter_endpoint, chain_id).await; - colocation::start_driver( - self.contracts, - vec![ - SolverEngine { - name: "test_solver".into(), - account: solver.clone(), - endpoint: colocated_solver_endpoint, - }, - SolverEngine { - name: "test_quoter".into(), - account: solver, - endpoint: colocated_quoter_endpoint, - }, - ], - ); - self.start_autopilot( - Some(Duration::from_secs(11)), - vec![ + let mut solvers = vec![ + SolverEngine { + name: "test_solver".into(), + account: solver.clone(), + endpoint: colocated_solver_endpoint, + }, + SolverEngine { + name: "test_quoter".into(), + account: solver.clone(), + endpoint: colocated_quoter_endpoint, + }, + ]; + + let (autopilot_args, api_args) = if run_baseline { + let baseline_solver_endpoint = + colocation::start_baseline_solver(self.contracts.weth.address()).await; + + solvers.push(SolverEngine { + name: "baseline_solver".into(), + account: solver, + endpoint: baseline_solver_endpoint, + }); + + // Here we call the baseline_solver "test_quoter" to make the native price estimation + // use the baseline_solver instead of the test_quoter + let autopilot_args = vec![ + "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), + "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,legacy_test_quoter|http://localhost:11088/test_quoter".to_string(), + ]; + let api_args = vec![ + "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,legacy_test_quoter|http://localhost:11088/test_quoter".to_string(), + ]; + (autopilot_args, api_args) + } else { + let autopilot_args = vec![ "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter" .to_string(), - ], - ); - self.start_api(vec![ - "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter".to_string(), - ]) - .await; + ]; + + let api_args = vec![ + "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter" + .to_string(), + ]; + (autopilot_args, api_args) + }; + + colocation::start_driver(self.contracts, solvers); + + self.start_autopilot(Some(Duration::from_secs(11)), autopilot_args); + self.start_api(api_args).await; + } + + /// Starts a basic version of the protocol with a single external solver and + /// quoter. Optionally starts a baseline solver and uses it for price estimation. + pub async fn start_protocol_external_solver( + &self, + solver: TestAccount, + solver_endpoint: Option, + quoter_endpoint: Option, + run_baseline: bool, + ) { + let external_solver_endpoint = + solver_endpoint.unwrap_or("http://localhost:8000/solve".parse().unwrap()); + + let external_quoter_endpoint = + quoter_endpoint.unwrap_or("http://localhost:8000/quote".parse().unwrap()); + + let mut solvers = vec![ + SolverEngine { + name: "test_solver".into(), + account: solver.clone(), + endpoint: external_solver_endpoint, + }, + SolverEngine { + name: "test_quoter".into(), + account: solver.clone(), + endpoint: external_quoter_endpoint, + }, + ]; + + let (autopilot_args, api_args) = if run_baseline { + let baseline_solver_endpoint = + colocation::start_baseline_solver(self.contracts.weth.address()).await; + + solvers.push(SolverEngine { + name: "baseline_solver".into(), + account: solver, + endpoint: baseline_solver_endpoint, + }); + + // Here we call the baseline_solver "test_quoter" to make the native price estimation + // use the baseline_solver instead of the test_quoter + let autopilot_args = vec![ + "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), + "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,legacy_test_quoter|http://localhost:11088/test_quoter".to_string(), + ]; + let api_args = vec![ + "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,legacy_test_quoter|http://localhost:11088/test_quoter".to_string(), + ]; + (autopilot_args, api_args) + } else { + let autopilot_args = vec![ + "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), + "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter" + .to_string(), + ]; + + let api_args = vec![ + "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter" + .to_string(), + ]; + (autopilot_args, api_args) + }; + + colocation::start_driver(self.contracts, solvers); + + self.start_autopilot(Some(Duration::from_secs(11)), autopilot_args); + self.start_api(api_args).await; } async fn wait_for_api_to_come_up() { From 7e40dc1c74de03716afa8c428890ec0f6aaf47e9 Mon Sep 17 00:00:00 2001 From: Devan Non Date: Wed, 13 Mar 2024 03:26:58 +0000 Subject: [PATCH 2/4] fix external solver setup --- crates/e2e/src/setup/services.rs | 46 +++++++++++++------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/crates/e2e/src/setup/services.rs b/crates/e2e/src/setup/services.rs index 1b71241c2a..055bfdb4bf 100644 --- a/crates/e2e/src/setup/services.rs +++ b/crates/e2e/src/setup/services.rs @@ -193,7 +193,8 @@ impl<'a> Services<'a> { } /// Starts a basic version of the protocol with a single legacy solver and - /// quoter. Optionally starts a baseline solver and uses it for price estimation. + /// quoter. Optionally starts a baseline solver and uses it for price + /// estimation. pub async fn start_protocol_legacy_solver( &self, solver: TestAccount, @@ -235,8 +236,8 @@ impl<'a> Services<'a> { endpoint: baseline_solver_endpoint, }); - // Here we call the baseline_solver "test_quoter" to make the native price estimation - // use the baseline_solver instead of the test_quoter + // Here we call the baseline_solver "test_quoter" to make the native price + // estimation use the baseline_solver instead of the test_quoter let autopilot_args = vec![ "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,legacy_test_quoter|http://localhost:11088/test_quoter".to_string(), @@ -265,33 +266,22 @@ impl<'a> Services<'a> { self.start_api(api_args).await; } - /// Starts a basic version of the protocol with a single external solver and - /// quoter. Optionally starts a baseline solver and uses it for price estimation. + /// Starts a basic version of the protocol with a single external solver. + /// Optionally starts a baseline solver and uses it for price estimation. pub async fn start_protocol_external_solver( &self, solver: TestAccount, solver_endpoint: Option, - quoter_endpoint: Option, run_baseline: bool, ) { let external_solver_endpoint = - solver_endpoint.unwrap_or("http://localhost:8000/solve".parse().unwrap()); + solver_endpoint.unwrap_or("http://localhost:8000/".parse().unwrap()); - let external_quoter_endpoint = - quoter_endpoint.unwrap_or("http://localhost:8000/quote".parse().unwrap()); - - let mut solvers = vec![ - SolverEngine { - name: "test_solver".into(), - account: solver.clone(), - endpoint: external_solver_endpoint, - }, - SolverEngine { - name: "test_quoter".into(), - account: solver.clone(), - endpoint: external_quoter_endpoint, - }, - ]; + let mut solvers = vec![SolverEngine { + name: "test_solver".into(), + account: solver.clone(), + endpoint: external_solver_endpoint, + }]; let (autopilot_args, api_args) = if run_baseline { let baseline_solver_endpoint = @@ -303,25 +293,25 @@ impl<'a> Services<'a> { endpoint: baseline_solver_endpoint, }); - // Here we call the baseline_solver "test_quoter" to make the native price estimation - // use the baseline_solver instead of the test_quoter + // Here we call the baseline_solver "test_quoter" to make the native price + // estimation use the baseline_solver instead of the test_quoter let autopilot_args = vec![ "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), - "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,legacy_test_quoter|http://localhost:11088/test_quoter".to_string(), + "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,test_solver|http://localhost:11088/test_solver".to_string(), ]; let api_args = vec![ - "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,legacy_test_quoter|http://localhost:11088/test_quoter".to_string(), + "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,test_solver|http://localhost:11088/test_solver".to_string(), ]; (autopilot_args, api_args) } else { let autopilot_args = vec![ "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), - "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter" + "--price-estimation-drivers=test_quoter|http://localhost:11088/test_solver" .to_string(), ]; let api_args = vec![ - "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter" + "--price-estimation-drivers=test_quoter|http://localhost:11088/test_solver" .to_string(), ]; (autopilot_args, api_args) From 5b3f9f90a969251824c19c1da7835255ec9ae965 Mon Sep 17 00:00:00 2001 From: Devan Non Date: Fri, 22 Mar 2024 17:40:17 +0100 Subject: [PATCH 3/4] remove start_protocol_legacy_solver function --- crates/e2e/src/setup/services.rs | 74 -------------------------------- 1 file changed, 74 deletions(-) diff --git a/crates/e2e/src/setup/services.rs b/crates/e2e/src/setup/services.rs index 055bfdb4bf..665aa8ce7c 100644 --- a/crates/e2e/src/setup/services.rs +++ b/crates/e2e/src/setup/services.rs @@ -192,80 +192,6 @@ impl<'a> Services<'a> { .await; } - /// Starts a basic version of the protocol with a single legacy solver and - /// quoter. Optionally starts a baseline solver and uses it for price - /// estimation. - pub async fn start_protocol_legacy_solver( - &self, - solver: TestAccount, - solver_endpoint: Option, - quoter_endpoint: Option, - chain_id: Option, - run_baseline: bool, - ) { - let external_solver_endpoint = - solver_endpoint.unwrap_or("http://localhost:8000/solve".parse().unwrap()); - let colocated_solver_endpoint = - start_legacy_solver(external_solver_endpoint, chain_id).await; - - let external_quoter_endpoint = - quoter_endpoint.unwrap_or("http://localhost:8000/quote".parse().unwrap()); - let colocated_quoter_endpoint = - start_legacy_solver(external_quoter_endpoint, chain_id).await; - - let mut solvers = vec![ - SolverEngine { - name: "test_solver".into(), - account: solver.clone(), - endpoint: colocated_solver_endpoint, - }, - SolverEngine { - name: "test_quoter".into(), - account: solver.clone(), - endpoint: colocated_quoter_endpoint, - }, - ]; - - let (autopilot_args, api_args) = if run_baseline { - let baseline_solver_endpoint = - colocation::start_baseline_solver(self.contracts.weth.address()).await; - - solvers.push(SolverEngine { - name: "baseline_solver".into(), - account: solver, - endpoint: baseline_solver_endpoint, - }); - - // Here we call the baseline_solver "test_quoter" to make the native price - // estimation use the baseline_solver instead of the test_quoter - let autopilot_args = vec![ - "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), - "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,legacy_test_quoter|http://localhost:11088/test_quoter".to_string(), - ]; - let api_args = vec![ - "--price-estimation-drivers=test_quoter|http://localhost:11088/baseline_solver,legacy_test_quoter|http://localhost:11088/test_quoter".to_string(), - ]; - (autopilot_args, api_args) - } else { - let autopilot_args = vec![ - "--drivers=test_solver|http://localhost:11088/test_solver".to_string(), - "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter" - .to_string(), - ]; - - let api_args = vec![ - "--price-estimation-drivers=test_quoter|http://localhost:11088/test_quoter" - .to_string(), - ]; - (autopilot_args, api_args) - }; - - colocation::start_driver(self.contracts, solvers); - - self.start_autopilot(Some(Duration::from_secs(11)), autopilot_args); - self.start_api(api_args).await; - } - /// Starts a basic version of the protocol with a single external solver. /// Optionally starts a baseline solver and uses it for price estimation. pub async fn start_protocol_external_solver( From ef143a3ce53dcd46f5b2de3a4ac1430d883ae133 Mon Sep 17 00:00:00 2001 From: Devan Non Date: Sun, 24 Mar 2024 10:16:45 +0100 Subject: [PATCH 4/4] fix: lint --- crates/e2e/src/setup/services.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/e2e/src/setup/services.rs b/crates/e2e/src/setup/services.rs index 665aa8ce7c..54d39548d3 100644 --- a/crates/e2e/src/setup/services.rs +++ b/crates/e2e/src/setup/services.rs @@ -1,5 +1,5 @@ use { - super::{colocation::start_legacy_solver, TestAccount}, + super::TestAccount, crate::setup::{ colocation::{self, SolverEngine}, wait_for_condition, @@ -8,7 +8,7 @@ use { }, autopilot::infra::persistence::dto, clap::Parser, - ethcontract::{H256, U256}, + ethcontract::H256, model::{ app_data::{AppDataDocument, AppDataHash}, order::{Order, OrderCreation, OrderUid},