Skip to content

Commit

Permalink
stake-pool-cli: Add validator list argument to create (solana-labs#2545)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joncinque authored Oct 25, 2021
1 parent d550f4f commit 756696e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
12 changes: 12 additions & 0 deletions docs/src/stake-pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions stake-pool/cli/scripts/setup-stake-pool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"

Expand Down
26 changes: 21 additions & 5 deletions stake-pool/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ fn command_create_pool(
stake_referral_fee: u8,
max_validators: u32,
stake_pool_keypair: Option<Keypair>,
validator_list_keypair: Option<Keypair>,
mint_keypair: Option<Keypair>,
reserve_keypair: Option<Keypair>,
) -> CommandResult {
Expand All @@ -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
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand All @@ -2497,6 +2512,7 @@ fn main() {
referral_fee.unwrap_or(0),
max_validators,
pool_keypair,
validator_list_keypair,
mint_keypair,
reserve_keypair,
)
Expand Down

0 comments on commit 756696e

Please sign in to comment.