Skip to content
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

Remove obsolete solver competition data #2143

Merged
merged 11 commits into from
Dec 18, 2023
14 changes: 5 additions & 9 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ impl RunLoop {
let mut settlement = SolverSettlement {
solver: participant.driver.name.clone(),
solver_address: participant.solution.account,
score: Some(Score::Solver(participant.solution.score.get())),
ranking: Some(solutions.len() - index),
score: Score::Solver(participant.solution.score.get()),
ranking: solutions.len() - index,
orders: participant
.solution
.orders()
Expand All @@ -256,21 +256,17 @@ impl RunLoop {
.iter()
.map(|(token, price)| (*token, *price))
.collect(),
// TODO: revisit once colocation is enabled (remove not populated
// fields) Not all fields can be populated in the colocated world
..Default::default()
call_data: None,
uninternalized_call_data: None,
};
if is_winner {
settlement.call_data = revealed.calldata.internalized.clone();
settlement.call_data = Some(revealed.calldata.internalized.clone());
settlement.uninternalized_call_data =
Some(revealed.calldata.uninternalized.clone());
}
settlement
})
.collect(),
// TODO: revisit once colocation is enabled (remove not populated fields)
// Not all fields can be populated in the colocated world
..Default::default()
};
let competition = Competition {
auction_id,
Expand Down
43 changes: 32 additions & 11 deletions crates/e2e/src/setup/colocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ risk-parameters = [0,0,0,0]
));
let args = vec![
"solvers".to_string(),
format!("--addr=0.0.0.0:0"),
"baseline".to_string(),
format!("--config={}", config_file.display()),
];
Expand All @@ -32,22 +33,43 @@ risk-parameters = [0,0,0,0]
format!("http://{solver_addr}").parse().unwrap()
}

pub fn start_driver(
contracts: &Contracts,
solver_endpoint: &Url,
solver_account: &TestAccount,
) -> JoinHandle<()> {
pub struct SolverEngine {
pub name: String,
pub endpoint: Url,
pub account: TestAccount,
}

pub fn start_driver(contracts: &Contracts, solvers: Vec<SolverEngine>) -> JoinHandle<()> {
let solvers = solvers
.iter()
.map(
|SolverEngine {
name,
account,
endpoint,
}| {
let account = hex::encode(account.private_key());
format!(
r#"
[[solver]]
name = "{name}"
endpoint = "{endpoint}"
relative-slippage = "0.1"
account = "{account}"

"#
)
},
)
.collect::<Vec<String>>()
.join("\n");
let config_file = config_tmp_file(format!(
r#"
[contracts]
gp-v2-settlement = "{:?}"
weth = "{:?}"

[[solver]]
name = "test_solver"
endpoint = "{solver_endpoint}"
relative-slippage = "0.1"
account = "0x{}"
{solvers}

[liquidity]
base-tokens = []
Expand All @@ -66,7 +88,6 @@ mempool = "public"
"#,
contracts.gp_settlement.address(),
contracts.weth.address(),
hex::encode(solver_account.private_key()),
contracts.uniswap_v2_router.address(),
H256(UNISWAP_INIT),
));
Expand Down
15 changes: 12 additions & 3 deletions crates/e2e/tests/e2e/colocation_buffers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use {
e2e::{setup::*, tx},
e2e::{
setup::{colocation::SolverEngine, *},
tx,
},
ethcontract::prelude::U256,
model::{
order::{OrderCreation, OrderKind},
Expand Down Expand Up @@ -41,8 +44,14 @@ async fn onchain_settlement_without_liquidity(web3: Web3) {

// Start system
let solver_endpoint = colocation::start_solver(onchain.contracts().weth.address()).await;
colocation::start_driver(onchain.contracts(), &solver_endpoint, &solver);

colocation::start_driver(
onchain.contracts(),
vec![SolverEngine {
name: "test_solver".into(),
account: solver,
endpoint: solver_endpoint,
}],
);
let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
Expand Down
11 changes: 9 additions & 2 deletions crates/e2e/tests/e2e/colocation_eth_safe.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
e2e::{
setup::{safe::Safe, *},
setup::{colocation::SolverEngine, safe::Safe, *},
tx,
},
ethcontract::U256,
Expand Down Expand Up @@ -38,7 +38,14 @@ async fn test(web3: Web3) {

tracing::info!("Starting services.");
let solver_endpoint = colocation::start_solver(onchain.contracts().weth.address()).await;
colocation::start_driver(onchain.contracts(), &solver_endpoint, &solver);
colocation::start_driver(
onchain.contracts(),
vec![SolverEngine {
name: "test_solver".into(),
account: solver,
endpoint: solver_endpoint,
}],
);

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
Expand Down
11 changes: 9 additions & 2 deletions crates/e2e/tests/e2e/colocation_ethflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use {
crate::ethflow::{EthFlowOrderOnchainStatus, EthFlowTradeIntent, ExtendedEthFlowOrder},
autopilot::database::onchain_order_events::ethflow_events::WRAP_ALL_SELECTOR,
contracts::ERC20Mintable,
e2e::setup::*,
e2e::setup::{colocation::SolverEngine, *},
ethcontract::{Account, H160, U256},
ethrpc::{current_block::timestamp_of_current_block_in_seconds, Web3},
model::{
Expand Down Expand Up @@ -43,7 +43,14 @@ async fn eth_flow_tx(web3: Web3) {
};

let solver_endpoint = colocation::start_solver(onchain.contracts().weth.address()).await;
colocation::start_driver(onchain.contracts(), &solver_endpoint, &solver);
colocation::start_driver(
onchain.contracts(),
vec![SolverEngine {
name: "test_solver".into(),
account: solver,
endpoint: solver_endpoint,
}],
);

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
Expand Down
29 changes: 25 additions & 4 deletions crates/e2e/tests/e2e/colocation_hooks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
contracts::GnosisSafe,
e2e::{
setup::{safe::Safe, *},
setup::{colocation::SolverEngine, safe::Safe, *},
tx,
tx_value,
},
Expand Down Expand Up @@ -70,7 +70,14 @@ async fn allowance(web3: Web3) {

tracing::info!("Starting services.");
let solver_endpoint = colocation::start_solver(onchain.contracts().weth.address()).await;
colocation::start_driver(onchain.contracts(), &solver_endpoint, &solver);
colocation::start_driver(
onchain.contracts(),
vec![SolverEngine {
name: "test_solver".into(),
account: solver,
endpoint: solver_endpoint,
}],
);

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
Expand Down Expand Up @@ -248,7 +255,14 @@ async fn signature(web3: Web3) {

tracing::info!("Starting services.");
let solver_endpoint = colocation::start_solver(onchain.contracts().weth.address()).await;
colocation::start_driver(onchain.contracts(), &solver_endpoint, &solver);
colocation::start_driver(
onchain.contracts(),
vec![SolverEngine {
name: "test_solver".into(),
account: solver,
endpoint: solver_endpoint,
}],
);

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
Expand Down Expand Up @@ -355,7 +369,14 @@ async fn partial_fills(web3: Web3) {

tracing::info!("Starting services.");
let solver_endpoint = colocation::start_solver(onchain.contracts().weth.address()).await;
colocation::start_driver(onchain.contracts(), &solver_endpoint, &solver);
colocation::start_driver(
onchain.contracts(),
vec![SolverEngine {
name: "test_solver".into(),
account: solver,
endpoint: solver_endpoint,
}],
);

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
Expand Down
15 changes: 13 additions & 2 deletions crates/e2e/tests/e2e/colocation_partial_fill.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use {
e2e::{setup::*, tx, tx_value},
e2e::{
setup::{colocation::SolverEngine, *},
tx,
tx_value,
},
ethcontract::U256,
model::{
order::{LimitOrderClass, OrderClass, OrderCreation, OrderKind},
Expand Down Expand Up @@ -42,7 +46,14 @@ async fn test(web3: Web3) {

tracing::info!("Starting services.");
let solver_endpoint = colocation::start_solver(onchain.contracts().weth.address()).await;
colocation::start_driver(onchain.contracts(), &solver_endpoint, &solver);
colocation::start_driver(
onchain.contracts(),
vec![SolverEngine {
name: "test_solver".into(),
account: solver,
endpoint: solver_endpoint,
}],
);

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
Expand Down
15 changes: 13 additions & 2 deletions crates/e2e/tests/e2e/colocation_quoting.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use {
e2e::{setup::*, tx, tx_value},
e2e::{
setup::{colocation::SolverEngine, *},
tx,
tx_value,
},
ethcontract::U256,
model::quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount},
number::nonzero::U256 as NonZeroU256,
Expand Down Expand Up @@ -37,7 +41,14 @@ async fn uses_stale_liquidity(web3: Web3) {

tracing::info!("Starting services.");
let solver_endpoint = colocation::start_solver(onchain.contracts().weth.address()).await;
colocation::start_driver(onchain.contracts(), &solver_endpoint, &solver);
colocation::start_driver(
onchain.contracts(),
vec![SolverEngine {
name: "test_solver".into(),
account: solver,
endpoint: solver_endpoint,
}],
);

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
Expand Down
Loading
Loading