Skip to content

Commit 489bad4

Browse files
squadgazzzfafk
authored andcommitted
Do not preprocess COW AMMs when not configured (#3925)
# Description When the driver's COW AMM config is empty, the corresponding task still tries to search for surplus capturing jit order owners among the AMMs and fires a redundant warning log in that case. When the driver doesn't expect any AMMs, this log doesn't make any sense. This PR fixes this. # Changes - [ ] Make the COW AMM cache optional based on the COW AMMs config. - [ ] When None, return fast with no AMMs for every auction with no redundant logs. ## How to test Logs on chains where COW AMMs are not configured. ## Related Issues Fixes #3890
1 parent 191c401 commit 489bad4

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

crates/driver/src/domain/competition/pre_processing.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub struct Utilities {
6060
liquidity_fetcher: infra::liquidity::Fetcher,
6161
tokens: tokens::Fetcher,
6262
balance_fetcher: Arc<dyn BalanceFetching>,
63-
cow_amm_cache: cow_amm::Cache,
63+
cow_amm_cache: Option<cow_amm::Cache>,
6464
}
6565

6666
impl std::fmt::Debug for Utilities {
@@ -390,12 +390,16 @@ impl Utilities {
390390
}
391391

392392
async fn cow_amm_orders(self: Arc<Self>, auction: Arc<Auction>) -> Arc<Vec<Order>> {
393+
let Some(ref cow_amm_cache) = self.cow_amm_cache else {
394+
// CoW AMMs are not configured, return empty vec
395+
return Default::default();
396+
};
397+
393398
let _timer = metrics::get().processing_stage_timer("cow_amm_orders");
394399
let _timer2 =
395400
observe::metrics::metrics().on_auction_overhead_start("driver", "cow_amm_orders");
396401

397-
let cow_amms = self
398-
.cow_amm_cache
402+
let cow_amms = cow_amm_cache
399403
.get_or_create_amms(&auction.surplus_capturing_jit_order_owners)
400404
.await;
401405

crates/driver/src/domain/cow_amm.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ pub struct Cache {
2424
}
2525

2626
impl Cache {
27-
pub fn new(web3: DynProvider, factory_mapping: HashMap<Address, Address>) -> Self {
27+
pub fn new(web3: DynProvider, factory_mapping: HashMap<Address, Address>) -> Option<Self> {
28+
if factory_mapping.is_empty() {
29+
return None;
30+
}
31+
2832
let helper_by_factory = factory_mapping
2933
.into_iter()
3034
.map(|(factory, helper)| {
@@ -34,11 +38,11 @@ impl Cache {
3438
)
3539
})
3640
.collect();
37-
Self {
41+
Some(Self {
3842
inner: RwLock::new(HashMap::new()),
3943
web3: web3.clone(),
4044
helper_by_factory,
41-
}
45+
})
4246
}
4347

4448
/// Gets or creates AMM instances for the given surplus capturing JIT order

0 commit comments

Comments
 (0)