-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(storage): wire RocksDB into DB Provider And Historical Provider [3/3] #20544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: yk/pr2-rocksdb-infrastructure
Are you sure you want to change the base?
feat(storage): wire RocksDB into DB Provider And Historical Provider [3/3] #20544
Conversation
3fe37d1 to
75a5a5d
Compare
e45acf9 to
40f84f2
Compare
75a5a5d to
28e5af4
Compare
de43672 to
9e5131e
Compare
7b937ec to
9aefeba
Compare
27ea434 to
6f04c58
Compare
e885749 to
6b3de83
Compare
6f04c58 to
48852bd
Compare
46f23c6 to
5a518d5
Compare
48852bd to
1a553ac
Compare
9161ae0 to
7549845
Compare
| /// | ||
| /// Uses the rank/select logic to efficiently find the first block >= target | ||
| /// where the account was modified. | ||
| pub fn account_history_info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the wiring up part, which is different from pr2 where its just rocks db
| /// Single `RocksDB` batch for history index operations. | ||
| /// All history index writes accumulate here and commit together at provider commit time. | ||
| #[cfg(all(unix, feature = "rocksdb"))] | ||
| pending_rocks_batch: parking_lot::Mutex<crate::providers::rocksdb::RocksDBBatch>, | ||
| /// In-memory cache of history-index "last shards" (the `u64::MAX` shard that receives appends) | ||
| /// for the shared `RocksDB` batch. | ||
| /// | ||
| /// History index appends are read-modify-write: read last shard, merge new block numbers, | ||
| /// then write it back. With MDBX, the write transaction can read its own writes, so | ||
| /// subsequent appends see earlier updates. `RocksDBBatch` is write-only, so without this | ||
| /// cache each append would read only the persisted state and clobber earlier batch writes. | ||
| #[cfg(all(unix, feature = "rocksdb"))] | ||
| pending_history_index_last_shards: parking_lot::Mutex<PendingHistoryIndexLastShards>, | ||
| /// Pending `RocksDB` batches to be committed at provider commit time (from `EitherWriter`). | ||
| #[cfg(all(unix, feature = "rocksdb"))] | ||
| pending_rocksdb_batches: parking_lot::Mutex<Vec<rocksdb::WriteBatchWithTransaction<true>>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels like rocksdb is leaking too much here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and it's not clear to me why we even need mutexes for this
| // MDBX path | ||
| let mut cursor = self.tx.cursor_read::<tables::TransactionHashNumbers>()?; | ||
| Ok(cursor.seek_exact(tx_hash)?.map(|(_, v)| v)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // MDBX path | |
| let mut cursor = self.tx.cursor_read::<tables::TransactionHashNumbers>()?; | |
| Ok(cursor.seek_exact(tx_hash)?.map(|(_, v)| v)) | |
| Ok(self.tx.get::<tables::TransactionHashNumbers>(tx_hash)?) |
|
|
||
| #[cfg(all(unix, feature = "rocksdb"))] | ||
| { | ||
| // Commit the shared history index batch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Commit the shared history index batch |
|
|
||
| #[cfg(all(unix, feature = "rocksdb"))] | ||
| { | ||
| // Commit the shared history index batch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Commit the shared history index batch |
joshieDo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think overall this needs to be refactored so rocksdb logic is mostly contained in a rocksdb type, right now its leaking with the mutexes and/or methods ending with _rocksdb
85460a0 to
9497ae7
Compare
fad81ba to
59af41c
Compare
9497ae7 to
878fc62
Compare
59af41c to
f3021e2
Compare
This wires RocksDB into the history lookup paths: - Adds account_history_info and storage_history_info methods to EitherReader - Updates HistoricalStateProviderRef to use EitherReader for lookups - Adds RocksDBProviderFactory trait bounds to provider impls - Uses the pure find_changeset_block_from_index API with lazy cursor.prev()
878fc62 to
0a6a08f
Compare
Summary
Complete RocksDB integration for history tables by wiring everything together. Closes #20388
This is PR 3/3 of a stacked PR series that splits #20412 for easier review.
Depends on: #20543 → #20542
Review focus
Stack