11use std:: collections:: HashMap ;
22use std:: error:: Error ;
33use std:: marker:: PhantomData ;
4+ use std:: path:: Path ;
45
56use apollo_committer_config:: config:: CommitterConfig ;
67use apollo_committer_types:: committer_types:: {
@@ -35,6 +36,7 @@ use starknet_committer::db::serde_db_utils::{
3536use starknet_committer:: forest:: filled_forest:: FilledForest ;
3637use starknet_patricia:: patricia_merkle_tree:: filled_tree:: tree:: FilledTreeImpl ;
3738use starknet_patricia_storage:: map_storage:: MapStorage ;
39+ use starknet_patricia_storage:: rocksdb_storage:: { RocksDbOptions , RocksDbStorage } ;
3840use starknet_patricia_storage:: storage_trait:: { DbValue , Storage } ;
3941use tracing:: { debug, error, info, warn} ;
4042
@@ -44,7 +46,7 @@ use crate::metrics::register_metrics;
4446#[ path = "committer_test.rs" ]
4547mod committer_test;
4648
47- pub type ApolloStorage = MapStorage ;
49+ pub type ApolloStorage = RocksDbStorage ;
4850
4951// TODO(Yoav): Move this to committer_test.rs and use index db reader.
5052pub struct CommitBlockMock ;
@@ -79,12 +81,21 @@ pub trait StorageConstructor: Storage {
7981 fn create_storage ( ) -> Self ;
8082}
8183
82- impl StorageConstructor for ApolloStorage {
84+ impl StorageConstructor for MapStorage {
8385 fn create_storage ( ) -> Self {
8486 Self :: default ( )
8587 }
8688}
8789
90+ impl StorageConstructor for RocksDbStorage {
91+ fn create_storage ( ) -> Self {
92+ // Concatenate a random hex string to the RocksDB path to avoid collisions.
93+ let rand_hex = format ! ( "{:08x}" , rand:: random:: <u32 >( ) ) ;
94+ let path = format ! ( "/tmp/committer_storage/rocksdb/{rand_hex}" ) ;
95+ Self :: open ( Path :: new ( & path) , RocksDbOptions :: default ( ) , false ) . unwrap ( )
96+ }
97+ }
98+
8899/// Apollo committer. Maintains the Starknet state tries in persistent storage.
89100pub struct Committer < S : StorageConstructor , CB : CommitBlockTrait > {
90101 /// Storage for forest operations.
0 commit comments