Skip to content

Commit 6ec8589

Browse files
committed
minimize diff
1 parent a2e6ec3 commit 6ec8589

File tree

12 files changed

+41
-43
lines changed

12 files changed

+41
-43
lines changed

crates/rbuilder/src/backtest/execute.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use alloy_primitives::{Address, U256};
1515
use reth::providers::ProviderFactory;
1616
use reth_chainspec::ChainSpec;
1717
use reth_db::{database::Database, DatabaseEnv};
18-
use reth_payload_builder::database::{CachedReads, SyncCachedReads};
18+
use reth_payload_builder::database::SyncCachedReads as CachedReads;
1919
use serde::{Deserialize, Serialize};
2020
use std::sync::Arc;
2121

@@ -151,7 +151,7 @@ pub fn backtest_simulate_block<ConfigType: LiveBuilderConfig>(
151151
let simulated_total_gas = sim_orders.iter().map(|o| o.sim_value.gas_used).sum();
152152
let mut builder_outputs = Vec::new();
153153

154-
let mut cached_reads = Some(SyncCachedReads::default());
154+
let mut cached_reads = Some(CachedReads::default());
155155
for building_algorithm_name in builders_names {
156156
let input = BacktestSimulateBlockInput {
157157
ctx: ctx.clone(),

crates/rbuilder/src/bin/debug-bench-machine.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
//! This only works when reth node is stopped and the chain moved forward form its synced state
33
//! It downloads block aftre the last one synced and re-executes all the txs in it.
44
use alloy_provider::Provider;
5-
use ahash::HashMap;
6-
use alloy_primitives::{B256, U256};
75
use clap::Parser;
86
use eyre::Context;
97
use itertools::Itertools;
@@ -13,7 +11,7 @@ use rbuilder::{
1311
utils::{extract_onchain_block_txs, find_suggested_fee_recipient, http_provider},
1412
};
1513
use reth::providers::BlockNumReader;
16-
use reth_payload_builder::database::{CachedReads, SyncCachedReads};
14+
use reth_payload_builder::database::SyncCachedReads as CachedReads;
1715
use reth_provider::StateProvider;
1816
use std::{path::PathBuf, sync::Arc, time::Instant};
1917
use tracing::{debug, info};
@@ -85,7 +83,7 @@ async fn main() -> eyre::Result<()> {
8583

8684
let mut build_times_ms = Vec::new();
8785
let mut finalize_time_ms = Vec::new();
88-
let mut cached_reads = Some(SyncCachedReads::default());
86+
let mut cached_reads = Some(CachedReads::default());
8987
for _ in 0..cli.iters {
9088
let ctx = ctx.clone();
9189
let txs = txs.clone();

crates/rbuilder/src/building/builders/block_building_helper.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ahash::HashMap;
66
use alloy_primitives::U256;
77
use reth::tasks::pool::BlockingTaskPool;
88
use reth_db::database::Database;
9-
use reth_payload_builder::database::{CachedReads, SyncCachedReads};
9+
use reth_payload_builder::database::SyncCachedReads as CachedReads;
1010
use reth_primitives::format_ether;
1111
use reth_provider::{BlockNumReader, ProviderFactory, StateProvider};
1212
use revm_primitives::ChainAddress;
@@ -69,7 +69,7 @@ pub trait BlockBuildingHelper: Send + Sync {
6969
) -> Result<FinalizeBlockResult, BlockBuildingHelperError>;
7070

7171
/// Useful if we want to give away this object but keep on building some other way.
72-
fn clone_cached_reads(&self) -> SyncCachedReads;
72+
fn clone_cached_reads(&self) -> CachedReads;
7373

7474
/// BuiltBlockTrace for current state.
7575
fn built_block_trace(&self) -> &BuiltBlockTrace;
@@ -78,7 +78,7 @@ pub trait BlockBuildingHelper: Send + Sync {
7878
fn building_context(&self) -> &BlockBuildingContext;
7979

8080
/// Updates the cached reads for the block state.
81-
fn update_cached_reads(&mut self, cached_reads: SyncCachedReads);
81+
fn update_cached_reads(&mut self, cached_reads: CachedReads);
8282
}
8383

8484
/// Implementation of BlockBuildingHelper based on a ProviderFactory<DB>
@@ -142,7 +142,7 @@ impl BlockBuildingHelperError {
142142
pub struct FinalizeBlockResult {
143143
pub block: Block,
144144
/// Since finalize_block eats the object we need the cached_reads in case we create a new
145-
pub cached_reads: SyncCachedReads,
145+
pub cached_reads: CachedReads,
146146
}
147147

148148
impl<DB: Database + Clone + 'static> BlockBuildingHelperFromDB<DB> {
@@ -157,7 +157,7 @@ impl<DB: Database + Clone + 'static> BlockBuildingHelperFromDB<DB> {
157157
root_hash_task_pool: BlockingTaskPool,
158158
root_hash_config: RootHashConfig,
159159
building_ctx: HashMap<u64, BlockBuildingContext>,
160-
cached_reads: Option<SyncCachedReads>,
160+
cached_reads: Option<CachedReads>,
161161
builder_name: String,
162162
discard_txs: bool,
163163
enforce_sorting: Option<Sorting>,
@@ -365,7 +365,7 @@ impl<DB: Database + Clone + 'static> BlockBuildingHelper for BlockBuildingHelper
365365

366366
let sim_gas_used = self.partial_block.tracer.used_gas;
367367
let mut blocks = HashMap::default();
368-
let mut cached_reads = SyncCachedReads::default();
368+
let mut cached_reads = CachedReads::default();
369369
for (chain_id, provider_factory) in self.provider_factory.iter() {
370370
// TODO Brecht: fix
371371
if *chain_id == 160010 {
@@ -444,7 +444,7 @@ impl<DB: Database + Clone + 'static> BlockBuildingHelper for BlockBuildingHelper
444444
})
445445
}
446446

447-
fn clone_cached_reads(&self) -> SyncCachedReads {
447+
fn clone_cached_reads(&self) -> CachedReads {
448448
self.block_state.clone_cached_reads()
449449
}
450450

@@ -460,7 +460,7 @@ impl<DB: Database + Clone + 'static> BlockBuildingHelper for BlockBuildingHelper
460460
Box::new(self.clone())
461461
}
462462

463-
fn update_cached_reads(&mut self, cached_reads: SyncCachedReads) {
463+
fn update_cached_reads(&mut self, cached_reads: CachedReads) {
464464
self.block_state = self.block_state.clone().with_cached_reads(cached_reads);
465465
}
466466
}

crates/rbuilder/src/building/builders/mock_block_building_helper.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
primitives::SimulatedOrder,
77
};
88
use alloy_primitives::U256;
9-
use reth_payload_builder::database::{CachedReads, SyncCachedReads};
9+
use reth_payload_builder::database::SyncCachedReads as CachedReads;
1010
use reth_primitives::SealedBlock;
1111
use time::OffsetDateTime;
1212

@@ -85,12 +85,12 @@ impl BlockBuildingHelper for MockBlockBuildingHelper {
8585

8686
Ok(FinalizeBlockResult {
8787
block,
88-
cached_reads: SyncCachedReads::default(),
88+
cached_reads: CachedReads::default(),
8989
})
9090
}
9191

92-
fn clone_cached_reads(&self) -> SyncCachedReads {
93-
SyncCachedReads::default()
92+
fn clone_cached_reads(&self) -> CachedReads {
93+
CachedReads::default()
9494
}
9595

9696
fn built_block_trace(&self) -> &BuiltBlockTrace {
@@ -101,7 +101,7 @@ impl BlockBuildingHelper for MockBlockBuildingHelper {
101101
&self.block_building_context
102102
}
103103

104-
fn update_cached_reads(&mut self, _cached_reads: SyncCachedReads) {
104+
fn update_cached_reads(&mut self, _cached_reads: CachedReads) {
105105
unimplemented!()
106106
}
107107
}

crates/rbuilder/src/building/builders/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use reth::{
1919
tasks::pool::BlockingTaskPool,
2020
};
2121
use reth_db::database::Database;
22-
use reth_payload_builder::database::{CachedReads, SyncCachedReads};
22+
use reth_payload_builder::database::SyncCachedReads as CachedReads;
2323
use std::sync::Arc;
2424
use tokio::sync::{broadcast, broadcast::error::TryRecvError};
2525
use tokio_util::sync::CancellationToken;
@@ -230,7 +230,7 @@ pub struct BacktestSimulateBlockInput<'a, DB> {
230230
pub sbundle_mergeabe_signers: Vec<Address>,
231231
pub sim_orders: &'a Vec<SimulatedOrder>,
232232
pub provider_factory: ProviderFactory<DB>,
233-
pub cached_reads: Option<SyncCachedReads>,
233+
pub cached_reads: Option<CachedReads>,
234234
}
235235

236236
/// Handles error from block filling stage.

crates/rbuilder/src/building/builders/ordering_builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use tokio_util::sync::CancellationToken;
2323

2424
use crate::{roothash::RootHashConfig, utils::check_provider_factory_health};
2525
use reth::tasks::pool::BlockingTaskPool;
26-
use reth_payload_builder::database::{CachedReads, SyncCachedReads};
26+
use reth_payload_builder::database::SyncCachedReads as CachedReads;
2727
use serde::Deserialize;
2828
use std::{os::unix::fs::lchown, time::{Duration, Instant}};
2929
use tracing::{error, info_span, trace};
@@ -131,7 +131,7 @@ pub fn run_ordering_builder<DB: Database + Clone + 'static>(
131131
pub fn backtest_simulate_block<DB: Database + Clone + 'static>(
132132
ordering_config: OrderingBuilderConfig,
133133
input: BacktestSimulateBlockInput<'_, DB>,
134-
) -> eyre::Result<(Block, SyncCachedReads)> {
134+
) -> eyre::Result<(Block, CachedReads)> {
135135

136136
let mut provider_factories = HashMap::default();
137137
provider_factories.insert(input.ctx.chain_spec.chain.id(), input.provider_factory.clone());
@@ -186,7 +186,7 @@ pub struct OrderingBuilderContext<DB> {
186186
root_hash_config: RootHashConfig,
187187

188188
// caches
189-
cached_reads: Option<SyncCachedReads>,
189+
cached_reads: Option<CachedReads>,
190190

191191
// scratchpad
192192
failed_orders: HashSet<OrderId>,
@@ -215,14 +215,14 @@ impl<DB: Database + Clone + 'static> OrderingBuilderContext<DB> {
215215
}
216216
}
217217

218-
pub fn with_cached_reads(self, cached_reads: SyncCachedReads) -> Self {
218+
pub fn with_cached_reads(self, cached_reads: CachedReads) -> Self {
219219
Self {
220220
cached_reads: Some(cached_reads),
221221
..self
222222
}
223223
}
224224

225-
pub fn take_cached_reads(&mut self) -> Option<SyncCachedReads> {
225+
pub fn take_cached_reads(&mut self) -> Option<CachedReads> {
226226
self.cached_reads.take()
227227
}
228228

crates/rbuilder/src/building/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use reth_evm::system_calls::{
4242
};
4343
use reth_evm_ethereum::{eip6110::parse_deposits_from_receipts, revm_spec, EthEvmConfig};
4444
use reth_node_api::PayloadBuilderAttributes;
45-
use reth_payload_builder::{database::{CachedReads, SyncCachedReads}, EthPayloadBuilderAttributes};
45+
use reth_payload_builder::{database::SyncCachedReads as CachedReads, EthPayloadBuilderAttributes};
4646
use revm::{
4747
db::states::bundle_state::BundleRetention::{self, PlainState},
4848
primitives::{BlobExcessGasAndPrice, BlockEnv, CfgEnvWithHandlerCfg, SpecId},
@@ -405,7 +405,7 @@ impl ExecutionError {
405405

406406
pub struct FinalizeResult {
407407
pub sealed_block: SealedBlock,
408-
pub cached_reads: SyncCachedReads,
408+
pub cached_reads: CachedReads,
409409
// sidecars for all txs in SealedBlock
410410
pub txs_blob_sidecars: Vec<Arc<BlobTransactionSidecar>>,
411411
}

crates/rbuilder/src/building/order_commit.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use alloy_primitives::{Address, B256, U256};
1414

1515
use reth::revm::database::{StateProviderDatabase, SyncStateProviderDatabase};
1616
use reth_errors::ProviderError;
17-
use reth_payload_builder::database::{CachedReads, SyncCachedReads};
17+
use reth_payload_builder::database::SyncCachedReads as CachedReads;
1818
use reth_primitives::{
1919
constants::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK},
2020
transaction::FillTxEnv,
@@ -36,7 +36,7 @@ use thiserror::Error;
3636
#[derive(Clone)]
3737
pub struct BlockState {
3838
providers: HashMap<u64, Arc<dyn StateProvider>>,
39-
cached_reads: SyncCachedReads,
39+
cached_reads: CachedReads,
4040
bundle_state: Option<BundleState>,
4141
}
4242

@@ -50,7 +50,7 @@ impl BlockState {
5050
pub fn new_arc(providers: HashMap<u64, Arc<dyn StateProvider>>) -> Self {
5151
Self {
5252
providers,
53-
cached_reads: SyncCachedReads::default(),
53+
cached_reads: CachedReads::default(),
5454
bundle_state: Some(BundleState::default()),
5555
}
5656
}
@@ -69,7 +69,7 @@ impl BlockState {
6969
self.providers[&chain_id].clone()
7070
}
7171

72-
pub fn with_cached_reads(mut self, cached_reads:SyncCachedReads) -> Self {
72+
pub fn with_cached_reads(mut self, cached_reads:CachedReads) -> Self {
7373
self.cached_reads = cached_reads;
7474
self
7575
}
@@ -79,11 +79,11 @@ impl BlockState {
7979
self
8080
}
8181

82-
pub fn into_parts(self) -> (SyncCachedReads, BundleState, HashMap<u64, Arc<dyn StateProvider>>) {
82+
pub fn into_parts(self) -> (CachedReads, BundleState, HashMap<u64, Arc<dyn StateProvider>>) {
8383
(self.cached_reads, self.bundle_state.unwrap(), self.providers)
8484
}
8585

86-
pub fn clone_bundle_and_cache(&self) -> (SyncCachedReads, BundleState) {
86+
pub fn clone_bundle_and_cache(&self) -> (CachedReads, BundleState) {
8787
(
8888
self.cached_reads.clone(),
8989
self.bundle_state.clone().unwrap(),
@@ -129,7 +129,7 @@ impl BlockState {
129129
.unwrap_or_else(|| KECCAK_EMPTY))
130130
}
131131

132-
pub fn clone_cached_reads(&self) -> SyncCachedReads {
132+
pub fn clone_cached_reads(&self) -> CachedReads {
133133
self.cached_reads.clone()
134134
}
135135
}

crates/rbuilder/src/building/sim.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rand::seq::SliceRandom;
1313
use reth::providers::ProviderFactory;
1414
use reth_db::database::Database;
1515
use reth_errors::ProviderError;
16-
use reth_payload_builder::database::{CachedReads, SyncCachedReads};
16+
use reth_payload_builder::database::SyncCachedReads as CachedReads;
1717
use reth_provider::StateProvider;
1818
use std::{
1919
cmp::{max, min, Ordering},
@@ -338,7 +338,7 @@ pub fn simulate_all_orders_with_sim_tree<DB: Database + Clone>(
338338
ctx.chain_spec.chain.id(),
339339
Arc::<dyn StateProvider>::from(factory.history_by_block_hash(ctx.attributes.parent)?),
340340
);
341-
let mut cache_reads = Some(SyncCachedReads::default());
341+
let mut cache_reads = Some(CachedReads::default());
342342
loop {
343343
// mix new orders into the sim_tree
344344
if randomize_insertion && !orders.is_empty() {

crates/rbuilder/src/live_builder/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{path::PathBuf, sync::Arc};
22

33
use clap::Parser;
44
use reth_db::DatabaseEnv;
5-
use reth_payload_builder::database::{CachedReads, SyncCachedReads};
5+
use reth_payload_builder::database::SyncCachedReads as CachedReads;
66
use tokio::signal::ctrl_c;
77
use tokio_util::sync::CancellationToken;
88

@@ -52,7 +52,7 @@ pub trait LiveBuilderConfig: std::fmt::Debug + serde::de::DeserializeOwned {
5252
&self,
5353
building_algorithm_name: &str,
5454
input: BacktestSimulateBlockInput<'_, Arc<DatabaseEnv>>,
55-
) -> eyre::Result<(Block, SyncCachedReads)>;
55+
) -> eyre::Result<(Block, CachedReads)>;
5656
}
5757

5858
/// print_version_info func that will be called on command Cli::Version

0 commit comments

Comments
 (0)