Skip to content

Use EitherReader/EitherWriter in DatabaseProvider and HistoricalStateProvider #20388

@fgimenez

Description

@fgimenez

Update provider methods to use EitherReader/EitherWriter so they can read from/write to RocksDB when the feature is enabled.

In crates/storage/provider/src/providers/database/provider.rs:

  1. TransactionsProvider::transaction_id():

    • Currently: self.tx.get::<tables::TransactionHashNumbers>(tx_hash)
    • Change to: Use EitherReader::new_transaction_hash_numbers() and call get_transaction_hash_number()
  2. insert_block() transaction hash writes:

    • Currently: self.tx.put::<tables::TransactionHashNumbers>(*hash, tx_num)
    • Change to: Use EitherWriter::new_transaction_hash_numbers() and call put_transaction_hash_number()
  3. remove_blocks_above() transaction hash deletes:

    • Currently: self.tx.delete::<tables::TransactionHashNumbers>(hash, None)
    • Change to: Use EitherWriter::new_transaction_hash_numbers() and call delete_transaction_hash_number()
  4. HistoryWriter::unwind_storage_history_indices():

    • Currently: Uses self.tx.cursor_write::<tables::StoragesHistory>()
    • Change to: Use EitherWriter::new_storages_history() for delete operations
    • Note: This method uses unwind_history_shards helper which walks the cursor - may need refactoring
  5. HistoryWriter::unwind_account_history_indices():

    • Currently: Uses self.tx.cursor_write::<tables::AccountsHistory>()
    • Change to: Use EitherWriter::new_accounts_history() for delete operations
    • Note: Same pattern as storage history - uses unwind_history_shards helper

In crates/storage/provider/src/providers/state/historical.rs:

  1. storage_history_lookup():

    • Currently: Uses history_info::<tables::StoragesHistory, _>() which internally uses DB cursor
    • Change to: Use EitherReader::new_storages_history() and call get_storage_history()
    • Note: The history_info helper uses cursor walking - may need a RocksDB-specific code path
  2. account_history_lookup():

    • Currently: Uses history_info::<tables::AccountsHistory, _>() which internally uses DB cursor
    • Change to: Use EitherReader::new_accounts_history() and call get_account_history()
    • Note: Same pattern as storage history - uses history_info helper

Helper methods that may need refactoring for RocksDB:

Metadata

Metadata

Assignees

Labels

A-dbRelated to the databaseC-enhancementNew feature or requestinhouseOnly for reth team

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions