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

feat(zk_toolbox): Add observability interactive option #2592

Merged
merged 5 commits into from
Aug 12, 2024
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
3 changes: 2 additions & 1 deletion .github/workflows/ci-zk-toolbox-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ jobs:
--server-db-name=zksync_server_localhost_era \
--prover-db-url=postgres://postgres:notsecurepassword@postgres:5432 \
--prover-db-name=zksync_prover_localhost_era \
--ignore-prerequisites --verbose
--ignore-prerequisites --verbose \
--observability=false

- name: Create and initialize chain
run: |
Expand Down
21 changes: 19 additions & 2 deletions zk_toolbox/crates/zk_inception/src/commands/args/containers.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
use clap::Parser;

use crate::messages::MSG_OBSERVABILITY_HELP;
use crate::messages::{MSG_OBSERVABILITY_HELP, MSG_OBSERVABILITY_RUN_PROMPT};

#[derive(Debug, Parser)]
pub struct ContainersArgs {
#[clap(long, short = 'o', help = MSG_OBSERVABILITY_HELP)]
#[clap(long, short = 'o', help = MSG_OBSERVABILITY_HELP, default_missing_value = "true", num_args = 0..=1)]
pub observability: Option<bool>,
}

#[derive(Debug)]
pub struct ContainersArgsFinal {
pub observability: bool,
}

impl ContainersArgs {
pub fn fill_values_with_prompt(self) -> ContainersArgsFinal {
let observability = self.observability.unwrap_or_else(|| {
common::PromptConfirm::new(MSG_OBSERVABILITY_RUN_PROMPT)
.default(true)
.ask()
});

ContainersArgsFinal { observability }
}
}
1 change: 1 addition & 0 deletions zk_toolbox/crates/zk_inception/src/commands/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::messages::{
};

pub fn run(shell: &Shell, args: ContainersArgs) -> anyhow::Result<()> {
let args = args.fill_values_with_prompt();
let ecosystem = EcosystemConfig::from_file(shell).context(MSG_FAILED_TO_FIND_ECOSYSTEM_ERR)?;

initialize_docker(shell, &ecosystem)?;
Expand Down
17 changes: 13 additions & 4 deletions zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
messages::{
MSG_DEPLOY_ECOSYSTEM_PROMPT, MSG_DEPLOY_ERC20_PROMPT, MSG_DEPLOY_PAYMASTER_PROMPT,
MSG_DEV_ARG_HELP, MSG_GENESIS_ARGS_HELP, MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR,
MSG_L1_RPC_URL_PROMPT, MSG_OBSERVABILITY_HELP,
MSG_L1_RPC_URL_PROMPT, MSG_OBSERVABILITY_HELP, MSG_OBSERVABILITY_PROMPT,
},
};

Expand Down Expand Up @@ -90,8 +90,8 @@ pub struct EcosystemInitArgs {
pub genesis_args: GenesisArgs,
#[clap(long, help = MSG_DEV_ARG_HELP)]
pub dev: bool,
#[clap(long, short = 'o', help = MSG_OBSERVABILITY_HELP)]
pub observability: bool,
#[clap(long, short = 'o', help = MSG_OBSERVABILITY_HELP, default_missing_value = "true", num_args = 0..=1)]
pub observability: Option<bool>,
}

impl EcosystemInitArgs {
Expand All @@ -112,14 +112,23 @@ impl EcosystemInitArgs {
(deploy_paymaster, deploy_erc20)
};
let ecosystem = self.ecosystem.fill_values_with_prompt(l1_network, self.dev);
let observability = if self.dev {
true
} else {
self.observability.unwrap_or_else(|| {
PromptConfirm::new(MSG_OBSERVABILITY_PROMPT)
.default(true)
.ask()
})
};

EcosystemInitArgsFinal {
deploy_paymaster,
deploy_erc20,
ecosystem,
forge_args: self.forge_args.clone(),
dev: self.dev,
observability: self.observability,
observability,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions zk_toolbox/crates/zk_inception/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub(super) const MSG_GENESIS_ARGS_HELP: &str = "Genesis options";
pub(super) const MSG_DEV_ARG_HELP: &str =
"Deploy ecosystem using all defaults. Suitable for local development";
pub(super) const MSG_OBSERVABILITY_HELP: &str = "Enable Grafana";
pub(super) const MSG_OBSERVABILITY_PROMPT: &str = "Do you want to setup observability? (Grafana)";
pub(super) const MSG_DEPLOY_ECOSYSTEM_PROMPT: &str =
"Do you want to deploy ecosystem contracts? (Not needed if you already have an existing one)";
pub(super) const MSG_L1_RPC_URL_PROMPT: &str = "What is the RPC URL of the L1 network?";
Expand Down Expand Up @@ -205,6 +206,7 @@ pub(super) const MSG_CONTAINERS_STARTED: &str = "Containers started successfully
pub(super) const MSG_RETRY_START_CONTAINERS_PROMPT: &str =
"Failed to start containers. Make sure there is nothing running on default ports for Ethereum node l1 and postgres. Want to try again?";
pub(super) const MSG_FAILED_TO_FIND_ECOSYSTEM_ERR: &str = "Failed to find ecosystem folder.";
pub(super) const MSG_OBSERVABILITY_RUN_PROMPT: &str = "Do you want to run observability?";

/// Server related messages
pub(super) const MSG_STARTING_SERVER: &str = "Starting server";
Expand Down
Loading