Skip to content

Commit

Permalink
remove CLI option "linera net up --extra-wallets" (#3393)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
ma2bd authored Feb 23, 2025
1 parent de61cef commit 4cd0ecb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 81 deletions.
3 changes: 1 addition & 2 deletions CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,7 @@ Start a Local Linera Network

###### **Options:**

* `--extra-wallets <EXTRA_WALLETS>` — The number of extra wallets and user chains to initialize. Default is 0
* `--other-initial-chains <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 <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 <INITIAL_AMOUNT>` — The initial amount of native tokens credited in the initial "root" chains, including the default "admin" chain
Expand Down
7 changes: 2 additions & 5 deletions linera-client/src/client_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize>,

/// 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,

Expand Down
4 changes: 0 additions & 4 deletions linera-service/src/linera/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,6 @@ async fn run(options: &ClientOptions) -> Result<i32, anyhow::Error> {
ClientCommand::Net(net_command) => match net_command {
#[cfg(feature = "kubernetes")]
NetCommand::Up {
extra_wallets,
other_initial_chains,
initial_amount,
validators,
Expand All @@ -1615,7 +1614,6 @@ async fn run(options: &ClientOptions) -> Result<i32, anyhow::Error> {
faucet_amount,
} => {
net_up_utils::handle_net_up_kubernetes(
*extra_wallets,
*other_initial_chains,
*initial_amount,
*validators,
Expand All @@ -1636,7 +1634,6 @@ async fn run(options: &ClientOptions) -> Result<i32, anyhow::Error> {
}

NetCommand::Up {
extra_wallets,
other_initial_chains,
initial_amount,
validators,
Expand All @@ -1653,7 +1650,6 @@ async fn run(options: &ClientOptions) -> Result<i32, anyhow::Error> {
..
} => {
net_up_utils::handle_net_up_service(
*extra_wallets,
*other_initial_chains,
*initial_amount,
*validators,
Expand Down
81 changes: 11 additions & 70 deletions linera-service/src/linera/net_up_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -102,7 +102,6 @@ impl StorageConfigProvider {
#[expect(clippy::too_many_arguments)]
#[cfg(feature = "kubernetes")]
pub async fn handle_net_up_kubernetes(
extra_wallets: Option<usize>,
num_other_initial_chains: u32,
initial_amount: u128,
num_initial_validators: usize,
Expand Down Expand Up @@ -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,
Expand All @@ -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<usize>,
num_other_initial_chains: u32,
initial_amount: u128,
num_initial_validators: usize,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -247,90 +241,37 @@ async fn wait_for_shutdown(
}

#[allow(clippy::too_many_arguments)]
async fn create_wallets_and_faucets(
extra_wallets: Option<usize>,
net: &mut impl LineraNet,
async fn print_messages_and_create_faucet(
client: ClientWrapper,
with_faucet: bool,
faucet_chain: Option<u32>,
faucet_port: NonZeroU16,
faucet_amount: Amount,
num_other_initial_chains: u32,
) -> Result<Option<FaucetService>, 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 {
Expand Down

0 comments on commit 4cd0ecb

Please sign in to comment.