Skip to content

Commit

Permalink
chore: Retire the lightweight tree component (#732)
Browse files Browse the repository at this point in the history
## 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

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

- [ ] 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`.
  • Loading branch information
popzxc authored Dec 22, 2023
1 parent 44b6e13 commit d1d919a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 30 deletions.
40 changes: 13 additions & 27 deletions core/lib/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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])),
Expand Down Expand Up @@ -754,6 +749,14 @@ async fn add_trees_to_task_futures(
store_factory: &ObjectStoreFactory,
stop_receiver: watch::Receiver<bool>,
) -> 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
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion etc/hyperchains/docker-compose-hyperchain-template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/zk/src/hyperchain_wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
}
];

Expand Down

0 comments on commit d1d919a

Please sign in to comment.