Skip to content

Commit

Permalink
refactor: Remove RocksDB backup leftovers (matter-labs#721)
Browse files Browse the repository at this point in the history
## What ❔

Removes leftovers of RocksDB backup functionality.

## Why ❔

Support for backups has been removed long ago, and we currently don't
have plans to restore it.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
- [x] Spellcheck has been run via `cargo spellcheck
--cfg=./spellcheck/era.cfg --code 1`.
  • Loading branch information
popzxc authored Dec 22, 2023
1 parent 0804674 commit 4ec3194
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 169 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ members = [
"core/bin/contract-verifier",
"core/bin/external_node",
"core/bin/merkle_tree_consistency_checker",
"core/bin/rocksdb_util",
"core/bin/snapshots_creator",
"core/bin/storage_logs_dedup_migration",
"core/bin/system-constants-generator",
Expand Down
22 changes: 0 additions & 22 deletions core/bin/rocksdb_util/Cargo.toml

This file was deleted.

85 changes: 0 additions & 85 deletions core/bin/rocksdb_util/src/main.rs

This file was deleted.

26 changes: 0 additions & 26 deletions core/lib/config/src/configs/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ pub struct MerkleTreeConfig {
/// Path to the RocksDB data directory for Merkle tree.
#[serde(default = "MerkleTreeConfig::default_path")]
pub path: String,
/// Path to merkle tree backup directory.
#[serde(default = "MerkleTreeConfig::default_backup_path")]
pub backup_path: String,
/// Operation mode for the Merkle tree. If not specified, the full mode will be used.
#[serde(default)]
pub mode: MerkleTreeMode,
Expand Down Expand Up @@ -53,7 +50,6 @@ impl Default for MerkleTreeConfig {
fn default() -> Self {
Self {
path: Self::default_path(),
backup_path: Self::default_backup_path(),
mode: MerkleTreeMode::default(),
multi_get_chunk_size: Self::default_multi_get_chunk_size(),
block_cache_size_mb: Self::default_block_cache_size_mb(),
Expand All @@ -69,10 +65,6 @@ impl MerkleTreeConfig {
"./db/lightweight-new".to_owned() // named this way for legacy reasons
}

fn default_backup_path() -> String {
"./db/backups".to_owned()
}

const fn default_multi_get_chunk_size() -> usize {
500
}
Expand Down Expand Up @@ -120,30 +112,12 @@ pub struct DBConfig {
// ^ Filled in separately in `Self::from_env()`. We cannot use `serde(flatten)` because it
// doesn't work with 'envy`.
pub merkle_tree: MerkleTreeConfig,
/// Number of backups to keep.
#[serde(default = "DBConfig::default_backup_count")]
pub backup_count: usize,
/// Time interval between performing backups.
#[serde(default = "DBConfig::default_backup_interval_ms")]
pub backup_interval_ms: u64,
}

impl DBConfig {
fn default_state_keeper_db_path() -> String {
"./db/state_keeper".to_owned()
}

const fn default_backup_count() -> usize {
5
}

const fn default_backup_interval_ms() -> u64 {
60_000
}

pub fn backup_interval(&self) -> Duration {
Duration::from_millis(self.backup_interval_ms)
}
}

/// Collection of different database URLs and general PostgreSQL options.
Expand Down
11 changes: 0 additions & 11 deletions core/lib/env_config/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,23 @@ mod tests {
let mut lock = MUTEX.lock();
let config = r#"
DATABASE_STATE_KEEPER_DB_PATH="/db/state_keeper"
DATABASE_MERKLE_TREE_BACKUP_PATH="/db/backups"
DATABASE_MERKLE_TREE_PATH="/db/tree"
DATABASE_MERKLE_TREE_MODE=lightweight
DATABASE_MERKLE_TREE_MULTI_GET_CHUNK_SIZE=250
DATABASE_MERKLE_TREE_MEMTABLE_CAPACITY_MB=512
DATABASE_MERKLE_TREE_STALLED_WRITES_TIMEOUT_SEC=60
DATABASE_MERKLE_TREE_MAX_L1_BATCHES_PER_ITER=50
DATABASE_BACKUP_COUNT=5
DATABASE_BACKUP_INTERVAL_MS=60000
"#;
lock.set_env(config);

let db_config = DBConfig::from_env().unwrap();
assert_eq!(db_config.state_keeper_db_path, "/db/state_keeper");
assert_eq!(db_config.merkle_tree.path, "/db/tree");
assert_eq!(db_config.merkle_tree.backup_path, "/db/backups");
assert_eq!(db_config.merkle_tree.mode, MerkleTreeMode::Lightweight);
assert_eq!(db_config.merkle_tree.multi_get_chunk_size, 250);
assert_eq!(db_config.merkle_tree.max_l1_batches_per_iter, 50);
assert_eq!(db_config.merkle_tree.memtable_capacity_mb, 512);
assert_eq!(db_config.merkle_tree.stalled_writes_timeout_sec, 60);
assert_eq!(db_config.backup_count, 5);
assert_eq!(db_config.backup_interval().as_secs(), 60);
}

#[test]
Expand All @@ -97,22 +91,17 @@ mod tests {
"DATABASE_MERKLE_TREE_MEMTABLE_CAPACITY_MB",
"DATABASE_MERKLE_TREE_STALLED_WRITES_TIMEOUT_SEC",
"DATABASE_MERKLE_TREE_MAX_L1_BATCHES_PER_ITER",
"DATABASE_BACKUP_COUNT",
"DATABASE_BACKUP_INTERVAL_MS",
]);

let db_config = DBConfig::from_env().unwrap();
assert_eq!(db_config.state_keeper_db_path, "./db/state_keeper");
assert_eq!(db_config.merkle_tree.path, "./db/lightweight-new");
assert_eq!(db_config.merkle_tree.backup_path, "./db/backups");
assert_eq!(db_config.merkle_tree.mode, MerkleTreeMode::Full);
assert_eq!(db_config.merkle_tree.multi_get_chunk_size, 500);
assert_eq!(db_config.merkle_tree.max_l1_batches_per_iter, 20);
assert_eq!(db_config.merkle_tree.block_cache_size_mb, 128);
assert_eq!(db_config.merkle_tree.memtable_capacity_mb, 256);
assert_eq!(db_config.merkle_tree.stalled_writes_timeout_sec, 30);
assert_eq!(db_config.backup_count, 5);
assert_eq!(db_config.backup_interval().as_secs(), 60);

// Check that new env variable for Merkle tree path is supported
lock.set_env("DATABASE_MERKLE_TREE_PATH=/db/tree/main");
Expand Down
6 changes: 0 additions & 6 deletions core/lib/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ pub enum Component {
Tree,
// TODO(BFT-273): Remove `TreeLightweight` component as obsolete
TreeLightweight,
TreeBackup,
/// Merkle tree API.
TreeApi,
EthWatcher,
Expand Down Expand Up @@ -257,7 +256,6 @@ impl FromStr for Components {
"tree_lightweight" | "tree_lightweight_new" => {
Ok(Components(vec![Component::TreeLightweight]))
}
"tree_backup" => Ok(Components(vec![Component::TreeBackup])),
"tree_api" => Ok(Components(vec![Component::TreeApi])),
"state_keeper" => Ok(Components(vec![Component::StateKeeper])),
"housekeeper" => Ok(Components(vec![Component::Housekeeper])),
Expand Down Expand Up @@ -756,10 +754,6 @@ async fn add_trees_to_task_futures(
store_factory: &ObjectStoreFactory,
stop_receiver: watch::Receiver<bool>,
) -> anyhow::Result<()> {
if components.contains(&Component::TreeBackup) {
anyhow::bail!("Tree backup mode is disabled");
}

let db_config = configs.db_config.clone().context("db_config")?;
let operation_config = configs
.operations_manager_config
Expand Down
3 changes: 0 additions & 3 deletions core/lib/zksync_core/src/metadata_calculator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pub struct MetadataCalculator {
impl MetadataCalculator {
/// Creates a calculator with the specified `config`.
pub async fn new(config: &MetadataCalculatorConfig<'_>) -> Self {
// TODO (SMA-1726): restore the tree from backup if appropriate
assert!(
config.max_l1_batches_per_iter > 0,
"Maximum L1 batches per iteration is misconfigured to be 0; please update it to positive value"
Expand Down Expand Up @@ -271,6 +270,4 @@ impl MetadataCalculator {
tracing::trace!("L1 batch metadata: {metadata:?}");
metadata
}

// TODO (SMA-1726): Integrate tree backup mode
}
2 changes: 0 additions & 2 deletions core/lib/zksync_core/src/metadata_calculator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ async fn genesis_creation() {
assert_eq!(tree.next_l1_batch_number(), L1BatchNumber(1));
}

// TODO (SMA-1726): Restore tests for tree backup mode

#[tokio::test]
async fn basic_workflow() {
let pool = ConnectionPool::test_pool().await;
Expand Down
1 change: 0 additions & 1 deletion docker/server-v2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ EXPOSE 3030
COPY --from=builder /usr/src/zksync/target/release/zksync_server /usr/bin
COPY --from=builder /usr/src/zksync/target/release/block_reverter /usr/bin
COPY --from=builder /usr/src/zksync/target/release/merkle_tree_consistency_checker /usr/bin
COPY --from=builder /usr/src/zksync/target/release/rocksdb_util /usr/bin
COPY contracts/system-contracts/bootloader/build/artifacts/ /contracts/system-contracts/bootloader/build/artifacts/
COPY contracts/system-contracts/contracts/artifacts/ /contracts/system-contracts/contracts/artifacts/
COPY contracts/system-contracts/contracts/precompiles/artifacts/ /contracts/system-contracts/contracts/precompiles/artifacts/
Expand Down

0 comments on commit 4ec3194

Please sign in to comment.