diff --git a/bin/reth/src/commands/debug_cmd/build_block.rs b/bin/reth/src/commands/debug_cmd/build_block.rs index 595f93e58dcd..1a6885b5ef32 100644 --- a/bin/reth/src/commands/debug_cmd/build_block.rs +++ b/bin/reth/src/commands/debug_cmd/build_block.rs @@ -29,7 +29,8 @@ use reth_fs_util as fs; use reth_node_api::{BlockTy, EngineApiMessageVersion, PayloadBuilderAttributes}; use reth_node_ethereum::{EthEvmConfig, EthExecutorProvider}; use reth_primitives::{ - BlockExt, SealedBlockFor, SealedBlockWithSenders, SealedHeader, Transaction, TransactionSigned, + BlockExt, EthPrimitives, SealedBlockFor, SealedBlockWithSenders, SealedHeader, Transaction, + TransactionSigned, }; use reth_provider::{ providers::{BlockchainProvider, ProviderNodeTypes}, @@ -121,7 +122,7 @@ impl> Command { } /// Execute `debug in-memory-merkle` command - pub async fn execute>( + pub async fn execute>( self, ctx: CliContext, ) -> eyre::Result<()> { diff --git a/bin/reth/src/commands/debug_cmd/execution.rs b/bin/reth/src/commands/debug_cmd/execution.rs index d4ffbb9fe3a6..e25bb6afff66 100644 --- a/bin/reth/src/commands/debug_cmd/execution.rs +++ b/bin/reth/src/commands/debug_cmd/execution.rs @@ -25,6 +25,7 @@ use reth_network_p2p::{headers::client::HeadersClient, EthBlockClient}; use reth_node_api::NodeTypesWithDBAdapter; use reth_node_ethereum::EthExecutorProvider; use reth_node_events::node::NodeEvent; +use reth_primitives::EthPrimitives; use reth_provider::{ providers::ProviderNodeTypes, ChainSpecProvider, ProviderFactory, StageCheckpointReader, }; @@ -59,7 +60,7 @@ pub struct Command { } impl> Command { - fn build_pipeline + CliNodeTypes, Client>( + fn build_pipeline( &self, config: &Config, client: Client, @@ -69,6 +70,7 @@ impl> Command { static_file_producer: StaticFileProducer>, ) -> eyre::Result> where + N: ProviderNodeTypes + CliNodeTypes, Client: EthBlockClient + 'static, { // building network downloaders using the fetch client @@ -117,7 +119,9 @@ impl> Command { Ok(pipeline) } - async fn build_network>( + async fn build_network< + N: CliNodeTypes, + >( &self, config: &Config, task_executor: TaskExecutor, @@ -161,7 +165,7 @@ impl> Command { } /// Execute `execution-debug` command - pub async fn execute>( + pub async fn execute>( self, ctx: CliContext, ) -> eyre::Result<()> { diff --git a/bin/reth/src/commands/debug_cmd/in_memory_merkle.rs b/bin/reth/src/commands/debug_cmd/in_memory_merkle.rs index ff75fccc8ddd..bd8c8d1cdcc1 100644 --- a/bin/reth/src/commands/debug_cmd/in_memory_merkle.rs +++ b/bin/reth/src/commands/debug_cmd/in_memory_merkle.rs @@ -21,7 +21,7 @@ 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_primitives::{BlockExt, EthPrimitives}; use reth_provider::{ providers::ProviderNodeTypes, AccountExtReader, ChainSpecProvider, DatabaseProviderFactory, HashedPostStateProvider, HashingWriter, LatestStateProviderRef, OriginalValuesKnown, @@ -88,7 +88,7 @@ impl> Command { } /// Execute `debug in-memory-merkle` command - pub async fn execute>( + pub async fn execute>( self, ctx: CliContext, ) -> eyre::Result<()> { diff --git a/bin/reth/src/commands/debug_cmd/merkle.rs b/bin/reth/src/commands/debug_cmd/merkle.rs index f273d7ddb23a..59fe2bafaf6c 100644 --- a/bin/reth/src/commands/debug_cmd/merkle.rs +++ b/bin/reth/src/commands/debug_cmd/merkle.rs @@ -19,6 +19,7 @@ use reth_network_api::NetworkInfo; use reth_network_p2p::full_block::FullBlockClient; use reth_node_api::{BlockTy, NodePrimitives}; use reth_node_ethereum::EthExecutorProvider; +use reth_primitives::EthPrimitives; use reth_provider::{ providers::ProviderNodeTypes, BlockNumReader, BlockWriter, ChainSpecProvider, DatabaseProviderFactory, HeaderProvider, LatestStateProviderRef, OriginalValuesKnown, @@ -87,7 +88,7 @@ impl> Command { } /// Execute `merkle-debug` command - pub async fn execute>( + pub async fn execute>( self, ctx: CliContext, ) -> eyre::Result<()> { diff --git a/bin/reth/src/commands/debug_cmd/mod.rs b/bin/reth/src/commands/debug_cmd/mod.rs index 65329f414007..4aaa1b1c82ec 100644 --- a/bin/reth/src/commands/debug_cmd/mod.rs +++ b/bin/reth/src/commands/debug_cmd/mod.rs @@ -6,6 +6,7 @@ use reth_cli::chainspec::ChainSpecParser; use reth_cli_commands::common::CliNodeTypes; use reth_cli_runner::CliContext; use reth_node_ethereum::EthEngineTypes; +use reth_primitives::EthPrimitives; mod build_block; mod execution; @@ -37,7 +38,9 @@ pub enum Subcommands { impl> Command { /// Execute `debug` command - pub async fn execute>( + pub async fn execute< + N: CliNodeTypes, + >( self, ctx: CliContext, ) -> eyre::Result<()> { diff --git a/bin/reth/src/commands/debug_cmd/replay_engine.rs b/bin/reth/src/commands/debug_cmd/replay_engine.rs index bd734f449a36..3d17ea456526 100644 --- a/bin/reth/src/commands/debug_cmd/replay_engine.rs +++ b/bin/reth/src/commands/debug_cmd/replay_engine.rs @@ -22,6 +22,7 @@ use reth_network_api::NetworkInfo; use reth_node_api::{EngineApiMessageVersion, NodePrimitives, NodeTypesWithDBAdapter}; use reth_node_ethereum::{EthEngineTypes, EthEvmConfig, EthExecutorProvider}; use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService}; +use reth_primitives::EthPrimitives; use reth_provider::{ providers::{BlockchainProvider, ProviderNodeTypes}, CanonStateSubscriptions, ChainSpecProvider, ProviderFactory, @@ -87,7 +88,9 @@ impl> Command { } /// Execute `debug replay-engine` command - pub async fn execute>( + pub async fn execute< + N: CliNodeTypes, + >( self, ctx: CliContext, ) -> eyre::Result<()> { diff --git a/crates/cli/commands/src/common.rs b/crates/cli/commands/src/common.rs index 074cea6558cd..192cf9cb4f91 100644 --- a/crates/cli/commands/src/common.rs +++ b/crates/cli/commands/src/common.rs @@ -15,7 +15,6 @@ use reth_node_core::{ args::{DatabaseArgs, DatadirArgs}, dirs::{ChainPath, DataDirPath}, }; -use reth_primitives::EthPrimitives; use reth_provider::{ providers::{NodeTypesForProvider, StaticFileProvider}, ProviderFactory, StaticFileProviderFactory, @@ -198,11 +197,5 @@ impl AccessRights { /// Helper trait with a common set of requirements for the /// [`NodeTypes`](reth_node_builder::NodeTypes) in CLI. -pub trait CliNodeTypes: - NodeTypesWithEngine + NodeTypesForProvider -{ -} -impl CliNodeTypes for N where - N: NodeTypesWithEngine + NodeTypesForProvider -{ -} +pub trait CliNodeTypes: NodeTypesWithEngine + NodeTypesForProvider {} +impl CliNodeTypes for N where N: NodeTypesWithEngine + NodeTypesForProvider {} diff --git a/crates/cli/commands/src/import.rs b/crates/cli/commands/src/import.rs index eb314b4e8a43..adb973815731 100644 --- a/crates/cli/commands/src/import.rs +++ b/crates/cli/commands/src/import.rs @@ -20,6 +20,7 @@ use reth_network_p2p::{ bodies::downloader::BodyDownloader, headers::downloader::{HeaderDownloader, SyncTarget}, }; +use reth_node_api::{BlockTy, BodyTy, HeaderTy}; use reth_node_core::version::SHORT_VERSION; use reth_node_events::node::NodeEvent; use reth_provider::{ @@ -86,7 +87,7 @@ impl> ImportComm let mut total_decoded_blocks = 0; let mut total_decoded_txns = 0; - while let Some(file_client) = reader.next_chunk::().await? { + while let Some(file_client) = reader.next_chunk::>().await? { // create a new FileClient from chunk read from file info!(target: "reth::cli", "Importing chain file chunk" @@ -161,14 +162,14 @@ pub fn build_import_pipeline( config: &Config, provider_factory: ProviderFactory, consensus: &Arc, - file_client: Arc, + file_client: Arc>>, static_file_producer: StaticFileProducer>, disable_exec: bool, executor: E, ) -> eyre::Result<(Pipeline, impl Stream>)> where N: ProviderNodeTypes + CliNodeTypes, - C: Consensus + 'static, + C: Consensus, BodyTy> + 'static, E: BlockExecutorProvider, { if !file_client.has_canonical_blocks() { diff --git a/crates/cli/commands/src/init_state/mod.rs b/crates/cli/commands/src/init_state/mod.rs index 3a78737808d3..07e5a7c86f98 100644 --- a/crates/cli/commands/src/init_state/mod.rs +++ b/crates/cli/commands/src/init_state/mod.rs @@ -6,11 +6,11 @@ use clap::Parser; use reth_chainspec::{EthChainSpec, EthereumHardforks}; use reth_cli::chainspec::ChainSpecParser; use reth_db_common::init::init_from_state_dump; +use reth_node_api::NodePrimitives; use reth_primitives::SealedHeader; use reth_provider::{ BlockNumReader, DatabaseProviderFactory, StaticFileProviderFactory, StaticFileWriter, }; - use std::{io::BufReader, path::PathBuf, str::FromStr}; use tracing::info; @@ -67,7 +67,13 @@ pub struct InitStateCommand { impl> InitStateCommand { /// Execute the `init` command - pub async fn execute>(self) -> eyre::Result<()> { + pub async fn execute(self) -> eyre::Result<()> + where + N: CliNodeTypes< + ChainSpec = C::ChainSpec, + Primitives: NodePrimitives, + >, + { info!(target: "reth::cli", "Reth init-state starting"); let Environment { config, provider_factory, .. } = self.env.init::(AccessRights::RW)?; diff --git a/crates/cli/commands/src/recover/storage_tries.rs b/crates/cli/commands/src/recover/storage_tries.rs index f879c393c6b1..4ae32ff8f68b 100644 --- a/crates/cli/commands/src/recover/storage_tries.rs +++ b/crates/cli/commands/src/recover/storage_tries.rs @@ -1,4 +1,5 @@ use crate::common::{AccessRights, CliNodeTypes, Environment, EnvironmentArgs}; +use alloy_consensus::BlockHeader; use clap::Parser; use reth_chainspec::{EthChainSpec, EthereumHardforks}; use reth_cli::chainspec::ChainSpecParser; @@ -51,10 +52,10 @@ impl> Command } let state_root = StateRoot::from_tx(tx_mut).root()?; - if state_root != best_header.state_root { + if state_root != best_header.state_root() { eyre::bail!( "Recovery failed. Incorrect state root. Expected: {:?}. Received: {:?}", - best_header.state_root, + best_header.state_root(), state_root ); } diff --git a/crates/cli/commands/src/stage/dump/execution.rs b/crates/cli/commands/src/stage/dump/execution.rs index 1460c6bb6f67..6910f76d17be 100644 --- a/crates/cli/commands/src/stage/dump/execution.rs +++ b/crates/cli/commands/src/stage/dump/execution.rs @@ -7,7 +7,6 @@ use reth_db_api::{ }; use reth_db_common::DbTool; use reth_evm::{execute::BlockExecutorProvider, noop::NoopBlockExecutorProvider}; -use reth_node_api::NodePrimitives; use reth_node_builder::NodeTypesWithDB; use reth_node_core::dirs::{ChainPath, DataDirPath}; use reth_provider::{ @@ -26,14 +25,7 @@ pub(crate) async fn dump_execution_stage( executor: E, ) -> eyre::Result<()> where - N: ProviderNodeTypes< - DB = Arc, - Primitives: NodePrimitives< - Block = reth_primitives::Block, - Receipt = reth_primitives::Receipt, - BlockHeader = reth_primitives::Header, - >, - >, + N: ProviderNodeTypes>, E: BlockExecutorProvider, { let (output_db, tip_block_number) = setup(from, to, &output_datadir.db(), db_tool)?; @@ -139,9 +131,7 @@ fn import_tables_with_range( /// Dry-run an unwind to FROM block, so we can get the `PlainStorageState` and /// `PlainAccountState` safely. There might be some state dependency from an address /// which hasn't been changed in the given range. -fn unwind_and_copy< - N: ProviderNodeTypes>, ->( +fn unwind_and_copy( db_tool: &DbTool, from: u64, tip_block_number: u64, @@ -179,13 +169,7 @@ fn dry_run( executor: E, ) -> eyre::Result<()> where - N: ProviderNodeTypes< - Primitives: NodePrimitives< - Block = reth_primitives::Block, - Receipt = reth_primitives::Receipt, - BlockHeader = reth_primitives::Header, - >, - >, + N: ProviderNodeTypes, E: BlockExecutorProvider, { info!(target: "reth::cli", "Executing stage. [dry-run]"); diff --git a/crates/cli/commands/src/stage/dump/merkle.rs b/crates/cli/commands/src/stage/dump/merkle.rs index f0dbb1a1fafb..8bcad66d146d 100644 --- a/crates/cli/commands/src/stage/dump/merkle.rs +++ b/crates/cli/commands/src/stage/dump/merkle.rs @@ -9,7 +9,6 @@ use reth_db_api::{database::Database, table::TableImporter}; use reth_db_common::DbTool; use reth_evm::noop::NoopBlockExecutorProvider; use reth_exex::ExExManagerHandle; -use reth_node_api::NodePrimitives; use reth_node_core::dirs::{ChainPath, DataDirPath}; use reth_provider::{ providers::{ProviderNodeTypes, StaticFileProvider}, @@ -33,14 +32,7 @@ pub(crate) async fn dump_merkle_stage( should_run: bool, ) -> Result<()> where - N: ProviderNodeTypes< - DB = Arc, - Primitives: NodePrimitives< - Block = reth_primitives::Block, - Receipt = reth_primitives::Receipt, - BlockHeader = reth_primitives::Header, - >, - >, + N: ProviderNodeTypes>, { let (output_db, tip_block_number) = setup(from, to, &output_datadir.db(), db_tool)?; @@ -78,15 +70,7 @@ where } /// Dry-run an unwind to FROM block and copy the necessary table data to the new database. -fn unwind_and_copy< - N: ProviderNodeTypes< - Primitives: NodePrimitives< - Block = reth_primitives::Block, - Receipt = reth_primitives::Receipt, - BlockHeader = reth_primitives::Header, - >, - >, ->( +fn unwind_and_copy( db_tool: &DbTool, range: (u64, u64), tip_block_number: u64, @@ -166,7 +150,7 @@ fn unwind_and_copy< /// Try to re-execute the stage straight away fn dry_run(output_provider_factory: ProviderFactory, to: u64, from: u64) -> eyre::Result<()> where - N: ProviderNodeTypes>, + N: ProviderNodeTypes, { info!(target: "reth::cli", "Executing stage."); let provider = output_provider_factory.database_provider_rw()?; diff --git a/crates/cli/commands/src/stage/run.rs b/crates/cli/commands/src/stage/run.rs index aba0c30bf1aa..1a4783b9d487 100644 --- a/crates/cli/commands/src/stage/run.rs +++ b/crates/cli/commands/src/stage/run.rs @@ -4,6 +4,7 @@ use crate::common::{AccessRights, CliNodeTypes, Environment, EnvironmentArgs}; use alloy_eips::BlockHashOrNumber; +use alloy_primitives::Sealable; use clap::Parser; use reth_beacon_consensus::EthBeaconConsensus; use reth_chainspec::{EthChainSpec, EthereumHardforks}; diff --git a/crates/net/eth-wire-types/src/primitives.rs b/crates/net/eth-wire-types/src/primitives.rs index 295f6f161f34..0db1dc7df508 100644 --- a/crates/net/eth-wire-types/src/primitives.rs +++ b/crates/net/eth-wire-types/src/primitives.rs @@ -32,13 +32,7 @@ pub trait NetworkPrimitives: type PooledTransaction: SignedTransaction + TryFrom + 'static; /// The transaction type which peers return in `GetReceipts` messages. - type Receipt: TxReceipt - + RlpEncodableReceipt - + RlpDecodableReceipt - + Encodable - + Decodable - + Unpin - + 'static; + type Receipt: TxReceipt + RlpEncodableReceipt + RlpDecodableReceipt + Unpin + 'static; } /// This is a helper trait for use in bounds, where some of the [`NetworkPrimitives`] associated diff --git a/crates/optimism/cli/src/commands/import.rs b/crates/optimism/cli/src/commands/import.rs index 11ad9c27cc31..d8e41f07df7e 100644 --- a/crates/optimism/cli/src/commands/import.rs +++ b/crates/optimism/cli/src/commands/import.rs @@ -15,7 +15,7 @@ use reth_downloaders::file_client::{ use reth_node_core::version::SHORT_VERSION; use reth_optimism_chainspec::OpChainSpec; use reth_optimism_evm::OpExecutorProvider; -use reth_optimism_primitives::bedrock::is_dup_tx; +use reth_optimism_primitives::{bedrock::is_dup_tx, OpPrimitives}; use reth_provider::{ChainSpecProvider, StageCheckpointReader}; use reth_prune::PruneModes; use reth_stages::StageId; @@ -43,7 +43,9 @@ pub struct ImportOpCommand { impl> ImportOpCommand { /// Execute `import` command - pub async fn execute>(self) -> eyre::Result<()> { + pub async fn execute>( + self, + ) -> eyre::Result<()> { info!(target: "reth::cli", "reth {} starting", SHORT_VERSION); info!(target: "reth::cli", diff --git a/crates/optimism/cli/src/commands/import_receipts.rs b/crates/optimism/cli/src/commands/import_receipts.rs index 7e7c40f127e4..0cf6bdb723e2 100644 --- a/crates/optimism/cli/src/commands/import_receipts.rs +++ b/crates/optimism/cli/src/commands/import_receipts.rs @@ -14,7 +14,7 @@ use reth_downloaders::{ use reth_execution_types::ExecutionOutcome; use reth_node_core::version::SHORT_VERSION; use reth_optimism_chainspec::OpChainSpec; -use reth_optimism_primitives::bedrock::is_dup_tx; +use reth_optimism_primitives::{bedrock::is_dup_tx, OpPrimitives}; use reth_primitives::{NodePrimitives, Receipts}; use reth_provider::{ providers::ProviderNodeTypes, writer::UnifiedStorageWriter, DatabaseProviderFactory, @@ -47,7 +47,9 @@ pub struct ImportReceiptsOpCommand { impl> ImportReceiptsOpCommand { /// Execute `import` command - pub async fn execute>(self) -> eyre::Result<()> { + pub async fn execute>( + self, + ) -> eyre::Result<()> { info!(target: "reth::cli", "reth {} starting", SHORT_VERSION); debug!(target: "reth::cli", diff --git a/crates/optimism/cli/src/commands/init_state.rs b/crates/optimism/cli/src/commands/init_state.rs index 7bbfc3bb820f..8317866ad2ef 100644 --- a/crates/optimism/cli/src/commands/init_state.rs +++ b/crates/optimism/cli/src/commands/init_state.rs @@ -5,7 +5,10 @@ use reth_cli::chainspec::ChainSpecParser; use reth_cli_commands::common::{AccessRights, CliNodeTypes, Environment}; use reth_db_common::init::init_from_state_dump; use reth_optimism_chainspec::OpChainSpec; -use reth_optimism_primitives::bedrock::{BEDROCK_HEADER, BEDROCK_HEADER_HASH, BEDROCK_HEADER_TTD}; +use reth_optimism_primitives::{ + bedrock::{BEDROCK_HEADER, BEDROCK_HEADER_HASH, BEDROCK_HEADER_TTD}, + OpPrimitives, +}; use reth_primitives::SealedHeader; use reth_provider::{ BlockNumReader, ChainSpecProvider, DatabaseProviderFactory, StaticFileProviderFactory, @@ -35,7 +38,9 @@ pub struct InitStateCommandOp { impl> InitStateCommandOp { /// Execute the `init` command - pub async fn execute>(self) -> eyre::Result<()> { + pub async fn execute>( + self, + ) -> eyre::Result<()> { info!(target: "reth::cli", "Reth init-state starting"); let Environment { config, provider_factory, .. } = diff --git a/crates/optimism/cli/src/receipt_file_codec.rs b/crates/optimism/cli/src/receipt_file_codec.rs index 115ee4f7d721..509c7e04ed8d 100644 --- a/crates/optimism/cli/src/receipt_file_codec.rs +++ b/crates/optimism/cli/src/receipt_file_codec.rs @@ -25,9 +25,15 @@ use reth_downloaders::{file_client::FileClientError, receipt_file_client::Receip /// /// It's recommended to use [`with_capacity`](tokio_util::codec::FramedRead::with_capacity) to set /// the capacity of the framed reader to the size of the file. -#[derive(Debug, Default)] +#[derive(Debug)] pub struct HackReceiptFileCodec(core::marker::PhantomData); +impl Default for HackReceiptFileCodec { + fn default() -> Self { + Self(Default::default()) + } +} + impl Decoder for HackReceiptFileCodec where R: TryFrom>,