From 85846499834599964584d0df78fe711da658a848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Ignacio=20Gonz=C3=A1lez?= Date: Fri, 29 Nov 2024 12:11:45 -0300 Subject: [PATCH] fix(zkstack): Fix duplicated chain layer (#3348) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ ## Why ❔ ## 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 `zkstack dev fmt` and `zkstack dev lint`. --- .../zkstack/src/commands/chain/args/create.rs | 6 ++---- .../zkstack/src/commands/chain/create.rs | 21 +++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/args/create.rs b/zkstack_cli/crates/zkstack/src/commands/chain/args/create.rs index c6f2f8b28362..27fd3ff8cf56 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/args/create.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/args/create.rs @@ -94,8 +94,6 @@ impl ChainCreateArgs { .unwrap_or_else(|| Prompt::new(MSG_CHAIN_NAME_PROMPT).ask()); chain_name = slugify!(&chain_name, separator = "_"); - let chain_path = chains_path.unwrap_or_default().join(&chain_name); - let chain_id = self .chain_id .map(|v| match v { @@ -261,7 +259,7 @@ impl ChainCreateArgs { legacy_bridge: self.legacy_bridge, evm_emulator, link_to_code, - chain_path, + chains_path, era_chain_id, internal_id, l1_network, @@ -282,7 +280,7 @@ pub struct ChainCreateArgsFinal { pub legacy_bridge: bool, pub evm_emulator: bool, pub link_to_code: String, - pub chain_path: PathBuf, + pub chains_path: Option, pub era_chain_id: L2ChainId, pub internal_id: u32, pub l1_network: L1Network, diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/create.rs b/zkstack_cli/crates/zkstack/src/commands/chain/create.rs index 4ef5f8573ed1..a27d1972b92c 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/create.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/create.rs @@ -1,4 +1,4 @@ -use std::cell::OnceCell; +use std::{cell::OnceCell, path::PathBuf}; use anyhow::Context; use common::{logger, spinner::Spinner}; @@ -95,7 +95,11 @@ pub(crate) fn create_chain_inner(args: ChainCreateArgsFinal, shell: &Shell) -> a logger::warn("WARNING!!! You are creating a chain with legacy bridge, use it only for testing compatibility") } let default_chain_name = args.chain_name.clone(); - let chain_path = args.chain_path; + let chain_path = args + .chains_path + .clone() + .unwrap_or_default() + .join(&default_chain_name); let chain_configs_path = create_local_configs_dir(shell, &chain_path)?; let (chain_id, legacy_bridge) = if args.legacy_bridge { // Legacy bridge is distinguished by using the same chain id as ecosystem @@ -112,8 +116,17 @@ pub(crate) fn create_chain_inner(args: ChainCreateArgsFinal, shell: &Shell) -> a if args.evm_emulator && !has_evm_emulation_support { anyhow::bail!(MSG_EVM_EMULATOR_HASH_MISSING_ERR); } - let rocks_db_path = chain_path.join(LOCAL_DB_PATH); - let artifacts = chain_path.join(LOCAL_ARTIFACTS_PATH); + let (rocks_db_path, artifacts) = if args.chains_path.is_none() { + ( + PathBuf::from(LOCAL_DB_PATH), + PathBuf::from(LOCAL_ARTIFACTS_PATH), + ) + } else { + ( + chain_path.join(LOCAL_DB_PATH), + chain_path.join(LOCAL_ARTIFACTS_PATH), + ) + }; let chain_config = ChainConfig { id: args.internal_id,