Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 756696e

Browse files
authored
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
1 parent d550f4f commit 756696e

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

docs/src/stake-pool.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,18 @@ This account holds onto additional stake used when rebalancing between validator
297297
For a stake pool with 1000 validators, the cost to create a stake pool is less
298298
than 0.5 SOL.
299299

300+
The `create-pool` command allows setting all of the accounts and keypairs to
301+
pre-generated values, including:
302+
303+
* stake pool, through the `--pool-keypair` flag
304+
* validator list, through the `--validator-list-keypair` flag
305+
* pool token mint, through the `--mint-keypair` flag
306+
* pool reserve stake account, through the `--reserve-keypair` flag
307+
308+
Otherwise, these will all default to newly-generated keypairs.
309+
310+
You can always check out the available options by running `spl-stake-pool create-pool -h`.
311+
300312
### Create a restricted stake pool
301313

302314
If a manager would like to restrict deposits (stake and SOL) to one key in

stake-pool/cli/scripts/setup-stake-pool.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ build_stake_pool_cli
7171

7272
echo "Creating pool"
7373
stake_pool_keyfile=$keys_dir/stake-pool.json
74+
validator_list_keyfile=$keys_dir/validator-list.json
7475
mint_keyfile=$keys_dir/mint.json
7576
reserve_keyfile=$keys_dir/reserve.json
7677
create_keypair $stake_pool_keyfile
78+
create_keypair $validator_list_keyfile
7779
create_keypair $mint_keyfile
7880
create_keypair $reserve_keyfile
7981

@@ -83,6 +85,7 @@ $spl_stake_pool \
8385
create-pool \
8486
"${command_args[@]}" \
8587
--pool-keypair "$stake_pool_keyfile" \
88+
--validator-list-keypair "$validator_list_keyfile" \
8689
--mint-keypair "$mint_keyfile" \
8790
--reserve-keypair "$reserve_keyfile"
8891

stake-pool/cli/src/main.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ fn command_create_pool(
187187
stake_referral_fee: u8,
188188
max_validators: u32,
189189
stake_pool_keypair: Option<Keypair>,
190+
validator_list_keypair: Option<Keypair>,
190191
mint_keypair: Option<Keypair>,
191192
reserve_keypair: Option<Keypair>,
192193
) -> CommandResult {
@@ -198,7 +199,7 @@ fn command_create_pool(
198199

199200
let stake_pool_keypair = stake_pool_keypair.unwrap_or_else(Keypair::new);
200201

201-
let validator_list = Keypair::new();
202+
let validator_list_keypair = validator_list_keypair.unwrap_or_else(Keypair::new);
202203

203204
let reserve_stake_balance = config
204205
.rpc_client
@@ -288,7 +289,7 @@ fn command_create_pool(
288289
// Validator stake account list storage
289290
system_instruction::create_account(
290291
&config.fee_payer.pubkey(),
291-
&validator_list.pubkey(),
292+
&validator_list_keypair.pubkey(),
292293
validator_list_balance,
293294
validator_list_size as u64,
294295
&spl_stake_pool::id(),
@@ -307,7 +308,7 @@ fn command_create_pool(
307308
&stake_pool_keypair.pubkey(),
308309
&config.manager.pubkey(),
309310
&config.staker.pubkey(),
310-
&validator_list.pubkey(),
311+
&validator_list_keypair.pubkey(),
311312
&reserve_keypair.pubkey(),
312313
&mint_keypair.pubkey(),
313314
&pool_fee_account,
@@ -335,11 +336,15 @@ fn command_create_pool(
335336
setup_transaction.sign(&setup_signers, recent_blockhash);
336337
send_transaction(config, setup_transaction)?;
337338

338-
println!("Creating stake pool {}", stake_pool_keypair.pubkey());
339+
println!(
340+
"Creating stake pool {} with validator list {}",
341+
stake_pool_keypair.pubkey(),
342+
validator_list_keypair.pubkey()
343+
);
339344
let mut initialize_signers = vec![
340345
config.fee_payer.as_ref(),
341346
&stake_pool_keypair,
342-
&validator_list,
347+
&validator_list_keypair,
343348
config.manager.as_ref(),
344349
];
345350
if let Some(deposit_authority) = deposit_authority {
@@ -874,6 +879,7 @@ fn command_list(config: &Config, stake_pool_address: &Pubkey) -> CommandResult {
874879
println!("Fee Account: {}", stake_pool.manager_fee_account);
875880
} else {
876881
println!("Stake Pool: {}", stake_pool_address);
882+
println!("Validator List: {}", stake_pool.validator_list);
877883
println!("Pool Token Mint: {}", stake_pool.pool_mint);
878884
}
879885

@@ -1823,6 +1829,14 @@ fn main() {
18231829
.takes_value(true)
18241830
.help("Stake pool keypair [default: new keypair]"),
18251831
)
1832+
.arg(
1833+
Arg::with_name("validator_list_keypair")
1834+
.long("validator-list-keypair")
1835+
.validator(is_keypair_or_ask_keyword)
1836+
.value_name("PATH")
1837+
.takes_value(true)
1838+
.help("Validator list keypair [default: new keypair]"),
1839+
)
18261840
.arg(
18271841
Arg::with_name("mint_keypair")
18281842
.long("mint-keypair")
@@ -2477,6 +2491,7 @@ fn main() {
24772491
let referral_fee = value_t!(arg_matches, "referral_fee", u8);
24782492
let max_validators = value_t_or_exit!(arg_matches, "max_validators", u32);
24792493
let pool_keypair = keypair_of(arg_matches, "pool_keypair");
2494+
let validator_list_keypair = keypair_of(arg_matches, "validator_list_keypair");
24802495
let mint_keypair = keypair_of(arg_matches, "mint_keypair");
24812496
let reserve_keypair = keypair_of(arg_matches, "reserve_keypair");
24822497
command_create_pool(
@@ -2497,6 +2512,7 @@ fn main() {
24972512
referral_fee.unwrap_or(0),
24982513
max_validators,
24992514
pool_keypair,
2515+
validator_list_keypair,
25002516
mint_keypair,
25012517
reserve_keypair,
25022518
)

0 commit comments

Comments
 (0)