Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt committed Jan 2, 2025
1 parent 1b42b4a commit a988074
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 43 deletions.
1 change: 0 additions & 1 deletion crates/rbuilder/src/provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use alloy_primitives::{BlockHash, BlockNumber, B256};
use reth::providers::ExecutionOutcome;
use reth_errors::ProviderResult;
use reth_provider::StateProviderBox;
use reth_provider::StateProviderFactory as A;
use tokio::sync::broadcast;
use tokio_util::sync::CancellationToken;

Expand Down
56 changes: 32 additions & 24 deletions crates/rbuilder/src/provider/reth_prov.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
use crate::live_builder::simulation::SimulatedOrderCommand;
use crate::roothash::{RootHashConfig, RootHashError};
use crate::roothash::{calculate_state_root, run_trie_prefetcher, RootHashConfig, RootHashError};
use alloy_consensus::Header;
use alloy_primitives::{BlockHash, BlockNumber, B256};
use reth::providers::ExecutionOutcome;
use reth_errors::ProviderResult;
use reth_provider::StateProviderBox;
use reth_provider::StateProviderFactory as A;
use reth_provider::{
providers::{BlockchainProvider, BlockchainProvider2},
BlockReader, DatabaseProviderFactory, HeaderProvider,
};
use reth_provider::{BlockReader, DatabaseProviderFactory, HeaderProvider};
use tokio::sync::broadcast;
use tokio_util::sync::CancellationToken;

Expand All @@ -24,44 +20,50 @@ where
+ 'static,
{
fn latest(&self) -> ProviderResult<StateProviderBox> {
unimplemented!()
self.latest()
}

fn history_by_block_number(&self, block: BlockNumber) -> ProviderResult<StateProviderBox> {
unimplemented!()
}

fn run_trie_prefetcher(
&self,
parent_hash: B256,
simulated_orders: broadcast::Receiver<SimulatedOrderCommand>,
cancel: CancellationToken,
) {
unimplemented!()
self.history_by_block_number(block)
}

fn history_by_block_hash(&self, block: BlockHash) -> ProviderResult<StateProviderBox> {
unimplemented!()
self.history_by_block_hash(block)
}

fn header(&self, block_hash: &BlockHash) -> ProviderResult<Option<Header>> {
unimplemented!()
self.header(block_hash)
}

fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>> {
unimplemented!()
self.block_hash(number)
}

fn best_block_number(&self) -> ProviderResult<BlockNumber> {
unimplemented!()
self.best_block_number()
}

fn header_by_number(&self, num: u64) -> ProviderResult<Option<Header>> {
unimplemented!()
self.header_by_number(num)
}

fn last_block_number(&self) -> ProviderResult<BlockNumber> {
unimplemented!()
self.last_block_number()
}

fn run_trie_prefetcher(
&self,
parent_hash: B256,
simulated_orders: broadcast::Receiver<SimulatedOrderCommand>,
cancel: CancellationToken,
) {
run_trie_prefetcher(
parent_hash,
Default::default(),
self,
simulated_orders,
cancel,
);
}

fn calculate_state_root(
Expand All @@ -70,6 +72,12 @@ where
outcome: &ExecutionOutcome,
config: RootHashConfig,
) -> Result<B256, RootHashError> {
unimplemented!()
calculate_state_root(
self.clone(),
parent_hash,
outcome,
Default::default(),
config,
)
}
}
14 changes: 5 additions & 9 deletions crates/rbuilder/src/utils/provider_factory_reopen.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
use crate::live_builder::simulation::SimulatedOrderCommand;
use crate::provider::StateProviderFactory as StateProviderFactory2;
use crate::provider::StateProviderFactory;
use crate::roothash::{calculate_state_root, run_trie_prefetcher, RootHashConfig, RootHashError};
use crate::telemetry::{inc_provider_bad_reopen_counter, inc_provider_reopen_counter};
use alloy_consensus::Header;
use alloy_eips::{BlockNumHash, BlockNumberOrTag};
use alloy_primitives::{BlockHash, BlockNumber};
use parking_lot::{Mutex, RwLock};
use reth::providers::ExecutionOutcome;
use reth::providers::{BlockHashReader, ChainSpecProvider, ProviderFactory};
use reth_chainspec::ChainInfo;
use reth_db::{Database, DatabaseError};
use reth_db::DatabaseError;
use reth_errors::{ProviderError, ProviderResult, RethResult};
use reth_node_api::NodeTypesWithDB;
use reth_primitives::SealedHeader;
use reth_provider::{
providers::{ProviderNodeTypes, StaticFileProvider},
BlockIdReader, BlockNumReader, DatabaseProvider, DatabaseProviderFactory, DatabaseProviderRO,
HeaderProvider, StateProviderBox, StateProviderFactory, StaticFileProviderFactory,
BlockNumReader, HeaderProvider, StateProviderBox, StaticFileProviderFactory,
};
use revm_primitives::B256;
use std::ops::DerefMut;
use std::{ops::RangeBounds, path::PathBuf, sync::Arc};
use std::{path::PathBuf, sync::Arc};
use tokio::sync::broadcast;
use tokio_util::sync::CancellationToken;
use tracing::debug;
Expand Down Expand Up @@ -169,7 +165,7 @@ pub fn check_block_hash_reader_health<R: BlockHashReader>(
Ok(())
}

impl<N: NodeTypesWithDB + ProviderNodeTypes + Clone> StateProviderFactory2
impl<N: NodeTypesWithDB + ProviderNodeTypes + Clone> StateProviderFactory
for ProviderFactoryReopener<N>
{
fn latest(&self) -> ProviderResult<StateProviderBox> {
Expand Down
18 changes: 9 additions & 9 deletions crates/reth-rbuilder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use rbuilder::{
provider::StateProviderFactory,
telemetry,
};
use reth::providers::ExecutionOutcome;
use reth::{chainspec::EthereumChainSpecParser, cli::Cli};
use reth_db_api::Database;
use reth_node_builder::{
Expand All @@ -21,14 +20,11 @@ use reth_node_builder::{
EngineNodeLauncher,
};
use reth_node_ethereum::{node::EthereumAddOns, EthereumNode};
use reth_provider::StateProviderBox;
use reth_provider::StateProviderFactory as A;
use reth_provider::{
providers::{BlockchainProvider, BlockchainProvider2},
BlockReader, DatabaseProviderFactory, HeaderProvider,
};
use std::{path::PathBuf, process};
use tokio::sync::broadcast;
use tokio::task;
use tracing::{error, info, warn};

Expand Down Expand Up @@ -126,9 +122,14 @@ fn main() {
/// Spawns a tokio rbuilder task.
///
/// Takes down the entire process if the rbuilder errors or stops.
fn spawn_rbuilder<P>(provider: P, config_path: PathBuf)
fn spawn_rbuilder<P, DB>(provider: P, config_path: PathBuf)
where
P: reth_provider::StateProviderFactory,
DB: Database + Clone + 'static,
P: DatabaseProviderFactory<DB = DB, Provider: BlockReader>
+ StateProviderFactory
+ HeaderProvider
+ Clone
+ 'static,
{
let _handle = task::spawn(async move {
let result = async {
Expand All @@ -148,9 +149,8 @@ where
)
.await?;

// FIX
//let builder = config.new_builder(provider, Default::default()).await?;
//builder.run().await?;
let builder = config.new_builder(provider, Default::default()).await?;
builder.run().await?;

Ok::<(), eyre::Error>(())
}
Expand Down

0 comments on commit a988074

Please sign in to comment.