Skip to content

Commit cc0a95b

Browse files
authored
feat: update zkstack-cli for updated scripts (#4481)
## 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`.
1 parent 1bb82d6 commit cc0a95b

File tree

15 files changed

+340
-168
lines changed

15 files changed

+340
-168
lines changed

zkstack_cli/crates/common/src/forge.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ pub struct ForgeScript {
5656
impl ForgeScript {
5757
/// Run the forge script command.
5858
pub fn run(mut self, shell: &Shell) -> anyhow::Result<()> {
59-
// When running the DeployL1 script, we skip recompiling the Bridgehub
59+
// When running the DeployCTM script, we skip recompiling the Bridgehub
6060
// because it must be compiled with a low optimizer-runs value.
61-
if self.script_path == Path::new("deploy-scripts/DeployL1.s.sol") {
61+
if self.script_path == Path::new("deploy-scripts/DeployCTM.s.sol") {
6262
let skip_path: String = String::from("contracts/bridgehub/*");
6363
self.args.add_arg(ForgeScriptArg::Skip { skip_path });
6464
}

zkstack_cli/crates/config/src/contracts.rs

Lines changed: 127 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use zksync_system_constants::{L2_ASSET_ROUTER_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADD
88
use crate::{
99
consts::CONTRACTS_FILE,
1010
forge_interface::{
11-
deploy_ecosystem::output::DeployL1Output,
11+
deploy_ecosystem::output::{DeployCTMOutput, DeployL1CoreContractsOutput},
1212
deploy_l2_contracts::output::{
1313
ConsensusRegistryOutput, DefaultL2UpgradeOutput, InitializeBridgeOutput,
1414
L2DAValidatorAddressOutput, Multicall3Output, TimestampAsserterOutput,
@@ -18,6 +18,80 @@ use crate::{
1818
traits::{FileConfigTrait, FileConfigWithDefaultName},
1919
};
2020

21+
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
22+
pub struct CoreContractsConfig {
23+
pub create2_factory_addr: Address,
24+
pub create2_factory_salt: H256,
25+
pub core_ecosystem_contracts: CoreEcosystemContracts,
26+
pub bridges: BridgesContracts,
27+
pub l1: L1CoreContracts,
28+
#[serde(flatten)]
29+
pub other: serde_json::Value,
30+
}
31+
32+
impl CoreContractsConfig {
33+
pub fn update_from_l1_output(
34+
&mut self,
35+
deploy_l1_core_contracts_output: &DeployL1CoreContractsOutput,
36+
) {
37+
self.create2_factory_addr = deploy_l1_core_contracts_output.create2_factory_addr;
38+
self.create2_factory_salt = deploy_l1_core_contracts_output.create2_factory_salt;
39+
self.bridges.erc20.l1_address = deploy_l1_core_contracts_output
40+
.deployed_addresses
41+
.bridges
42+
.erc20_bridge_proxy_addr;
43+
self.bridges.shared.l1_address = deploy_l1_core_contracts_output
44+
.deployed_addresses
45+
.bridges
46+
.shared_bridge_proxy_addr;
47+
self.bridges.l1_nullifier_addr = Some(
48+
deploy_l1_core_contracts_output
49+
.deployed_addresses
50+
.bridges
51+
.l1_nullifier_proxy_addr,
52+
);
53+
self.core_ecosystem_contracts.bridgehub_proxy_addr = deploy_l1_core_contracts_output
54+
.deployed_addresses
55+
.bridgehub
56+
.bridgehub_proxy_addr;
57+
self.core_ecosystem_contracts.message_root_proxy_addr = Some(
58+
deploy_l1_core_contracts_output
59+
.deployed_addresses
60+
.bridgehub
61+
.message_root_proxy_addr,
62+
);
63+
self.core_ecosystem_contracts.transparent_proxy_admin_addr =
64+
deploy_l1_core_contracts_output
65+
.deployed_addresses
66+
.transparent_proxy_admin_addr;
67+
self.core_ecosystem_contracts
68+
.stm_deployment_tracker_proxy_addr = Some(
69+
deploy_l1_core_contracts_output
70+
.deployed_addresses
71+
.bridgehub
72+
.ctm_deployment_tracker_proxy_addr,
73+
);
74+
75+
self.l1.governance_addr = deploy_l1_core_contracts_output
76+
.deployed_addresses
77+
.governance_addr;
78+
self.core_ecosystem_contracts.native_token_vault_addr = Some(
79+
deploy_l1_core_contracts_output
80+
.deployed_addresses
81+
.native_token_vault_addr,
82+
);
83+
self.l1.chain_admin_addr = deploy_l1_core_contracts_output
84+
.deployed_addresses
85+
.chain_admin;
86+
}
87+
}
88+
89+
impl FileConfigWithDefaultName for CoreContractsConfig {
90+
const FILE_NAME: &'static str = CONTRACTS_FILE;
91+
}
92+
93+
impl FileConfigTrait for CoreContractsConfig {}
94+
2195
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
2296
pub struct ContractsConfig {
2397
pub create2_factory_addr: Address,
@@ -33,7 +107,7 @@ pub struct ContractsConfig {
33107
}
34108

35109
impl ContractsConfig {
36-
pub fn update_from_l1_output(&mut self, deploy_l1_output: &DeployL1Output) {
110+
pub fn update_from_l1_output(&mut self, deploy_l1_output: &DeployCTMOutput) {
37111
self.create2_factory_addr = deploy_l1_output.create2_factory_addr;
38112
self.create2_factory_salt = deploy_l1_output.create2_factory_salt;
39113
self.bridges.erc20.l1_address = deploy_l1_output
@@ -216,6 +290,44 @@ impl FileConfigWithDefaultName for ContractsConfig {
216290

217291
impl FileConfigTrait for ContractsConfig {}
218292

293+
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
294+
pub struct ContractsConfigForDeployERC20 {
295+
pub create2_factory_addr: Address,
296+
pub create2_factory_salt: H256,
297+
}
298+
299+
impl From<ContractsConfig> for ContractsConfigForDeployERC20 {
300+
fn from(config: ContractsConfig) -> Self {
301+
ContractsConfigForDeployERC20 {
302+
create2_factory_addr: config.create2_factory_addr,
303+
create2_factory_salt: config.create2_factory_salt,
304+
}
305+
}
306+
}
307+
308+
impl From<CoreContractsConfig> for ContractsConfigForDeployERC20 {
309+
fn from(config: CoreContractsConfig) -> Self {
310+
ContractsConfigForDeployERC20 {
311+
create2_factory_addr: config.create2_factory_addr,
312+
create2_factory_salt: config.create2_factory_salt,
313+
}
314+
}
315+
}
316+
317+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
318+
pub struct CoreEcosystemContracts {
319+
pub bridgehub_proxy_addr: Address,
320+
#[serde(skip_serializing_if = "Option::is_none")]
321+
pub message_root_proxy_addr: Option<Address>,
322+
pub transparent_proxy_admin_addr: Address,
323+
// `Option` to be able to parse configs from pre-gateway protocol version.
324+
#[serde(skip_serializing_if = "Option::is_none")]
325+
pub stm_deployment_tracker_proxy_addr: Option<Address>,
326+
// `Option` to be able to parse configs from pre-gateway protocol version.
327+
#[serde(skip_serializing_if = "Option::is_none")]
328+
pub native_token_vault_addr: Option<Address>,
329+
}
330+
219331
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
220332
pub struct EcosystemContracts {
221333
pub bridgehub_proxy_addr: Address,
@@ -299,6 +411,19 @@ pub struct L1Contracts {
299411
pub transaction_filterer_addr: Option<Address>,
300412
}
301413

414+
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
415+
pub struct L1CoreContracts {
416+
pub governance_addr: Address,
417+
#[serde(default)]
418+
pub chain_admin_addr: Address,
419+
// `Option` to be able to parse configs from pre-gateway protocol version.
420+
#[serde(skip_serializing_if = "Option::is_none")]
421+
pub access_control_restriction_addr: Option<Address>,
422+
// `Option` to be able to parse configs from pre-gateway protocol version.
423+
#[serde(skip_serializing_if = "Option::is_none")]
424+
pub chain_proxy_admin_addr: Option<Address>,
425+
}
426+
302427
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
303428
pub struct EthProofManagerContracts {
304429
pub proof_manager_addr: Address,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use zksync_basic_types::{protocol_version::ProtocolSemanticVersion, L2ChainId};
1212
use crate::{
1313
consts::INITIAL_DEPLOYMENT_FILE,
1414
traits::{FileConfigTrait, FileConfigWithDefaultName},
15-
ContractsConfig, GenesisConfig, WalletsConfig, ERC20_DEPLOYMENT_FILE,
15+
ContractsConfigForDeployERC20, GenesisConfig, WalletsConfig, ERC20_DEPLOYMENT_FILE,
1616
};
1717

1818
/// Part of the genesis config influencing `DeployGatewayCTMInput`.
@@ -256,7 +256,7 @@ impl FileConfigTrait for DeployErc20Config {}
256256
impl DeployErc20Config {
257257
pub fn new(
258258
erc20_deployment_config: &Erc20DeploymentConfig,
259-
contracts_config: &ContractsConfig,
259+
contracts_config: &ContractsConfigForDeployERC20,
260260
additional_addresses_for_minting: Vec<Address>,
261261
) -> Self {
262262
let mut tokens = HashMap::new();

zkstack_cli/crates/config/src/forge_interface/deploy_ecosystem/output.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,45 @@ use crate::{
99
};
1010

1111
#[derive(Debug, Deserialize, Serialize, Clone)]
12-
pub struct DeployL1Output {
12+
pub struct DeployL1CoreContractsOutput {
13+
pub create2_factory_addr: Address,
14+
pub create2_factory_salt: H256,
15+
pub deployer_addr: Address,
16+
pub era_chain_id: u32,
17+
pub l1_chain_id: u32,
18+
pub owner_address: Address,
19+
pub deployed_addresses: DeployL1CoreContractsDeployedAddressesOutput,
20+
}
21+
22+
#[derive(Debug, Deserialize, Serialize, Clone)]
23+
pub struct DeployL1CoreContractsDeployedAddressesOutput {
24+
pub governance_addr: Address,
25+
pub transparent_proxy_admin_addr: Address,
26+
pub chain_admin: Address,
27+
pub access_control_restriction_addr: Address,
28+
pub bridgehub: L1BridgehubOutput,
29+
pub bridges: L1BridgesOutput,
30+
pub native_token_vault_addr: Address,
31+
}
32+
33+
impl FileConfigTrait for DeployL1CoreContractsOutput {}
34+
35+
#[derive(Debug, Deserialize, Serialize, Clone)]
36+
pub struct DeployCTMOutput {
1337
pub create2_factory_addr: Address,
1438
pub create2_factory_salt: H256,
1539
pub deployer_addr: Address,
1640
pub era_chain_id: u32,
1741
pub l1_chain_id: u32,
1842
pub multicall3_addr: Address,
1943
pub owner_address: Address,
20-
pub contracts_config: DeployL1ContractsConfigOutput,
21-
pub deployed_addresses: DeployL1DeployedAddressesOutput,
44+
pub contracts_config: DeployCTMContractsConfigOutput,
45+
pub deployed_addresses: DeployCTMDeployedAddressesOutput,
2246
pub expected_rollup_l2_da_validator_addr: Address,
2347
}
2448

2549
#[derive(Debug, Deserialize, Serialize, Clone)]
26-
pub struct DeployL1DeployedAddressesOutput {
50+
pub struct DeployCTMDeployedAddressesOutput {
2751
pub governance_addr: Address,
2852
pub transparent_proxy_admin_addr: Address,
2953
pub validator_timelock_addr: Address,
@@ -40,10 +64,10 @@ pub struct DeployL1DeployedAddressesOutput {
4064
pub server_notifier_proxy_addr: Address,
4165
}
4266

43-
impl FileConfigTrait for DeployL1Output {}
67+
impl FileConfigTrait for DeployCTMOutput {}
4468

4569
#[derive(Debug, Deserialize, Serialize, Clone)]
46-
pub struct DeployL1ContractsConfigOutput {
70+
pub struct DeployCTMContractsConfigOutput {
4771
pub diamond_cut_data: String,
4872
pub force_deployments_data: Option<String>,
4973
}

zkstack_cli/crates/config/src/forge_interface/script_params.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ impl ForgeScriptParams {
2424
}
2525
}
2626

27-
pub const DEPLOY_ECOSYSTEM_SCRIPT_PARAMS: ForgeScriptParams = ForgeScriptParams {
27+
pub const DEPLOY_CTM_SCRIPT_PARAMS: ForgeScriptParams = ForgeScriptParams {
2828
input: "script-config/config-deploy-l1.toml",
2929
output: "script-out/output-deploy-l1.toml",
30-
script_path: "deploy-scripts/DeployL1.s.sol",
30+
script_path: "deploy-scripts/DeployCTM.s.sol",
3131
};
3232

3333
pub const DEPLOY_ECOSYSTEM_CORE_CONTRACTS_SCRIPT_PARAMS: ForgeScriptParams = ForgeScriptParams {
@@ -37,7 +37,7 @@ pub const DEPLOY_ECOSYSTEM_CORE_CONTRACTS_SCRIPT_PARAMS: ForgeScriptParams = For
3737
};
3838

3939
pub const REGISTER_CTM_SCRIPT_PARAMS: ForgeScriptParams = ForgeScriptParams {
40-
input: "script-config/config-deploy-l1.toml",
40+
input: "script-config/config-register-ctm-l1.toml",
4141
output: "script-out/register-ctm-l1.toml",
4242
script_path: "deploy-scripts/RegisterCTM.s.sol",
4343
};

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{path::PathBuf, str::FromStr};
22

3+
use anyhow::{Context, Result};
34
use clap::Parser;
45
use serde::{Deserialize, Serialize};
56
use url::Url;
@@ -10,7 +11,7 @@ use crate::{
1011
consts::DEFAULT_UNSIGNED_TRANSACTIONS_DIR,
1112
defaults::LOCAL_RPC_URL,
1213
messages::{
13-
MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR, MSG_RPC_URL_PROMPT,
14+
MSG_BRIDGEHUB, MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR, MSG_RPC_URL_PROMPT,
1415
MSG_SENDER_ADDRESS_PROMPT,
1516
},
1617
};
@@ -28,10 +29,12 @@ pub struct BuildTransactionsArgs {
2829
#[clap(flatten)]
2930
#[serde(flatten)]
3031
pub forge_args: ForgeScriptArgs,
32+
#[clap(long, help = MSG_BRIDGEHUB)]
33+
pub bridgehub: String,
3134
}
3235

3336
impl BuildTransactionsArgs {
34-
pub fn fill_values_with_prompt(self) -> BuildTransactionsFinal {
37+
pub fn fill_values_with_prompt(self) -> Result<BuildTransactionsFinal> {
3538
let sender = self.sender.unwrap_or_else(|| {
3639
Prompt::new(MSG_SENDER_ADDRESS_PROMPT)
3740
.validate_with(|val: &String| -> Result<(), String> {
@@ -50,12 +53,20 @@ impl BuildTransactionsArgs {
5053
})
5154
.ask()
5255
});
53-
BuildTransactionsFinal {
56+
57+
// Parse bridgehub address
58+
let bridgehub_address = self
59+
.bridgehub
60+
.parse::<H160>()
61+
.with_context(|| format!("Invalid bridgehub address format: {}", self.bridgehub))?;
62+
63+
Ok(BuildTransactionsFinal {
5464
sender,
5565
out: self.out.unwrap_or(DEFAULT_UNSIGNED_TRANSACTIONS_DIR.into()),
5666
forge_args: self.forge_args.clone(),
5767
l1_rpc_url,
58-
}
68+
bridgehub_address,
69+
})
5970
}
6071
}
6172

@@ -65,4 +76,5 @@ pub struct BuildTransactionsFinal {
6576
pub out: PathBuf,
6677
pub forge_args: ForgeScriptArgs,
6778
pub l1_rpc_url: String,
79+
pub bridgehub_address: H160,
6880
}

0 commit comments

Comments
 (0)