diff --git a/zkstack_cli/crates/zkstack/completion/_zkstack.zsh b/zkstack_cli/crates/zkstack/completion/_zkstack.zsh index a8a60a6130a6..b985f5b93346 100644 --- a/zkstack_cli/crates/zkstack/completion/_zkstack.zsh +++ b/zkstack_cli/crates/zkstack/completion/_zkstack.zsh @@ -131,12 +131,10 @@ _arguments "${_arguments_options[@]}" : \ '--observability=[Enable Grafana]' \ '--chain=[Chain to use]:CHAIN: ' \ '--resume[]' \ -'-u[Use default database urls and names]' \ -'--use-default[Use default database urls and names]' \ '-d[]' \ '--dont-drop[]' \ '--ecosystem-only[Initialize ecosystem only and skip chain initialization (chain can be initialized later with \`chain init\` subcommand)]' \ -'--dev[Deploy ecosystem using all defaults. Suitable for local development]' \ +'--dev[Use defaults for all options and flags. Suitable for local development]' \ '--no-port-reallocation[Do not reallocate ports]' \ '-v[Verbose mode]' \ '--verbose[Verbose mode]' \ @@ -286,11 +284,10 @@ _arguments "${_arguments_options[@]}" : \ '--l1-rpc-url=[L1 RPC URL]:L1_RPC_URL: ' \ '--chain=[Chain to use]:CHAIN: ' \ '--resume[]' \ -'-u[Use default database urls and names]' \ -'--use-default[Use default database urls and names]' \ '-d[]' \ '--dont-drop[]' \ '--no-port-reallocation[Do not reallocate ports]' \ +'--dev[Use defaults for all options and flags. Suitable for local development]' \ '-v[Verbose mode]' \ '--verbose[Verbose mode]' \ '--ignore-prerequisites[Ignores prerequisites checks]' \ @@ -312,8 +309,8 @@ _arguments "${_arguments_options[@]}" : \ '--server-db-name=[Server database name]:SERVER_DB_NAME: ' \ '--l1-rpc-url=[L1 RPC URL]:L1_RPC_URL: ' \ '--chain=[Chain to use]:CHAIN: ' \ -'-u[Use default database urls and names]' \ -'--use-default[Use default database urls and names]' \ +'-d[Use default database urls and names]' \ +'--dev[Use default database urls and names]' \ '-d[]' \ '--dont-drop[]' \ '--no-port-reallocation[Do not reallocate ports]' \ @@ -357,8 +354,8 @@ _arguments "${_arguments_options[@]}" : \ '--server-db-url=[Server database url without database name]:SERVER_DB_URL: ' \ '--server-db-name=[Server database name]:SERVER_DB_NAME: ' \ '--chain=[Chain to use]:CHAIN: ' \ -'-u[Use default database urls and names]' \ -'--use-default[Use default database urls and names]' \ +'-d[Use default database urls and names]' \ +'--dev[Use default database urls and names]' \ '-d[]' \ '--dont-drop[]' \ '-v[Verbose mode]' \ @@ -381,8 +378,8 @@ _arguments "${_arguments_options[@]}" : \ '--server-db-url=[Server database url without database name]:SERVER_DB_URL: ' \ '--server-db-name=[Server database name]:SERVER_DB_NAME: ' \ '--chain=[Chain to use]:CHAIN: ' \ -'-u[Use default database urls and names]' \ -'--use-default[Use default database urls and names]' \ +'-d[Use default database urls and names]' \ +'--dev[Use default database urls and names]' \ '-d[]' \ '--dont-drop[]' \ '-v[Verbose mode]' \ diff --git a/zkstack_cli/crates/zkstack/completion/zkstack.fish b/zkstack_cli/crates/zkstack/completion/zkstack.fish index d490085e6154..f90bcf2c4ac3 100644 --- a/zkstack_cli/crates/zkstack/completion/zkstack.fish +++ b/zkstack_cli/crates/zkstack/completion/zkstack.fish @@ -107,10 +107,9 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_se complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -s o -l observability -d 'Enable Grafana' -r -f -a "{true\t'',false\t''}" complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l chain -d 'Chain to use' -r complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l resume -complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -s u -l use-default -d 'Use default database urls and names' complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -s d -l dont-drop complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l ecosystem-only -d 'Initialize ecosystem only and skip chain initialization (chain can be initialized later with `chain init` subcommand)' -complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l dev -d 'Deploy ecosystem using all defaults. Suitable for local development' +complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l dev -d 'Use defaults for all options and flags. Suitable for local development' complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l no-port-reallocation -d 'Do not reallocate ports' complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -s v -l verbose -d 'Verbose mode' complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from init" -l ignore-prerequisites -d 'Ignores prerequisites checks' @@ -185,9 +184,9 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_s complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l l1-rpc-url -d 'L1 RPC URL' -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l chain -d 'Chain to use' -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l resume -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -s u -l use-default -d 'Use default database urls and names' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -s d -l dont-drop complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l no-port-reallocation -d 'Do not reallocate ports' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l dev -d 'Use defaults for all options and flags. Suitable for local development' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -s v -l verbose -d 'Verbose mode' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -l ignore-prerequisites -d 'Ignores prerequisites checks' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from init" -s h -l help -d 'Print help (see more with \'--help\')' @@ -196,7 +195,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_s complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from genesis" -l server-db-url -d 'Server database url without database name' -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from genesis" -l server-db-name -d 'Server database name' -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from genesis" -l chain -d 'Chain to use' -r -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from genesis" -s u -l use-default -d 'Use default database urls and names' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from genesis" -s d -l dev -d 'Use default database urls and names' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from genesis" -s d -l dont-drop complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from genesis" -s v -l verbose -d 'Verbose mode' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from genesis" -l ignore-prerequisites -d 'Ignores prerequisites checks' diff --git a/zkstack_cli/crates/zkstack/completion/zkstack.sh b/zkstack_cli/crates/zkstack/completion/zkstack.sh index 27639acd50be..d21480bba2ca 100644 --- a/zkstack_cli/crates/zkstack/completion/zkstack.sh +++ b/zkstack_cli/crates/zkstack/completion/zkstack.sh @@ -1441,7 +1441,7 @@ _zkstack() { return 0 ;; zkstack__chain__genesis) - opts="-u -d -v -h --server-db-url --server-db-name --use-default --dont-drop --verbose --chain --ignore-prerequisites --help init-database server help" + opts="-d -d -v -h --server-db-url --server-db-name --dev --dont-drop --verbose --chain --ignore-prerequisites --help init-database server help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1523,7 +1523,7 @@ _zkstack() { return 0 ;; zkstack__chain__genesis__init__database) - opts="-u -d -v -h --server-db-url --server-db-name --use-default --dont-drop --verbose --chain --ignore-prerequisites --help" + opts="-d -d -v -h --server-db-url --server-db-name --dev --dont-drop --verbose --chain --ignore-prerequisites --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1819,7 +1819,7 @@ _zkstack() { return 0 ;; zkstack__chain__init) - opts="-a -u -d -v -h --verify --verifier --verifier-url --verifier-api-key --resume --additional-args --server-db-url --server-db-name --use-default --dont-drop --deploy-paymaster --l1-rpc-url --no-port-reallocation --verbose --chain --ignore-prerequisites --help configs help" + opts="-a -d -v -h --verify --verifier --verifier-url --verifier-api-key --resume --additional-args --server-db-url --server-db-name --dont-drop --deploy-paymaster --l1-rpc-url --no-port-reallocation --dev --verbose --chain --ignore-prerequisites --help configs help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1877,7 +1877,7 @@ _zkstack() { return 0 ;; zkstack__chain__init__configs) - opts="-u -d -v -h --server-db-url --server-db-name --use-default --dont-drop --l1-rpc-url --no-port-reallocation --verbose --chain --ignore-prerequisites --help" + opts="-d -d -v -h --server-db-url --server-db-name --dev --dont-drop --l1-rpc-url --no-port-reallocation --verbose --chain --ignore-prerequisites --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -4829,7 +4829,7 @@ _zkstack() { return 0 ;; zkstack__ecosystem__init) - opts="-a -u -d -o -v -h --deploy-erc20 --deploy-ecosystem --ecosystem-contracts-path --l1-rpc-url --verify --verifier --verifier-url --verifier-api-key --resume --additional-args --deploy-paymaster --server-db-url --server-db-name --use-default --dont-drop --ecosystem-only --dev --observability --no-port-reallocation --verbose --chain --ignore-prerequisites --help" + opts="-a -d -o -v -h --deploy-erc20 --deploy-ecosystem --ecosystem-contracts-path --l1-rpc-url --verify --verifier --verifier-url --verifier-api-key --resume --additional-args --deploy-paymaster --server-db-url --server-db-name --dont-drop --ecosystem-only --dev --observability --no-port-reallocation --verbose --chain --ignore-prerequisites --help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/args/genesis.rs b/zkstack_cli/crates/zkstack/src/commands/chain/args/genesis.rs index aaf995985a36..f990cbfd77da 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/args/genesis.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/args/genesis.rs @@ -21,7 +21,7 @@ pub struct GenesisArgs { #[clap(long, help = MSG_SERVER_DB_NAME_HELP)] pub server_db_name: Option, #[clap(long, short, help = MSG_USE_DEFAULT_DATABASES_HELP)] - pub use_default: bool, + pub dev: bool, #[clap(long, short, action)] pub dont_drop: bool, } @@ -30,7 +30,7 @@ impl GenesisArgs { pub fn fill_values_with_prompt(self, config: &ChainConfig) -> GenesisArgsFinal { let DBNames { server_name, .. } = generate_db_names(config); let chain_name = config.name.clone(); - if self.use_default { + if self.dev { GenesisArgsFinal { server_db: DatabaseConfig::new(DATABASE_SERVER_URL.clone(), server_name), dont_drop: self.dont_drop, diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/args/init/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/args/init/mod.rs index d92de9a0641b..a5c7a6890ca1 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/args/init/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/args/init/mod.rs @@ -9,8 +9,9 @@ use crate::{ commands::chain::args::genesis::{GenesisArgs, GenesisArgsFinal}, defaults::LOCAL_RPC_URL, messages::{ - MSG_DEPLOY_PAYMASTER_PROMPT, MSG_GENESIS_ARGS_HELP, MSG_L1_RPC_URL_HELP, + MSG_DEPLOY_PAYMASTER_PROMPT, MSG_DEV_ARG_HELP, MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR, MSG_L1_RPC_URL_PROMPT, MSG_NO_PORT_REALLOCATION_HELP, + MSG_SERVER_DB_NAME_HELP, MSG_SERVER_DB_URL_HELP, }, }; @@ -22,45 +23,70 @@ pub struct InitArgs { #[clap(flatten)] #[serde(flatten)] pub forge_args: ForgeScriptArgs, - #[clap(flatten, next_help_heading = MSG_GENESIS_ARGS_HELP)] - #[serde(flatten)] - pub genesis_args: GenesisArgs, + #[clap(long, help = MSG_SERVER_DB_URL_HELP)] + pub server_db_url: Option, + #[clap(long, help = MSG_SERVER_DB_NAME_HELP)] + pub server_db_name: Option, + #[clap(long, short, action)] + pub dont_drop: bool, #[clap(long, default_missing_value = "true", num_args = 0..=1)] pub deploy_paymaster: Option, #[clap(long, help = MSG_L1_RPC_URL_HELP)] pub l1_rpc_url: Option, #[clap(long, help = MSG_NO_PORT_REALLOCATION_HELP)] pub no_port_reallocation: bool, + #[clap(long, help = MSG_DEV_ARG_HELP)] + pub dev: bool, } impl InitArgs { + pub fn get_genesis_args(&self) -> GenesisArgs { + GenesisArgs { + server_db_url: self.server_db_url.clone(), + server_db_name: self.server_db_name.clone(), + dev: self.dev, + dont_drop: self.dont_drop, + } + } + pub fn fill_values_with_prompt(self, config: &ChainConfig) -> InitArgsFinal { - let deploy_paymaster = self.deploy_paymaster.unwrap_or_else(|| { - common::PromptConfirm::new(MSG_DEPLOY_PAYMASTER_PROMPT) - .default(true) - .ask() - }); + let genesis = self.get_genesis_args(); + + let deploy_paymaster = if self.dev { + true + } else { + self.deploy_paymaster.unwrap_or_else(|| { + common::PromptConfirm::new(MSG_DEPLOY_PAYMASTER_PROMPT) + .default(true) + .ask() + }) + }; - let l1_rpc_url = self.l1_rpc_url.unwrap_or_else(|| { - let mut prompt = Prompt::new(MSG_L1_RPC_URL_PROMPT); - if config.l1_network == L1Network::Localhost { - prompt = prompt.default(LOCAL_RPC_URL); - } - prompt - .validate_with(|val: &String| -> Result<(), String> { - Url::parse(val) - .map(|_| ()) - .map_err(|_| MSG_L1_RPC_URL_INVALID_ERR.to_string()) - }) - .ask() - }); + let l1_rpc_url = if self.dev { + LOCAL_RPC_URL.to_string() + } else { + self.l1_rpc_url.unwrap_or_else(|| { + let mut prompt = Prompt::new(MSG_L1_RPC_URL_PROMPT); + if config.l1_network == L1Network::Localhost { + prompt = prompt.default(LOCAL_RPC_URL); + } + prompt + .validate_with(|val: &String| -> Result<(), String> { + Url::parse(val) + .map(|_| ()) + .map_err(|_| MSG_L1_RPC_URL_INVALID_ERR.to_string()) + }) + .ask() + }) + }; InitArgsFinal { forge_args: self.forge_args, - genesis_args: self.genesis_args.fill_values_with_prompt(config), + genesis_args: genesis.fill_values_with_prompt(config), deploy_paymaster, l1_rpc_url, no_port_reallocation: self.no_port_reallocation, + dev: self.dev, } } } @@ -72,4 +98,5 @@ pub struct InitArgsFinal { pub deploy_paymaster: bool, pub l1_rpc_url: String, pub no_port_reallocation: bool, + pub dev: bool, } diff --git a/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/init.rs b/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/init.rs index a77a9c28ca93..09115fd49ba7 100644 --- a/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/init.rs +++ b/zkstack_cli/crates/zkstack/src/commands/ecosystem/args/init.rs @@ -11,9 +11,9 @@ use crate::{ defaults::LOCAL_RPC_URL, messages::{ MSG_DEPLOY_ECOSYSTEM_PROMPT, MSG_DEPLOY_ERC20_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_NO_PORT_REALLOCATION_HELP, MSG_OBSERVABILITY_HELP, - MSG_OBSERVABILITY_PROMPT, + MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR, MSG_L1_RPC_URL_PROMPT, + MSG_NO_PORT_REALLOCATION_HELP, MSG_OBSERVABILITY_HELP, MSG_OBSERVABILITY_PROMPT, + MSG_SERVER_DB_NAME_HELP, MSG_SERVER_DB_URL_HELP, }, }; @@ -86,9 +86,12 @@ pub struct EcosystemInitArgs { /// Deploy Paymaster contract #[clap(long, default_missing_value = "true", num_args = 0..=1)] pub deploy_paymaster: Option, - #[clap(flatten, next_help_heading = MSG_GENESIS_ARGS_HELP)] - #[serde(flatten)] - pub genesis_args: GenesisArgs, + #[clap(long, help = MSG_SERVER_DB_URL_HELP)] + pub server_db_url: Option, + #[clap(long, help = MSG_SERVER_DB_NAME_HELP)] + pub server_db_name: Option, + #[clap(long, short, action)] + pub dont_drop: bool, /// Initialize ecosystem only and skip chain initialization (chain can be initialized later with `chain init` subcommand) #[clap(long, default_value_t = false)] pub ecosystem_only: bool, @@ -101,6 +104,15 @@ pub struct EcosystemInitArgs { } impl EcosystemInitArgs { + pub fn get_genesis_args(&self) -> GenesisArgs { + GenesisArgs { + server_db_url: self.server_db_url.clone(), + server_db_name: self.server_db_name.clone(), + dev: self.dev, + dont_drop: self.dont_drop, + } + } + pub fn fill_values_with_prompt(self, l1_network: L1Network) -> EcosystemInitArgsFinal { let deploy_erc20 = if self.dev { true diff --git a/zkstack_cli/crates/zkstack/src/commands/ecosystem/init.rs b/zkstack_cli/crates/zkstack/src/commands/ecosystem/init.rs index 6e006f8d65df..06b9b9161112 100644 --- a/zkstack_cli/crates/zkstack/src/commands/ecosystem/init.rs +++ b/zkstack_cli/crates/zkstack/src/commands/ecosystem/init.rs @@ -341,10 +341,10 @@ async fn init_chains( }; // Set default values for dev mode let mut deploy_paymaster = init_args.deploy_paymaster; - let mut genesis_args = init_args.genesis_args.clone(); + let mut genesis_args = init_args.get_genesis_args().clone(); if final_init_args.dev { deploy_paymaster = Some(true); - genesis_args.use_default = true; + genesis_args.dev = true; } // Can't initialize multiple chains with the same DB if list_of_chains.len() > 1 { @@ -359,10 +359,13 @@ async fn init_chains( let chain_init_args = chain::args::init::InitArgs { forge_args: final_init_args.forge_args.clone(), - genesis_args: genesis_args.clone(), + server_db_url: genesis_args.server_db_url.clone(), + server_db_name: genesis_args.server_db_name.clone(), + dont_drop: genesis_args.dont_drop, deploy_paymaster, l1_rpc_url: Some(final_init_args.ecosystem.l1_rpc_url.clone()), no_port_reallocation: final_init_args.no_port_reallocation, + dev: final_init_args.dev, }; let final_chain_init_args = chain_init_args.fill_values_with_prompt(&chain_config); diff --git a/zkstack_cli/crates/zkstack/src/messages.rs b/zkstack_cli/crates/zkstack/src/messages.rs index e2145c18ffd0..b9786dc4d8d1 100644 --- a/zkstack_cli/crates/zkstack/src/messages.rs +++ b/zkstack_cli/crates/zkstack/src/messages.rs @@ -15,6 +15,8 @@ pub(super) const MSG_SELECTED_CONFIG: &str = "Selected config"; pub(super) const MSG_CHAIN_NOT_INITIALIZED: &str = "Chain not initialized. Please create a chain first"; pub(super) const MSG_ARGS_VALIDATOR_ERR: &str = "Invalid arguments"; +pub(super) const MSG_DEV_ARG_HELP: &str = + "Use defaults for all options and flags. Suitable for local development"; /// Autocomplete message pub(super) fn msg_generate_autocomplete_file(filename: &str) -> String { @@ -61,8 +63,6 @@ pub(super) fn msg_path_to_zksync_does_not_exist_err(path: &str) -> String { pub(super) const MSG_L1_RPC_URL_HELP: &str = "L1 RPC URL"; pub(super) const MSG_NO_PORT_REALLOCATION_HELP: &str = "Do not reallocate ports"; 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 =