diff --git a/crates/driver/src/domain/competition/bad_tokens/metrics.rs b/crates/driver/src/domain/competition/bad_tokens/metrics.rs index 662d464567..10eb559ada 100644 --- a/crates/driver/src/domain/competition/bad_tokens/metrics.rs +++ b/crates/driver/src/domain/competition/bad_tokens/metrics.rs @@ -5,7 +5,7 @@ use {super::Quality, crate::domain::eth, dashmap::DashMap, std::sync::Arc}; /// have participated in at least `REQUIRED_MEASUREMENTS` attempts to be /// evaluated. If, at that point, the ratio of failures is greater than or equal /// to `FAILURE_RATIO`, the token is considered unsupported. -#[derive(Default)] +#[derive(Default, Clone)] pub struct Detector(Arc); #[derive(Default)] diff --git a/crates/driver/src/domain/competition/bad_tokens/mod.rs b/crates/driver/src/domain/competition/bad_tokens/mod.rs index 4b27cad388..52c9f0fb59 100644 --- a/crates/driver/src/domain/competition/bad_tokens/mod.rs +++ b/crates/driver/src/domain/competition/bad_tokens/mod.rs @@ -52,8 +52,8 @@ impl Detector { } /// Enables detection of unsupported tokens based on heuristics. - pub fn enable_heuristic_detector(&mut self) -> &mut Self { - self.metrics = Some(metrics::Detector::default()); + pub fn with_metrics_detector(&mut self, detector: metrics::Detector) -> &mut Self { + self.metrics = Some(detector); self } diff --git a/crates/driver/src/infra/api/mod.rs b/crates/driver/src/infra/api/mod.rs index ea4506110f..c6f57364d3 100644 --- a/crates/driver/src/infra/api/mod.rs +++ b/crates/driver/src/infra/api/mod.rs @@ -58,6 +58,8 @@ impl Api { app = routes::metrics(app); app = routes::healthz(app); + let metrics_bad_token_detector = bad_tokens::metrics::Detector::default(); + // Multiplex each solver as part of the API. Multiple solvers are multiplexed // on the same driver so only one liquidity collector collects the liquidity // for all of them. This is important because liquidity collection is @@ -82,9 +84,9 @@ impl Api { if solver .bad_token_detection() - .enable_heuristic_based_bad_token_detection + .enable_metrics_based_bad_token_detection { - bad_tokens.enable_heuristic_detector(); + bad_tokens.with_metrics_detector(metrics_bad_token_detector.clone()); } let router = router.with_state(State(Arc::new(Inner { diff --git a/crates/driver/src/infra/config/file/load.rs b/crates/driver/src/infra/config/file/load.rs index 6070445e8b..137d162042 100644 --- a/crates/driver/src/infra/config/file/load.rs +++ b/crates/driver/src/infra/config/file/load.rs @@ -110,7 +110,7 @@ pub async fn load(chain: chain::Id, path: &Path) -> infra::Config { .collect(), enable_simulation_based_bad_token_detection: config .enable_simulation_bad_token_detection, - enable_heuristic_based_bad_token_detection: config + enable_metrics_based_bad_token_detection: config .enable_heuristic_based_bad_token_detection, }, } diff --git a/crates/driver/src/infra/solver/mod.rs b/crates/driver/src/infra/solver/mod.rs index 196356651a..84adcb6d1b 100644 --- a/crates/driver/src/infra/solver/mod.rs +++ b/crates/driver/src/infra/solver/mod.rs @@ -307,5 +307,5 @@ pub struct BadTokenDetection { /// Tokens that are explicitly allow- or deny-listed. pub tokens_supported: HashMap, pub enable_simulation_based_bad_token_detection: bool, - pub enable_heuristic_based_bad_token_detection: bool, + pub enable_metrics_based_bad_token_detection: bool, }