Skip to content

Commit

Permalink
feat(zk_toolbox): Add update command (#2440)
Browse files Browse the repository at this point in the history
## What ❔
Add update command

---------

Signed-off-by: Danil <deniallugo@gmail.com>
Co-authored-by: Danil <deniallugo@gmail.com>
  • Loading branch information
matias-gonz and Deniallugo authored Jul 26, 2024
1 parent a629ba1 commit e2fa86f
Show file tree
Hide file tree
Showing 10 changed files with 585 additions and 9 deletions.
9 changes: 9 additions & 0 deletions zk_toolbox/crates/common/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ pub fn submodule_update(shell: &Shell, link_to_code: PathBuf) -> anyhow::Result<
.run()?;
Ok(())
}

pub fn pull(shell: &Shell, link_to_code: PathBuf) -> anyhow::Result<()> {
let _dir_guard = shell.push_dir(link_to_code);
let res = Cmd::new(cmd!(shell, "git rev-parse --abbrev-ref HEAD")).run_with_output()?;
let current_branch = String::from_utf8(res.stdout)?;
let current_branch = current_branch.trim_end();
Cmd::new(cmd!(shell, "git pull origin {current_branch}")).run()?;
Ok(())
}
17 changes: 16 additions & 1 deletion zk_toolbox/crates/config/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use xshell::Shell;
use zksync_basic_types::L2ChainId;

use crate::{
consts::{CONFIG_NAME, GENERAL_FILE, L1_CONTRACTS_FOUNDRY, SECRETS_FILE, WALLETS_FILE},
consts::{
CONFIG_NAME, CONTRACTS_FILE, EN_CONFIG_FILE, GENERAL_FILE, GENESIS_FILE,
L1_CONTRACTS_FOUNDRY, SECRETS_FILE, WALLETS_FILE,
},
create_localhost_wallets,
traits::{
FileConfigWithDefaultName, ReadConfig, ReadConfigWithBasePath, SaveConfig,
Expand Down Expand Up @@ -101,6 +104,18 @@ impl ChainConfig {
self.configs.join(GENERAL_FILE)
}

pub fn path_to_external_node_config(&self) -> PathBuf {
self.configs.join(EN_CONFIG_FILE)
}

pub fn path_to_genesis_config(&self) -> PathBuf {
self.configs.join(GENESIS_FILE)
}

pub fn path_to_contracts_config(&self) -> PathBuf {
self.configs.join(CONTRACTS_FILE)
}

pub fn path_to_secrets_config(&self) -> PathBuf {
self.configs.join(SECRETS_FILE)
}
Expand Down
12 changes: 6 additions & 6 deletions zk_toolbox/crates/config/src/consts.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/// Name of the main configuration file
pub(crate) const CONFIG_NAME: &str = "ZkStack.yaml";
/// Name of the wallets file
pub(crate) const WALLETS_FILE: &str = "wallets.yaml";
pub const WALLETS_FILE: &str = "wallets.yaml";
/// Name of the secrets config file
pub(crate) const SECRETS_FILE: &str = "secrets.yaml";
pub const SECRETS_FILE: &str = "secrets.yaml";
/// Name of the general config file
pub(crate) const GENERAL_FILE: &str = "general.yaml";
pub const GENERAL_FILE: &str = "general.yaml";
/// Name of the genesis config file
pub(crate) const GENESIS_FILE: &str = "genesis.yaml";
pub const GENESIS_FILE: &str = "genesis.yaml";

// Name of external node specific config
pub(crate) const EN_CONFIG_FILE: &str = "external_node.yaml";
pub const EN_CONFIG_FILE: &str = "external_node.yaml";
pub(crate) const ERC20_CONFIGS_FILE: &str = "erc20.yaml";
/// Name of the initial deployments config file
pub(crate) const INITIAL_DEPLOYMENT_FILE: &str = "initial_deployments.yaml";
/// Name of the erc20 deployments config file
pub(crate) const ERC20_DEPLOYMENT_FILE: &str = "erc20_deployments.yaml";
/// Name of the contracts file
pub(crate) const CONTRACTS_FILE: &str = "contracts.yaml";
pub const CONTRACTS_FILE: &str = "contracts.yaml";
/// Main repository for the ZKsync project
pub const ZKSYNC_ERA_GIT_REPO: &str = "https://github.com/matter-labs/zksync-era";
/// Name of the docker-compose file inside zksync repository
Expand Down
2 changes: 1 addition & 1 deletion zk_toolbox/crates/config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub use chain::*;
pub use consts::{DOCKER_COMPOSE_FILE, ZKSYNC_ERA_GIT_REPO};
pub use consts::*;
pub use contracts::*;
pub use ecosystem::*;
pub use file_config::*;
Expand Down
2 changes: 2 additions & 0 deletions zk_toolbox/crates/zk_inception/src/commands/args/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub use run_server::*;
pub use update::*;

mod run_server;
mod update;
9 changes: 9 additions & 0 deletions zk_toolbox/crates/zk_inception/src/commands/args/update.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use clap::Parser;

use crate::messages::MSG_UPDATE_ONLY_CONFIG_HELP;

#[derive(Debug, Parser)]
pub struct UpdateArgs {
#[clap(long, short = 'c', help = MSG_UPDATE_ONLY_CONFIG_HELP)]
pub only_config: bool,
}
1 change: 1 addition & 0 deletions zk_toolbox/crates/zk_inception/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pub mod ecosystem;
pub mod external_node;
pub mod prover;
pub mod server;
pub mod update;
Loading

0 comments on commit e2fa86f

Please sign in to comment.