diff --git a/Makefile b/Makefile index ecb9a382c..1df6805a6 100644 --- a/Makefile +++ b/Makefile @@ -153,7 +153,7 @@ build-deb: build-deb-bid-scraper build-deb-rbuilder-operator build-deb-rbuilder- .PHONY: lint lint: ## Run the linters cargo fmt -- --check - cargo clippy --workspace --features "$(FEATURES)" -- -D warnings + cargo clippy --workspace --features "$(FEATURES)" --all-targets -- -D warnings .PHONY: test test: ## Run the tests for rbuilder. At reth 1.8.2 we started getting some memory errors (when creating the tmp dbs) so we had to limit the number of threads. @@ -166,7 +166,7 @@ lt: lint test ## Run "lint" and "test" fmt: ## Format the code cargo fmt cargo fix --allow-staged - cargo clippy --features "$(FEATURES)" --fix --allow-staged + cargo clippy --workspace --features "$(FEATURES)" --all-targets --fix --allow-staged .PHONY: bench bench: ## Run benchmarks diff --git a/crates/rbuilder/benches/benchmarks/txpool_fetcher.rs b/crates/rbuilder/benches/benchmarks/txpool_fetcher.rs index cdff5e6ca..a07db3327 100644 --- a/crates/rbuilder/benches/benchmarks/txpool_fetcher.rs +++ b/crates/rbuilder/benches/benchmarks/txpool_fetcher.rs @@ -6,9 +6,10 @@ use alloy_rpc_types::TransactionRequest; use alloy_signer_local::PrivateKeySigner; use criterion::{criterion_group, Criterion}; use rbuilder::live_builder::order_input::{ - txpool_fetcher::subscribe_to_txpool_with_blobs, OrderInputConfig, + mempool_txs_detector::MempoolTxsDetector, txpool_fetcher::subscribe_to_txpool_with_blobs, + OrderInputConfig, }; -use std::time::Duration; +use std::{sync::Arc, time::Duration}; use tokio::sync::mpsc; use tokio_util::sync::CancellationToken; @@ -22,6 +23,7 @@ async fn txpool_receive_util(count: u32) { subscribe_to_txpool_with_blobs( OrderInputConfig::default_e2e(), sender, + Arc::new(MempoolTxsDetector::new()), CancellationToken::new(), ) .await diff --git a/crates/rbuilder/src/building/block_orders/mod.rs b/crates/rbuilder/src/building/block_orders/mod.rs index dcc518bd0..44c99743a 100644 --- a/crates/rbuilder/src/building/block_orders/mod.rs +++ b/crates/rbuilder/src/building/block_orders/mod.rs @@ -1,7 +1,5 @@ mod prioritized_order_store; -#[cfg(test)] -mod order_dumper; pub mod order_priority; mod test_data_generator; use std::sync::Arc; diff --git a/crates/rbuilder/src/building/block_orders/order_dumper.rs b/crates/rbuilder/src/building/block_orders/order_dumper.rs deleted file mode 100644 index 80d762fa9..000000000 --- a/crates/rbuilder/src/building/block_orders/order_dumper.rs +++ /dev/null @@ -1,64 +0,0 @@ -//! Soon to be replaced my mockall - -use std::{collections::VecDeque, sync::Arc}; - -use rbuilder_primitives::{OrderId, SimulatedOrder}; - -use super::SimulatedOrderSink; -pub enum OrderStoreAction { - Insert(Arc), - Remove(OrderId), -} - -/// Helper to analyze the generated flow of orders -/// The idea es to create this as a sink for a source object and the -/// when we execute something on the source we check via pop_insert, pop_remove,etc -/// if the behavior was correct. -#[derive(Default)] -pub struct OrderDumper { - pub actions: VecDeque, -} - -impl SimulatedOrderSink for OrderDumper { - fn insert_order(&mut self, order: Arc) { - self.actions.push_back(OrderStoreAction::Insert(order)); - } - - fn remove_order(&mut self, id: OrderId) -> Option> { - self.actions.push_back(OrderStoreAction::Remove(id)); - None - } -} - -impl Drop for OrderDumper { - fn drop(&mut self) { - // Every action must be analyzed - assert!(self.actions.is_empty()); - } -} - -impl OrderDumper { - /// # Panics - /// empty or first not insert - pub fn pop_insert(&mut self) -> Arc { - if self.actions.is_empty() { - panic!("No actions, expected insert"); - } - match self.actions.pop_front().unwrap() { - OrderStoreAction::Insert(sim_order) => sim_order, - OrderStoreAction::Remove(_) => panic!("Expected insert found remove"), - } - } - - /// # Panics - /// empty or first not remove - pub fn pop_remove(&mut self) -> OrderId { - if self.actions.is_empty() { - panic!("No actions, expected insert"); - } - match self.actions.pop_front().unwrap() { - OrderStoreAction::Insert(_) => panic!("Expected remove found insert"), - OrderStoreAction::Remove(id) => id, - } - } -}