Compare commits

...

6 Commits

Author SHA1 Message Date
joshieDo
48d404d392 fix: skip MDBX history writes in append_blocks_with_state when RocksDB configured
When edge storage settings configure history to be read from RocksDB,
skip writing history indices to MDBX in append_blocks_with_state.
This matches the existing pattern in update_history_indices.

History data will be populated via healing/stages instead.
2026-01-27 15:01:30 +00:00
joshieDo
098749e63a Revert "fix: use EitherWriter for history index insertion to support RocksDB"
This reverts commit a4ae97f1a6.
2026-01-27 15:00:47 +00:00
joshieDo
a4ae97f1a6 fix: use EitherWriter for history index insertion to support RocksDB
The insert_account_history_index and insert_storage_history_index
functions were always writing to MDBX, but when edge feature is enabled,
the readers look in RocksDB based on storage settings.

This fix:
- Adds append_account_history_index and append_storage_history_index
  methods to EitherWriter that handle the sharding logic
- Updates insert_*_history_index in DatabaseProvider to use EitherWriter
  which correctly routes writes to MDBX or RocksDB based on settings
- Removes the now-unused append_history_index helper function
- Simplifies update_history_indices since EitherWriter handles routing
2026-01-27 14:58:05 +00:00
joshieDo
7c3713645f fix: use cfg for RocksDB iter method which only exists with edge feature 2026-01-27 14:22:26 +00:00
joshieDo
e581192da9 test: fix edge tests by checking storage settings and adding RocksDB tables
- Update init_genesis_history test to check storage settings instead of
  compile-time feature flags to determine where history is stored
- Add .with_default_tables() to RocksDBProvider builder in e2e tests
  to ensure history column families are created when edge feature is enabled
2026-01-27 14:03:58 +00:00
joshieDo
445b1e92c2 fix: ensure edge enables history in rocksdb 2026-01-27 13:30:51 +00:00
4 changed files with 71 additions and 24 deletions

View File

@@ -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
@@ -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(),
)
@@ -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(),
)
@@ -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");

View File

@@ -63,9 +63,9 @@ impl StorageSettings {
transaction_senders_in_static_files: true,
account_changesets_in_static_files: true,
storage_changesets_in_static_files: true,
storages_history_in_rocksdb: false,
storages_history_in_rocksdb: true,
transaction_hash_numbers_in_rocksdb: true,
account_history_in_rocksdb: false,
account_history_in_rocksdb: true,
}
}

View File

@@ -932,27 +932,59 @@ mod tests {
let factory = create_test_provider_factory_with_chain_spec(chain_spec);
init_genesis(&factory).unwrap();
let provider = factory.provider().unwrap();
let expected_accounts = vec![
(ShardedKey::new(address_with_balance, u64::MAX), IntegerList::new([0]).unwrap()),
(ShardedKey::new(address_with_storage, u64::MAX), IntegerList::new([0]).unwrap()),
];
let expected_storages = vec![(
StorageShardedKey::new(address_with_storage, storage_key, u64::MAX),
IntegerList::new([0]).unwrap(),
)];
let tx = provider.tx_ref();
let collect_from_mdbx = |factory: &ProviderFactory<MockNodeTypesWithDB>| {
let provider = factory.provider().unwrap();
let tx = provider.tx_ref();
(
collect_table_entries::<Arc<DatabaseEnv>, tables::AccountsHistory>(tx).unwrap(),
collect_table_entries::<Arc<DatabaseEnv>, tables::StoragesHistory>(tx).unwrap(),
)
};
assert_eq!(
collect_table_entries::<Arc<DatabaseEnv>, tables::AccountsHistory>(tx)
.expect("failed to collect"),
vec![
(ShardedKey::new(address_with_balance, u64::MAX), IntegerList::new([0]).unwrap()),
(ShardedKey::new(address_with_storage, u64::MAX), IntegerList::new([0]).unwrap())
],
);
#[cfg(feature = "edge")]
{
let settings = factory.cached_storage_settings();
let rocksdb = factory.rocksdb_provider();
assert_eq!(
collect_table_entries::<Arc<DatabaseEnv>, tables::StoragesHistory>(tx)
.expect("failed to collect"),
vec![(
StorageShardedKey::new(address_with_storage, storage_key, u64::MAX),
IntegerList::new([0]).unwrap()
)],
);
let collect_rocksdb = |rocksdb: &reth_provider::providers::RocksDBProvider| {
(
rocksdb
.iter::<tables::AccountsHistory>()
.unwrap()
.collect::<Result<Vec<_>, _>>()
.unwrap(),
rocksdb
.iter::<tables::StoragesHistory>()
.unwrap()
.collect::<Result<Vec<_>, _>>()
.unwrap(),
)
};
let (accounts, storages) = if settings.account_history_in_rocksdb {
collect_rocksdb(&rocksdb)
} else {
collect_from_mdbx(&factory)
};
assert_eq!(accounts, expected_accounts);
assert_eq!(storages, expected_storages);
}
#[cfg(not(feature = "edge"))]
{
let (accounts, storages) = collect_from_mdbx(&factory);
assert_eq!(accounts, expected_accounts);
assert_eq!(storages, expected_storages);
}
}
#[test]

View File

@@ -3376,8 +3376,15 @@ impl<TX: DbTxMut + DbTx + 'static, N: NodeTypesForProvider> BlockWriter
// Use pre-computed transitions for history indices since static file
// writes aren't visible until commit.
self.insert_account_history_index(account_transitions)?;
self.insert_storage_history_index(storage_transitions)?;
// Skip MDBX history index writes when RocksDB is configured for history
// (history will be read from RocksDB via healing/stages instead).
let storage_settings = self.cached_storage_settings();
if !storage_settings.account_history_in_rocksdb {
self.insert_account_history_index(account_transitions)?;
}
if !storage_settings.storages_history_in_rocksdb {
self.insert_storage_history_index(storage_transitions)?;
}
durations_recorder.record_relative(metrics::Action::InsertHistoryIndices);
// Update pipeline progress