Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zkstack): Fix duplicated chain layer #3348

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions zkstack_cli/crates/zkstack/src/commands/chain/args/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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<PathBuf>,
pub era_chain_id: L2ChainId,
pub internal_id: u32,
pub l1_network: L1Network,
Expand Down
21 changes: 17 additions & 4 deletions zkstack_cli/crates/zkstack/src/commands/chain/create.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::cell::OnceCell;
use std::{cell::OnceCell, path::PathBuf};

use anyhow::Context;
use common::{logger, spinner::Spinner};
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down