Skip to content

Commit

Permalink
Merge pull request #210 from matter-labs/fix-boojum-rocksdb
Browse files Browse the repository at this point in the history
fix(boojum): remove extra code from state crate
  • Loading branch information
perekopskiy authored Oct 12, 2023
2 parents 9eefd43 + 1d6fda4 commit 5e7bc64
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
1 change: 0 additions & 1 deletion core/lib/state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ metrics = "0.21"

[dev-dependencies]
db_test_macro = { path = "../db_test_macro" }
itertools = "0.10.3"

rand = "0.8.5"
tempfile = "3.0.2"
2 changes: 1 addition & 1 deletion core/lib/state/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl InMemoryStorage {

let last_enum_index_set = state.len() as u64;
Self {
state: state.into_iter().collect(),
state,
factory_deps,
last_enum_index_set,
}
Expand Down
26 changes: 9 additions & 17 deletions core/lib/state/src/rocksdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,17 @@ enum StateKeeperColumnFamily {
State,
Contracts,
FactoryDeps,
EnumIndices,
}

impl NamedColumnFamily for StateKeeperColumnFamily {
const DB_NAME: &'static str = "state_keeper";
const ALL: &'static [Self] = &[
Self::State,
Self::Contracts,
Self::FactoryDeps,
Self::EnumIndices,
];
const ALL: &'static [Self] = &[Self::State, Self::Contracts, Self::FactoryDeps];

fn name(&self) -> &'static str {
match self {
Self::State => "state",
Self::Contracts => "contracts",
Self::FactoryDeps => "factory_deps",
Self::EnumIndices => "enum_indices",
}
}
}
Expand Down Expand Up @@ -192,7 +185,10 @@ impl RocksdbStorage {
"Secondary storage for L1 batch #{latest_l1_batch_number} initialized, size is {estimated_size}"
);

self.save_missing_enum_indices(conn).await;
// Enum indices must be at the storage. Run migration till the end.
while self.enum_migration_start_from().is_some() {
self.save_missing_enum_indices(conn).await;
}
}

async fn apply_storage_logs(
Expand Down Expand Up @@ -391,21 +387,18 @@ impl RocksdbStorage {
&StateValue::new(prev_value, Some(prev_index)).serialize(),
);
} else {
batch.delete_cf(StateKeeperColumnFamily::State, key.as_bytes());
batch.delete_cf(StateKeeperColumnFamily::EnumIndices, key.as_bytes());
batch.delete_cf(cf, key.as_bytes());
}
}
batch.put_cf(
StateKeeperColumnFamily::State,
cf,
Self::BLOCK_NUMBER_KEY,
&serialize_block_number(last_l1_batch_to_keep.0 + 1),
);

let cf = StateKeeperColumnFamily::FactoryDeps;
for factory_dep_hash in &factory_deps {
batch.delete_cf(
StateKeeperColumnFamily::FactoryDeps,
factory_dep_hash.as_bytes(),
);
batch.delete_cf(cf, factory_dep_hash.as_bytes());
}

db.write(batch)
Expand Down Expand Up @@ -512,7 +505,6 @@ impl ReadStorage for RocksdbStorage {
#[cfg(test)]
mod tests {
use db_test_macro::db_test;
use itertools::Itertools;
use tempfile::TempDir;

use super::*;
Expand Down

0 comments on commit 5e7bc64

Please sign in to comment.