Skip to content

Commit 9e59509

Browse files
authored
fix(zkstack): get rid of more dependencies from config (#4554)
## What ❔ Don't ask for unnecessary configs ## 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 1cd803d commit 9e59509

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

zkstack_cli/crates/config/src/forge_interface/deploy_l2_contracts/input.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ impl DeployL2ContractsInput {
4444
}
4545

4646
async fn get_da_validator_type(config: &ChainConfig) -> anyhow::Result<DAValidatorType> {
47-
let general = config.get_general_config().await?;
47+
let da_client_type = config
48+
.get_general_config()
49+
.await
50+
.map(|c| c.da_client_type())
51+
.unwrap_or_default();
4852

4953
match (
5054
config.l1_batch_commit_data_generator_mode,
51-
general.da_client_type().as_deref(),
55+
da_client_type.as_deref(),
5256
) {
5357
(L1BatchCommitmentMode::Rollup, _) => Ok(DAValidatorType::Rollup),
5458
(L1BatchCommitmentMode::Validium, None | Some("NoDA")) => Ok(DAValidatorType::NoDA),

zkstack_cli/crates/zkstack/src/commands/chain/deploy_l2_contracts.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub async fn run(
5151

5252
let spinner = Spinner::new(MSG_DEPLOYING_L2_CONTRACT_SPINNER);
5353

54+
let l1_rpc_url = chain_config.get_secrets_config().await?.l1_rpc_url()?;
5455
match deploy_option {
5556
Deploy2ContractsOption::All => {
5657
deploy_l2_contracts(
@@ -60,6 +61,7 @@ pub async fn run(
6061
&mut contracts,
6162
args,
6263
true,
64+
l1_rpc_url,
6365
)
6466
.await?;
6567
}
@@ -70,6 +72,7 @@ pub async fn run(
7072
&ecosystem_config,
7173
&mut contracts,
7274
args,
75+
l1_rpc_url,
7376
)
7477
.await?;
7578
}
@@ -80,6 +83,7 @@ pub async fn run(
8083
&ecosystem_config,
8184
&mut contracts,
8285
args,
86+
l1_rpc_url,
8387
)
8488
.await?;
8589
}
@@ -90,6 +94,7 @@ pub async fn run(
9094
&ecosystem_config,
9195
&mut contracts,
9296
args,
97+
l1_rpc_url,
9398
)
9499
.await?;
95100
}
@@ -100,6 +105,7 @@ pub async fn run(
100105
&ecosystem_config,
101106
&mut contracts,
102107
args,
108+
l1_rpc_url,
103109
)
104110
.await?;
105111
}
@@ -110,6 +116,7 @@ pub async fn run(
110116
&ecosystem_config,
111117
&mut contracts,
112118
args,
119+
l1_rpc_url,
113120
)
114121
.await?
115122
}
@@ -123,6 +130,7 @@ pub async fn run(
123130

124131
/// Build the L2 contracts, deploy one or all of them with `forge`, then update the config
125132
/// by reading one or all outputs written by the deploy scripts.
133+
#[allow(clippy::too_many_arguments)]
126134
async fn build_and_deploy(
127135
shell: &Shell,
128136
chain_config: &ChainConfig,
@@ -131,6 +139,7 @@ async fn build_and_deploy(
131139
signature: Option<&str>,
132140
mut update_config: impl FnMut(&Shell, &Path) -> anyhow::Result<()>,
133141
with_broadcast: bool,
142+
l1_rpc_url: String,
134143
) -> anyhow::Result<()> {
135144
build_l2_contracts(shell.clone(), &chain_config.contracts_path())?;
136145
call_forge(
@@ -140,6 +149,7 @@ async fn build_and_deploy(
140149
forge_args,
141150
signature,
142151
with_broadcast,
152+
l1_rpc_url,
143153
)
144154
.await?;
145155
update_config(
@@ -155,6 +165,7 @@ pub async fn deploy_upgrader(
155165
ecosystem_config: &EcosystemConfig,
156166
contracts_config: &mut ContractsConfig,
157167
forge_args: ForgeScriptArgs,
168+
l1_rpc_url: String,
158169
) -> anyhow::Result<()> {
159170
build_and_deploy(
160171
shell,
@@ -166,6 +177,7 @@ pub async fn deploy_upgrader(
166177
contracts_config.set_default_l2_upgrade(&DefaultL2UpgradeOutput::read(shell, out)?)
167178
},
168179
true,
180+
l1_rpc_url,
169181
)
170182
.await
171183
}
@@ -176,6 +188,7 @@ pub async fn deploy_consensus_registry(
176188
ecosystem_config: &EcosystemConfig,
177189
contracts_config: &mut ContractsConfig,
178190
forge_args: ForgeScriptArgs,
191+
l1_rpc_url: String,
179192
) -> anyhow::Result<()> {
180193
build_and_deploy(
181194
shell,
@@ -187,6 +200,7 @@ pub async fn deploy_consensus_registry(
187200
contracts_config.set_consensus_registry(&ConsensusRegistryOutput::read(shell, out)?)
188201
},
189202
true,
203+
l1_rpc_url,
190204
)
191205
.await
192206
}
@@ -197,6 +211,7 @@ pub async fn deploy_multicall3(
197211
ecosystem_config: &EcosystemConfig,
198212
contracts_config: &mut ContractsConfig,
199213
forge_args: ForgeScriptArgs,
214+
l1_rpc_url: String,
200215
) -> anyhow::Result<()> {
201216
build_and_deploy(
202217
shell,
@@ -206,6 +221,7 @@ pub async fn deploy_multicall3(
206221
Some("runDeployMulticall3"),
207222
|shell, out| contracts_config.set_multicall3(&Multicall3Output::read(shell, out)?),
208223
true,
224+
l1_rpc_url,
209225
)
210226
.await
211227
}
@@ -216,6 +232,7 @@ pub async fn deploy_timestamp_asserter(
216232
ecosystem_config: &EcosystemConfig,
217233
contracts_config: &mut ContractsConfig,
218234
forge_args: ForgeScriptArgs,
235+
l1_rpc_url: String,
219236
) -> anyhow::Result<()> {
220237
build_and_deploy(
221238
shell,
@@ -228,6 +245,7 @@ pub async fn deploy_timestamp_asserter(
228245
.set_timestamp_asserter_addr(&TimestampAsserterOutput::read(shell, out)?)
229246
},
230247
true,
248+
l1_rpc_url,
231249
)
232250
.await
233251
}
@@ -238,6 +256,7 @@ pub async fn deploy_l2_da_validator(
238256
ecosystem_config: &EcosystemConfig,
239257
contracts_config: &mut ContractsConfig,
240258
forge_args: ForgeScriptArgs,
259+
l1_rpc_url: String,
241260
) -> anyhow::Result<()> {
242261
build_and_deploy(
243262
shell,
@@ -250,6 +269,7 @@ pub async fn deploy_l2_da_validator(
250269
.set_l2_da_validator_address(&L2DAValidatorAddressOutput::read(shell, out)?)
251270
},
252271
true,
272+
l1_rpc_url,
253273
)
254274
.await
255275
}
@@ -261,6 +281,7 @@ pub async fn deploy_l2_contracts(
261281
contracts_config: &mut ContractsConfig,
262282
forge_args: ForgeScriptArgs,
263283
with_broadcast: bool,
284+
l1_rpc_url: String,
264285
) -> anyhow::Result<()> {
265286
build_and_deploy(
266287
shell,
@@ -278,6 +299,7 @@ pub async fn deploy_l2_contracts(
278299
Ok(())
279300
},
280301
with_broadcast,
302+
l1_rpc_url,
281303
)
282304
.await
283305
}
@@ -289,6 +311,7 @@ async fn call_forge(
289311
forge_args: ForgeScriptArgs,
290312
signature: Option<&str>,
291313
with_broadcast: bool,
314+
l1_rpc_url: String,
292315
) -> anyhow::Result<()> {
293316
let input = DeployL2ContractsInput::new(
294317
chain_config,
@@ -298,7 +321,6 @@ async fn call_forge(
298321
.await?;
299322

300323
let foundry_contracts_path = chain_config.path_to_foundry_scripts();
301-
let secrets = chain_config.get_secrets_config().await?;
302324
input.save(
303325
shell,
304326
DEPLOY_L2_CONTRACTS_SCRIPT_PARAMS.input(&chain_config.path_to_foundry_scripts()),
@@ -310,7 +332,7 @@ async fn call_forge(
310332
forge_args.clone(),
311333
)
312334
.with_ffi()
313-
.with_rpc_url(secrets.l1_rpc_url()?);
335+
.with_rpc_url(l1_rpc_url);
314336
if with_broadcast {
315337
forge = forge.with_broadcast();
316338
}

zkstack_cli/crates/zkstack/src/commands/chain/deploy_paymaster.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ use crate::utils::forge::{check_the_balance, fill_forge_private_key, WalletOwner
1414
pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> {
1515
let chain_config = ZkStackConfig::current_chain(shell)?;
1616
let mut contracts = chain_config.get_contracts_config()?;
17-
deploy_paymaster(shell, &chain_config, &mut contracts, args, None, true).await?;
17+
let l1_rpc_url = chain_config.get_secrets_config().await?.l1_rpc_url()?;
18+
deploy_paymaster(
19+
shell,
20+
&chain_config,
21+
&mut contracts,
22+
args,
23+
None,
24+
true,
25+
l1_rpc_url,
26+
)
27+
.await?;
1828
contracts.save_with_base_path(shell, chain_config.configs)
1929
}
2030

@@ -25,19 +35,19 @@ pub async fn deploy_paymaster(
2535
forge_args: ForgeScriptArgs,
2636
sender: Option<String>,
2737
broadcast: bool,
38+
l1_rpc_url: String,
2839
) -> anyhow::Result<()> {
2940
let input = DeployPaymasterInput::new(chain_config)?;
3041
let foundry_contracts_path = chain_config.path_to_foundry_scripts();
3142
input.save(
3243
shell,
3344
DEPLOY_PAYMASTER_SCRIPT_PARAMS.input(&foundry_contracts_path),
3445
)?;
35-
let secrets = chain_config.get_secrets_config().await?;
3646

3747
let mut forge = Forge::new(&foundry_contracts_path)
3848
.script(&DEPLOY_PAYMASTER_SCRIPT_PARAMS.script(), forge_args.clone())
3949
.with_ffi()
40-
.with_rpc_url(secrets.l1_rpc_url()?);
50+
.with_rpc_url(l1_rpc_url);
4151

4252
if let Some(address) = sender {
4353
forge = forge.with_sender(address);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ pub async fn init(
168168
&mut contracts_config,
169169
init_args.forge_args.clone(),
170170
true,
171+
init_args.l1_rpc_url.clone(),
171172
)
172173
.await?;
173174
contracts_config.save_with_base_path(shell, &chain_config.configs)?;
@@ -233,6 +234,7 @@ pub async fn init(
233234
init_args.forge_args.clone(),
234235
None,
235236
true,
237+
init_args.l1_rpc_url.clone(),
236238
)
237239
.await?;
238240
contracts_config.save_with_base_path(shell, &chain_config.configs)?;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub async fn init_chains(
169169
let mut deploy_paymaster = args.deploy_paymaster;
170170
let genesis_args = &mut args.genesis_args;
171171
if args.dev {
172-
deploy_paymaster = Some(true);
172+
deploy_paymaster = Some(deploy_paymaster.unwrap_or(true));
173173
if let Some(genesis) = genesis_args {
174174
genesis.dev = true;
175175
}

0 commit comments

Comments
 (0)