Skip to content

Commit ba57132

Browse files
committed
apollo_committer: use rocks db storage
1 parent 9f35e4b commit ba57132

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/apollo_committer/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ apollo_committer_types.workspace = true
1515
apollo_infra.workspace = true
1616
apollo_metrics.workspace = true
1717
async-trait.workspace = true
18+
rand.workspace = true
1819
starknet_api.workspace = true
1920
starknet_committer.workspace = true
2021
starknet_patricia.workspace = true
21-
starknet_patricia_storage.workspace = true
22+
starknet_patricia_storage = { workspace = true, features = ["rocksdb_storage"] }
2223
tracing.workspace = true
2324

2425
[dev-dependencies]

crates/apollo_committer/src/committer.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::collections::HashMap;
22
use std::error::Error;
33
use std::marker::PhantomData;
4+
use std::path::Path;
45

56
use apollo_committer_config::config::CommitterConfig;
67
use apollo_committer_types::committer_types::{
@@ -35,6 +36,7 @@ use starknet_committer::db::serde_db_utils::{
3536
use starknet_committer::forest::filled_forest::FilledForest;
3637
use starknet_patricia::patricia_merkle_tree::filled_tree::tree::FilledTreeImpl;
3738
use starknet_patricia_storage::map_storage::MapStorage;
39+
use starknet_patricia_storage::rocksdb_storage::{RocksDbOptions, RocksDbStorage};
3840
use starknet_patricia_storage::storage_trait::{DbValue, Storage};
3941
use tracing::{debug, error, info, warn};
4042

@@ -44,7 +46,7 @@ use crate::metrics::register_metrics;
4446
#[path = "committer_test.rs"]
4547
mod 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.
5052
pub 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.
89100
pub struct Committer<S: StorageConstructor, CB: CommitBlockTrait> {
90101
/// Storage for forest operations.

0 commit comments

Comments
 (0)