feat(storage): add rocksdb provider into database provider (#20253)

This commit is contained in:
ligt
2025-12-15 17:15:57 +07:00
committed by GitHub
parent 997848c2a1
commit 662c0486a1
60 changed files with 564 additions and 64 deletions

View File

@@ -23,7 +23,7 @@ use reth_node_core::{
dirs::{ChainPath, DataDirPath},
};
use reth_provider::{
providers::{BlockchainProvider, NodeTypesForProvider, StaticFileProvider},
providers::{BlockchainProvider, NodeTypesForProvider, RocksDBProvider, StaticFileProvider},
ProviderFactory, StaticFileProviderFactory,
};
use reth_stages::{sets::DefaultStages, Pipeline, PipelineTarget};
@@ -75,10 +75,12 @@ impl<C: ChainSpecParser> EnvironmentArgs<C> {
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain());
let db_path = data_dir.db();
let sf_path = data_dir.static_files();
let rocksdb_path = data_dir.rocksdb();
if access.is_read_write() {
reth_fs_util::create_dir_all(&db_path)?;
reth_fs_util::create_dir_all(&sf_path)?;
reth_fs_util::create_dir_all(&rocksdb_path)?;
}
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config());
@@ -108,8 +110,13 @@ impl<C: ChainSpecParser> EnvironmentArgs<C> {
StaticFileProvider::read_only(sf_path, false)?,
),
};
// TransactionDB only support read-write mode
let rocksdb_provider = RocksDBProvider::builder(data_dir.rocksdb())
.with_database_log_level(self.db.log_level)
.build()?;
let provider_factory = self.create_provider_factory(&config, db, sfp, access)?;
let provider_factory =
self.create_provider_factory(&config, db, sfp, rocksdb_provider, access)?;
if access.is_read_write() {
debug!(target: "reth::cli", chain=%self.chain.chain(), genesis=?self.chain.genesis_hash(), "Initializing genesis");
init_genesis_with_settings(&provider_factory, self.static_files.to_settings())?;
@@ -128,6 +135,7 @@ impl<C: ChainSpecParser> EnvironmentArgs<C> {
config: &Config,
db: Arc<DatabaseEnv>,
static_file_provider: StaticFileProvider<N::Primitives>,
rocksdb_provider: RocksDBProvider,
access: AccessRights,
) -> eyre::Result<ProviderFactory<NodeTypesWithDBAdapter<N, Arc<DatabaseEnv>>>>
where
@@ -138,6 +146,7 @@ impl<C: ChainSpecParser> EnvironmentArgs<C> {
db,
self.chain.clone(),
static_file_provider,
rocksdb_provider,
)?
.with_prune_modes(prune_modes.clone());

View File

@@ -9,7 +9,7 @@ use reth_evm::ConfigureEvm;
use reth_node_builder::NodeTypesWithDB;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_provider::{
providers::{ProviderNodeTypes, StaticFileProvider},
providers::{ProviderNodeTypes, RocksDBProvider, StaticFileProvider},
DatabaseProviderFactory, ProviderFactory,
};
use reth_stages::{stages::ExecutionStage, Stage, StageCheckpoint, UnwindInput};
@@ -42,6 +42,7 @@ where
Arc::new(output_db),
db_tool.chain(),
StaticFileProvider::read_write(output_datadir.static_files())?,
RocksDBProvider::builder(output_datadir.rocksdb()).build()?,
)?,
to,
from,

View File

@@ -6,7 +6,7 @@ use reth_db_api::{database::Database, table::TableImporter, tables};
use reth_db_common::DbTool;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_provider::{
providers::{ProviderNodeTypes, StaticFileProvider},
providers::{ProviderNodeTypes, RocksDBProvider, StaticFileProvider},
DatabaseProviderFactory, ProviderFactory,
};
use reth_stages::{stages::AccountHashingStage, Stage, StageCheckpoint, UnwindInput};
@@ -39,6 +39,7 @@ pub(crate) async fn dump_hashing_account_stage<N: ProviderNodeTypes<DB = Arc<Dat
Arc::new(output_db),
db_tool.chain(),
StaticFileProvider::read_write(output_datadir.static_files())?,
RocksDBProvider::builder(output_datadir.rocksdb()).build()?,
)?,
to,
from,

View File

@@ -5,7 +5,7 @@ use reth_db_api::{database::Database, table::TableImporter, tables};
use reth_db_common::DbTool;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_provider::{
providers::{ProviderNodeTypes, StaticFileProvider},
providers::{ProviderNodeTypes, RocksDBProvider, StaticFileProvider},
DatabaseProviderFactory, ProviderFactory,
};
use reth_stages::{stages::StorageHashingStage, Stage, StageCheckpoint, UnwindInput};
@@ -29,6 +29,7 @@ pub(crate) async fn dump_hashing_storage_stage<N: ProviderNodeTypes<DB = Arc<Dat
Arc::new(output_db),
db_tool.chain(),
StaticFileProvider::read_write(output_datadir.static_files())?,
RocksDBProvider::builder(output_datadir.rocksdb()).build()?,
)?,
to,
from,

View File

@@ -12,7 +12,7 @@ use reth_evm::ConfigureEvm;
use reth_exex::ExExManagerHandle;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_provider::{
providers::{ProviderNodeTypes, StaticFileProvider},
providers::{ProviderNodeTypes, RocksDBProvider, StaticFileProvider},
DatabaseProviderFactory, ProviderFactory,
};
use reth_stages::{
@@ -62,6 +62,7 @@ where
Arc::new(output_db),
db_tool.chain(),
StaticFileProvider::read_write(output_datadir.static_files())?,
RocksDBProvider::builder(output_datadir.rocksdb()).build()?,
)?,
to,
from,

View File

@@ -110,6 +110,7 @@ pub async fn setup_engine_with_chain_import(
// Create database path and static files path
let db_path = datadir.join("db");
let static_files_path = datadir.join("static_files");
let rocksdb_dir_path = datadir.join("rocksdb");
// Initialize the database using init_db (same as CLI import command)
// Use the same database arguments as the node will use
@@ -125,6 +126,7 @@ pub async fn setup_engine_with_chain_import(
db.clone(),
chain_spec.clone(),
reth_provider::providers::StaticFileProvider::read_write(static_files_path.clone())?,
reth_provider::providers::RocksDBProvider::builder(rocksdb_dir_path).build().unwrap(),
)?;
// Initialize genesis if needed
@@ -311,6 +313,7 @@ mod tests {
std::fs::create_dir_all(&datadir).unwrap();
let db_path = datadir.join("db");
let static_files_path = datadir.join("static_files");
let rocksdb_dir_path = datadir.join("rocksdb");
// Import the chain
{
@@ -324,6 +327,9 @@ mod tests {
chain_spec.clone(),
reth_provider::providers::StaticFileProvider::read_write(static_files_path.clone())
.unwrap(),
reth_provider::providers::RocksDBProvider::builder(rocksdb_dir_path.clone())
.build()
.unwrap(),
)
.expect("failed to create provider factory");
@@ -385,6 +391,9 @@ mod tests {
chain_spec.clone(),
reth_provider::providers::StaticFileProvider::read_only(static_files_path, false)
.unwrap(),
reth_provider::providers::RocksDBProvider::builder(rocksdb_dir_path)
.build()
.unwrap(),
)
.expect("failed to create provider factory");
@@ -472,11 +481,15 @@ mod tests {
// Create static files path
let static_files_path = datadir.join("static_files");
// Create rocksdb path
let rocksdb_dir_path = datadir.join("rocksdb");
// Create a provider factory
let provider_factory: ProviderFactory<MockNodeTypesWithDB> = ProviderFactory::new(
db.clone(),
chain_spec.clone(),
reth_provider::providers::StaticFileProvider::read_write(static_files_path).unwrap(),
reth_provider::providers::RocksDBProvider::builder(rocksdb_dir_path).build().unwrap(),
)
.expect("failed to create provider factory");

View File

@@ -118,13 +118,14 @@ impl EthereumNode {
/// use reth_chainspec::ChainSpecBuilder;
/// use reth_db::open_db_read_only;
/// use reth_node_ethereum::EthereumNode;
/// use reth_provider::providers::StaticFileProvider;
/// use reth_provider::providers::{RocksDBProvider, StaticFileProvider};
/// use std::sync::Arc;
///
/// let factory = EthereumNode::provider_factory_builder()
/// .db(Arc::new(open_db_read_only("db", Default::default()).unwrap()))
/// .chainspec(ChainSpecBuilder::mainnet().build().into())
/// .static_file(StaticFileProvider::read_only("db/static_files", false).unwrap())
/// .rocksdb_provider(RocksDBProvider::builder("db/rocksdb").build().unwrap())
/// .build_provider_factory();
/// ```
pub fn provider_factory_builder() -> ProviderFactoryBuilder<Self> {

View File

@@ -28,6 +28,7 @@ async fn testing_rpc_build_block_works() -> eyre::Result<()> {
datadir: MaybePlatformPath::<DataDirPath>::from_str(tempdir.path().to_str().unwrap())
.expect("valid datadir"),
static_files_path: Some(tempdir.path().join("static")),
rocksdb_path: Some(tempdir.path().join("rocksdb")),
};
let config = NodeConfig::test().with_datadir_args(datadir_args).with_rpc(rpc_args);
let db = create_test_rw_db();

View File

@@ -20,7 +20,9 @@ use futures_util::FutureExt;
use reth_chainspec::{ChainSpec, MAINNET};
use reth_consensus::test_utils::TestConsensus;
use reth_db::{
test_utils::{create_test_rw_db, create_test_static_files_dir, TempDatabase},
test_utils::{
create_test_rocksdb_dir, create_test_rw_db, create_test_static_files_dir, TempDatabase,
},
DatabaseEnv,
};
use reth_db_common::init::init_genesis;
@@ -50,7 +52,7 @@ use reth_node_ethereum::{
use reth_payload_builder::noop::NoopPayloadBuilderService;
use reth_primitives_traits::{Block as _, RecoveredBlock};
use reth_provider::{
providers::{BlockchainProvider, StaticFileProvider},
providers::{BlockchainProvider, RocksDBProvider, StaticFileProvider},
BlockReader, EthStorage, ProviderFactory,
};
use reth_tasks::TaskManager;
@@ -239,11 +241,13 @@ pub async fn test_exex_context_with_chain_spec(
let consensus = Arc::new(TestConsensus::default());
let (static_dir, _) = create_test_static_files_dir();
let (rocksdb_dir, _) = create_test_rocksdb_dir();
let db = create_test_rw_db();
let provider_factory = ProviderFactory::<NodeTypesWithDBAdapter<TestNode, _>>::new(
db,
chain_spec.clone(),
StaticFileProvider::read_write(static_dir.keep()).expect("static file provider"),
RocksDBProvider::builder(rocksdb_dir.keep()).build().unwrap(),
)?;
let genesis_hash = init_genesis(&provider_factory)?;

View File

@@ -65,7 +65,7 @@ use reth_node_metrics::{
version::VersionInfo,
};
use reth_provider::{
providers::{NodeTypesForProvider, ProviderNodeTypes, StaticFileProvider},
providers::{NodeTypesForProvider, ProviderNodeTypes, RocksDBProvider, StaticFileProvider},
BlockHashReader, BlockNumReader, ProviderError, ProviderFactory, ProviderResult,
StageCheckpointReader, StaticFileProviderBuilder, StaticFileProviderFactory,
};
@@ -485,9 +485,19 @@ where
.with_blocks_per_file_for_segments(static_files_config.as_blocks_per_file_map())
.build()?;
let factory =
ProviderFactory::new(self.right().clone(), self.chain_spec(), static_file_provider)?
.with_prune_modes(self.prune_modes());
// Initialize RocksDB provider with metrics and statistics enabled
let rocksdb_provider = RocksDBProvider::builder(self.data_dir().rocksdb())
.with_metrics()
.with_statistics()
.build()?;
let factory = ProviderFactory::new(
self.right().clone(),
self.chain_spec(),
static_file_provider,
rocksdb_provider,
)?
.with_prune_modes(self.prune_modes());
// Check for consistency between database and static files. If it fails, it unwinds to
// the first block that's consistent between database and static files.

View File

@@ -27,6 +27,10 @@ pub struct DatadirArgs {
verbatim_doc_comment
)]
pub static_files_path: Option<PathBuf>,
/// The absolute path to store `RocksDB` database in.
#[arg(long = "datadir.rocksdb", value_name = "PATH", verbatim_doc_comment)]
pub rocksdb_path: Option<PathBuf>,
}
impl DatadirArgs {

View File

@@ -301,6 +301,18 @@ impl<D> ChainPath<D> {
}
}
/// Returns the path to the `RocksDB` database directory for this chain.
///
/// `<DIR>/<CHAIN_ID>/rocksdb`
pub fn rocksdb(&self) -> PathBuf {
let datadir_args = &self.2;
if let Some(rocksdb_path) = &datadir_args.rocksdb_path {
rocksdb_path.clone()
} else {
self.data_dir().join("rocksdb")
}
}
/// Returns the path to the reth p2p secret key for this chain.
///
/// `<DIR>/<CHAIN_ID>/discovery-secret`

View File

@@ -218,13 +218,14 @@ impl OpNode {
/// use reth_db::open_db_read_only;
/// use reth_optimism_chainspec::OpChainSpecBuilder;
/// use reth_optimism_node::OpNode;
/// use reth_provider::providers::StaticFileProvider;
/// use reth_provider::providers::{RocksDBProvider, StaticFileProvider};
/// use std::sync::Arc;
///
/// let factory = OpNode::provider_factory_builder()
/// .db(Arc::new(open_db_read_only("db", Default::default()).unwrap()))
/// .chainspec(OpChainSpecBuilder::base_mainnet().build().into())
/// .static_file(StaticFileProvider::read_only("db/static_files", false).unwrap())
/// .rocksdb_provider(RocksDBProvider::builder("db/rocksdb").build().unwrap())
/// .build_provider_factory();
/// ```
pub fn provider_factory_builder() -> ProviderFactoryBuilder<Self> {

View File

@@ -324,11 +324,13 @@ impl<Provider, S: Stage<Provider> + ?Sized> StageExt<Provider> for S {}
#[cfg(test)]
mod tests {
use reth_chainspec::MAINNET;
use reth_db::test_utils::{create_test_rw_db, create_test_static_files_dir};
use reth_db::test_utils::{
create_test_rocksdb_dir, create_test_rw_db, create_test_static_files_dir,
};
use reth_db_api::{models::StoredBlockBodyIndices, tables, transaction::DbTxMut};
use reth_provider::{
test_utils::MockNodeTypesWithDB, ProviderFactory, StaticFileProviderBuilder,
StaticFileProviderFactory, StaticFileSegment,
providers::RocksDBProvider, test_utils::MockNodeTypesWithDB, ProviderFactory,
StaticFileProviderBuilder, StaticFileProviderFactory, StaticFileSegment,
};
use reth_stages_types::StageCheckpoint;
use reth_testing_utils::generators::{self, random_signed_tx};
@@ -346,6 +348,7 @@ mod tests {
.with_blocks_per_file(1)
.build()
.unwrap(),
RocksDBProvider::builder(create_test_rocksdb_dir().0.keep()).build().unwrap(),
)
.unwrap();

View File

@@ -1,7 +1,10 @@
use alloy_primitives::{keccak256, Address, BlockNumber, TxHash, TxNumber, B256};
use reth_chainspec::MAINNET;
use reth_db::{
test_utils::{create_test_rw_db, create_test_rw_db_with_path, create_test_static_files_dir},
test_utils::{
create_test_rocksdb_dir, create_test_rw_db, create_test_rw_db_with_path,
create_test_static_files_dir,
},
DatabaseEnv,
};
use reth_db_api::{
@@ -17,7 +20,9 @@ use reth_db_api::{
use reth_ethereum_primitives::{Block, EthPrimitives, Receipt};
use reth_primitives_traits::{Account, SealedBlock, SealedHeader, StorageEntry};
use reth_provider::{
providers::{StaticFileProvider, StaticFileProviderRWRefMut, StaticFileWriter},
providers::{
RocksDBProvider, StaticFileProvider, StaticFileProviderRWRefMut, StaticFileWriter,
},
test_utils::MockNodeTypesWithDB,
HistoryWriter, ProviderError, ProviderFactory, StaticFileProviderFactory, StatsReader,
};
@@ -38,12 +43,14 @@ impl Default for TestStageDB {
/// Create a new instance of [`TestStageDB`]
fn default() -> Self {
let (static_dir, static_dir_path) = create_test_static_files_dir();
let (_, rocksdb_dir_path) = create_test_rocksdb_dir();
Self {
temp_static_files_dir: static_dir,
factory: ProviderFactory::new(
create_test_rw_db(),
MAINNET.clone(),
StaticFileProvider::read_write(static_dir_path).unwrap(),
RocksDBProvider::builder(rocksdb_dir_path).build().unwrap(),
)
.expect("failed to create test provider factory"),
}
@@ -53,6 +60,7 @@ impl Default for TestStageDB {
impl TestStageDB {
pub fn new(path: &Path) -> Self {
let (static_dir, static_dir_path) = create_test_static_files_dir();
let (_, rocksdb_dir_path) = create_test_rocksdb_dir();
Self {
temp_static_files_dir: static_dir,
@@ -60,6 +68,7 @@ impl TestStageDB {
create_test_rw_db_with_path(path),
MAINNET.clone(),
StaticFileProvider::read_write(static_dir_path).unwrap(),
RocksDBProvider::builder(rocksdb_dir_path).build().unwrap(),
)
.expect("failed to create test provider factory"),
}

View File

@@ -711,7 +711,7 @@ mod tests {
};
use reth_provider::{
test_utils::{create_test_provider_factory_with_chain_spec, MockNodeTypesWithDB},
ProviderFactory,
ProviderFactory, RocksDBProviderFactory,
};
use std::{collections::BTreeMap, sync::Arc};
@@ -756,6 +756,7 @@ mod tests {
fn fail_init_inconsistent_db() {
let factory = create_test_provider_factory_with_chain_spec(SEPOLIA.clone());
let static_file_provider = factory.static_file_provider();
let rocksdb_provider = factory.rocksdb_provider();
init_genesis(&factory).unwrap();
// Try to init db with a different genesis block
@@ -764,6 +765,7 @@ mod tests {
factory.into_db(),
MAINNET.clone(),
static_file_provider,
rocksdb_provider,
)
.unwrap(),
);

View File

@@ -159,6 +159,14 @@ pub mod test_utils {
(temp_dir, path)
}
/// Create `rocksdb` path for testing
#[track_caller]
pub fn create_test_rocksdb_dir() -> (TempDir, PathBuf) {
let temp_dir = TempDir::with_prefix("reth-test-rocksdb-").expect(ERROR_TEMPDIR);
let path = temp_dir.path().to_path_buf();
(temp_dir, path)
}
/// Get a temporary directory path to use for the database
pub fn tempdir_path() -> PathBuf {
let builder = tempfile::Builder::new().prefix("reth-test-").rand_bytes(8).tempdir();

View File

@@ -1,14 +1,15 @@
use crate::{
providers::{
ConsistentProvider, ProviderNodeTypes, StaticFileProvider, StaticFileProviderRWRefMut,
ConsistentProvider, ProviderNodeTypes, RocksDBProvider, StaticFileProvider,
StaticFileProviderRWRefMut,
},
AccountReader, BlockHashReader, BlockIdReader, BlockNumReader, BlockReader, BlockReaderIdExt,
BlockSource, CanonChainTracker, CanonStateNotifications, CanonStateSubscriptions,
ChainSpecProvider, ChainStateBlockReader, ChangeSetReader, DatabaseProviderFactory,
HashedPostStateProvider, HeaderProvider, ProviderError, ProviderFactory, PruneCheckpointReader,
ReceiptProvider, ReceiptProviderIdExt, StageCheckpointReader, StateProviderBox,
StateProviderFactory, StateReader, StaticFileProviderFactory, TransactionVariant,
TransactionsProvider, TrieReader,
ReceiptProvider, ReceiptProviderIdExt, RocksDBProviderFactory, StageCheckpointReader,
StateProviderBox, StateProviderFactory, StateReader, StaticFileProviderFactory,
TransactionVariant, TransactionsProvider, TrieReader,
};
use alloy_consensus::transaction::TransactionMeta;
use alloy_eips::{BlockHashOrNumber, BlockId, BlockNumHash, BlockNumberOrTag};
@@ -176,6 +177,12 @@ impl<N: ProviderNodeTypes> StaticFileProviderFactory for BlockchainProvider<N> {
}
}
impl<N: ProviderNodeTypes> RocksDBProviderFactory for BlockchainProvider<N> {
fn rocksdb_provider(&self) -> RocksDBProvider {
self.database.rocksdb_provider()
}
}
impl<N: ProviderNodeTypes> HeaderProvider for BlockchainProvider<N> {
type Header = HeaderTy<N>;

View File

@@ -4,7 +4,7 @@
//! up to the intended build target.
use crate::{
providers::{NodeTypesForProvider, StaticFileProvider},
providers::{NodeTypesForProvider, RocksDBProvider, StaticFileProvider},
ProviderFactory,
};
use reth_db::{
@@ -104,11 +104,12 @@ impl<N> ProviderFactoryBuilder<N> {
where
N: NodeTypesForProvider,
{
let ReadOnlyConfig { db_dir, db_args, static_files_dir, watch_static_files } =
let ReadOnlyConfig { db_dir, db_args, static_files_dir, rocksdb_dir, watch_static_files } =
config.into();
self.db(Arc::new(open_db_read_only(db_dir, db_args)?))
.chainspec(chainspec)
.static_file(StaticFileProvider::read_only(static_files_dir, watch_static_files)?)
.rocksdb_provider(RocksDBProvider::builder(&rocksdb_dir).build()?)
.build_provider_factory()
.map_err(Into::into)
}
@@ -120,7 +121,7 @@ impl<N> Default for ProviderFactoryBuilder<N> {
}
}
/// Settings for how to open the database and static files.
/// Settings for how to open the database, static files, and `RocksDB`.
///
/// The default derivation from a path assumes the path is the datadir:
/// [`ReadOnlyConfig::from_datadir`]
@@ -132,6 +133,8 @@ pub struct ReadOnlyConfig {
pub db_args: DatabaseArguments,
/// The path to the static file dir
pub static_files_dir: PathBuf,
/// The path to the `RocksDB` directory
pub rocksdb_dir: PathBuf,
/// Whether the static files should be watched for changes.
pub watch_static_files: bool,
}
@@ -144,6 +147,7 @@ impl ReadOnlyConfig {
/// ```text
/// -`datadir`
/// |__db
/// |__rocksdb
/// |__static_files
/// ```
///
@@ -151,7 +155,13 @@ impl ReadOnlyConfig {
/// [`StaticFileProvider::read_only`]
pub fn from_datadir(datadir: impl AsRef<Path>) -> Self {
let datadir = datadir.as_ref();
Self::from_dirs(datadir.join("db"), datadir.join("static_files"))
Self {
db_dir: datadir.join("db"),
db_args: Default::default(),
static_files_dir: datadir.join("static_files"),
rocksdb_dir: datadir.join("rocksdb"),
watch_static_files: true,
}
}
/// Disables long-lived read transaction safety guarantees.
@@ -169,7 +179,8 @@ impl ReadOnlyConfig {
///
/// ```text
/// - db
/// -static_files
/// - rocksdb
/// - static_files
/// ```
///
/// By default this watches the static file directory for changes, see also
@@ -180,13 +191,10 @@ impl ReadOnlyConfig {
/// If the path does not exist
pub fn from_db_dir(db_dir: impl AsRef<Path>) -> Self {
let db_dir = db_dir.as_ref();
let static_files_dir = std::fs::canonicalize(db_dir)
.unwrap()
.parent()
.unwrap()
.to_path_buf()
.join("static_files");
Self::from_dirs(db_dir, static_files_dir)
let datadir = std::fs::canonicalize(db_dir).unwrap().parent().unwrap().to_path_buf();
let static_files_dir = datadir.join("static_files");
let rocksdb_dir = datadir.join("rocksdb");
Self::from_dirs(db_dir, static_files_dir, rocksdb_dir)
}
/// Creates the config for the given paths.
@@ -194,11 +202,16 @@ impl ReadOnlyConfig {
///
/// By default this watches the static file directory for changes, see also
/// [`StaticFileProvider::read_only`]
pub fn from_dirs(db_dir: impl AsRef<Path>, static_files_dir: impl AsRef<Path>) -> Self {
pub fn from_dirs(
db_dir: impl AsRef<Path>,
static_files_dir: impl AsRef<Path>,
rocksdb_dir: impl AsRef<Path>,
) -> Self {
Self {
static_files_dir: static_files_dir.as_ref().into(),
db_dir: db_dir.as_ref().into(),
db_args: Default::default(),
static_files_dir: static_files_dir.as_ref().into(),
rocksdb_dir: rocksdb_dir.as_ref().into(),
watch_static_files: true,
}
}
@@ -317,7 +330,37 @@ impl<N, Val1, Val2, Val3> TypesAnd3<N, Val1, Val2, Val3> {
}
}
impl<N, DB> TypesAnd3<N, DB, Arc<N::ChainSpec>, StaticFileProvider<N::Primitives>>
impl<N, DB, C> TypesAnd3<N, DB, Arc<C>, StaticFileProvider<N::Primitives>>
where
N: NodeTypes,
{
/// Configures the `RocksDB` provider.
pub fn rocksdb_provider(
self,
rocksdb_provider: RocksDBProvider,
) -> TypesAnd4<N, DB, Arc<C>, StaticFileProvider<N::Primitives>, RocksDBProvider> {
TypesAnd4::new(self.val_1, self.val_2, self.val_3, rocksdb_provider)
}
}
/// This is staging type that contains the configured types and _four_ values.
#[derive(Debug)]
pub struct TypesAnd4<N, Val1, Val2, Val3, Val4> {
_types: PhantomData<N>,
val_1: Val1,
val_2: Val2,
val_3: Val3,
val_4: Val4,
}
impl<N, Val1, Val2, Val3, Val4> TypesAnd4<N, Val1, Val2, Val3, Val4> {
/// Creates a new instance with the given types and four values.
pub fn new(val_1: Val1, val_2: Val2, val_3: Val3, val_4: Val4) -> Self {
Self { _types: Default::default(), val_1, val_2, val_3, val_4 }
}
}
impl<N, DB> TypesAnd4<N, DB, Arc<N::ChainSpec>, StaticFileProvider<N::Primitives>, RocksDBProvider>
where
N: NodeTypesForProvider,
DB: Database + DatabaseMetrics + Clone + Unpin + 'static,
@@ -326,7 +369,7 @@ where
pub fn build_provider_factory(
self,
) -> ProviderResult<ProviderFactory<NodeTypesWithDBAdapter<N, DB>>> {
let Self { _types, val_1, val_2, val_3 } = self;
ProviderFactory::new(val_1, val_2, val_3)
let Self { _types, val_1, val_2, val_3, val_4 } = self;
ProviderFactory::new(val_1, val_2, val_3, val_4)
}
}

View File

@@ -1,15 +1,15 @@
use crate::{
providers::{
state::latest::LatestStateProvider, NodeTypesForProvider, StaticFileProvider,
StaticFileProviderRWRefMut,
state::latest::LatestStateProvider, NodeTypesForProvider, RocksDBProvider,
StaticFileProvider, StaticFileProviderRWRefMut,
},
to_range,
traits::{BlockSource, ReceiptProvider},
BlockHashReader, BlockNumReader, BlockReader, ChainSpecProvider, DatabaseProviderFactory,
EitherWriterDestination, HashedPostStateProvider, HeaderProvider, HeaderSyncGapProvider,
MetadataProvider, ProviderError, PruneCheckpointReader, StageCheckpointReader,
StateProviderBox, StaticFileProviderFactory, StaticFileWriter, TransactionVariant,
TransactionsProvider,
MetadataProvider, ProviderError, PruneCheckpointReader, RocksDBProviderFactory,
StageCheckpointReader, StateProviderBox, StaticFileProviderFactory, StaticFileWriter,
TransactionVariant, TransactionsProvider,
};
use alloy_consensus::transaction::TransactionMeta;
use alloy_eips::BlockHashOrNumber;
@@ -72,6 +72,8 @@ pub struct ProviderFactory<N: NodeTypesWithDB> {
storage: Arc<N::Storage>,
/// Storage configuration settings for this node
storage_settings: Arc<RwLock<StorageSettings>>,
/// `RocksDB` provider
rocksdb_provider: RocksDBProvider,
}
impl<N: NodeTypesForProvider> ProviderFactory<NodeTypesWithDBAdapter<N, Arc<DatabaseEnv>>> {
@@ -87,6 +89,7 @@ impl<N: ProviderNodeTypes> ProviderFactory<N> {
db: N::DB,
chain_spec: Arc<N::ChainSpec>,
static_file_provider: StaticFileProvider<N::Primitives>,
rocksdb_provider: RocksDBProvider,
) -> ProviderResult<Self> {
// Load storage settings from database at init time. Creates a temporary provider
// to read persisted settings, falling back to legacy defaults if none exist.
@@ -100,6 +103,7 @@ impl<N: ProviderNodeTypes> ProviderFactory<N> {
Default::default(),
Default::default(),
Arc::new(RwLock::new(legacy_settings)),
rocksdb_provider.clone(),
)
.storage_settings()?
.unwrap_or(legacy_settings);
@@ -111,6 +115,7 @@ impl<N: ProviderNodeTypes> ProviderFactory<N> {
prune_modes: PruneModes::default(),
storage: Default::default(),
storage_settings: Arc::new(RwLock::new(storage_settings)),
rocksdb_provider,
})
}
}
@@ -144,6 +149,12 @@ impl<N: NodeTypesWithDB> StorageSettingsCache for ProviderFactory<N> {
}
}
impl<N: NodeTypesWithDB> RocksDBProviderFactory for ProviderFactory<N> {
fn rocksdb_provider(&self) -> RocksDBProvider {
self.rocksdb_provider.clone()
}
}
impl<N: ProviderNodeTypes<DB = Arc<DatabaseEnv>>> ProviderFactory<N> {
/// Create new database provider by passing a path. [`ProviderFactory`] will own the database
/// instance.
@@ -152,11 +163,13 @@ impl<N: ProviderNodeTypes<DB = Arc<DatabaseEnv>>> ProviderFactory<N> {
chain_spec: Arc<N::ChainSpec>,
args: DatabaseArguments,
static_file_provider: StaticFileProvider<N::Primitives>,
rocksdb_provider: RocksDBProvider,
) -> RethResult<Self> {
Self::new(
Arc::new(init_db(path, args).map_err(RethError::msg)?),
chain_spec,
static_file_provider,
rocksdb_provider,
)
.map_err(RethError::Provider)
}
@@ -178,6 +191,7 @@ impl<N: ProviderNodeTypes> ProviderFactory<N> {
self.prune_modes.clone(),
self.storage.clone(),
self.storage_settings.clone(),
self.rocksdb_provider.clone(),
))
}
@@ -194,6 +208,7 @@ impl<N: ProviderNodeTypes> ProviderFactory<N> {
self.prune_modes.clone(),
self.storage.clone(),
self.storage_settings.clone(),
self.rocksdb_provider.clone(),
)))
}
@@ -595,8 +610,15 @@ where
N: NodeTypesWithDB<DB: fmt::Debug, ChainSpec: fmt::Debug, Storage: fmt::Debug>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let Self { db, chain_spec, static_file_provider, prune_modes, storage, storage_settings } =
self;
let Self {
db,
chain_spec,
static_file_provider,
prune_modes,
storage,
storage_settings,
rocksdb_provider,
} = self;
f.debug_struct("ProviderFactory")
.field("db", &db)
.field("chain_spec", &chain_spec)
@@ -604,6 +626,7 @@ where
.field("prune_modes", &prune_modes)
.field("storage", &storage)
.field("storage_settings", &*storage_settings.read())
.field("rocksdb_provider", &rocksdb_provider)
.finish()
}
}
@@ -617,6 +640,7 @@ impl<N: NodeTypesWithDB> Clone for ProviderFactory<N> {
prune_modes: self.prune_modes.clone(),
storage: self.storage.clone(),
storage_settings: self.storage_settings.clone(),
rocksdb_provider: self.rocksdb_provider.clone(),
}
}
}
@@ -635,7 +659,7 @@ mod tests {
use reth_chainspec::ChainSpecBuilder;
use reth_db::{
mdbx::DatabaseArguments,
test_utils::{create_test_static_files_dir, ERROR_TEMPDIR},
test_utils::{create_test_rocksdb_dir, create_test_static_files_dir, ERROR_TEMPDIR},
};
use reth_db_api::tables;
use reth_primitives_traits::SignerRecoverable;
@@ -674,11 +698,13 @@ mod tests {
fn provider_factory_with_database_path() {
let chain_spec = ChainSpecBuilder::mainnet().build();
let (_static_dir, static_dir_path) = create_test_static_files_dir();
let (_, rocksdb_path) = create_test_rocksdb_dir();
let factory = ProviderFactory::<MockNodeTypesWithDB<DatabaseEnv>>::new_with_database_path(
tempfile::TempDir::new().expect(ERROR_TEMPDIR).keep(),
Arc::new(chain_spec),
DatabaseArguments::new(Default::default()),
StaticFileProvider::read_write(static_dir_path).unwrap(),
RocksDBProvider::builder(&rocksdb_path).build().unwrap(),
)
.unwrap();
let provider = factory.provider().unwrap();

View File

@@ -4,6 +4,7 @@ use crate::{
},
providers::{
database::{chain::ChainStorage, metrics},
rocksdb::RocksDBProvider,
static_file::StaticFileWriter,
NodeTypesForProvider, StaticFileProvider,
},
@@ -16,10 +17,10 @@ use crate::{
DBProvider, EitherReader, EitherWriter, EitherWriterDestination, HashingWriter, HeaderProvider,
HeaderSyncGapProvider, HistoricalStateProvider, HistoricalStateProviderRef, HistoryWriter,
LatestStateProvider, LatestStateProviderRef, OriginalValuesKnown, ProviderError,
PruneCheckpointReader, PruneCheckpointWriter, RevertsInit, StageCheckpointReader,
StateProviderBox, StateWriter, StaticFileProviderFactory, StatsReader, StorageReader,
StorageTrieWriter, TransactionVariant, TransactionsProvider, TransactionsProviderExt,
TrieReader, TrieWriter,
PruneCheckpointReader, PruneCheckpointWriter, RevertsInit, RocksDBProviderFactory,
StageCheckpointReader, StateProviderBox, StateWriter, StaticFileProviderFactory, StatsReader,
StorageReader, StorageTrieWriter, TransactionVariant, TransactionsProvider,
TransactionsProviderExt, TrieReader, TrieWriter,
};
use alloy_consensus::{
transaction::{SignerRecoverable, TransactionMeta, TxHashRef},
@@ -164,6 +165,8 @@ pub struct DatabaseProvider<TX, N: NodeTypes> {
storage: Arc<N::Storage>,
/// Storage configuration settings for this node
storage_settings: Arc<RwLock<StorageSettings>>,
/// `RocksDB` provider
rocksdb_provider: RocksDBProvider,
/// Minimum distance from tip required for pruning
minimum_pruning_distance: u64,
}
@@ -251,6 +254,13 @@ impl<TX, N: NodeTypes> StaticFileProviderFactory for DatabaseProvider<TX, N> {
}
}
impl<TX, N: NodeTypes> RocksDBProviderFactory for DatabaseProvider<TX, N> {
/// Returns the `RocksDB` provider.
fn rocksdb_provider(&self) -> RocksDBProvider {
self.rocksdb_provider.clone()
}
}
impl<TX: Debug + Send + Sync, N: NodeTypes<ChainSpec: EthChainSpec + 'static>> ChainSpecProvider
for DatabaseProvider<TX, N>
{
@@ -270,6 +280,7 @@ impl<TX: DbTxMut, N: NodeTypes> DatabaseProvider<TX, N> {
prune_modes: PruneModes,
storage: Arc<N::Storage>,
storage_settings: Arc<RwLock<StorageSettings>>,
rocksdb_provider: RocksDBProvider,
) -> Self {
Self {
tx,
@@ -278,6 +289,7 @@ impl<TX: DbTxMut, N: NodeTypes> DatabaseProvider<TX, N> {
prune_modes,
storage,
storage_settings,
rocksdb_provider,
minimum_pruning_distance: MINIMUM_PRUNING_DISTANCE,
}
}
@@ -523,6 +535,7 @@ impl<TX: DbTx + 'static, N: NodeTypesForProvider> DatabaseProvider<TX, N> {
prune_modes: PruneModes,
storage: Arc<N::Storage>,
storage_settings: Arc<RwLock<StorageSettings>>,
rocksdb_provider: RocksDBProvider,
) -> Self {
Self {
tx,
@@ -531,6 +544,7 @@ impl<TX: DbTx + 'static, N: NodeTypesForProvider> DatabaseProvider<TX, N> {
prune_modes,
storage,
storage_settings,
rocksdb_provider,
minimum_pruning_distance: MINIMUM_PRUNING_DISTANCE,
}
}

View File

@@ -31,9 +31,10 @@ pub use consistent::ConsistentProvider;
// RocksDB currently only supported on Unix platforms
// Windows support is planned for future releases
#[cfg(all(unix, feature = "rocksdb"))]
#[cfg_attr(all(unix, feature = "rocksdb"), path = "rocksdb/mod.rs")]
#[cfg_attr(not(all(unix, feature = "rocksdb")), path = "rocksdb_stub.rs")]
pub(crate) mod rocksdb;
#[cfg(all(unix, feature = "rocksdb"))]
pub use rocksdb::{RocksDBBuilder, RocksDBProvider, RocksTx};
/// Helper trait to bound [`NodeTypes`] so that combined with database they satisfy

View File

@@ -151,8 +151,10 @@ impl RocksDBBuilder {
}
/// Sets the log level from `DatabaseArgs` configuration.
pub const fn with_database_log_level(mut self, log_level: LogLevel) -> Self {
self.log_level = convert_log_level(log_level);
pub const fn with_database_log_level(mut self, log_level: Option<LogLevel>) -> Self {
if let Some(level) = log_level {
self.log_level = convert_log_level(level);
}
self
}

View File

@@ -0,0 +1,210 @@
//! Stub implementation of `RocksDB` provider.
//!
//! This module provides placeholder types that allow the code to compile when `RocksDB` is not
//! available (either on non-Unix platforms or when the `rocksdb` feature is not enabled).
//! Operations will produce errors if actually attempted.
use reth_db_api::table::{Encode, Table};
use reth_storage_errors::{
db::LogLevel,
provider::{ProviderError::UnsupportedProvider, ProviderResult},
};
use std::path::Path;
/// A stub `RocksDB` provider.
///
/// This type exists to allow code to compile when `RocksDB` is not available (either on non-Unix
/// platforms or when the `rocksdb` feature is not enabled). When using this stub, the
/// `transaction_hash_numbers_in_rocksdb` flag should be set to `false` to ensure all operations
/// route to MDBX instead.
#[derive(Debug, Clone)]
pub struct RocksDBProvider;
impl RocksDBProvider {
/// Creates a new stub `RocksDB` provider.
///
/// On non-Unix platforms, this returns an error indicating `RocksDB` is not supported.
pub fn new(_path: impl AsRef<Path>) -> ProviderResult<Self> {
Ok(Self)
}
/// Creates a new stub `RocksDB` provider builder.
pub fn builder(path: impl AsRef<Path>) -> RocksDBBuilder {
RocksDBBuilder::new(path)
}
/// Get a value from `RocksDB` (stub implementation).
pub fn get<T: Table>(&self, _key: T::Key) -> ProviderResult<Option<T::Value>> {
Err(UnsupportedProvider)
}
/// Get a value from `RocksDB` using pre-encoded key (stub implementation).
pub const fn get_encoded<T: Table>(
&self,
_key: &<T::Key as Encode>::Encoded,
) -> ProviderResult<Option<T::Value>> {
Err(UnsupportedProvider)
}
/// Put a value into `RocksDB` (stub implementation).
pub fn put<T: Table>(&self, _key: T::Key, _value: &T::Value) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
/// Put a value into `RocksDB` using pre-encoded key (stub implementation).
pub const fn put_encoded<T: Table>(
&self,
_key: &<T::Key as Encode>::Encoded,
_value: &T::Value,
) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
/// Delete a value from `RocksDB` (stub implementation).
pub fn delete<T: Table>(&self, _key: T::Key) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
/// Write a batch of operations (stub implementation).
pub fn write_batch<F>(&self, _f: F) -> ProviderResult<()>
where
F: FnOnce(&mut RocksDBBatch) -> ProviderResult<()>,
{
Err(UnsupportedProvider)
}
/// Creates a new transaction (stub implementation).
pub const fn tx(&self) -> RocksTx {
RocksTx
}
}
/// A stub batch writer for `RocksDB` on non-Unix platforms.
#[derive(Debug)]
pub struct RocksDBBatch;
impl RocksDBBatch {
/// Puts a value into the batch (stub implementation).
pub fn put<T: Table>(&self, _key: T::Key, _value: &T::Value) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
/// Puts a value into the batch using pre-encoded key (stub implementation).
pub const fn put_encoded<T: Table>(
&self,
_key: &<T::Key as Encode>::Encoded,
_value: &T::Value,
) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
/// Deletes a value from the batch (stub implementation).
pub fn delete<T: Table>(&self, _key: T::Key) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
}
/// A stub builder for `RocksDB` on non-Unix platforms.
#[derive(Debug)]
pub struct RocksDBBuilder;
impl RocksDBBuilder {
/// Creates a new stub builder.
pub fn new<P: AsRef<Path>>(_path: P) -> Self {
Self
}
/// Adds a column family for a specific table type (stub implementation).
pub const fn with_table<T: Table>(self) -> Self {
self
}
/// Enables metrics (stub implementation).
pub const fn with_metrics(self) -> Self {
self
}
/// Enables `RocksDB` internal statistics collection (stub implementation).
pub const fn with_statistics(self) -> Self {
self
}
/// Sets the log level from `DatabaseArgs` configuration (stub implementation).
pub const fn with_database_log_level(self, _log_level: Option<LogLevel>) -> Self {
self
}
/// Sets a custom block cache size (stub implementation).
pub const fn with_block_cache_size(self, _capacity_bytes: usize) -> Self {
self
}
/// Build the `RocksDB` provider (stub implementation).
pub const fn build(self) -> ProviderResult<RocksDBProvider> {
Ok(RocksDBProvider)
}
}
/// A stub transaction for `RocksDB`.
#[derive(Debug)]
pub struct RocksTx;
impl RocksTx {
/// Gets a value from the specified table (stub implementation).
pub fn get<T: Table>(&self, _key: T::Key) -> ProviderResult<Option<T::Value>> {
Err(UnsupportedProvider)
}
/// Gets a value using pre-encoded key (stub implementation).
pub const fn get_encoded<T: Table>(
&self,
_key: &<T::Key as Encode>::Encoded,
) -> ProviderResult<Option<T::Value>> {
Err(UnsupportedProvider)
}
/// Puts a value into the specified table (stub implementation).
pub fn put<T: Table>(&self, _key: T::Key, _value: &T::Value) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
/// Puts a value using pre-encoded key (stub implementation).
pub const fn put_encoded<T: Table>(
&self,
_key: &<T::Key as Encode>::Encoded,
_value: &T::Value,
) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
/// Deletes a value from the specified table (stub implementation).
pub fn delete<T: Table>(&self, _key: T::Key) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
/// Creates an iterator for the specified table (stub implementation).
pub const fn iter<T: Table>(&self) -> ProviderResult<RocksTxIter<'_, T>> {
Err(UnsupportedProvider)
}
/// Creates an iterator starting from the given key (stub implementation).
pub fn iter_from<T: Table>(&self, _key: T::Key) -> ProviderResult<RocksTxIter<'_, T>> {
Err(UnsupportedProvider)
}
/// Commits the transaction (stub implementation).
pub const fn commit(self) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
/// Rolls back the transaction (stub implementation).
pub const fn rollback(self) -> ProviderResult<()> {
Err(UnsupportedProvider)
}
}
/// A stub iterator for `RocksDB` transactions.
#[derive(Debug)]
pub struct RocksTxIter<'a, T> {
_marker: std::marker::PhantomData<(&'a (), T)>,
}

View File

@@ -1,11 +1,13 @@
use crate::{
providers::{NodeTypesForProvider, ProviderNodeTypes, StaticFileProvider},
providers::{NodeTypesForProvider, ProviderNodeTypes, RocksDBProvider, StaticFileProvider},
HashingWriter, ProviderFactory, TrieWriter,
};
use alloy_primitives::B256;
use reth_chainspec::{ChainSpec, MAINNET};
use reth_db::{
test_utils::{create_test_rw_db, create_test_static_files_dir, TempDatabase},
test_utils::{
create_test_rocksdb_dir, create_test_rw_db, create_test_static_files_dir, TempDatabase,
},
DatabaseEnv,
};
use reth_errors::ProviderResult;
@@ -54,11 +56,13 @@ pub fn create_test_provider_factory_with_node_types<N: NodeTypesForProvider>(
chain_spec: Arc<N::ChainSpec>,
) -> ProviderFactory<NodeTypesWithDBAdapter<N, Arc<TempDatabase<DatabaseEnv>>>> {
let (static_dir, _) = create_test_static_files_dir();
let (rocksdb_dir, _) = create_test_rocksdb_dir();
let db = create_test_rw_db();
ProviderFactory::new(
db,
chain_spec,
StaticFileProvider::read_write(static_dir.keep()).expect("static file provider"),
RocksDBProvider::new(&rocksdb_dir).expect("failed to create test RocksDB provider"),
)
.expect("failed to create test provider factory")
}

View File

@@ -1,8 +1,8 @@
//! Additional testing support for `NoopProvider`.
use crate::{
providers::{StaticFileProvider, StaticFileProviderRWRefMut},
StaticFileProviderFactory,
providers::{RocksDBProvider, StaticFileProvider, StaticFileProviderRWRefMut},
RocksDBProviderFactory, StaticFileProviderFactory,
};
use reth_errors::{ProviderError, ProviderResult};
use reth_primitives_traits::NodePrimitives;
@@ -24,3 +24,9 @@ impl<C: Send + Sync, N: NodePrimitives> StaticFileProviderFactory for NoopProvid
Err(ProviderError::ReadOnlyStaticFileAccess)
}
}
impl<C: Send + Sync, N: NodePrimitives> RocksDBProviderFactory for NoopProvider<C, N> {
fn rocksdb_provider(&self) -> RocksDBProvider {
RocksDBProvider::builder(PathBuf::default()).build().unwrap()
}
}

View File

@@ -2,8 +2,9 @@
use crate::{
AccountReader, BlockReader, BlockReaderIdExt, ChainSpecProvider, ChangeSetReader,
DatabaseProviderFactory, HashedPostStateProvider, PruneCheckpointReader, StageCheckpointReader,
StateProviderFactory, StateReader, StaticFileProviderFactory, TrieReader,
DatabaseProviderFactory, HashedPostStateProvider, PruneCheckpointReader,
RocksDBProviderFactory, StageCheckpointReader, StateProviderFactory, StateReader,
StaticFileProviderFactory, TrieReader,
};
use reth_chain_state::{CanonStateSubscriptions, ForkChoiceSubscriptions};
use reth_node_types::{BlockTy, HeaderTy, NodeTypesWithDB, ReceiptTy, TxTy};
@@ -17,6 +18,7 @@ pub trait FullProvider<N: NodeTypesWithDB>:
Provider: BlockReader + TrieReader + StageCheckpointReader + PruneCheckpointReader,
> + NodePrimitivesProvider<Primitives = N::Primitives>
+ StaticFileProviderFactory<Primitives = N::Primitives>
+ RocksDBProviderFactory
+ BlockReaderIdExt<
Transaction = TxTy<N>,
Block = BlockTy<N>,
@@ -44,6 +46,7 @@ impl<T, N: NodeTypesWithDB> FullProvider<N> for T where
Provider: BlockReader + TrieReader + StageCheckpointReader + PruneCheckpointReader,
> + NodePrimitivesProvider<Primitives = N::Primitives>
+ StaticFileProviderFactory<Primitives = N::Primitives>
+ RocksDBProviderFactory
+ BlockReaderIdExt<
Transaction = TxTy<N>,
Block = BlockTy<N>,

View File

@@ -8,5 +8,8 @@ pub use reth_chainspec::ChainSpecProvider;
mod static_file_provider;
pub use static_file_provider::StaticFileProviderFactory;
mod rocksdb_provider;
pub use rocksdb_provider::RocksDBProviderFactory;
mod full;
pub use full::FullProvider;

View File

@@ -0,0 +1,9 @@
use crate::providers::RocksDBProvider;
/// `RocksDB` provider factory.
///
/// This trait provides access to the `RocksDB` provider
pub trait RocksDBProviderFactory {
/// Returns the `RocksDB` provider.
fn rocksdb_provider(&self) -> RocksDBProvider;
}

View File

@@ -43,6 +43,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -71,6 +71,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
Networking:
-d, --disable-discovery
Disable the discovery service

View File

@@ -248,6 +248,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use.

View File

@@ -248,6 +248,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use.

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -34,6 +34,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -32,6 +32,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -43,6 +43,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -71,6 +71,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
Networking:
-d, --disable-discovery
Disable the discovery service

View File

@@ -248,6 +248,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use.

View File

@@ -248,6 +248,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use.

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -34,6 +34,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -27,6 +27,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -32,6 +32,9 @@ Datadir:
--datadir.static-files <PATH>
The absolute path to store static files in.
--datadir.rocksdb <PATH>
The absolute path to store `RocksDB` database in.
--config <FILE>
The path to the configuration file to use

View File

@@ -24,7 +24,7 @@ use reth_ethereum::{
pool::noop::NoopTransactionPool,
provider::{
db::{mdbx::DatabaseArguments, open_db_read_only, ClientVersion, DatabaseEnv},
providers::{BlockchainProvider, StaticFileProvider},
providers::{BlockchainProvider, RocksDBProvider, StaticFileProvider},
ProviderFactory,
},
rpc::{
@@ -53,6 +53,7 @@ async fn main() -> eyre::Result<()> {
db.clone(),
spec.clone(),
StaticFileProvider::read_only(db_path.join("static_files"), true)?,
RocksDBProvider::builder(db_path.join("rocksdb")).build().unwrap(),
)?;
// 2. Set up the blockchain provider using only the database provider and a noop for the tree to