Skip to content

Commit 89fcb3a

Browse files
authored
fix(zk-toolbox): Make token multiplier optional (matter-labs#2843)
## 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? --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## 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 `zk fmt` and `zk lint`. Signed-off-by: Danil <deniallugo@gmail.com>
1 parent 3506731 commit 89fcb3a

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

zk_toolbox/crates/config/src/wallet_creation.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ pub fn create_localhost_wallets(
5858
blob_operator: Wallet::from_mnemonic(&eth_mnemonic.test_mnemonic, &base_path, 2)?,
5959
fee_account: Wallet::from_mnemonic(&eth_mnemonic.test_mnemonic, &base_path, 3)?,
6060
governor: Wallet::from_mnemonic(&eth_mnemonic.test_mnemonic, &base_path, 4)?,
61-
token_multiplier_setter: Wallet::from_mnemonic(&eth_mnemonic.test_mnemonic, &base_path, 5)?,
61+
token_multiplier_setter: Some(Wallet::from_mnemonic(
62+
&eth_mnemonic.test_mnemonic,
63+
&base_path,
64+
5,
65+
)?),
6266
})
6367
}

zk_toolbox/crates/config/src/wallets.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct WalletsConfig {
1515
pub blob_operator: Wallet,
1616
pub fee_account: Wallet,
1717
pub governor: Wallet,
18-
pub token_multiplier_setter: Wallet,
18+
pub token_multiplier_setter: Option<Wallet>,
1919
}
2020

2121
impl WalletsConfig {
@@ -27,7 +27,7 @@ impl WalletsConfig {
2727
blob_operator: Wallet::random(rng),
2828
fee_account: Wallet::random(rng),
2929
governor: Wallet::random(rng),
30-
token_multiplier_setter: Wallet::random(rng),
30+
token_multiplier_setter: Some(Wallet::random(rng)),
3131
}
3232
}
3333

@@ -39,7 +39,7 @@ impl WalletsConfig {
3939
blob_operator: Wallet::empty(),
4040
fee_account: Wallet::empty(),
4141
governor: Wallet::empty(),
42-
token_multiplier_setter: Wallet::empty(),
42+
token_multiplier_setter: Some(Wallet::empty()),
4343
}
4444
}
4545
pub fn deployer_private_key(&self) -> Option<H256> {

zk_toolbox/crates/zk_inception/src/commands/chain/init.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use crate::{
3636
MSG_CHAIN_NOT_FOUND_ERR, MSG_DISTRIBUTING_ETH_SPINNER, MSG_GENESIS_DATABASE_ERR,
3737
MSG_MINT_BASE_TOKEN_SPINNER, MSG_PORTAL_FAILED_TO_CREATE_CONFIG_ERR,
3838
MSG_REGISTERING_CHAIN_SPINNER, MSG_SELECTED_CONFIG,
39-
MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER,
39+
MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER, MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND,
4040
},
4141
utils::forge::{check_the_balance, fill_forge_private_key},
4242
};
@@ -112,22 +112,25 @@ pub async fn init(
112112
.await?;
113113
spinner.finish();
114114

115-
let spinner = Spinner::new(MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER);
116-
set_token_multiplier_setter(
117-
shell,
118-
ecosystem_config,
119-
chain_config.get_wallets_config()?.governor_private_key(),
120-
contracts_config.l1.chain_admin_addr,
121-
ecosystem_config
122-
.get_wallets()
123-
.unwrap()
124-
.token_multiplier_setter
125-
.address,
126-
&init_args.forge_args.clone(),
127-
init_args.l1_rpc_url.clone(),
128-
)
129-
.await?;
130-
spinner.finish();
115+
if chain_config.base_token != BaseToken::eth() {
116+
let spinner = Spinner::new(MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER);
117+
set_token_multiplier_setter(
118+
shell,
119+
ecosystem_config,
120+
chain_config.get_wallets_config()?.governor_private_key(),
121+
contracts_config.l1.chain_admin_addr,
122+
chain_config
123+
.get_wallets_config()
124+
.unwrap()
125+
.token_multiplier_setter
126+
.context(MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND)?
127+
.address,
128+
&init_args.forge_args.clone(),
129+
init_args.l1_rpc_url.clone(),
130+
)
131+
.await?;
132+
spinner.finish();
133+
}
131134

132135
deploy_l2_contracts::deploy_l2_contracts(
133136
shell,

zk_toolbox/crates/zk_inception/src/commands/chain/set_token_multiplier_setter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
messages::{
1616
MSG_CHAIN_NOT_INITIALIZED, MSG_L1_SECRETS_MUST_BE_PRESENTED,
1717
MSG_TOKEN_MULTIPLIER_SETTER_UPDATED_TO, MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER,
18-
MSG_WALLETS_CONFIG_MUST_BE_PRESENT,
18+
MSG_WALLETS_CONFIG_MUST_BE_PRESENT, MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND,
1919
},
2020
utils::forge::{check_the_balance, fill_forge_private_key},
2121
};
@@ -47,6 +47,7 @@ pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> {
4747
.get_wallets()
4848
.context(MSG_WALLETS_CONFIG_MUST_BE_PRESENT)?
4949
.token_multiplier_setter
50+
.context(MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND)?
5051
.address;
5152

5253
let spinner = Spinner::new(MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER);

zk_toolbox/crates/zk_inception/src/messages.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ pub(super) const MSG_CHAIN_ID_VALIDATOR_ERR: &str = "Invalid chain id";
157157
pub(super) const MSG_BASE_TOKEN_ADDRESS_VALIDATOR_ERR: &str = "Invalid base token address";
158158
pub(super) const MSG_WALLET_CREATION_VALIDATOR_ERR: &str =
159159
"Localhost wallet is not supported for external networks";
160+
pub(super) const MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND: &str =
161+
"Token Multiplier Setter not found. Specify it in a wallet config";
160162

161163
/// Chain genesis related messages
162164
pub(super) const MSG_L1_SECRETS_MUST_BE_PRESENTED: &str = "L1 secret must be presented";

0 commit comments

Comments
 (0)