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

Commit 9e4f190

Browse files
authored
stake-pool: Rename instructions / structs (#1536)
* stake-pool: Rename instructions / structs * Cargo fmt * Fix proptest
1 parent 0247661 commit 9e4f190

File tree

14 files changed

+370
-387
lines changed

14 files changed

+370
-387
lines changed

docs/src/stake-pool.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ We created new validator stake accounts in the last step and staked them. Once
235235
the stake activates, we can add them to the stake pool.
236236

237237
```sh
238-
$ spl-stake-pool add-validator-stake 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN
238+
$ spl-stake-pool add-validator 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC FYQB64aEzSmECvnG8RVvdAXBxRnzrLvcA3R22aGH2hUN
239239
Creating account to receive tokens Gu8xqzYFg2sPHWHhUivKNBeF9uikiauihLs9hLzziKu7
240240
Signature: 3N1K89rGV9gWueTTrPGTDBwKAp8BikQhKHMFoREw98Q1piXFeZSSxqfnRQexrfAZQfrpYH9qwsaPWRruwkVeBivV
241241
```
@@ -265,7 +265,7 @@ totally remove the validator stake account from the stake pool by providing
265265
staking derivatives, just like `withdraw`.
266266

267267
```sh
268-
$ spl-stake-pool remove-validator-stake 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC CrStLEWfme37kDc3nubK9HsmWR5dsuVUuqEKqTR4Mc5E --withdraw-from 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF
268+
$ spl-stake-pool remove-validator 3CLwo9CntMi4D1enHEFBe3pRJQzGJBCAYe66xFuEbmhC CrStLEWfme37kDc3nubK9HsmWR5dsuVUuqEKqTR4Mc5E --withdraw-from 34XMHa3JUPv46ftU4dGHvemZ9oKVjnciRePYMcX3rjEF
269269
Signature: 5rrQ3xhDWyiPkUTAQkNAeq31n6sMf1xsg2x9hVY8Vj1NonwBnhxuTv87nADLkwC8Xzc4CGTNCTX2Vph9esWnXk2d
270270
```
271271

stake-pool/cli/src/main.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ use {
3434
spl_stake_pool::{
3535
borsh::{get_instance_packed_len, try_from_slice_unchecked},
3636
instruction::{
37-
add_validator_stake_account, create_validator_stake_account, deposit,
38-
initialize as initialize_pool, remove_validator_stake_account, set_owner,
39-
update_list_balance, update_pool_balance, withdraw, Fee as PoolFee,
37+
add_validator_to_pool, create_validator_stake_account, deposit,
38+
initialize as initialize_pool, remove_validator_from_pool, set_owner,
39+
update_stake_pool_balance, update_validator_list_balance, withdraw, Fee as PoolFee,
4040
},
4141
processor::Processor as PoolProcessor,
4242
stake::authorize as authorize_stake,
4343
stake::id as stake_program_id,
4444
stake::StakeAuthorize,
4545
stake::StakeState,
4646
state::StakePool,
47-
state::ValidatorStakeList,
47+
state::ValidatorList,
4848
},
4949
spl_token::{
5050
self, instruction::approve as approve_token, instruction::initialize_account,
@@ -145,7 +145,7 @@ fn command_create_pool(config: &Config, fee: PoolFee, max_validators: u32) -> Co
145145
let pool_account = Keypair::new();
146146
println!("Creating stake pool {}", pool_account.pubkey());
147147

148-
let validator_stake_list = Keypair::new();
148+
let validator_list = Keypair::new();
149149

150150
let mint_account_balance = config
151151
.rpc_client
@@ -156,15 +156,15 @@ fn command_create_pool(config: &Config, fee: PoolFee, max_validators: u32) -> Co
156156
let pool_account_balance = config
157157
.rpc_client
158158
.get_minimum_balance_for_rent_exemption(get_packed_len::<StakePool>())?;
159-
let empty_validator_list = ValidatorStakeList::new_with_max_validators(max_validators);
160-
let validator_stake_list_size = get_instance_packed_len(&empty_validator_list)?;
161-
let validator_stake_list_balance = config
159+
let empty_validator_list = ValidatorList::new_with_max_validators(max_validators);
160+
let validator_list_size = get_instance_packed_len(&empty_validator_list)?;
161+
let validator_list_balance = config
162162
.rpc_client
163-
.get_minimum_balance_for_rent_exemption(validator_stake_list_size)?;
163+
.get_minimum_balance_for_rent_exemption(validator_list_size)?;
164164
let total_rent_free_balances = mint_account_balance
165165
+ pool_fee_account_balance
166166
+ pool_account_balance
167-
+ validator_stake_list_balance;
167+
+ validator_list_balance;
168168

169169
let default_decimals = native_mint::DECIMALS;
170170

@@ -208,9 +208,9 @@ fn command_create_pool(config: &Config, fee: PoolFee, max_validators: u32) -> Co
208208
// Validator stake account list storage
209209
system_instruction::create_account(
210210
&config.fee_payer.pubkey(),
211-
&validator_stake_list.pubkey(),
212-
validator_stake_list_balance,
213-
validator_stake_list_size as u64,
211+
&validator_list.pubkey(),
212+
validator_list_balance,
213+
validator_list_size as u64,
214214
&spl_stake_pool::id(),
215215
),
216216
// Initialize pool token mint account
@@ -233,7 +233,7 @@ fn command_create_pool(config: &Config, fee: PoolFee, max_validators: u32) -> Co
233233
&spl_stake_pool::id(),
234234
&pool_account.pubkey(),
235235
&config.owner.pubkey(),
236-
&validator_stake_list.pubkey(),
236+
&validator_list.pubkey(),
237237
&mint_account.pubkey(),
238238
&pool_fee_account.pubkey(),
239239
&spl_token::id(),
@@ -252,7 +252,7 @@ fn command_create_pool(config: &Config, fee: PoolFee, max_validators: u32) -> Co
252252
let mut signers = vec![
253253
config.fee_payer.as_ref(),
254254
&pool_account,
255-
&validator_stake_list,
255+
&validator_list,
256256
&mint_account,
257257
&pool_fee_account,
258258
config.owner.as_ref(),
@@ -367,13 +367,13 @@ fn command_vsa_add(
367367
StakeAuthorize::Staker,
368368
),
369369
// Add validator stake account to the pool
370-
add_validator_stake_account(
370+
add_validator_to_pool(
371371
&spl_stake_pool::id(),
372372
&pool,
373373
&config.owner.pubkey(),
374374
&pool_deposit_authority,
375375
&pool_withdraw_authority,
376-
&pool_data.validator_stake_list,
376+
&pool_data.validator_list,
377377
&stake,
378378
&token_receiver,
379379
&pool_data.pool_mint,
@@ -458,13 +458,13 @@ fn command_vsa_remove(
458458
tokens_to_withdraw,
459459
)?,
460460
// Create new validator stake account address
461-
remove_validator_stake_account(
461+
remove_validator_from_pool(
462462
&spl_stake_pool::id(),
463463
&pool,
464464
&config.owner.pubkey(),
465465
&pool_withdraw_authority,
466466
&new_authority,
467-
&pool_data.validator_stake_list,
467+
&pool_data.validator_list,
468468
&stake,
469469
&withdraw_from,
470470
&pool_data.pool_mint,
@@ -559,12 +559,12 @@ fn command_deposit(
559559
}?;
560560

561561
// Check if this vote account has staking account in the pool
562-
let validator_stake_list_data = config
562+
let validator_list_data = config
563563
.rpc_client
564-
.get_account_data(&pool_data.validator_stake_list)?;
565-
let validator_stake_list_data =
566-
try_from_slice_unchecked::<ValidatorStakeList>(&validator_stake_list_data.as_slice())?;
567-
if !validator_stake_list_data.contains(&vote_account) {
564+
.get_account_data(&pool_data.validator_list)?;
565+
let validator_list_data =
566+
try_from_slice_unchecked::<ValidatorList>(&validator_list_data.as_slice())?;
567+
if !validator_list_data.contains(&vote_account) {
568568
return Err("Stake account for this validator does not exist in the pool.".into());
569569
}
570570

@@ -637,7 +637,7 @@ fn command_deposit(
637637
deposit(
638638
&spl_stake_pool::id(),
639639
&pool,
640-
&pool_data.validator_stake_list,
640+
&pool_data.validator_list,
641641
&pool_deposit_authority,
642642
&pool_withdraw_authority,
643643
&stake,
@@ -672,11 +672,11 @@ fn command_list(config: &Config, pool: &Pubkey) -> CommandResult {
672672
if config.verbose {
673673
let validator_list = config
674674
.rpc_client
675-
.get_account_data(&pool_data.validator_stake_list)?;
676-
let validator_stake_list_data =
677-
try_from_slice_unchecked::<ValidatorStakeList>(&validator_list.as_slice())?;
675+
.get_account_data(&pool_data.validator_list)?;
676+
let validator_list_data =
677+
try_from_slice_unchecked::<ValidatorList>(&validator_list.as_slice())?;
678678
println!("Current validator list");
679-
for validator in validator_stake_list_data.validators {
679+
for validator in validator_list_data.validators {
680680
println!(
681681
"Vote Account: {}\tBalance: {}\tEpoch: {}",
682682
validator.validator_account, validator.balance, validator.last_update_epoch
@@ -720,15 +720,15 @@ fn command_update(config: &Config, pool: &Pubkey) -> CommandResult {
720720
// Get stake pool state
721721
let pool_data = config.rpc_client.get_account_data(&pool)?;
722722
let pool_data = StakePool::try_from_slice(pool_data.as_slice()).unwrap();
723-
let validator_stake_list_data = config
723+
let validator_list_data = config
724724
.rpc_client
725-
.get_account_data(&pool_data.validator_stake_list)?;
726-
let validator_stake_list_data =
727-
try_from_slice_unchecked::<ValidatorStakeList>(&validator_stake_list_data.as_slice())?;
725+
.get_account_data(&pool_data.validator_list)?;
726+
let validator_list_data =
727+
try_from_slice_unchecked::<ValidatorList>(&validator_list_data.as_slice())?;
728728

729729
let epoch_info = config.rpc_client.get_epoch_info()?;
730730

731-
let accounts_to_update: Vec<Pubkey> = validator_stake_list_data
731+
let accounts_to_update: Vec<Pubkey> = validator_list_data
732732
.validators
733733
.iter()
734734
.filter_map(|item| {
@@ -748,9 +748,9 @@ fn command_update(config: &Config, pool: &Pubkey) -> CommandResult {
748748
let mut instructions: Vec<Instruction> = vec![];
749749

750750
for chunk in accounts_to_update.chunks(MAX_ACCOUNTS_TO_UPDATE) {
751-
instructions.push(update_list_balance(
751+
instructions.push(update_validator_list_balance(
752752
&spl_stake_pool::id(),
753-
&pool_data.validator_stake_list,
753+
&pool_data.validator_list,
754754
&chunk,
755755
)?);
756756
}
@@ -760,10 +760,10 @@ fn command_update(config: &Config, pool: &Pubkey) -> CommandResult {
760760
Ok(())
761761
} else {
762762
println!("Updating stake pool...");
763-
instructions.push(update_pool_balance(
763+
instructions.push(update_stake_pool_balance(
764764
&spl_stake_pool::id(),
765765
pool,
766-
&pool_data.validator_stake_list,
766+
&pool_data.validator_list,
767767
)?);
768768

769769
let mut transaction =
@@ -976,7 +976,7 @@ fn command_withdraw(
976976
instructions.push(withdraw(
977977
&spl_stake_pool::id(),
978978
&pool,
979-
&pool_data.validator_stake_list,
979+
&pool_data.validator_list,
980980
&pool_withdraw_authority,
981981
&withdraw_stake.pubkey,
982982
&stake_receiver.unwrap(), // Cannot be none at this point
@@ -1183,7 +1183,7 @@ fn main() {
11831183
.help("The validator vote account that this stake will be delegated to"),
11841184
)
11851185
)
1186-
.subcommand(SubCommand::with_name("add-validator-stake").about("Add validator stake account to the stake pool. Must be signed by the pool owner.")
1186+
.subcommand(SubCommand::with_name("add-validator").about("Add validator account to the stake pool. Must be signed by the pool owner.")
11871187
.arg(
11881188
Arg::with_name("pool")
11891189
.index(1)
@@ -1211,7 +1211,7 @@ fn main() {
12111211
.help("Account to receive pool token. Must be initialized account of the stake pool token. Defaults to the new pool token account."),
12121212
)
12131213
)
1214-
.subcommand(SubCommand::with_name("remove-validator-stake").about("Add validator stake account to the stake pool. Must be signed by the pool owner.")
1214+
.subcommand(SubCommand::with_name("remove-validator").about("Remove validator account from the stake pool. Must be signed by the pool owner.")
12151215
.arg(
12161216
Arg::with_name("pool")
12171217
.index(1)
@@ -1435,13 +1435,13 @@ fn main() {
14351435
let vote_account: Pubkey = pubkey_of(arg_matches, "vote_account").unwrap();
14361436
command_vsa_create(&config, &pool_account, &vote_account)
14371437
}
1438-
("add-validator-stake", Some(arg_matches)) => {
1438+
("add-validator", Some(arg_matches)) => {
14391439
let pool_account: Pubkey = pubkey_of(arg_matches, "pool").unwrap();
14401440
let stake_account: Pubkey = pubkey_of(arg_matches, "stake_account").unwrap();
14411441
let token_receiver: Option<Pubkey> = pubkey_of(arg_matches, "token_receiver");
14421442
command_vsa_add(&config, &pool_account, &stake_account, &token_receiver)
14431443
}
1444-
("remove-validator-stake", Some(arg_matches)) => {
1444+
("remove-validator", Some(arg_matches)) => {
14451445
let pool_account: Pubkey = pubkey_of(arg_matches, "pool").unwrap();
14461446
let stake_account: Pubkey = pubkey_of(arg_matches, "stake_account").unwrap();
14471447
let withdraw_from: Pubkey = pubkey_of(arg_matches, "withdraw_from").unwrap();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cc 41ce1c46341336993e5e5d5aa94c30865e63f9e00d31d397aef88ec79fc312ca

0 commit comments

Comments
 (0)