From 756696ee8e7b8dbe640113079ba11447ba3524c1 Mon Sep 17 00:00:00 2001 From: Jon Cinque Date: Mon, 25 Oct 2021 23:13:58 +0200 Subject: [PATCH] stake-pool-cli: Add validator list argument to create (#2545) People want to know more about the validator list, but there isn't too much info provided. * Include the validator list as an optional parameter to pool creation * Print out the address during creation * Always print out the address during `list` * Add docs about it --- docs/src/stake-pool.md | 12 ++++++++++ stake-pool/cli/scripts/setup-stake-pool.sh | 3 +++ stake-pool/cli/src/main.rs | 26 +++++++++++++++++----- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/docs/src/stake-pool.md b/docs/src/stake-pool.md index 10a7a18d549..b6482292bec 100644 --- a/docs/src/stake-pool.md +++ b/docs/src/stake-pool.md @@ -297,6 +297,18 @@ This account holds onto additional stake used when rebalancing between validator For a stake pool with 1000 validators, the cost to create a stake pool is less than 0.5 SOL. +The `create-pool` command allows setting all of the accounts and keypairs to +pre-generated values, including: + +* stake pool, through the `--pool-keypair` flag +* validator list, through the `--validator-list-keypair` flag +* pool token mint, through the `--mint-keypair` flag +* pool reserve stake account, through the `--reserve-keypair` flag + +Otherwise, these will all default to newly-generated keypairs. + +You can always check out the available options by running `spl-stake-pool create-pool -h`. + ### Create a restricted stake pool If a manager would like to restrict deposits (stake and SOL) to one key in diff --git a/stake-pool/cli/scripts/setup-stake-pool.sh b/stake-pool/cli/scripts/setup-stake-pool.sh index 8e0e4994f32..58a34fd4b07 100755 --- a/stake-pool/cli/scripts/setup-stake-pool.sh +++ b/stake-pool/cli/scripts/setup-stake-pool.sh @@ -71,9 +71,11 @@ build_stake_pool_cli echo "Creating pool" stake_pool_keyfile=$keys_dir/stake-pool.json +validator_list_keyfile=$keys_dir/validator-list.json mint_keyfile=$keys_dir/mint.json reserve_keyfile=$keys_dir/reserve.json create_keypair $stake_pool_keyfile +create_keypair $validator_list_keyfile create_keypair $mint_keyfile create_keypair $reserve_keyfile @@ -83,6 +85,7 @@ $spl_stake_pool \ create-pool \ "${command_args[@]}" \ --pool-keypair "$stake_pool_keyfile" \ + --validator-list-keypair "$validator_list_keyfile" \ --mint-keypair "$mint_keyfile" \ --reserve-keypair "$reserve_keyfile" diff --git a/stake-pool/cli/src/main.rs b/stake-pool/cli/src/main.rs index 1a0aedd6ed4..7bd12cbe77d 100644 --- a/stake-pool/cli/src/main.rs +++ b/stake-pool/cli/src/main.rs @@ -187,6 +187,7 @@ fn command_create_pool( stake_referral_fee: u8, max_validators: u32, stake_pool_keypair: Option, + validator_list_keypair: Option, mint_keypair: Option, reserve_keypair: Option, ) -> CommandResult { @@ -198,7 +199,7 @@ fn command_create_pool( let stake_pool_keypair = stake_pool_keypair.unwrap_or_else(Keypair::new); - let validator_list = Keypair::new(); + let validator_list_keypair = validator_list_keypair.unwrap_or_else(Keypair::new); let reserve_stake_balance = config .rpc_client @@ -288,7 +289,7 @@ fn command_create_pool( // Validator stake account list storage system_instruction::create_account( &config.fee_payer.pubkey(), - &validator_list.pubkey(), + &validator_list_keypair.pubkey(), validator_list_balance, validator_list_size as u64, &spl_stake_pool::id(), @@ -307,7 +308,7 @@ fn command_create_pool( &stake_pool_keypair.pubkey(), &config.manager.pubkey(), &config.staker.pubkey(), - &validator_list.pubkey(), + &validator_list_keypair.pubkey(), &reserve_keypair.pubkey(), &mint_keypair.pubkey(), &pool_fee_account, @@ -335,11 +336,15 @@ fn command_create_pool( setup_transaction.sign(&setup_signers, recent_blockhash); send_transaction(config, setup_transaction)?; - println!("Creating stake pool {}", stake_pool_keypair.pubkey()); + println!( + "Creating stake pool {} with validator list {}", + stake_pool_keypair.pubkey(), + validator_list_keypair.pubkey() + ); let mut initialize_signers = vec![ config.fee_payer.as_ref(), &stake_pool_keypair, - &validator_list, + &validator_list_keypair, config.manager.as_ref(), ]; if let Some(deposit_authority) = deposit_authority { @@ -874,6 +879,7 @@ fn command_list(config: &Config, stake_pool_address: &Pubkey) -> CommandResult { println!("Fee Account: {}", stake_pool.manager_fee_account); } else { println!("Stake Pool: {}", stake_pool_address); + println!("Validator List: {}", stake_pool.validator_list); println!("Pool Token Mint: {}", stake_pool.pool_mint); } @@ -1823,6 +1829,14 @@ fn main() { .takes_value(true) .help("Stake pool keypair [default: new keypair]"), ) + .arg( + Arg::with_name("validator_list_keypair") + .long("validator-list-keypair") + .validator(is_keypair_or_ask_keyword) + .value_name("PATH") + .takes_value(true) + .help("Validator list keypair [default: new keypair]"), + ) .arg( Arg::with_name("mint_keypair") .long("mint-keypair") @@ -2477,6 +2491,7 @@ fn main() { let referral_fee = value_t!(arg_matches, "referral_fee", u8); let max_validators = value_t_or_exit!(arg_matches, "max_validators", u32); let pool_keypair = keypair_of(arg_matches, "pool_keypair"); + let validator_list_keypair = keypair_of(arg_matches, "validator_list_keypair"); let mint_keypair = keypair_of(arg_matches, "mint_keypair"); let reserve_keypair = keypair_of(arg_matches, "reserve_keypair"); command_create_pool( @@ -2497,6 +2512,7 @@ fn main() { referral_fee.unwrap_or(0), max_validators, pool_keypair, + validator_list_keypair, mint_keypair, reserve_keypair, )