Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cf89d57
parallelize save_blocks
joshieDo Jan 13, 2026
ad4998d
rm Tx: Sync bound
joshieDo Jan 13, 2026
55e0f3d
touch-ups
joshieDo Jan 13, 2026
40ea593
fix
joshieDo Jan 13, 2026
fadc97a
feat: enable account changesets on `save_blocks` (#21012)
joshieDo Jan 14, 2026
c2ddcb2
Merge branch 'main' into joshie/par-save-blocks
joshieDo Jan 14, 2026
84bdf71
feat(storage): add tracing spans (#21072)
pepyakin Jan 14, 2026
d8a600c
add rocksdb writer to save_blocks
joshieDo Jan 13, 2026
851d813
add rocksdb writer to save_blocks
joshieDo Jan 13, 2026
38f0d2a
feat(storage): wire RocksDB into history lookups via EitherReader
yongkangc Jan 9, 2026
7bd3fd9
refactor(provider): simplify EitherReader and encapsulate RocksDB logic
yongkangc Jan 12, 2026
dddc3be
fix: use PhantomData in EitherReader to capture lifetime 'a
yongkangc Jan 12, 2026
ef6a6d8
fix: clippy warnings and fmt issues
yongkangc Jan 14, 2026
f8a98e7
refactor(provider): extract compute_history_rank helper to reduce dup…
yongkangc Jan 14, 2026
98b8c9a
fix(rocksdb): treat empty RocksDB tables as first-run scenario
yongkangc Jan 13, 2026
5b63859
fix(rocksdb): handle sentinel-only entries in consistency check
yongkangc Jan 13, 2026
7a9e46f
fix: use proper shard logic for history indices in RocksDB write_bloc…
yongkangc Jan 14, 2026
fc776db
feat(stages): add RocksDB helper functions for stage operations
yongkangc Jan 14, 2026
126621c
feat(stages): implement RocksDB unwind for index history stages
yongkangc Jan 14, 2026
ff75aa9
feat(storage): RocksDB support for genesis init and tx lookup stage
yongkangc Jan 14, 2026
9ef853d
feat(cli): add --storage.rocksdb flag for RocksDB history indices
yongkangc Jan 14, 2026
bba7821
fix: clippy warnings (doc_markdown, unreachable_pub, for_kv_map)
yongkangc Jan 14, 2026
f775cc9
docs: update CLI documentation for --storage.rocksdb flag
yongkangc Jan 13, 2026
7c1744a
fix: update CLI commands and test utilities for RocksDB support
yongkangc Jan 14, 2026
766eabc
feat(provider): add RocksDBProvider::clear method for table cleanup
yongkangc Jan 16, 2026
7477c97
fix: remove dead code using non-existent RocksDBProvider::clear method
yongkangc Jan 16, 2026
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
39 changes: 39 additions & 0 deletions crates/cli/commands/src/db/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ pub enum SetCommand {
#[clap(action(ArgAction::Set))]
value: bool,
},
/// Store storages history in RocksDB instead of MDBX
StoragesHistory {
#[clap(action(ArgAction::Set))]
value: bool,
},
/// Store account history in RocksDB instead of MDBX
AccountHistory {
#[clap(action(ArgAction::Set))]
value: bool,
},
/// Store transaction hash numbers in RocksDB instead of MDBX
TxHashNumbers {
#[clap(action(ArgAction::Set))]
value: bool,
},
}

impl Command {
Expand Down Expand Up @@ -128,6 +143,30 @@ impl Command {
settings.account_changesets_in_static_files = value;
println!("Set account_changesets_in_static_files = {}", value);
}
SetCommand::StoragesHistory { value } => {
if settings.storages_history_in_rocksdb == value {
println!("storages_history_in_rocksdb is already set to {}", value);
return Ok(());
}
settings.storages_history_in_rocksdb = value;
println!("Set storages_history_in_rocksdb = {}", value);
}
SetCommand::AccountHistory { value } => {
if settings.account_history_in_rocksdb == value {
println!("account_history_in_rocksdb is already set to {}", value);
return Ok(());
}
settings.account_history_in_rocksdb = value;
println!("Set account_history_in_rocksdb = {}", value);
}
SetCommand::TxHashNumbers { value } => {
if settings.transaction_hash_numbers_in_rocksdb == value {
println!("transaction_hash_numbers_in_rocksdb is already set to {}", value);
return Ok(());
}
settings.transaction_hash_numbers_in_rocksdb = value;
println!("Set transaction_hash_numbers_in_rocksdb = {}", value);
}
}

// Write updated settings
Expand Down
1 change: 1 addition & 0 deletions crates/cli/commands/src/stage/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ impl<C: ChainSpecParser> Command<C> {
}
StageEnum::TxLookup => {
tx.clear::<tables::TransactionHashNumbers>()?;

reset_prune_checkpoint(tx, PruneSegment::TransactionLookup)?;

reset_stage_checkpoint(tx, StageId::TransactionLookup)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/stage/dump/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ where
Arc::new(output_db),
db_tool.chain(),
StaticFileProvider::read_write(output_datadir.static_files())?,
RocksDBProvider::builder(output_datadir.rocksdb()).build()?,
RocksDBProvider::builder(output_datadir.rocksdb()).with_default_tables().build()?,
)?,
to,
from,
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/stage/dump/hashing_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +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()?,
RocksDBProvider::builder(output_datadir.rocksdb()).with_default_tables().build()?,
)?,
to,
from,
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/stage/dump/hashing_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +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()?,
RocksDBProvider::builder(output_datadir.rocksdb()).with_default_tables().build()?,
)?,
to,
from,
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/commands/src/stage/dump/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ where
Arc::new(output_db),
db_tool.chain(),
StaticFileProvider::read_write(output_datadir.static_files())?,
RocksDBProvider::builder(output_datadir.rocksdb()).build()?,
RocksDBProvider::builder(output_datadir.rocksdb()).with_default_tables().build()?,
)?,
to,
from,
Expand Down
12 changes: 10 additions & 2 deletions crates/e2e-test-utils/src/setup_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ 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(),
reth_provider::providers::RocksDBProvider::builder(rocksdb_dir_path)
.with_default_tables()
.build()
.unwrap(),
)?;

// Initialize genesis if needed
Expand Down Expand Up @@ -328,6 +331,7 @@ mod tests {
reth_provider::providers::StaticFileProvider::read_write(static_files_path.clone())
.unwrap(),
reth_provider::providers::RocksDBProvider::builder(rocksdb_dir_path.clone())
.with_default_tables()
.build()
.unwrap(),
)
Expand Down Expand Up @@ -392,6 +396,7 @@ mod tests {
reth_provider::providers::StaticFileProvider::read_only(static_files_path, false)
.unwrap(),
reth_provider::providers::RocksDBProvider::builder(rocksdb_dir_path)
.with_default_tables()
.build()
.unwrap(),
)
Expand Down Expand Up @@ -490,7 +495,10 @@ mod tests {
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(),
reth_provider::providers::RocksDBProvider::builder(rocksdb_dir_path)
.with_default_tables()
.build()
.unwrap(),
)
.expect("failed to create provider factory");

Expand Down
4 changes: 2 additions & 2 deletions crates/engine/tree/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use reth_ethereum_primitives::EthPrimitives;
use reth_primitives_traits::NodePrimitives;
use reth_provider::{
providers::ProviderNodeTypes, BlockExecutionWriter, BlockHashReader, ChainStateBlockWriter,
DBProvider, DatabaseProviderFactory, ProviderFactory,
DBProvider, DatabaseProviderFactory, ProviderFactory, SaveBlocksMode,
};
use reth_prune::{PrunerError, PrunerOutput, PrunerWithFactory};
use reth_stages_api::{MetricEvent, MetricEventsSender};
Expand Down Expand Up @@ -151,7 +151,7 @@ where
if last_block.is_some() {
let provider_rw = self.provider.database_provider_rw()?;

provider_rw.save_blocks(blocks)?;
provider_rw.save_blocks(blocks, SaveBlocksMode::Full)?;
provider_rw.commit()?;
}

Expand Down
2 changes: 1 addition & 1 deletion crates/exex/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub async fn test_exex_context_with_chain_spec(
db,
chain_spec.clone(),
StaticFileProvider::read_write(static_dir.keep()).expect("static file provider"),
RocksDBProvider::builder(rocksdb_dir.keep()).build().unwrap(),
RocksDBProvider::builder(rocksdb_dir.keep()).with_default_tables().build().unwrap(),
)?;

let genesis_hash = init_genesis(&provider_factory)?;
Expand Down
13 changes: 13 additions & 0 deletions crates/node/core/src/args/static_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ pub struct StaticFilesArgs {
/// the node has been initialized, changing this flag requires re-syncing from scratch.
#[arg(long = "static-files.account-change-sets")]
pub account_changesets: bool,

/// Use `RocksDB` for history indices instead of MDBX.
///
/// When enabled, `AccountsHistory`, `StoragesHistory`, and `TransactionHashNumbers`
/// tables will be stored in `RocksDB` for better write performance.
///
/// Note: This setting can only be configured at genesis initialization. Once
/// the node has been initialized, changing this flag requires re-syncing from scratch.
#[arg(long = "storage.rocksdb")]
pub rocksdb: bool,
}

impl StaticFilesArgs {
Expand Down Expand Up @@ -101,5 +111,8 @@ impl StaticFilesArgs {
.with_receipts_in_static_files(self.receipts)
.with_transaction_senders_in_static_files(self.transaction_senders)
.with_account_changesets_in_static_files(self.account_changesets)
.with_account_history_in_rocksdb(self.rocksdb)
.with_storages_history_in_rocksdb(self.rocksdb)
.with_transaction_hash_numbers_in_rocksdb(self.rocksdb)
}
}
8 changes: 8 additions & 0 deletions crates/node/core/src/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,14 @@ impl<ChainSpec> NodeConfig<ChainSpec> {
self
}

/// Converts the node configuration to [`StorageSettings`].
///
/// This returns storage settings configured via CLI arguments including
/// static file settings and `RocksDB` settings.
pub const fn to_storage_settings(&self) -> reth_provider::StorageSettings {
self.static_files.to_settings()
}

/// Returns pruning configuration.
pub fn prune_config(&self) -> Option<PruneConfig>
where
Expand Down
8 changes: 6 additions & 2 deletions crates/optimism/cli/src/commands/import_receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use reth_optimism_primitives::{bedrock::is_dup_tx, OpPrimitives, OpReceipt};
use reth_primitives_traits::NodePrimitives;
use reth_provider::{
providers::ProviderNodeTypes, DBProvider, DatabaseProviderFactory, OriginalValuesKnown,
ProviderFactory, StageCheckpointReader, StageCheckpointWriter, StateWriter,
ProviderFactory, StageCheckpointReader, StageCheckpointWriter, StateWriteConfig, StateWriter,
StaticFileProviderFactory, StatsReader,
};
use reth_stages::{StageCheckpoint, StageId};
Expand Down Expand Up @@ -228,7 +228,11 @@ where
ExecutionOutcome::new(Default::default(), receipts, first_block, Default::default());

// finally, write the receipts
provider.write_state(&execution_outcome, OriginalValuesKnown::Yes)?;
provider.write_state(
&execution_outcome,
OriginalValuesKnown::Yes,
StateWriteConfig::default(),
)?;
}

// Only commit if we have imported as many receipts as the number of transactions.
Expand Down
5 changes: 4 additions & 1 deletion crates/stages/api/src/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ mod tests {
.with_blocks_per_file(1)
.build()
.unwrap(),
RocksDBProvider::builder(create_test_rocksdb_dir().0.keep()).build().unwrap(),
RocksDBProvider::builder(create_test_rocksdb_dir().0.keep())
.with_default_tables()
.build()
.unwrap(),
)
.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions crates/stages/stages/src/stages/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use reth_primitives_traits::{format_gas_throughput, BlockBody, NodePrimitives};
use reth_provider::{
providers::{StaticFileProvider, StaticFileWriter},
BlockHashReader, BlockReader, DBProvider, EitherWriter, ExecutionOutcome, HeaderProvider,
LatestStateProviderRef, OriginalValuesKnown, ProviderError, StateWriter,
LatestStateProviderRef, OriginalValuesKnown, ProviderError, StateWriteConfig, StateWriter,
StaticFileProviderFactory, StatsReader, StorageSettingsCache, TransactionVariant,
};
use reth_revm::database::StateProviderDatabase;
Expand Down Expand Up @@ -463,7 +463,7 @@ where
}

// write output
provider.write_state(&state, OriginalValuesKnown::Yes)?;
provider.write_state(&state, OriginalValuesKnown::Yes, StateWriteConfig::default())?;

let db_write_duration = time.elapsed();
debug!(
Expand Down
Loading