From ed71e0057f1df2d6613430f97327cfb81f5dad74 Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Fri, 29 Nov 2024 10:08:56 -0300 Subject: [PATCH 1/2] Fix update only_config --- zkstack_cli/crates/zkstack/src/commands/update.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/zkstack_cli/crates/zkstack/src/commands/update.rs b/zkstack_cli/crates/zkstack/src/commands/update.rs index 43f15703b159..298e4e0d88da 100644 --- a/zkstack_cli/crates/zkstack/src/commands/update.rs +++ b/zkstack_cli/crates/zkstack/src/commands/update.rs @@ -31,6 +31,12 @@ pub async fn run(shell: &Shell, args: UpdateArgs) -> anyhow::Result<()> { if !args.only_config { update_repo(shell, &ecosystem)?; + let path_to_era_observability = shell.current_dir().join(ERA_OBSERBAVILITY_DIR); + if shell.path_exists(path_to_era_observability.clone()) { + let spinner = Spinner::new(MSG_UPDATING_ERA_OBSERVABILITY_SPINNER); + git::pull(shell, path_to_era_observability)?; + spinner.finish(); + } } let general_config_path = ecosystem.get_default_configs_path().join(GENERAL_FILE); @@ -56,13 +62,6 @@ pub async fn run(shell: &Shell, args: UpdateArgs) -> anyhow::Result<()> { .await?; } - let path_to_era_observability = shell.current_dir().join(ERA_OBSERBAVILITY_DIR); - if shell.path_exists(path_to_era_observability.clone()) { - let spinner = Spinner::new(MSG_UPDATING_ERA_OBSERVABILITY_SPINNER); - git::pull(shell, path_to_era_observability)?; - spinner.finish(); - } - logger::outro(MSG_ZKSYNC_UPDATED); Ok(()) From 110741d02f2a1679393517d8c659b22ebf542c54 Mon Sep 17 00:00:00 2001 From: matias-gonz Date: Fri, 29 Nov 2024 10:27:45 -0300 Subject: [PATCH 2/2] Run update without ecosystem --- zkstack_cli/crates/config/src/consts.rs | 2 +- .../crates/zkstack/src/commands/update.rs | 53 +++++++++++-------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/zkstack_cli/crates/config/src/consts.rs b/zkstack_cli/crates/config/src/consts.rs index 1332d59037f4..7d8768260c34 100644 --- a/zkstack_cli/crates/config/src/consts.rs +++ b/zkstack_cli/crates/config/src/consts.rs @@ -25,7 +25,7 @@ pub const ZKSYNC_ERA_GIT_REPO: &str = "https://github.com/matter-labs/zksync-era /// Name of the docker-compose file inside zksync repository pub const DOCKER_COMPOSE_FILE: &str = "docker-compose.yml"; /// Path to the config file with mnemonic for localhost wallets -pub(crate) const CONFIGS_PATH: &str = "etc/env/file_based"; +pub const CONFIGS_PATH: &str = "etc/env/file_based"; /// Path to the docker-compose file for grafana pub const ERA_OBSERVABILITY_COMPOSE_FILE: &str = "era-observability/docker-compose.yml"; /// Path to era observability repository diff --git a/zkstack_cli/crates/zkstack/src/commands/update.rs b/zkstack_cli/crates/zkstack/src/commands/update.rs index 298e4e0d88da..65edb9864b05 100644 --- a/zkstack_cli/crates/zkstack/src/commands/update.rs +++ b/zkstack_cli/crates/zkstack/src/commands/update.rs @@ -1,6 +1,6 @@ -use std::path::Path; +use std::path::{Path, PathBuf}; -use anyhow::{Context, Ok}; +use anyhow::Ok; use common::{ db::migrate_db, git, logger, @@ -8,7 +8,7 @@ use common::{ yaml::{merge_yaml, ConfigDiff}, }; use config::{ - zkstack_config::ZkStackConfig, ChainConfig, EcosystemConfig, CONTRACTS_FILE, EN_CONFIG_FILE, + zkstack_config::ZkStackConfig, ChainConfig, CONFIGS_PATH, CONTRACTS_FILE, EN_CONFIG_FILE, ERA_OBSERBAVILITY_DIR, GENERAL_FILE, GENESIS_FILE, SECRETS_FILE, }; use xshell::Shell; @@ -18,19 +18,20 @@ use crate::{ consts::{PROVER_MIGRATIONS, SERVER_MIGRATIONS}, messages::{ msg_diff_contracts_config, msg_diff_genesis_config, msg_diff_secrets, msg_updating_chain, - MSG_CHAIN_NOT_FOUND_ERR, MSG_DIFF_EN_CONFIG, MSG_DIFF_EN_GENERAL_CONFIG, - MSG_DIFF_GENERAL_CONFIG, MSG_PULLING_ZKSYNC_CODE_SPINNER, - MSG_UPDATING_ERA_OBSERVABILITY_SPINNER, MSG_UPDATING_SUBMODULES_SPINNER, - MSG_UPDATING_ZKSYNC, MSG_ZKSYNC_UPDATED, + MSG_DIFF_EN_CONFIG, MSG_DIFF_EN_GENERAL_CONFIG, MSG_DIFF_GENERAL_CONFIG, + MSG_PULLING_ZKSYNC_CODE_SPINNER, MSG_UPDATING_ERA_OBSERVABILITY_SPINNER, + MSG_UPDATING_SUBMODULES_SPINNER, MSG_UPDATING_ZKSYNC, MSG_ZKSYNC_UPDATED, }, }; pub async fn run(shell: &Shell, args: UpdateArgs) -> anyhow::Result<()> { logger::info(MSG_UPDATING_ZKSYNC); - let ecosystem = ZkStackConfig::ecosystem(shell)?; + let config = ZkStackConfig::from_file(shell)?; + let link_to_code = config.link_to_code(); + let default_configs_path = link_to_code.join(CONFIGS_PATH); if !args.only_config { - update_repo(shell, &ecosystem)?; + update_repo(shell, link_to_code)?; let path_to_era_observability = shell.current_dir().join(ERA_OBSERBAVILITY_DIR); if shell.path_exists(path_to_era_observability.clone()) { let spinner = Spinner::new(MSG_UPDATING_ERA_OBSERVABILITY_SPINNER); @@ -39,17 +40,25 @@ pub async fn run(shell: &Shell, args: UpdateArgs) -> anyhow::Result<()> { } } - let general_config_path = ecosystem.get_default_configs_path().join(GENERAL_FILE); - let external_node_config_path = ecosystem.get_default_configs_path().join(EN_CONFIG_FILE); - let genesis_config_path = ecosystem.get_default_configs_path().join(GENESIS_FILE); - let contracts_config_path = ecosystem.get_default_configs_path().join(CONTRACTS_FILE); - let secrets_path = ecosystem.get_default_configs_path().join(SECRETS_FILE); - - for chain in ecosystem.list_of_chains() { - logger::step(msg_updating_chain(&chain)); - let chain = ecosystem - .load_chain(Some(chain)) - .context(MSG_CHAIN_NOT_FOUND_ERR)?; + let general_config_path = default_configs_path.join(GENERAL_FILE); + let external_node_config_path = default_configs_path.join(EN_CONFIG_FILE); + let genesis_config_path = default_configs_path.join(GENESIS_FILE); + let contracts_config_path = default_configs_path.join(CONTRACTS_FILE); + let secrets_path = default_configs_path.join(SECRETS_FILE); + + let chains = match config { + ZkStackConfig::EcosystemConfig(ecosystem) => { + let mut chains = vec![]; + for chain_name in ecosystem.list_of_chains() { + chains.push(ecosystem.load_chain(Some(chain_name))?); + } + chains + } + ZkStackConfig::ChainConfig(chain) => vec![chain], + }; + + for chain in chains { + logger::step(msg_updating_chain(&chain.name)); update_chain( shell, &chain, @@ -67,9 +76,7 @@ pub async fn run(shell: &Shell, args: UpdateArgs) -> anyhow::Result<()> { Ok(()) } -fn update_repo(shell: &Shell, ecosystem: &EcosystemConfig) -> anyhow::Result<()> { - let link_to_code = ecosystem.link_to_code.clone(); - +fn update_repo(shell: &Shell, link_to_code: PathBuf) -> anyhow::Result<()> { let spinner = Spinner::new(MSG_PULLING_ZKSYNC_CODE_SPINNER); git::pull(shell, link_to_code.clone())?; spinner.finish();