Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No roothash on backtest #359

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rbuilder/src/backtest/backtest_build_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ where
print_order_and_timestamp(&block_data.available_orders, &block_data);
}

let provider_factory = config.base_config().create_provider_factory()?;
let provider_factory = config.base_config().create_provider_factory(true)?;
let chain_spec = config.base_config().chain_spec()?;

if cli.sim_landed_block {
Expand Down
2 changes: 1 addition & 1 deletion crates/rbuilder/src/backtest/backtest_build_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ where
result
};

let provider_factory = config.base_config().create_provider_factory()?;
let provider_factory = config.base_config().create_provider_factory(true)?;
let chain_spec = config.base_config().chain_spec()?;

let mut profits = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/rbuilder/src/backtest/redistribute/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ where
let mut historical_data_storage =
HistoricalDataStorage::new_from_path(&config.base_config().backtest_fetch_output_file)
.await?;
let provider = config.base_config().create_provider_factory()?;
let provider = config.base_config().create_provider_factory(true)?;
let mut csv_writer = cli
.csv
.map(|path| -> io::Result<_> { CSVResultWriter::new(path) })
Expand Down
2 changes: 1 addition & 1 deletion crates/rbuilder/src/bin/debug-bench-machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async fn main() -> eyre::Result<()> {

let chain_spec = config.base_config().chain_spec()?;

let provider_factory = config.base_config().create_provider_factory()?;
let provider_factory = config.base_config().create_provider_factory(true)?;

let last_block = provider_factory.last_block_number()?;

Expand Down
8 changes: 7 additions & 1 deletion crates/rbuilder/src/live_builder/base_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ impl BaseConfig {
}

/// Open reth db and DB should be opened once per process but it can be cloned and moved to different threads.
/// skip_root_hash -> will create a mock roothasher. Used on backtesting since reth can't compute roothashes on the past.
pub fn create_provider_factory(
&self,
skip_root_hash: bool,
) -> eyre::Result<ProviderFactoryReopener<NodeTypesWithDBAdapter<EthereumNode, Arc<DatabaseEnv>>>>
{
create_provider_factory(
Expand All @@ -240,7 +242,11 @@ impl BaseConfig {
self.reth_static_files_path.as_deref(),
self.chain_spec()?,
false,
Some(self.live_root_hash_config()?),
if skip_root_hash {
None
} else {
Some(self.live_root_hash_config()?)
},
)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rbuilder/src/live_builder/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ where
config.base_config().log_enable_dynamic,
)
.await?;
let provider = config.base_config().create_provider_factory()?;
let provider = config.base_config().create_provider_factory(false)?;
let builder = config.new_builder(provider, cancel.clone()).await?;

let ctrlc = tokio::spawn(async move {
Expand Down