Skip to content

Commit

Permalink
feat: relax provider bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Nov 25, 2024
1 parent 769d030 commit e57cc67
Show file tree
Hide file tree
Showing 37 changed files with 360 additions and 235 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bin/reth/src/commands/debug_cmd/build_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use reth_fs_util as fs;
use reth_node_api::{BlockTy, EngineApiMessageVersion, PayloadBuilderAttributes};
use reth_node_ethereum::{EthEvmConfig, EthExecutorProvider};
use reth_primitives::{
BlobTransaction, BlockExt, PooledTransactionsElement, SealedBlock, SealedBlockWithSenders,
BlobTransaction, BlockExt, PooledTransactionsElement, SealedBlockFor, SealedBlockWithSenders,
SealedHeader, Transaction, TransactionSigned,
};
use reth_provider::{
Expand Down Expand Up @@ -90,7 +90,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
fn lookup_best_block<N: ProviderNodeTypes<ChainSpec = C::ChainSpec>>(
&self,
factory: ProviderFactory<N>,
) -> RethResult<Arc<SealedBlock>> {
) -> RethResult<Arc<SealedBlockFor<BlockTy<N>>>> {
let provider = factory.provider()?;

let best_number =
Expand Down
10 changes: 8 additions & 2 deletions bin/reth/src/commands/debug_cmd/in_memory_merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use reth_evm::execute::{BlockExecutorProvider, Executor};
use reth_execution_types::ExecutionOutcome;
use reth_network::{BlockDownloaderProvider, NetworkHandle};
use reth_network_api::NetworkInfo;
use reth_node_api::{BlockTy, NodePrimitives};
use reth_node_ethereum::EthExecutorProvider;
use reth_primitives::BlockExt;
use reth_provider::{
Expand Down Expand Up @@ -56,7 +57,12 @@ pub struct Command<C: ChainSpecParser> {
}

impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
async fn build_network<N: ProviderNodeTypes<ChainSpec = C::ChainSpec>>(
async fn build_network<
N: ProviderNodeTypes<
ChainSpec = C::ChainSpec,
Primitives: NodePrimitives<Block = reth_primitives::Block>,
>,
>(
&self,
config: &Config,
task_executor: TaskExecutor,
Expand Down Expand Up @@ -143,7 +149,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
(
&block
.clone()
.unseal()
.unseal::<BlockTy<N>>()
.with_recovered_senders()
.ok_or(BlockValidationError::SenderRecoveryError)?,
merkle_block_td + block.difficulty,
Expand Down
9 changes: 7 additions & 2 deletions bin/reth/src/commands/debug_cmd/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use reth_evm::execute::{BatchExecutor, BlockExecutorProvider};
use reth_network::{BlockDownloaderProvider, NetworkHandle};
use reth_network_api::NetworkInfo;
use reth_network_p2p::full_block::FullBlockClient;
use reth_node_api::BlockTy;
use reth_node_api::{BlockTy, NodePrimitives};
use reth_node_ethereum::EthExecutorProvider;
use reth_provider::{
providers::ProviderNodeTypes, writer::UnifiedStorageWriter, BlockNumReader, BlockWriter,
Expand Down Expand Up @@ -56,7 +56,12 @@ pub struct Command<C: ChainSpecParser> {
}

impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
async fn build_network<N: ProviderNodeTypes<ChainSpec = C::ChainSpec>>(
async fn build_network<
N: ProviderNodeTypes<
ChainSpec = C::ChainSpec,
Primitives: NodePrimitives<Block = reth_primitives::Block>,
>,
>(
&self,
config: &Config,
task_executor: TaskExecutor,
Expand Down
9 changes: 7 additions & 2 deletions bin/reth/src/commands/debug_cmd/replay_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use reth_engine_util::engine_store::{EngineMessageStore, StoredEngineApiMessage}
use reth_fs_util as fs;
use reth_network::{BlockDownloaderProvider, NetworkHandle};
use reth_network_api::NetworkInfo;
use reth_node_api::{EngineApiMessageVersion, NodeTypesWithDBAdapter};
use reth_node_api::{EngineApiMessageVersion, NodePrimitives, NodeTypesWithDBAdapter};
use reth_node_ethereum::{EthEngineTypes, EthEvmConfig, EthExecutorProvider};
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_provider::{
Expand Down Expand Up @@ -55,7 +55,12 @@ pub struct Command<C: ChainSpecParser> {
}

impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
async fn build_network<N: ProviderNodeTypes<ChainSpec = C::ChainSpec>>(
async fn build_network<
N: ProviderNodeTypes<
ChainSpec = C::ChainSpec,
Primitives: NodePrimitives<Block = reth_primitives::Block>,
>,
>(
&self,
config: &Config,
task_executor: TaskExecutor,
Expand Down
16 changes: 4 additions & 12 deletions crates/blockchain-tree/src/externals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,15 @@ use reth_consensus::Consensus;
use reth_db::{static_file::BlockHashMask, tables};
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx};
use reth_node_types::NodeTypesWithDB;
use reth_primitives::{EthPrimitives, StaticFileSegment};
use reth_primitives::StaticFileSegment;
use reth_provider::{
providers::{NodeTypesForProvider, ProviderNodeTypes},
ChainStateBlockReader, ChainStateBlockWriter, ProviderFactory, StaticFileProviderFactory,
StatsReader,
providers::ProviderNodeTypes, ChainStateBlockReader, ChainStateBlockWriter, ProviderFactory,
StaticFileProviderFactory, StatsReader,
};
use reth_storage_errors::provider::ProviderResult;
use std::{collections::BTreeMap, sync::Arc};

/// A helper trait with requirements for [`ProviderNodeTypes`] to be used within [`TreeExternals`].
pub trait NodeTypesForTree: NodeTypesForProvider<Primitives = EthPrimitives> {}

impl<T> NodeTypesForTree for T where T: NodeTypesForProvider<Primitives = EthPrimitives> {}

/// A helper trait with requirements for [`ProviderNodeTypes`] to be used within [`TreeExternals`].
pub trait TreeNodeTypes: ProviderNodeTypes + NodeTypesForTree {}
impl<T> TreeNodeTypes for T where T: ProviderNodeTypes + NodeTypesForTree {}
pub use reth_provider::providers::{NodeTypesForTree, TreeNodeTypes};

/// A container for external components.
///
Expand Down
Loading

0 comments on commit e57cc67

Please sign in to comment.