Skip to content

Commit

Permalink
fix(zkstack): Fix duplicated chain layer (#3348)
Browse files Browse the repository at this point in the history
## What ❔

<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## 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 `zkstack dev fmt` and `zkstack dev
lint`.
  • Loading branch information
matias-gonz authored Nov 29, 2024
1 parent 8256433 commit 8584649
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
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

0 comments on commit 8584649

Please sign in to comment.