Skip to content

Commit 903e6f4

Browse files
committed
just fix
1 parent 9038a1e commit 903e6f4

File tree

19 files changed

+412
-384
lines changed

19 files changed

+412
-384
lines changed

crates/simulator/src/config/mod.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
mod simulator_node;
21
pub mod playground;
2+
mod simulator_node;
33

44
pub use playground::PlaygroundOptions;
55
pub use simulator_node::SimulatorNodeConfig;
@@ -44,18 +44,10 @@ impl CliExt for Cli {
4444
}
4545

4646
impl SimulatorNodeConfig {
47-
pub fn into_parts(
48-
self,
49-
cli: Cli,
50-
) -> (Cli, ExExSimulationConfig, MempoolListenerConfig, u64) {
47+
pub fn into_parts(self, cli: Cli) -> (Cli, ExExSimulationConfig, MempoolListenerConfig, u64) {
5148
let exex_config = (&self).into();
5249
let mempool_config = (&self).into();
53-
(
54-
cli,
55-
exex_config,
56-
mempool_config,
57-
self.chain_block_time,
58-
)
50+
(cli, exex_config, mempool_config, self.chain_block_time)
5951
}
6052
}
6153

crates/simulator/src/config/playground.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
use alloy_primitives::hex;
2222
use anyhow::{anyhow, Result};
23-
use clap::{CommandFactory, parser::ValueSource};
23+
use clap::{parser::ValueSource, CommandFactory};
2424
use core::{
2525
net::{IpAddr, Ipv4Addr, SocketAddr},
2626
time::Duration,
@@ -351,4 +351,3 @@ fn resolve_trusted_peer_host() -> Host {
351351
Host::Ipv4(Ipv4Addr::LOCALHOST)
352352
}
353353
}
354-

crates/simulator/src/config/simulator_node.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use crate::{
2-
listeners::MempoolListenerConfig,
3-
types::ExExSimulationConfig,
4-
};
1+
use crate::{listeners::MempoolListenerConfig, types::ExExSimulationConfig};
52
use anyhow::{anyhow, Result};
63
use clap::Args;
74
use std::path::PathBuf;
@@ -30,11 +27,7 @@ pub struct SimulatorNodeConfig {
3027
pub kafka_brokers: String,
3128

3229
/// Kafka topic for mempool events
33-
#[arg(
34-
long,
35-
env = "TIPS_SIMULATOR_KAFKA_TOPIC",
36-
default_value = "tips-audit"
37-
)]
30+
#[arg(long, env = "TIPS_SIMULATOR_KAFKA_TOPIC", default_value = "tips-audit")]
3831
pub kafka_topic: String,
3932

4033
/// Kafka consumer group ID
@@ -102,4 +95,3 @@ fn expand_path(s: &str) -> Result<PathBuf> {
10295
.parse()
10396
.map_err(|e| anyhow!("invalid path after expansion: {e}"))
10497
}
105-

crates/simulator/src/core.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ where
2929
P: SimulationPublisher,
3030
{
3131
pub fn new(engine: E, publisher: P) -> Self {
32-
Self {
33-
engine,
34-
publisher,
35-
}
32+
Self { engine, publisher }
3633
}
3734
}
3835

crates/simulator/src/engine.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ where
101101
#[async_trait]
102102
pub trait SimulationEngine: Send + Sync {
103103
/// Simulate a bundle execution
104-
async fn simulate_bundle(
105-
&self,
106-
request: &SimulationRequest,
107-
) -> Result<SimulationResult>;
104+
async fn simulate_bundle(&self, request: &SimulationRequest) -> Result<SimulationResult>;
108105
}
109106

110107
#[derive(Clone)]
@@ -134,10 +131,7 @@ where
134131
Node: FullNodeComponents,
135132
<Node as FullNodeComponents>::Evm: ConfigureEvm<NextBlockEnvCtx = OpNextBlockEnvAttributes>,
136133
{
137-
async fn simulate_bundle(
138-
&self,
139-
request: &SimulationRequest,
140-
) -> Result<SimulationResult> {
134+
async fn simulate_bundle(&self, request: &SimulationRequest) -> Result<SimulationResult> {
141135
let start_time = Instant::now();
142136
let simulation_id = Uuid::new_v4();
143137

crates/simulator/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ pub use worker_pool::SimulationWorkerPool;
2525
// Type aliases for concrete implementations
2626
pub type TipsBundleSimulator<Node> =
2727
RethBundleSimulator<RethSimulationEngine<Node>, TipsSimulationPublisher>;
28-
pub type TipsExExEventListener<Node> = ExExEventListener<
29-
Node,
30-
TipsBundleSimulator<Node>,
31-
tips_datastore::PostgresDatastore,
32-
>;
33-
pub type TipsMempoolEventListener<Node> =
34-
MempoolEventListener<Node, TipsBundleSimulator<Node>>;
28+
pub type TipsExExEventListener<Node> =
29+
ExExEventListener<Node, TipsBundleSimulator<Node>, tips_datastore::PostgresDatastore>;
30+
pub type TipsMempoolEventListener<Node> = MempoolEventListener<Node, TipsBundleSimulator<Node>>;
3531

3632
// Initialization functions
3733

crates/simulator/src/listeners/exex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ where
136136
);
137137

138138
// Process each block in the committed chain
139-
for (_block_num, block) in new.blocks() {
139+
for block in new.blocks().values() {
140140
let block_hash = block.hash();
141141
self.process_block((&block_hash, block)).await?;
142142
}
@@ -156,7 +156,7 @@ where
156156
);
157157

158158
// Process the new canonical chain
159-
for (_block_num, block) in new.blocks() {
159+
for block in new.blocks().values() {
160160
let block_hash = block.hash();
161161
self.process_block((&block_hash, block)).await?;
162162
}

crates/simulator/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ fn main() -> eyre::Result<()> {
2727

2828
cli.run(|builder, _| async move {
2929
// Keep the Base mempool private.
30-
let mut rollup_args = RollupArgs::default();
31-
rollup_args.disable_txpool_gossip = true;
30+
let rollup_args = RollupArgs {
31+
disable_txpool_gossip: true,
32+
..Default::default()
33+
};
3234

3335
let handle = builder
3436
.node(reth_optimism_node::OpNode::new(rollup_args))

crates/simulator/src/worker_pool.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ where
3535
B: BundleSimulator + 'static,
3636
{
3737
/// Create a new simulation worker pool
38-
pub fn new(
39-
simulator: Arc<B>,
40-
max_concurrent_simulations: usize,
41-
) -> Arc<Self> {
38+
pub fn new(simulator: Arc<B>, max_concurrent_simulations: usize) -> Arc<Self> {
4239
let (simulation_tx, simulation_rx) = mpsc::channel(1000);
4340

4441
Arc::new(Self {
@@ -132,11 +129,7 @@ where
132129
}
133130

134131
// Execute the simulation
135-
match pool
136-
.simulator
137-
.simulate(&task.request)
138-
.await
139-
{
132+
match pool.simulator.simulate(&task.request).await {
140133
Ok(_) => {
141134
debug!(
142135
worker_id,

crates/simulator/tests/common/builders.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ impl SimulationResultBuilder {
159159
let mut builder = Self::new();
160160
builder.success = false;
161161
builder.gas_used = None;
162-
builder.error = Some(SimulationError::Unknown {
163-
message: "Test failure".to_string()
162+
builder.error = Some(SimulationError::Unknown {
163+
message: "Test failure".to_string(),
164164
});
165165
builder
166166
}
@@ -211,7 +211,11 @@ impl SimulationResultBuilder {
211211
}
212212

213213
pub fn with_invalid_nonce(self, tx_index: usize, expected: u64, actual: u64) -> Self {
214-
self.with_error(SimulationError::InvalidNonce { tx_index, expected, actual })
214+
self.with_error(SimulationError::InvalidNonce {
215+
tx_index,
216+
expected,
217+
actual,
218+
})
215219
}
216220

217221
pub fn build(self) -> SimulationResult {
@@ -232,8 +236,8 @@ impl SimulationResultBuilder {
232236
self.block_number,
233237
self.block_hash.unwrap_or_else(B256::random),
234238
self.execution_time_us,
235-
self.error.unwrap_or(SimulationError::Unknown {
236-
message: "Unknown error".to_string()
239+
self.error.unwrap_or(SimulationError::Unknown {
240+
message: "Unknown error".to_string(),
237241
}),
238242
)
239243
}
@@ -268,13 +272,12 @@ impl ScenarioBuilder {
268272
}
269273

270274
pub fn add_simple_bundle(mut self, num_txs: usize) -> Self {
271-
let mut builder = TestBundleBuilder::new()
272-
.with_block_number(self.block_number);
273-
275+
let mut builder = TestBundleBuilder::new().with_block_number(self.block_number);
276+
274277
for i in 0..num_txs {
275278
builder = builder.with_simple_transaction(&[i as u8, 0x01, 0x02]);
276279
}
277-
280+
278281
self.bundles.push(builder.build());
279282
self
280283
}

0 commit comments

Comments
 (0)