Skip to content

Commit

Permalink
Remove colocation flag (#2208)
Browse files Browse the repository at this point in the history
# Description
Initiative to simplify autopilot parameters so we can move them to
`toml` format.

Removes colocation flag as we no longer see we will revert to
non-colocated driver.
  • Loading branch information
sunce86 authored Dec 23, 2023
1 parent f665c65 commit 23148dd
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 72 deletions.
6 changes: 0 additions & 6 deletions crates/autopilot/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ pub struct Arguments {
)]
pub trusted_tokens_update_interval: Duration,

/// Enable the colocation run loop.
#[clap(long, env, action = clap::ArgAction::Set, default_value = "false")]
pub enable_colocation: bool,

/// A list of drivers in the following format: `<NAME>|<URL>,<NAME>|<URL>`
#[clap(long, env, use_value_delimiter = true)]
pub drivers: Vec<ExternalSolver>,
Expand Down Expand Up @@ -243,7 +239,6 @@ impl std::fmt::Display for Arguments {
trusted_tokens_url,
trusted_tokens,
trusted_tokens_update_interval,
enable_colocation,
drivers,
submission_deadline,
additional_deadline_for_rewards,
Expand Down Expand Up @@ -300,7 +295,6 @@ impl std::fmt::Display for Arguments {
"trusted_tokens_update_interval: {:?}",
trusted_tokens_update_interval
)?;
writeln!(f, "enable_colocation: {:?}", enable_colocation,)?;
display_list(f, "drivers", drivers.iter())?;
writeln!(f, "submission_deadline: {}", submission_deadline)?;
writeln!(
Expand Down
75 changes: 33 additions & 42 deletions crates/autopilot/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ pub async fn start(args: impl Iterator<Item = String>) {
tracing::info!("running autopilot with validated arguments:\n{}", args);
observe::metrics::setup_registry(Some("gp_v2_autopilot".into()), None);

if args.drivers.is_empty() {
panic!("colocation is enabled but no drivers are configured");
}

if args.shadow.is_some() {
shadow_mode(args).await;
} else {
Expand Down Expand Up @@ -567,7 +571,6 @@ pub async fn run(args: Arguments) {
args.limit_order_price_factor
.try_into()
.expect("limit order price factor can't be converted to BigDecimal"),
!args.enable_colocation,
);
solvable_orders_cache
.update(block)
Expand All @@ -577,7 +580,7 @@ pub async fn run(args: Arguments) {
max_auction_age: args.max_auction_age,
solvable_orders_cache: solvable_orders_cache.clone(),
};
let serve_metrics = shared::metrics::serve_metrics(Arc::new(liveness), args.metrics_address);
shared::metrics::serve_metrics(Arc::new(liveness), args.metrics_address);

let on_settlement_event_updater =
crate::on_settlement_event_updater::OnSettlementEventUpdater {
Expand Down Expand Up @@ -607,43 +610,34 @@ pub async fn run(args: Arguments) {
.instrument(tracing::info_span!("order_events_cleaner")),
);

if args.enable_colocation {
if args.drivers.is_empty() {
panic!("colocation is enabled but no drivers are configured");
}
let market_makable_token_list_configuration = TokenListConfiguration {
url: args.trusted_tokens_url,
update_interval: args.trusted_tokens_update_interval,
chain_id,
client: http_factory.create(),
hardcoded: args.trusted_tokens.unwrap_or_default(),
};
// updated in background task
let market_makable_token_list =
AutoUpdatingTokenList::from_configuration(market_makable_token_list_configuration)
.await;
let run = RunLoop {
solvable_orders_cache,
database: Arc::new(db),
drivers: args.drivers.into_iter().map(Driver::new).collect(),
current_block: current_block_stream,
web3,
network_block_interval: network_time_between_blocks,
market_makable_token_list,
submission_deadline: args.submission_deadline as u64,
additional_deadline_for_rewards: args.additional_deadline_for_rewards as u64,
score_cap: args.score_cap,
max_settlement_transaction_wait: args.max_settlement_transaction_wait,
solve_deadline: args.solve_deadline,
in_flight_orders: Default::default(),
fee_policy: args.fee_policy,
};
run.run_forever().await;
unreachable!("run loop exited");
} else {
let result = serve_metrics.await;
unreachable!("serve_metrics exited {result:?}");
}
let market_makable_token_list_configuration = TokenListConfiguration {
url: args.trusted_tokens_url,
update_interval: args.trusted_tokens_update_interval,
chain_id,
client: http_factory.create(),
hardcoded: args.trusted_tokens.unwrap_or_default(),
};
// updated in background task
let market_makable_token_list =
AutoUpdatingTokenList::from_configuration(market_makable_token_list_configuration).await;
let run = RunLoop {
solvable_orders_cache,
database: Arc::new(db),
drivers: args.drivers.into_iter().map(Driver::new).collect(),
current_block: current_block_stream,
web3,
network_block_interval: network_time_between_blocks,
market_makable_token_list,
submission_deadline: args.submission_deadline as u64,
additional_deadline_for_rewards: args.additional_deadline_for_rewards as u64,
score_cap: args.score_cap,
max_settlement_transaction_wait: args.max_settlement_transaction_wait,
solve_deadline: args.solve_deadline,
in_flight_orders: Default::default(),
fee_policy: args.fee_policy,
};
run.run_forever().await;
unreachable!("run loop exited");
}

async fn shadow_mode(args: Arguments) -> ! {
Expand All @@ -654,9 +648,6 @@ async fn shadow_mode(args: Arguments) -> ! {
args.shadow.expect("missing shadow mode configuration"),
);

if args.drivers.is_empty() {
panic!("shadow mode is enabled but no drivers are configured");
}
let drivers = args.drivers.into_iter().map(Driver::new).collect();

let trusted_tokens = {
Expand Down
14 changes: 1 addition & 13 deletions crates/autopilot/src/solvable_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ pub struct SolvableOrdersCache {
ethflow_contract_address: Option<H160>,
weth: H160,
limit_order_price_factor: BigDecimal,
// Will be obsolete when the new autopilot run loop takes over the competition.
store_in_db: bool,
}

type Balances = HashMap<Query, U256>;
Expand Down Expand Up @@ -112,7 +110,6 @@ impl SolvableOrdersCache {
ethflow_contract_address: Option<H160>,
weth: H160,
limit_order_price_factor: BigDecimal,
store_in_db: bool,
) -> Arc<Self> {
let self_ = Arc::new(Self {
min_order_validity_period,
Expand All @@ -135,7 +132,6 @@ impl SolvableOrdersCache {
ethflow_contract_address,
weth,
limit_order_price_factor,
store_in_db,
});
tokio::task::spawn(
update_task(Arc::downgrade(&self_), update_interval, current_block)
Expand Down Expand Up @@ -239,14 +235,6 @@ impl SolvableOrdersCache {

self.database.store_order_events(&order_events).await;

let id = if self.store_in_db {
let id = self.database.replace_current_auction(&auction).await?;
tracing::info!(auction = %id, %block, "stored new auction in database");
Some(id)
} else {
None
};

*self.cache.lock().unwrap() = Inner {
auction: Some(auction),
orders: SolvableOrders {
Expand All @@ -257,7 +245,7 @@ impl SolvableOrdersCache {
},
};

tracing::debug!(%block, ?id, "updated current auction cache");
tracing::debug!(%block, "updated current auction cache");
Ok(())
}

Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/colocation_buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ async fn onchain_settlement_without_liquidity(web3: Web3) {
);
let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
format!(
"--trusted-tokens={weth:#x},{token_a:#x},{token_b:#x}",
weth = onchain.contracts().weth.address(),
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/colocation_eth_safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ async fn test(web3: Web3) {

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
"--drivers=test_solver|http://localhost:11088/test_solver".to_string(),
]);
services
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/colocation_ethflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ async fn eth_flow_tx(web3: Web3) {

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
"--drivers=test_solver|http://localhost:11088/test_solver".to_string(),
]);
services.start_api(vec![]).await;
Expand Down
3 changes: 0 additions & 3 deletions crates/e2e/tests/e2e/colocation_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ async fn allowance(web3: Web3) {

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
"--drivers=test_solver|http://localhost:11088/test_solver".to_string(),
]);
services
Expand Down Expand Up @@ -266,7 +265,6 @@ async fn signature(web3: Web3) {

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
"--drivers=test_solver|http://localhost:11088/test_solver".to_string(),
]);
services
Expand Down Expand Up @@ -380,7 +378,6 @@ async fn partial_fills(web3: Web3) {

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
"--drivers=test_solver|http://localhost:11088/test_solver".to_string(),
]);
services
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/colocation_partial_fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async fn test(web3: Web3) {

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
"--drivers=test_solver|http://localhost:11088/test_solver".to_string(),
]);
services
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/colocation_quoting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ async fn uses_stale_liquidity(web3: Web3) {

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
"--drivers=test_solver|http://localhost:11088/test_solver".to_string(),
]);
services
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/colocation_solver_competition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async fn solver_competition(web3: Web3) {

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
"--drivers=solver1|http://localhost:11088/solver1,solver2|http://localhost:11088/solver2"
.to_string(),
]);
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/colocation_univ2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async fn test(web3: Web3) {

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
"--drivers=test_solver|http://localhost:11088/test_solver".to_string(),
]);
services.start_api(vec![]).await;
Expand Down
1 change: 0 additions & 1 deletion crates/e2e/tests/e2e/tracking_insufficient_funds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async fn test(web3: Web3) {

let services = Services::new(onchain.contracts()).await;
services.start_autopilot(vec![
"--enable-colocation=true".to_string(),
"--drivers=test_solver|http://localhost:11088/test_solver".to_string(),
]);
services.start_api(vec![]).await;
Expand Down

0 comments on commit 23148dd

Please sign in to comment.