- Removed unused imports related to `StorageShardedKey` and `ShardedKey` to streamline the code.
- Added comments to clarify the logic for writing full shards keyed by the highest block and handling the last chunk in memory.
- These changes improve code readability and maintainability.
- Changed the return type of `unwind_history_via_rocksdb` and related functions from `Result<usize, StageError>` to `Result<(), StageError>` to simplify the return value.
- Renamed parameters `mk_start_key` and `mk_sentinel_key` to `lowest_shard_key` and `sentinel_shard_key` for improved clarity.
- Removed the count variable and adjusted logic to focus on batch processing without tracking the count of affected keys.
These changes enhance code clarity and streamline the function's implementation while maintaining its core functionality.
- Updated the function name from `unwind_history_via_rocksdb_generic` to `unwind_history_via_rocksdb` for improved clarity and consistency.
- Adjusted related function calls to reflect the new name, enhancing code readability.
These changes streamline the function's naming and maintain the existing functionality.
- Introduced a new doc comment for the `flush_account_shards` function, detailing its purpose and behavior.
- Explained how the function splits a list into chunks and manages shard writing, including the handling of the last chunk when `flush_all` is false.
- Clarified the use of `u64::MAX` as the sentinel key in the final shard.
These changes enhance the understanding of the function's implementation and usage.
- Introduced a new doc comment for the `flush_storage_shards` function, detailing its purpose and behavior.
- Explained how the function splits a list into chunks and manages shard writing, including the handling of the last chunk when `flush_all` is false.
- Improved clarity on the use of `u64::MAX` as a sentinel key in the final shard.
These changes enhance the understanding of the function's implementation and usage.
- Updated the generic type parameter from `PK` to `PartialKey` for clarity in the `unwind_history_via_rocksdb_generic` function.
- Adjusted related function signatures and internal references to maintain consistency.
- These changes improve code readability and better convey the purpose of the parameters.
- Introduced a new test `unwind_crosses_shard_boundary` in both `index_account_history.rs` and `index_storage_history.rs`.
- The test verifies that unwinding correctly manages indices that span multiple shards, ensuring that the sentinel shard only contains blocks below the unwind threshold and that the old full shard is deleted.
- Enhancements to the existing test suite improve coverage for edge cases in shard management.
These changes enhance the robustness of the unwind functionality in the RocksDB implementation.
- Consolidate RocksDB provider initialization to reduce redundancy in `flush_storage_shards` and related functions.
- Rename `flush` parameter to `flush_all` for clarity in intent.
- Ensure non-empty checks for chunk processing in storage shard logic.
These changes enhance code readability and maintainability while preserving existing functionality.
Implements #20390 - Modify history indexing stages to use EitherWriter for RocksDB writes.
**Execute changes:**
- Add RocksDB write path to IndexStorageHistoryStage using EitherWriter
- Add RocksDB write path to IndexAccountHistoryStage using EitherWriter
- Add load_storage_history_indices_via_writer and load_account_history_indices_via_writer
helpers with proper sharding logic and merge support for incremental syncs
- Add StorageSettingsCache, RocksDBProviderFactory, NodePrimitivesProvider trait bounds
**Unwind changes:**
- Add unwind_history_via_rocksdb_generic helper to reduce code duplication
- Stream changesets directly into BTreeSet instead of collecting Vec first
- Add comprehensive test coverage for edge cases
When storages_history_in_rocksdb or account_history_in_rocksdb is enabled,
writes and unwinds are routed to RocksDB instead of MDBX.
Amp-Thread-ID: https://ampcode.com/threads/T-019b8ca2-143e-73fa-93d3-c806e9da7b92