From 4cd0ecba01984875dfddf5af3999987cb887739e Mon Sep 17 00:00:00 2001 From: Mathieu Baudet <1105398+ma2bd@users.noreply.github.com> Date: Sun, 23 Feb 2025 12:01:27 -0500 Subject: [PATCH] remove CLI option "linera net up --extra-wallets" (#3393) ## Motivation This option is no longer needed after #3388. ## Proposal Remove CLI option "linera net up --extra-wallets" ## Test Plan CI ## Release Plan - Nothing to do / These changes follow the usual release cycle. --- CLI.md | 3 +- linera-client/src/client_options.rs | 7 +- linera-service/src/linera/main.rs | 4 -- linera-service/src/linera/net_up_utils.rs | 81 +++-------------------- 4 files changed, 14 insertions(+), 81 deletions(-) diff --git a/CLI.md b/CLI.md index 387aaeec54fa..1981011ba002 100644 --- a/CLI.md +++ b/CLI.md @@ -936,8 +936,7 @@ Start a Local Linera Network ###### **Options:** -* `--extra-wallets ` — The number of extra wallets and user chains to initialize. Default is 0 -* `--other-initial-chains ` — The number of initial "root" chains created in the genesis config on top of the default "admin" chain. All initial chains belong to the first "admin" wallet +* `--other-initial-chains ` — The number of initial "root" chains created in the genesis config on top of the default "admin" chain. All initial chains belong to the first "admin" wallet. It is recommended to use at least one other initial chain for the faucet Default value: `2` * `--initial-amount ` — The initial amount of native tokens credited in the initial "root" chains, including the default "admin" chain diff --git a/linera-client/src/client_options.rs b/linera-client/src/client_options.rs index 1e6a8987572d..feb2ba351caf 100644 --- a/linera-client/src/client_options.rs +++ b/linera-client/src/client_options.rs @@ -1028,13 +1028,10 @@ impl DatabaseToolCommand { pub enum NetCommand { /// Start a Local Linera Network Up { - /// The number of extra wallets and user chains to initialize. Default is 0. - #[arg(long)] - extra_wallets: Option, - /// The number of initial "root" chains created in the genesis config on top of /// the default "admin" chain. All initial chains belong to the first "admin" - /// wallet. + /// wallet. It is recommended to use at least one other initial chain for the + /// faucet. #[arg(long, default_value = "2")] other_initial_chains: u32, diff --git a/linera-service/src/linera/main.rs b/linera-service/src/linera/main.rs index fe818963a753..66b7311f8868 100644 --- a/linera-service/src/linera/main.rs +++ b/linera-service/src/linera/main.rs @@ -1595,7 +1595,6 @@ async fn run(options: &ClientOptions) -> Result { ClientCommand::Net(net_command) => match net_command { #[cfg(feature = "kubernetes")] NetCommand::Up { - extra_wallets, other_initial_chains, initial_amount, validators, @@ -1615,7 +1614,6 @@ async fn run(options: &ClientOptions) -> Result { faucet_amount, } => { net_up_utils::handle_net_up_kubernetes( - *extra_wallets, *other_initial_chains, *initial_amount, *validators, @@ -1636,7 +1634,6 @@ async fn run(options: &ClientOptions) -> Result { } NetCommand::Up { - extra_wallets, other_initial_chains, initial_amount, validators, @@ -1653,7 +1650,6 @@ async fn run(options: &ClientOptions) -> Result { .. } => { net_up_utils::handle_net_up_service( - *extra_wallets, *other_initial_chains, *initial_amount, *validators, diff --git a/linera-service/src/linera/net_up_utils.rs b/linera-service/src/linera/net_up_utils.rs index 9a6a4bf6946a..f7ac9fab255c 100644 --- a/linera-service/src/linera/net_up_utils.rs +++ b/linera-service/src/linera/net_up_utils.rs @@ -11,7 +11,7 @@ use linera_client::storage::{StorageConfig, StorageConfigNamespace}; use linera_execution::ResourceControlPolicy; use linera_service::cli_wrappers::{ local_net::{Database, LocalNetConfig, PathProvider, StorageConfigBuilder}, - ClientWrapper, FaucetOption, FaucetService, LineraNet, LineraNetConfig, Network, NetworkConfig, + ClientWrapper, FaucetService, LineraNet, LineraNetConfig, Network, NetworkConfig, }; #[cfg(feature = "storage-service")] use linera_storage_service::{ @@ -102,7 +102,6 @@ impl StorageConfigProvider { #[expect(clippy::too_many_arguments)] #[cfg(feature = "kubernetes")] pub async fn handle_net_up_kubernetes( - extra_wallets: Option, num_other_initial_chains: u32, initial_amount: u128, num_initial_validators: usize, @@ -146,9 +145,7 @@ pub async fn handle_net_up_kubernetes( policy, }; let (mut net, client) = config.instantiate().await?; - let faucet_service = create_wallets_and_faucets( - extra_wallets, - &mut net, + let faucet_service = print_messages_and_create_faucet( client, with_faucet, faucet_chain, @@ -162,7 +159,6 @@ pub async fn handle_net_up_kubernetes( #[expect(clippy::too_many_arguments)] pub async fn handle_net_up_service( - extra_wallets: Option, num_other_initial_chains: u32, initial_amount: u128, num_initial_validators: usize, @@ -214,9 +210,7 @@ pub async fn handle_net_up_service( path_provider, }; let (mut net, client) = config.instantiate().await?; - let faucet_service = create_wallets_and_faucets( - extra_wallets, - &mut net, + let faucet_service = print_messages_and_create_faucet( client, with_faucet, faucet_chain, @@ -247,9 +241,7 @@ async fn wait_for_shutdown( } #[allow(clippy::too_many_arguments)] -async fn create_wallets_and_faucets( - extra_wallets: Option, - net: &mut impl LineraNet, +async fn print_messages_and_create_faucet( client: ClientWrapper, with_faucet: bool, faucet_chain: Option, @@ -257,80 +249,29 @@ async fn create_wallets_and_faucets( faucet_amount: Amount, num_other_initial_chains: u32, ) -> Result, anyhow::Error> { - let default_chain = client - .default_chain() - .expect("Initialized clients should always have a default chain"); - // Make time to (hopefully) display the message after the tracing logs. linera_base::time::timer::sleep(Duration::from_secs(1)).await; // Create the wallet for the initial "root" chains. info!("Local test network successfully started."); - let suffix = if let Some(extra_wallets) = extra_wallets { - eprintln!( - "To use the initial wallet and the extra wallets of this test \ - network, you may set the environment variables LINERA_WALLET_$N \ - and LINERA_STORAGE_$N (N = 0..={extra_wallets}) as printed on \ - the standard output, then use the option `--with-wallet $N` (or \ - `-w $N` for short) to select a wallet in the linera tool.\n" - ); - "_0" - } else { - eprintln!( - "To use the initial wallet of this test network, you may set \ - the environment variables LINERA_WALLET and LINERA_STORAGE as follows.\n" - ); - "" - }; + + eprintln!( + "To use the initial wallet of this test network, you may set \ + the environment variables LINERA_WALLET and LINERA_STORAGE as follows.\n" + ); println!( "{}", format!( - "export LINERA_WALLET{suffix}=\"{}\"", + "export LINERA_WALLET=\"{}\"", client.wallet_path().display() ) .bold() ); println!( "{}", - format!( - "export LINERA_STORAGE{suffix}=\"{}\"\n", - client.storage_path() - ) - .bold() + format!("export LINERA_STORAGE=\"{}\"\n", client.storage_path()).bold() ); - // Create the extra wallets. - if let Some(extra_wallets) = extra_wallets { - for wallet in 1..=extra_wallets { - let extra_wallet = net.make_client().await; - extra_wallet.wallet_init(&[], FaucetOption::None).await?; - let unassigned_owner = extra_wallet.keygen().await?; - let new_chain_msg_id = client - .open_chain(default_chain, Some(unassigned_owner), Amount::ZERO) - .await? - .0; - extra_wallet - .assign(unassigned_owner, new_chain_msg_id) - .await?; - println!( - "{}", - format!( - "export LINERA_WALLET_{wallet}=\"{}\"", - extra_wallet.wallet_path().display(), - ) - .bold() - ); - println!( - "{}", - format!( - "export LINERA_STORAGE_{wallet}=\"{}\"\n", - extra_wallet.storage_path(), - ) - .bold() - ); - } - } - // Run the faucet, let faucet_service = if with_faucet { let faucet_chain = if let Some(faucet_chain) = faucet_chain {