Skip to content

Commit 9034246

Browse files
authored
feat(zkstack): No genesis arg (#4453)
## 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? --> <!-- The `Why` has to be clear to non-Matter Labs entities running their own ZK Chain --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Is this a breaking change? - [ ] Yes - [ ] No ## Operational changes <!-- Any config changes? Any new flags? Any changes to any scripts? --> <!-- Please add anything that non-Matter Labs entities running their own ZK Chain may need to know --> ## 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`. Signed-off-by: Danil <[email protected]>
1 parent ef21c1a commit 9034246

File tree

9 files changed

+44
-27
lines changed

9 files changed

+44
-27
lines changed

zkstack_cli/crates/zkstack/src/commands/chain/args/init/configs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct InitConfigsArgs {
3030

3131
#[derive(Debug, Clone)]
3232
pub struct InitConfigsArgsFinal {
33-
pub genesis_args: GenesisArgsFinal,
33+
pub genesis_args: Option<GenesisArgsFinal>,
3434
pub l1_rpc_url: String,
3535
pub no_port_reallocation: bool,
3636
pub validium_config: Option<ValidiumType>,
@@ -53,7 +53,7 @@ impl InitConfigsArgs {
5353
});
5454

5555
InitConfigsArgsFinal {
56-
genesis_args: self.genesis_args.fill_values_with_prompt(config),
56+
genesis_args: Some(self.genesis_args.fill_values_with_prompt(config)),
5757
l1_rpc_url,
5858
no_port_reallocation: self.no_port_reallocation,
5959
validium_config: Some(ValidiumType::read()),

zkstack_cli/crates/zkstack/src/commands/chain/args/init/mod.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use crate::{
1313
defaults::LOCAL_RPC_URL,
1414
messages::{
1515
MSG_DEPLOY_PAYMASTER_PROMPT, MSG_DEV_ARG_HELP, MSG_L1_RPC_URL_HELP,
16-
MSG_L1_RPC_URL_INVALID_ERR, MSG_NO_PORT_REALLOCATION_HELP, MSG_RPC_URL_PROMPT,
17-
MSG_SERVER_COMMAND_HELP, MSG_SERVER_DB_NAME_HELP, MSG_SERVER_DB_URL_HELP,
16+
MSG_L1_RPC_URL_INVALID_ERR, MSG_NO_GENESIS, MSG_NO_PORT_REALLOCATION_HELP,
17+
MSG_RPC_URL_PROMPT, MSG_SERVER_COMMAND_HELP, MSG_SERVER_DB_NAME_HELP,
18+
MSG_SERVER_DB_URL_HELP,
1819
},
1920
};
2021

@@ -49,17 +50,22 @@ pub struct InitArgs {
4950
pub validium_args: da_configs::ValidiumTypeArgs,
5051
#[clap(long, help = MSG_SERVER_COMMAND_HELP)]
5152
pub server_command: Option<String>,
53+
#[clap(long, short, action, help = MSG_NO_GENESIS)]
54+
pub no_genesis: bool,
5255
}
5356

5457
impl InitArgs {
55-
pub fn get_genesis_args(&self) -> GenesisArgs {
56-
GenesisArgs {
58+
fn get_genesis_args(&self) -> Option<GenesisArgs> {
59+
if self.no_genesis {
60+
return None;
61+
}
62+
Some(GenesisArgs {
5763
server_db_url: self.server_db_url.clone(),
5864
server_db_name: self.server_db_name.clone(),
5965
dev: self.dev,
6066
dont_drop: self.dont_drop,
6167
server_command: self.server_command.clone(),
62-
}
68+
})
6369
}
6470

6571
pub fn fill_values_with_prompt(self, config: &ChainConfig) -> InitArgsFinal {
@@ -107,7 +113,7 @@ impl InitArgs {
107113

108114
InitArgsFinal {
109115
forge_args: self.forge_args,
110-
genesis_args: genesis.fill_values_with_prompt(config),
116+
genesis_args: genesis.map(|genesis| genesis.fill_values_with_prompt(config)),
111117
deploy_paymaster,
112118
l1_rpc_url,
113119
no_port_reallocation: self.no_port_reallocation,
@@ -120,7 +126,7 @@ impl InitArgs {
120126
#[derive(Debug, Clone)]
121127
pub struct InitArgsFinal {
122128
pub forge_args: ForgeScriptArgs,
123-
pub genesis_args: GenesisArgsFinal,
129+
pub genesis_args: Option<GenesisArgsFinal>,
124130
pub deploy_paymaster: bool,
125131
pub l1_rpc_url: String,
126132
pub no_port_reallocation: bool,

zkstack_cli/crates/zkstack/src/commands/chain/genesis/database.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub async fn initialize_server_database(
7474
}
7575

7676
pub async fn update_configs(
77-
args: GenesisArgsFinal,
77+
args: &GenesisArgsFinal,
7878
shell: &Shell,
7979
config: &ChainConfig,
8080
override_validium_config: bool,

zkstack_cli/crates/zkstack/src/commands/chain/genesis/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ pub async fn run_genesis(args: GenesisArgs, shell: &Shell) -> anyhow::Result<()>
4848
let chain_config = ZkStackConfig::current_chain(shell)?;
4949
let args = args.fill_values_with_prompt(&chain_config);
5050

51-
genesis(args, shell, &chain_config).await?;
51+
genesis(&args, shell, &chain_config).await?;
5252
logger::outro(MSG_GENESIS_COMPLETED);
5353

5454
Ok(())
5555
}
5656

5757
pub async fn genesis(
58-
args: GenesisArgsFinal,
58+
args: &GenesisArgsFinal,
5959
shell: &Shell,
6060
config: &ChainConfig,
6161
) -> anyhow::Result<()> {
6262
let override_validium_config = true;
63-
database::update_configs(args.clone(), shell, config, override_validium_config).await?;
63+
database::update_configs(args, shell, config, override_validium_config).await?;
6464

6565
logger::note(
6666
MSG_SELECTED_CONFIG,
@@ -82,7 +82,7 @@ pub async fn genesis(
8282
spinner.finish();
8383

8484
let spinner = Spinner::new(MSG_STARTING_GENESIS_SPINNER);
85-
run_server_genesis(args.server_command, config, shell)?;
85+
run_server_genesis(args.server_command.clone(), config, shell)?;
8686
spinner.finish();
8787

8888
Ok(())

zkstack_cli/crates/zkstack/src/commands/chain/init/configs.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,16 @@ pub async fn init_configs(
131131
secrets.save().await?;
132132

133133
let override_validium_config = false; // We've initialized validium params above.
134-
genesis::database::update_configs(
135-
init_args.genesis_args.clone(),
136-
shell,
137-
chain_config,
138-
override_validium_config,
139-
)
140-
.await?;
134+
if let Some(genesis_args) = &init_args.genesis_args {
135+
// Initialize genesis database if needed
136+
genesis::database::update_configs(
137+
genesis_args,
138+
shell,
139+
chain_config,
140+
override_validium_config,
141+
)
142+
.await?;
143+
}
141144

142145
update_portal_config(shell, chain_config)
143146
.await

zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,11 @@ pub async fn init(
243243
spinner.finish();
244244
}
245245

246-
genesis(init_args.genesis_args.clone(), shell, chain_config)
247-
.await
248-
.context(MSG_GENESIS_DATABASE_ERR)?;
246+
if let Some(genesis_args) = &init_args.genesis_args {
247+
genesis(genesis_args, shell, chain_config)
248+
.await
249+
.context(MSG_GENESIS_DATABASE_ERR)?;
250+
}
249251

250252
Ok(())
251253
}

zkstack_cli/crates/zkstack/src/commands/ecosystem/args/init.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ use crate::{
1515
defaults::LOCAL_RPC_URL,
1616
messages::{
1717
MSG_BRIDGEHUB, MSG_DEPLOY_ECOSYSTEM_PROMPT, MSG_DEPLOY_ERC20_PROMPT, MSG_DEV_ARG_HELP,
18-
MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR, MSG_NO_PORT_REALLOCATION_HELP,
19-
MSG_OBSERVABILITY_HELP, MSG_OBSERVABILITY_PROMPT, MSG_RPC_URL_PROMPT,
20-
MSG_SERVER_COMMAND_HELP, MSG_SERVER_DB_NAME_HELP, MSG_SERVER_DB_URL_HELP,
18+
MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR, MSG_NO_GENESIS,
19+
MSG_NO_PORT_REALLOCATION_HELP, MSG_OBSERVABILITY_HELP, MSG_OBSERVABILITY_PROMPT,
20+
MSG_RPC_URL_PROMPT, MSG_SERVER_COMMAND_HELP, MSG_SERVER_DB_NAME_HELP,
21+
MSG_SERVER_DB_URL_HELP,
2122
},
2223
};
2324

@@ -127,6 +128,8 @@ pub struct EcosystemInitArgs {
127128
pub server_command: Option<String>,
128129
#[clap(long, help = MSG_BRIDGEHUB)]
129130
pub bridgehub: Option<String>,
131+
#[clap(long, short, action, help = MSG_NO_GENESIS)]
132+
pub no_genesis: bool,
130133
}
131134

132135
impl EcosystemInitArgs {

zkstack_cli/crates/zkstack/src/commands/ecosystem/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ pub async fn init_chains(
309309
validium_args: final_init_args.validium_args.clone(),
310310
server_command: genesis_args.server_command.clone(),
311311
make_permanent_rollup: init_args.make_permanent_rollup,
312+
no_genesis: init_args.no_genesis,
312313
};
313314
let final_chain_init_args = chain_init_args.fill_values_with_prompt(&chain_config);
314315

zkstack_cli/crates/zkstack/src/messages.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,3 +662,5 @@ pub(super) const MSG_AVAIL_BRIDGE_API_URL_PROMPT: &str = "Attestation bridge API
662662
pub(super) const MSG_AVAIL_SEED_PHRASE_PROMPT: &str = "Seed phrase";
663663
pub(super) const MSG_AVAIL_GAS_RELAY_API_KEY_PROMPT: &str = "Gas relay API key";
664664
pub(super) const MSG_INVALID_URL_ERR: &str = "Invalid URL format";
665+
666+
pub(super) const MSG_NO_GENESIS: &str = "Do not run genesis";

0 commit comments

Comments
 (0)