chore: Replace reth-provider dependency for reth-eth-types with direct dependencies (#10175)

This commit is contained in:
Nikolai Golub
2024-08-07 20:05:19 +02:00
committed by GitHub
parent d191886c37
commit e199173dee
20 changed files with 57 additions and 49 deletions

6
Cargo.lock generated
View File

@ -6511,6 +6511,7 @@ dependencies = [
"alloy-primitives", "alloy-primitives",
"alloy-rlp", "alloy-rlp",
"alloy-trie", "alloy-trie",
"auto_impl",
"derive_more", "derive_more",
"once_cell", "once_cell",
"op-alloy-rpc-types", "op-alloy-rpc-types",
@ -8443,17 +8444,18 @@ dependencies = [
"jsonrpsee-types", "jsonrpsee-types",
"metrics", "metrics",
"rand 0.8.5", "rand 0.8.5",
"reth-chain-state",
"reth-chainspec", "reth-chainspec",
"reth-errors", "reth-errors",
"reth-evm", "reth-evm",
"reth-execution-types", "reth-execution-types",
"reth-metrics", "reth-metrics",
"reth-primitives", "reth-primitives",
"reth-provider",
"reth-revm", "reth-revm",
"reth-rpc-server-types", "reth-rpc-server-types",
"reth-rpc-types", "reth-rpc-types",
"reth-rpc-types-compat", "reth-rpc-types-compat",
"reth-storage-api",
"reth-tasks", "reth-tasks",
"reth-transaction-pool", "reth-transaction-pool",
"reth-trie", "reth-trie",
@ -8755,6 +8757,7 @@ dependencies = [
"proptest", "proptest",
"proptest-arbitrary-interop", "proptest-arbitrary-interop",
"rand 0.8.5", "rand 0.8.5",
"reth-chain-state",
"reth-chainspec", "reth-chainspec",
"reth-eth-wire-types", "reth-eth-wire-types",
"reth-execution-types", "reth-execution-types",
@ -8762,6 +8765,7 @@ dependencies = [
"reth-metrics", "reth-metrics",
"reth-primitives", "reth-primitives",
"reth-provider", "reth-provider",
"reth-storage-api",
"reth-tasks", "reth-tasks",
"reth-tracing", "reth-tracing",
"revm", "revm",

View File

@ -29,6 +29,7 @@ op-alloy-rpc-types = { workspace = true, optional = true }
# misc # misc
auto_impl.workspace = true
once_cell.workspace = true once_cell.workspace = true
serde = { workspace = true, optional = true } serde = { workspace = true, optional = true }
serde_json.workspace = true serde_json.workspace = true

View File

@ -12,8 +12,8 @@
pub use alloy_chains::{Chain, ChainKind, NamedChain}; pub use alloy_chains::{Chain, ChainKind, NamedChain};
pub use info::ChainInfo; pub use info::ChainInfo;
pub use spec::{ pub use spec::{
BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, DepositContract, BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, ChainSpecProvider,
ForkBaseFeeParams, DEV, HOLESKY, MAINNET, SEPOLIA, DepositContract, ForkBaseFeeParams, DEV, HOLESKY, MAINNET, SEPOLIA,
}; };
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
pub use spec::{BASE_MAINNET, BASE_SEPOLIA, OP_MAINNET, OP_SEPOLIA}; pub use spec::{BASE_MAINNET, BASE_SEPOLIA, OP_MAINNET, OP_SEPOLIA};

View File

@ -808,6 +808,13 @@ impl From<Genesis> for ChainSpec {
} }
} }
/// A trait for reading the current [`ChainSpec`].
#[auto_impl::auto_impl(&, Arc)]
pub trait ChainSpecProvider: Send + Sync {
/// Get an [`Arc`] to the [`ChainSpec`].
fn chain_spec(&self) -> Arc<ChainSpec>;
}
/// A helper to build custom chain specs /// A helper to build custom chain specs
#[derive(Debug, Default, Clone)] #[derive(Debug, Default, Clone)]
pub struct ChainSpecBuilder { pub struct ChainSpecBuilder {

View File

@ -13,12 +13,13 @@ workspace = true
[dependencies] [dependencies]
reth-chainspec.workspace = true reth-chainspec.workspace = true
reth-chain-state.workspace = true
reth-errors.workspace = true reth-errors.workspace = true
reth-evm.workspace = true reth-evm.workspace = true
reth-execution-types.workspace = true reth-execution-types.workspace = true
reth-metrics.workspace = true reth-metrics.workspace = true
reth-primitives = { workspace = true, features = ["secp256k1"] } reth-primitives = { workspace = true, features = ["secp256k1"] }
reth-provider.workspace = true reth-storage-api.workspace = true
reth-revm.workspace = true reth-revm.workspace = true
reth-rpc-server-types.workspace = true reth-rpc-server-types.workspace = true
reth-rpc-types.workspace = true reth-rpc-types.workspace = true

View File

@ -1,6 +1,8 @@
//! Context required for building `eth` namespace APIs. //! Context required for building `eth` namespace APIs.
use reth_provider::{BlockReaderIdExt, CanonStateSubscriptions, ChainSpecProvider}; use reth_chain_state::CanonStateSubscriptions;
use reth_chainspec::ChainSpecProvider;
use reth_storage_api::BlockReaderIdExt;
use reth_tasks::TaskSpawner; use reth_tasks::TaskSpawner;
use crate::{ use crate::{

View File

@ -4,8 +4,8 @@
use reth_errors::ProviderResult; use reth_errors::ProviderResult;
use reth_primitives::{Address, B256, U256}; use reth_primitives::{Address, B256, U256};
use reth_provider::StateProvider;
use reth_revm::{database::StateProviderDatabase, db::CacheDB, DatabaseRef}; use reth_revm::{database::StateProviderDatabase, db::CacheDB, DatabaseRef};
use reth_storage_api::StateProvider;
use reth_trie::HashedStorage; use reth_trie::HashedStorage;
use revm::Database; use revm::Database;
@ -17,7 +17,7 @@ pub type StateCacheDb<'a> = CacheDB<StateProviderDatabase<StateProviderTraitObjW
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct StateProviderTraitObjWrapper<'a>(pub &'a dyn StateProvider); pub struct StateProviderTraitObjWrapper<'a>(pub &'a dyn StateProvider);
impl<'a> reth_provider::StateRootProvider for StateProviderTraitObjWrapper<'a> { impl<'a> reth_storage_api::StateRootProvider for StateProviderTraitObjWrapper<'a> {
fn hashed_state_root( fn hashed_state_root(
&self, &self,
hashed_state: reth_trie::HashedPostState, hashed_state: reth_trie::HashedPostState,
@ -41,7 +41,7 @@ impl<'a> reth_provider::StateRootProvider for StateProviderTraitObjWrapper<'a> {
} }
} }
impl<'a> reth_provider::StateProofProvider for StateProviderTraitObjWrapper<'a> { impl<'a> reth_storage_api::StateProofProvider for StateProviderTraitObjWrapper<'a> {
fn hashed_proof( fn hashed_proof(
&self, &self,
hashed_state: reth_trie::HashedPostState, hashed_state: reth_trie::HashedPostState,
@ -60,7 +60,7 @@ impl<'a> reth_provider::StateProofProvider for StateProviderTraitObjWrapper<'a>
} }
} }
impl<'a> reth_provider::AccountReader for StateProviderTraitObjWrapper<'a> { impl<'a> reth_storage_api::AccountReader for StateProviderTraitObjWrapper<'a> {
fn basic_account( fn basic_account(
&self, &self,
address: revm_primitives::Address, address: revm_primitives::Address,
@ -69,7 +69,7 @@ impl<'a> reth_provider::AccountReader for StateProviderTraitObjWrapper<'a> {
} }
} }
impl<'a> reth_provider::BlockHashReader for StateProviderTraitObjWrapper<'a> { impl<'a> reth_storage_api::BlockHashReader for StateProviderTraitObjWrapper<'a> {
fn block_hash( fn block_hash(
&self, &self,
block_number: reth_primitives::BlockNumber, block_number: reth_primitives::BlockNumber,

View File

@ -1,16 +1,15 @@
//! Async caching support for eth RPC //! Async caching support for eth RPC
use futures::{future::Either, Stream, StreamExt}; use futures::{future::Either, Stream, StreamExt};
use reth_chain_state::CanonStateNotification;
use reth_errors::{ProviderError, ProviderResult}; use reth_errors::{ProviderError, ProviderResult};
use reth_evm::ConfigureEvm; use reth_evm::{provider::EvmEnvProvider, ConfigureEvm};
use reth_execution_types::Chain; use reth_execution_types::Chain;
use reth_primitives::{ use reth_primitives::{
Block, BlockHashOrNumber, BlockWithSenders, Receipt, SealedBlock, SealedBlockWithSenders, Block, BlockHashOrNumber, BlockWithSenders, Receipt, SealedBlock, SealedBlockWithSenders,
TransactionSigned, TransactionSignedEcRecovered, B256, TransactionSigned, TransactionSignedEcRecovered, B256,
}; };
use reth_provider::{ use reth_storage_api::{BlockReader, StateProviderFactory, TransactionVariant};
BlockReader, CanonStateNotification, EvmEnvProvider, StateProviderFactory, TransactionVariant,
};
use reth_tasks::{TaskSpawner, TokioTaskExecutor}; use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use revm::primitives::{BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, SpecId}; use revm::primitives::{BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, SpecId};
use schnellru::{ByLength, Limiter}; use schnellru::{ByLength, Limiter};
@ -265,10 +264,11 @@ impl EthStateCache {
/// A task than manages caches for data required by the `eth` rpc implementation. /// A task than manages caches for data required by the `eth` rpc implementation.
/// ///
/// It provides a caching layer on top of the given [`StateProvider`](reth_provider::StateProvider) /// It provides a caching layer on top of the given
/// and keeps data fetched via the provider in memory in an LRU cache. If the requested data is /// [`StateProvider`](reth_storage_api::StateProvider) and keeps data fetched via the provider in
/// missing in the cache it is fetched and inserted into the cache afterwards. While fetching data /// memory in an LRU cache. If the requested data is missing in the cache it is fetched and inserted
/// from disk is sync, this service is async since requests and data is shared via channels. /// into the cache afterwards. While fetching data from disk is sync, this service is async since
/// requests and data is shared via channels.
/// ///
/// This type is an endless future that listens for incoming messages from the user facing /// This type is an endless future that listens for incoming messages from the user facing
/// [`EthStateCache`] via a channel. If the requested data is not cached then it spawns a new task /// [`EthStateCache`] via a channel. If the requested data is not cached then it spawns a new task

View File

@ -11,14 +11,15 @@ use futures::{
FutureExt, Stream, StreamExt, FutureExt, Stream, StreamExt,
}; };
use metrics::atomics::AtomicU64; use metrics::atomics::AtomicU64;
use reth_chainspec::ChainSpec; use reth_chain_state::CanonStateNotification;
use reth_chainspec::{ChainSpec, ChainSpecProvider};
use reth_primitives::{ use reth_primitives::{
basefee::calc_next_block_base_fee, basefee::calc_next_block_base_fee,
eip4844::{calc_blob_gasprice, calculate_excess_blob_gas}, eip4844::{calc_blob_gasprice, calculate_excess_blob_gas},
Receipt, SealedBlock, TransactionSigned, B256, Receipt, SealedBlock, TransactionSigned, B256,
}; };
use reth_provider::{BlockReaderIdExt, CanonStateNotification, ChainSpecProvider};
use reth_rpc_types::TxGasAndReward; use reth_rpc_types::TxGasAndReward;
use reth_storage_api::BlockReaderIdExt;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::trace; use tracing::trace;

View File

@ -5,8 +5,8 @@ use std::fmt::{self, Debug, Formatter};
use derive_more::{Deref, DerefMut, From, Into}; use derive_more::{Deref, DerefMut, From, Into};
use reth_primitives::{constants::GWEI_TO_WEI, BlockNumberOrTag, B256, U256}; use reth_primitives::{constants::GWEI_TO_WEI, BlockNumberOrTag, B256, U256};
use reth_provider::BlockReaderIdExt;
use reth_rpc_server_types::constants; use reth_rpc_server_types::constants;
use reth_storage_api::BlockReaderIdExt;
use schnellru::{ByLength, LruMap}; use schnellru::{ByLength, LruMap};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::sync::Mutex; use tokio::sync::Mutex;

View File

@ -3,10 +3,11 @@
//! Log parsing for building filter. //! Log parsing for building filter.
use reth_chainspec::ChainInfo; use reth_chainspec::ChainInfo;
use reth_errors::ProviderError;
use reth_primitives::{BlockNumHash, Receipt, TxHash}; use reth_primitives::{BlockNumHash, Receipt, TxHash};
use reth_provider::{BlockReader, ProviderError};
use reth_rpc_server_types::result::rpc_error_with_code; use reth_rpc_server_types::result::rpc_error_with_code;
use reth_rpc_types::{FilterId, FilteredParams, Log}; use reth_rpc_types::{FilterId, FilteredParams, Log};
use reth_storage_api::BlockReader;
use crate::EthApiError; use crate::EthApiError;

View File

@ -7,8 +7,8 @@ use std::{fmt, time::Instant};
use derive_more::Constructor; use derive_more::Constructor;
use reth_chainspec::ChainSpec; use reth_chainspec::ChainSpec;
use reth_primitives::{BlockId, BlockNumberOrTag, SealedBlockWithSenders, SealedHeader, B256}; use reth_primitives::{BlockId, BlockNumberOrTag, SealedBlockWithSenders, SealedHeader, B256};
use reth_provider::ProviderError;
use reth_revm::state_change::apply_blockhashes_update; use reth_revm::state_change::apply_blockhashes_update;
use reth_storage_api::errors::provider::ProviderError;
use revm_primitives::{ use revm_primitives::{
db::{Database, DatabaseCommit}, db::{Database, DatabaseCommit},
BlockEnv, CfgEnvWithHandlerCfg, BlockEnv, CfgEnvWithHandlerCfg,

View File

@ -18,8 +18,7 @@ pub use header_sync_gap::{HeaderSyncGap, HeaderSyncGapProvider};
mod state; mod state;
pub use state::{StateChangeWriter, StateWriter}; pub use state::{StateChangeWriter, StateWriter};
mod spec; pub use reth_chainspec::ChainSpecProvider;
pub use spec::ChainSpecProvider;
mod hashing; mod hashing;
pub use hashing::HashingWriter; pub use hashing::HashingWriter;

View File

@ -1,9 +0,0 @@
use reth_chainspec::ChainSpec;
use std::sync::Arc;
/// A trait for reading the current chainspec.
#[auto_impl::auto_impl(&, Arc)]
pub trait ChainSpecProvider: Send + Sync {
/// Get an [`Arc`] to the chainspec.
fn chain_spec(&self) -> Arc<ChainSpec>;
}

View File

@ -13,12 +13,13 @@ workspace = true
[dependencies] [dependencies]
# reth # reth
reth-chain-state.workspace = true
reth-chainspec.workspace = true reth-chainspec.workspace = true
reth-eth-wire-types.workspace = true reth-eth-wire-types.workspace = true
reth-primitives = { workspace = true, features = ["c-kzg", "secp256k1"] } reth-primitives = { workspace = true, features = ["c-kzg", "secp256k1"] }
reth-execution-types.workspace = true reth-execution-types.workspace = true
reth-fs-util.workspace = true reth-fs-util.workspace = true
reth-provider.workspace = true reth-storage-api.workspace = true
reth-tasks.workspace = true reth-tasks.workspace = true
revm.workspace = true revm.workspace = true

View File

@ -1,7 +1,7 @@
//! Support for maintaining the blob pool. //! Support for maintaining the blob pool.
use reth_execution_types::ChainBlocks;
use reth_primitives::{BlockNumber, B256}; use reth_primitives::{BlockNumber, B256};
use reth_provider::ChainBlocks;
use std::collections::BTreeMap; use std::collections::BTreeMap;
/// The type that is used to track canonical blob transactions. /// The type that is used to track canonical blob transactions.

View File

@ -79,8 +79,8 @@
//! Listen for new transactions and print them: //! Listen for new transactions and print them:
//! //!
//! ``` //! ```
//! use reth_chainspec::MAINNET; //! use reth_chainspec::{MAINNET, ChainSpecProvider};
//! use reth_provider::{BlockReaderIdExt, ChainSpecProvider, StateProviderFactory}; //! use reth_storage_api::{BlockReaderIdExt, StateProviderFactory};
//! use reth_tasks::TokioTaskExecutor; //! use reth_tasks::TokioTaskExecutor;
//! use reth_transaction_pool::{TransactionValidationTaskExecutor, Pool, TransactionPool}; //! use reth_transaction_pool::{TransactionValidationTaskExecutor, Pool, TransactionPool};
//! use reth_transaction_pool::blobstore::InMemoryBlobStore; //! use reth_transaction_pool::blobstore::InMemoryBlobStore;
@ -107,8 +107,9 @@
//! //!
//! ``` //! ```
//! use futures_util::Stream; //! use futures_util::Stream;
//! use reth_chainspec::MAINNET; //! use reth_chain_state::CanonStateNotification;
//! use reth_provider::{BlockReaderIdExt, CanonStateNotification, ChainSpecProvider, StateProviderFactory}; //! use reth_chainspec::{MAINNET, ChainSpecProvider};
//! use reth_storage_api::{BlockReaderIdExt, StateProviderFactory};
//! use reth_tasks::TokioTaskExecutor; //! use reth_tasks::TokioTaskExecutor;
//! use reth_tasks::TaskSpawner; //! use reth_tasks::TaskSpawner;
//! use reth_tasks::TaskManager; //! use reth_tasks::TaskManager;
@ -153,7 +154,7 @@ use crate::{identifier::TransactionId, pool::PoolInner};
use aquamarine as _; use aquamarine as _;
use reth_eth_wire_types::HandleMempoolData; use reth_eth_wire_types::HandleMempoolData;
use reth_primitives::{Address, BlobTransactionSidecar, PooledTransactionsElement, TxHash, U256}; use reth_primitives::{Address, BlobTransactionSidecar, PooledTransactionsElement, TxHash, U256};
use reth_provider::StateProviderFactory; use reth_storage_api::StateProviderFactory;
use std::{collections::HashSet, sync::Arc}; use std::{collections::HashSet, sync::Arc};
use tokio::sync::mpsc::Receiver; use tokio::sync::mpsc::Receiver;
use tracing::{instrument, trace}; use tracing::{instrument, trace};
@ -275,7 +276,7 @@ where
impl<Client, S> EthTransactionPool<Client, S> impl<Client, S> EthTransactionPool<Client, S>
where where
Client: StateProviderFactory + reth_provider::BlockReaderIdExt + Clone + 'static, Client: StateProviderFactory + reth_storage_api::BlockReaderIdExt + Clone + 'static,
S: BlobStore, S: BlobStore,
{ {
/// Returns a new [`Pool`] that uses the default [`TransactionValidationTaskExecutor`] when /// Returns a new [`Pool`] that uses the default [`TransactionValidationTaskExecutor`] when
@ -285,7 +286,7 @@ where
/// ///
/// ``` /// ```
/// use reth_chainspec::MAINNET; /// use reth_chainspec::MAINNET;
/// use reth_provider::{BlockReaderIdExt, StateProviderFactory}; /// use reth_storage_api::{BlockReaderIdExt, StateProviderFactory};
/// use reth_tasks::TokioTaskExecutor; /// use reth_tasks::TokioTaskExecutor;
/// use reth_transaction_pool::{ /// use reth_transaction_pool::{
/// blobstore::InMemoryBlobStore, Pool, TransactionValidationTaskExecutor, /// blobstore::InMemoryBlobStore, Pool, TransactionValidationTaskExecutor,

View File

@ -11,16 +11,15 @@ use futures_util::{
future::{BoxFuture, Fuse, FusedFuture}, future::{BoxFuture, Fuse, FusedFuture},
FutureExt, Stream, StreamExt, FutureExt, Stream, StreamExt,
}; };
use reth_chain_state::CanonStateNotification;
use reth_chainspec::ChainSpecProvider;
use reth_execution_types::ExecutionOutcome; use reth_execution_types::ExecutionOutcome;
use reth_fs_util::FsPathError; use reth_fs_util::FsPathError;
use reth_primitives::{ use reth_primitives::{
Address, BlockHash, BlockNumber, BlockNumberOrTag, IntoRecoveredTransaction, Address, BlockHash, BlockNumber, BlockNumberOrTag, IntoRecoveredTransaction,
PooledTransactionsElementEcRecovered, TransactionSigned, PooledTransactionsElementEcRecovered, TransactionSigned,
}; };
use reth_provider::{ use reth_storage_api::{errors::provider::ProviderError, BlockReaderIdExt, StateProviderFactory};
BlockReaderIdExt, CanonStateNotification, ChainSpecProvider, ProviderError,
StateProviderFactory,
};
use reth_tasks::TaskSpawner; use reth_tasks::TaskSpawner;
use std::{ use std::{
borrow::Borrow, borrow::Borrow,

View File

@ -15,7 +15,7 @@ use reth_primitives::{
EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID,
LEGACY_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
}; };
use reth_provider::{AccountReader, BlockReaderIdExt, StateProviderFactory}; use reth_storage_api::{AccountReader, BlockReaderIdExt, StateProviderFactory};
use reth_tasks::TaskSpawner; use reth_tasks::TaskSpawner;
use revm::{ use revm::{
interpreter::gas::validate_initial_tx_gas, interpreter::gas::validate_initial_tx_gas,

View File

@ -9,7 +9,7 @@ use crate::{
use futures_util::{lock::Mutex, StreamExt}; use futures_util::{lock::Mutex, StreamExt};
use reth_chainspec::ChainSpec; use reth_chainspec::ChainSpec;
use reth_primitives::SealedBlock; use reth_primitives::SealedBlock;
use reth_provider::BlockReaderIdExt; use reth_storage_api::BlockReaderIdExt;
use reth_tasks::TaskSpawner; use reth_tasks::TaskSpawner;
use std::{future::Future, pin::Pin, sync::Arc}; use std::{future::Future, pin::Pin, sync::Arc};
use tokio::{ use tokio::{