From d1d919a8d7209353ea969e11f0744eeb4b7dabc1 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Fri, 22 Dec 2023 13:22:05 +0400 Subject: [PATCH] chore: Retire the lightweight tree component (#732) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Removes the component-based option to enable the lightweight tree. Also, it drops the support for `_new` postfix for the tree component. ## Why ❔ The tree can be configured via configuration options in a more elegant way. ## Checklist - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`. - [ ] Spellcheck has been run via `cargo spellcheck --cfg=./spellcheck/era.cfg --code 1`. --- core/lib/zksync_core/src/lib.rs | 40 ++++++------------- .../docker-compose-hyperchain-template.hbs | 2 +- infrastructure/zk/src/hyperchain_wizard.ts | 4 +- 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/core/lib/zksync_core/src/lib.rs b/core/lib/zksync_core/src/lib.rs index 275a81e23229..b4ddea4a797a 100644 --- a/core/lib/zksync_core/src/lib.rs +++ b/core/lib/zksync_core/src/lib.rs @@ -216,8 +216,6 @@ pub enum Component { ContractVerificationApi, /// Metadata calculator. Tree, - // TODO(BFT-273): Remove `TreeLightweight` component as obsolete - TreeLightweight, /// Merkle tree API. TreeApi, EthWatcher, @@ -252,10 +250,7 @@ impl FromStr for Components { "http_api" => Ok(Components(vec![Component::HttpApi])), "ws_api" => Ok(Components(vec![Component::WsApi])), "contract_verification_api" => Ok(Components(vec![Component::ContractVerificationApi])), - "tree" | "tree_new" => Ok(Components(vec![Component::Tree])), - "tree_lightweight" | "tree_lightweight_new" => { - Ok(Components(vec![Component::TreeLightweight])) - } + "tree" => Ok(Components(vec![Component::Tree])), "tree_api" => Ok(Components(vec![Component::TreeApi])), "state_keeper" => Ok(Components(vec![Component::StateKeeper])), "housekeeper" => Ok(Components(vec![Component::Housekeeper])), @@ -754,6 +749,14 @@ async fn add_trees_to_task_futures( store_factory: &ObjectStoreFactory, stop_receiver: watch::Receiver, ) -> anyhow::Result<()> { + if !components.contains(&Component::Tree) { + anyhow::ensure!( + !components.contains(&Component::TreeApi), + "Merkle tree API cannot be started without a tree component" + ); + return Ok(()); + } + let db_config = configs.db_config.clone().context("db_config")?; let operation_config = configs .operations_manager_config @@ -769,28 +772,11 @@ async fn add_trees_to_task_futures( .contains(&Component::TreeApi) .then_some(&api_config); - let has_tree_component = components.contains(&Component::Tree); - let has_lightweight_component = components.contains(&Component::TreeLightweight); - let mode = match (has_tree_component, has_lightweight_component) { - (true, true) => anyhow::bail!( - "Cannot start a node with a Merkle tree in both full and lightweight modes. \ - Since the storage layout is mode-independent, choose either of modes and run \ - the node with it." - ), - (false, true) => MetadataCalculatorModeConfig::Lightweight, - (true, false) => match db_config.merkle_tree.mode { - MerkleTreeMode::Lightweight => MetadataCalculatorModeConfig::Lightweight, - MerkleTreeMode::Full => MetadataCalculatorModeConfig::Full { - store_factory: Some(store_factory), - }, + let mode = match db_config.merkle_tree.mode { + MerkleTreeMode::Lightweight => MetadataCalculatorModeConfig::Lightweight, + MerkleTreeMode::Full => MetadataCalculatorModeConfig::Full { + store_factory: Some(store_factory), }, - (false, false) => { - anyhow::ensure!( - !components.contains(&Component::TreeApi), - "Merkle tree API cannot be started without a tree component" - ); - return Ok(()); - } }; run_tree( diff --git a/etc/hyperchains/docker-compose-hyperchain-template.hbs b/etc/hyperchains/docker-compose-hyperchain-template.hbs index 6b540db6a7f2..a66da9e47fa1 100644 --- a/etc/hyperchains/docker-compose-hyperchain-template.hbs +++ b/etc/hyperchains/docker-compose-hyperchain-template.hbs @@ -10,7 +10,7 @@ services: networks: - zksync-era_zkstack image: {{orgName}}/server-v2:latest - command: ["--components", "tree_new,eth,state_keeper,housekeeper,proof_data_handler"] + command: ["--components", "tree,eth,state_keeper,housekeeper,proof_data_handler"] healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3071/health"] interval: 10s diff --git a/infrastructure/zk/src/hyperchain_wizard.ts b/infrastructure/zk/src/hyperchain_wizard.ts index c13fe29b38c4..73e3f69d7a10 100644 --- a/infrastructure/zk/src/hyperchain_wizard.ts +++ b/infrastructure/zk/src/hyperchain_wizard.ts @@ -489,7 +489,7 @@ async function startServer() { const results: any = await enquirer.prompt(questions); let components: string[] = []; - const defaultChoices = ['http_api', 'eth', 'state_keeper', 'housekeeper', 'tree_lightweight']; + const defaultChoices = ['http_api', 'eth', 'state_keeper', 'housekeeper', 'tree']; if (results.start === NO) { return; @@ -499,7 +499,7 @@ async function startServer() { message: 'Please select the desired components', name: 'components', type: 'multiselect', - choices: ['api', 'ws_api', ...defaultChoices, 'tree'].sort() + choices: ['api', 'ws_api', ...defaultChoices].sort() } ];