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

Remove reth-provider dependency for reth-eth-types #12

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 5 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions crates/chainspec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ op-alloy-rpc-types = { workspace = true, optional = true }


# misc
auto_impl.workspace = true
once_cell.workspace = true
serde = { workspace = true, optional = true }
serde_json.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
pub use alloy_chains::{Chain, ChainKind, NamedChain};
pub use info::ChainInfo;
pub use spec::{
BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, DepositContract,
ForkBaseFeeParams, DEV, HOLESKY, MAINNET, SEPOLIA,
BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, ChainSpecProvider,
DepositContract, ForkBaseFeeParams, DEV, HOLESKY, MAINNET, SEPOLIA,
};
#[cfg(feature = "optimism")]
pub use spec::{BASE_MAINNET, BASE_SEPOLIA, OP_MAINNET, OP_SEPOLIA};
Expand Down
7 changes: 7 additions & 0 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
#[derive(Debug, Default, Clone)]
pub struct ChainSpecBuilder {
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-eth-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ workspace = true

[dependencies]
reth-chainspec.workspace = true
reth-chain-state.workspace = true
reth-errors.workspace = true
reth-evm.workspace = true
reth-execution-types.workspace = true
reth-metrics.workspace = true
reth-primitives = { workspace = true, features = ["secp256k1"] }
reth-provider.workspace = true
reth-storage-api.workspace = true
reth-revm.workspace = true
reth-rpc-server-types.workspace = true
reth-rpc-types.workspace = true
Expand Down
4 changes: 3 additions & 1 deletion crates/rpc/rpc-eth-types/src/builder/ctx.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! 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 crate::{
Expand Down
10 changes: 5 additions & 5 deletions crates/rpc/rpc-eth-types/src/cache/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use reth_errors::ProviderResult;
use reth_primitives::{Address, B256, U256};
use reth_provider::StateProvider;
use reth_revm::{database::StateProviderDatabase, db::CacheDB, DatabaseRef};
use reth_storage_api::StateProvider;
use reth_trie::HashedStorage;
use revm::Database;

Expand All @@ -17,7 +17,7 @@ pub type StateCacheDb<'a> = CacheDB<StateProviderDatabase<StateProviderTraitObjW
#[allow(missing_debug_implementations)]
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(
&self,
hashed_state: reth_trie::HashedPostState,
Expand All @@ -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(
&self,
hashed_state: reth_trie::HashedPostState,
Expand All @@ -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(
&self,
address: revm_primitives::Address,
Expand All @@ -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(
&self,
block_number: reth_primitives::BlockNumber,
Expand Down
16 changes: 8 additions & 8 deletions crates/rpc/rpc-eth-types/src/cache/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
//! Async caching support for eth RPC

use futures::{future::Either, Stream, StreamExt};
use reth_chain_state::CanonStateNotification;
use reth_errors::{ProviderError, ProviderResult};
use reth_evm::ConfigureEvm;
use reth_evm::{provider::EvmEnvProvider, ConfigureEvm};
use reth_execution_types::Chain;
use reth_primitives::{
Block, BlockHashOrNumber, BlockWithSenders, Receipt, SealedBlock, SealedBlockWithSenders,
TransactionSigned, TransactionSignedEcRecovered, B256,
};
use reth_provider::{
BlockReader, CanonStateNotification, EvmEnvProvider, StateProviderFactory, TransactionVariant,
};
use reth_storage_api::{BlockReader, StateProviderFactory, TransactionVariant};
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use revm::primitives::{BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, SpecId};
use schnellru::{ByLength, Limiter};
Expand Down Expand Up @@ -265,10 +264,11 @@ impl EthStateCache {

/// 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)
/// and keeps data fetched via the provider in memory in an LRU cache. If the requested data is
/// missing in the cache it is fetched and inserted into the cache afterwards. While fetching data
/// from disk is sync, this service is async since requests and data is shared via channels.
/// It provides a caching layer on top of the given
/// [`StateProvider`](reth_storage_api::StateProvider) and keeps data fetched via the provider in
/// memory in an LRU cache. If the requested data is missing in the cache it is fetched and inserted
/// 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
/// [`EthStateCache`] via a channel. If the requested data is not cached then it spawns a new task
Expand Down
5 changes: 3 additions & 2 deletions crates/rpc/rpc-eth-types/src/fee_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ use futures::{
FutureExt, Stream, StreamExt,
};
use metrics::atomics::AtomicU64;
use reth_chainspec::ChainSpec;
use reth_chain_state::CanonStateNotification;
use reth_chainspec::{ChainSpec, ChainSpecProvider};
use reth_primitives::{
basefee::calc_next_block_base_fee,
eip4844::{calc_blob_gasprice, calculate_excess_blob_gas},
Receipt, SealedBlock, TransactionSigned, B256,
};
use reth_provider::{BlockReaderIdExt, CanonStateNotification, ChainSpecProvider};
use reth_rpc_types::TxGasAndReward;
use reth_storage_api::BlockReaderIdExt;
use serde::{Deserialize, Serialize};
use tracing::trace;

Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-eth-types/src/gas_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::fmt::{self, Debug, Formatter};

use derive_more::{Deref, DerefMut, From, Into};
use reth_primitives::{constants::GWEI_TO_WEI, BlockNumberOrTag, B256, U256};
use reth_provider::BlockReaderIdExt;
use reth_rpc_server_types::constants;
use reth_storage_api::BlockReaderIdExt;
use schnellru::{ByLength, LruMap};
use serde::{Deserialize, Serialize};
use tokio::sync::Mutex;
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-eth-types/src/logs_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
//! Log parsing for building filter.

use reth_chainspec::ChainInfo;
use reth_errors::ProviderError;
use reth_primitives::{BlockNumHash, Receipt, TxHash};
use reth_provider::{BlockReader, ProviderError};
use reth_rpc_server_types::result::rpc_error_with_code;
use reth_rpc_types::{FilterId, FilteredParams, Log};
use reth_storage_api::BlockReader;

use crate::EthApiError;

Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-eth-types/src/pending_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::{fmt, time::Instant};
use derive_more::Constructor;
use reth_chainspec::ChainSpec;
use reth_primitives::{BlockId, BlockNumberOrTag, SealedBlockWithSenders, SealedHeader, B256};
use reth_provider::ProviderError;
use reth_revm::state_change::apply_blockhashes_update;
use reth_storage_api::errors::provider::ProviderError;
use revm_primitives::{
db::{Database, DatabaseCommit},
BlockEnv, CfgEnvWithHandlerCfg,
Expand Down
3 changes: 1 addition & 2 deletions crates/storage/provider/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ pub use header_sync_gap::{HeaderSyncGap, HeaderSyncGapProvider};
mod state;
pub use state::{StateChangeWriter, StateWriter};

mod spec;
pub use spec::ChainSpecProvider;
pub use reth_chainspec::ChainSpecProvider;

mod hashing;
pub use hashing::HashingWriter;
Expand Down
9 changes: 0 additions & 9 deletions crates/storage/provider/src/traits/spec.rs

This file was deleted.

3 changes: 2 additions & 1 deletion crates/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ workspace = true

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

Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/blobstore/tracker.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Support for maintaining the blob pool.

use reth_execution_types::ChainBlocks;
use reth_primitives::{BlockNumber, B256};
use reth_provider::ChainBlocks;
use std::collections::BTreeMap;

/// The type that is used to track canonical blob transactions.
Expand Down
15 changes: 8 additions & 7 deletions crates/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
//! Listen for new transactions and print them:
//!
//! ```
//! use reth_chainspec::MAINNET;
//! use reth_provider::{BlockReaderIdExt, ChainSpecProvider, StateProviderFactory};
//! use reth_chainspec::{MAINNET, ChainSpecProvider};
//! use reth_storage_api::{BlockReaderIdExt, StateProviderFactory};
//! use reth_tasks::TokioTaskExecutor;
//! use reth_transaction_pool::{TransactionValidationTaskExecutor, Pool, TransactionPool};
//! use reth_transaction_pool::blobstore::InMemoryBlobStore;
Expand All @@ -107,8 +107,9 @@
//!
//! ```
//! use futures_util::Stream;
//! use reth_chainspec::MAINNET;
//! use reth_provider::{BlockReaderIdExt, CanonStateNotification, ChainSpecProvider, StateProviderFactory};
//! use reth_chain_state::CanonStateNotification;
//! use reth_chainspec::{MAINNET, ChainSpecProvider};
//! use reth_storage_api::{BlockReaderIdExt, StateProviderFactory};
//! use reth_tasks::TokioTaskExecutor;
//! use reth_tasks::TaskSpawner;
//! use reth_tasks::TaskManager;
Expand Down Expand Up @@ -153,7 +154,7 @@ use crate::{identifier::TransactionId, pool::PoolInner};
use aquamarine as _;
use reth_eth_wire_types::HandleMempoolData;
use reth_primitives::{Address, BlobTransactionSidecar, PooledTransactionsElement, TxHash, U256};
use reth_provider::StateProviderFactory;
use reth_storage_api::StateProviderFactory;
use std::{collections::HashSet, sync::Arc};
use tokio::sync::mpsc::Receiver;
use tracing::{instrument, trace};
Expand Down Expand Up @@ -275,7 +276,7 @@ where

impl<Client, S> EthTransactionPool<Client, S>
where
Client: StateProviderFactory + reth_provider::BlockReaderIdExt + Clone + 'static,
Client: StateProviderFactory + reth_storage_api::BlockReaderIdExt + Clone + 'static,
S: BlobStore,
{
/// Returns a new [`Pool`] that uses the default [`TransactionValidationTaskExecutor`] when
Expand All @@ -285,7 +286,7 @@ where
///
/// ```
/// use reth_chainspec::MAINNET;
/// use reth_provider::{BlockReaderIdExt, StateProviderFactory};
/// use reth_storage_api::{BlockReaderIdExt, StateProviderFactory};
/// use reth_tasks::TokioTaskExecutor;
/// use reth_transaction_pool::{
/// blobstore::InMemoryBlobStore, Pool, TransactionValidationTaskExecutor,
Expand Down
7 changes: 3 additions & 4 deletions crates/transaction-pool/src/maintain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ use futures_util::{
future::{BoxFuture, Fuse, FusedFuture},
FutureExt, Stream, StreamExt,
};
use reth_chain_state::CanonStateNotification;
use reth_chainspec::ChainSpecProvider;
use reth_execution_types::ExecutionOutcome;
use reth_fs_util::FsPathError;
use reth_primitives::{
Address, BlockHash, BlockNumber, BlockNumberOrTag, IntoRecoveredTransaction,
PooledTransactionsElementEcRecovered, TransactionSigned,
};
use reth_provider::{
BlockReaderIdExt, CanonStateNotification, ChainSpecProvider, ProviderError,
StateProviderFactory,
};
use reth_storage_api::{errors::provider::ProviderError, BlockReaderIdExt, StateProviderFactory};
use reth_tasks::TaskSpawner;
use std::{
borrow::Borrow,
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use reth_primitives::{
EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_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 revm::{
interpreter::gas::validate_initial_tx_gas,
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/validate/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
use futures_util::{lock::Mutex, StreamExt};
use reth_chainspec::ChainSpec;
use reth_primitives::SealedBlock;
use reth_provider::BlockReaderIdExt;
use reth_storage_api::BlockReaderIdExt;
use reth_tasks::TaskSpawner;
use std::{future::Future, pin::Pin, sync::Arc};
use tokio::{
Expand Down
Loading