CompositeStateStore: Add RocksDB backend support #2956
Conversation
Introduce an EVMDBEngine interface and backend registry (matching the existing pattern in ss/pebbledb_init.go and ss/rocksdb_init.go) so that EVM sub-databases can use either PebbleDB or RocksDB. New files: - evm/engine.go: EVMDBEngine interface + RegisterEVMBackend registry - evm/db_rocksdb.go: RocksDB implementation using user-defined timestamps and column families (mirrors the rocksdb/mvcc pattern), includes timestamp comparator and backend registration Modified files: - evm/db.go: registers PebbleDB EVM backend at init - evm/store.go: EVMStateStore uses EVMDBEngine interface; NewEVMStateStore accepts a backend name parameter - composite/store.go: NewCompositeStateStore accepts a pre-created cosmos store (removing the hardcoded pebbledb/mvcc import) and passes the backend name through to NewEVMStateStore - ss/store.go: NewStateStore uses the backend registry to create the cosmos store, then passes it to the composite store Both Cosmos_SS and EVM_SS now respect ssConfig.Backend for engine selection. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2956 +/- ##
===========================================
+ Coverage 58.10% 63.44% +5.33%
===========================================
Files 2109 12 -2097
Lines 173384 1209 -172175
===========================================
- Hits 100749 767 -99982
+ Misses 63683 331 -63352
+ Partials 8952 111 -8841
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| opts.SetCreateIfMissing(true) | ||
| opts.SetComparator(createTimestampComparator()) | ||
| opts.IncreaseParallelism(runtime.NumCPU()) | ||
| opts.OptimizeLevelStyleCompaction(512 * 1024 * 1024) |
There was a problem hiding this comment.
Will have to tune these opts more
| // EVM stores are opened when ssConfig.EVMEnabled() returns true (derived from WriteMode/ReadMode). | ||
| // The same backend (ssConfig.Backend) is used for EVM sub-databases. | ||
| func NewCompositeStateStore( | ||
| cosmosStore types.StateStore, |
There was a problem hiding this comment.
Having to pass in cosmosStore seems a bit weird to me, why can't we keep the previous interface but just move backend to top level ssconfig?
There was a problem hiding this comment.
The ss package imports composite, so composite can't import ss back to use the backend registry (would be a circular import). The old code addressed by hardcoding pebbledb/mvcc directly, but now that we support both PebbleDB and RocksDB (with RocksDB behind a build tag), we need the registry-based selection that lives in ss. Passing in the pre-created store is the standard dependency injection pattern to avoid the cycle
There was a problem hiding this comment.
Let me think about whether there's other way to address this, thanks for the explanation!
jewei1997
left a comment
There was a problem hiding this comment.
similar comments to Yiren
once those are fixed, lgtm
Apply the same fix from #2971 to the EVM RocksDB backend: assign ReadOptions to a local, defer Destroy(), and use heap-allocated timestamp slices so the backing array outlives the stack frame. Co-authored-by: Cursor <cursoragent@cursor.com>
- Destroy C-allocated Options (defaultOpts, cfOpts) after OpenDbColumnFamilies - Destroy ColumnFamilyHandle before DB.Close() to prevent C memory leak - Update latestVersion in Delete to match Set/ApplyBatch and PebbleDB behavior Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Describe your changes and provide context
EVMDBEngineinterface + backend registry so both Cosmos_SS and EVM_SS respectssConfig.Backendfor engine selectionNewCompositeStateStorenow accepts a pre-created cosmos store from the existing backend registry instead of importingpebbledb/mvccdirectlyTesting performed to validate your change