31
31
spl_stake_pool:: {
32
32
self ,
33
33
borsh:: get_instance_packed_len,
34
- find_stake_program_address, find_transient_stake_program_address,
35
- find_withdraw_authority_program_address,
34
+ find_stake_program_address, find_withdraw_authority_program_address,
36
35
stake_program:: { self , StakeState } ,
37
36
state:: { Fee , StakePool , ValidatorList } ,
38
- MAX_VALIDATORS_TO_UPDATE ,
39
37
} ,
40
38
std:: process:: exit,
41
39
} ;
@@ -243,7 +241,7 @@ fn command_create_pool(
243
241
deposit_authority,
244
242
fee,
245
243
max_validators,
246
- ) ? ,
244
+ ) ,
247
245
] ,
248
246
Some ( & config. fee_payer . pubkey ( ) ) ,
249
247
) ;
@@ -283,22 +281,17 @@ fn command_vsa_create(
283
281
stake_pool_address : & Pubkey ,
284
282
vote_account : & Pubkey ,
285
283
) -> CommandResult {
286
- let ( stake_account, _) =
287
- find_stake_program_address ( & spl_stake_pool:: id ( ) , & vote_account, & stake_pool_address) ;
288
-
289
- println ! ( "Creating stake account {}" , stake_account) ;
284
+ println ! ( "Creating stake account on {}" , vote_account) ;
290
285
291
286
let mut transaction = Transaction :: new_with_payer (
292
287
& [
293
288
// Create new validator stake account address
294
- spl_stake_pool:: instruction:: create_validator_stake_account (
295
- & spl_stake_pool:: id ( ) ,
289
+ spl_stake_pool:: instruction:: create_validator_stake_account_with_vote (
296
290
& stake_pool_address,
297
291
& config. staker . pubkey ( ) ,
298
292
& config. fee_payer . pubkey ( ) ,
299
- & stake_account,
300
293
& vote_account,
301
- ) ? ,
294
+ ) ,
302
295
] ,
303
296
Some ( & config. fee_payer . pubkey ( ) ) ,
304
297
) ;
@@ -348,30 +341,18 @@ fn command_vsa_add(
348
341
command_update ( config, stake_pool_address, false , false ) ?;
349
342
}
350
343
351
- let mut instructions: Vec < Instruction > = vec ! [ ] ;
352
- let mut signers = vec ! [ config. fee_payer. as_ref( ) , config. staker. as_ref( ) ] ;
353
-
354
- // Calculate Withdraw stake pool authorities
355
- let pool_withdraw_authority =
356
- find_withdraw_authority_program_address ( & spl_stake_pool:: id ( ) , stake_pool_address) . 0 ;
357
-
358
- instructions. extend ( vec ! [
359
- // Add validator stake account to the pool
360
- spl_stake_pool:: instruction:: add_validator_to_pool(
361
- & spl_stake_pool:: id( ) ,
362
- & stake_pool_address,
363
- & config. staker. pubkey( ) ,
364
- & pool_withdraw_authority,
365
- & stake_pool. validator_list,
366
- & stake_account_address,
367
- ) ?,
368
- ] ) ;
344
+ let instruction = spl_stake_pool:: instruction:: add_validator_to_pool_with_vote (
345
+ & stake_pool,
346
+ & stake_pool_address,
347
+ & vote_account,
348
+ ) ;
369
349
370
350
let mut transaction =
371
- Transaction :: new_with_payer ( & instructions , Some ( & config. fee_payer . pubkey ( ) ) ) ;
351
+ Transaction :: new_with_payer ( & [ instruction ] , Some ( & config. fee_payer . pubkey ( ) ) ) ;
372
352
373
353
let ( recent_blockhash, fee_calculator) = config. rpc_client . get_recent_blockhash ( ) ?;
374
354
check_fee_payer_balance ( config, fee_calculator. calculate_fee ( & transaction. message ( ) ) ) ?;
355
+ let mut signers = vec ! [ config. fee_payer. as_ref( ) , config. staker. as_ref( ) ] ;
375
356
unique_signers ! ( signers) ;
376
357
transaction. sign ( & signers, recent_blockhash) ;
377
358
send_transaction ( & config, transaction) ?;
@@ -389,32 +370,19 @@ fn command_vsa_remove(
389
370
}
390
371
391
372
let stake_pool = get_stake_pool ( & config. rpc_client , stake_pool_address) ?;
392
- let pool_withdraw_authority =
393
- find_withdraw_authority_program_address ( & spl_stake_pool:: id ( ) , stake_pool_address) . 0 ;
394
- let ( validator_stake_account, _) =
395
- find_stake_program_address ( & spl_stake_pool:: id ( ) , & vote_account, stake_pool_address) ;
396
- let ( transient_stake_account, _) = find_transient_stake_program_address (
397
- & spl_stake_pool:: id ( ) ,
398
- & vote_account,
399
- stake_pool_address,
400
- ) ;
401
373
402
374
let staker_pubkey = config. staker . pubkey ( ) ;
403
375
let new_authority = new_authority. as_ref ( ) . unwrap_or ( & staker_pubkey) ;
404
376
405
377
let mut transaction = Transaction :: new_with_payer (
406
378
& [
407
379
// Create new validator stake account address
408
- spl_stake_pool:: instruction:: remove_validator_from_pool (
409
- & spl_stake_pool:: id ( ) ,
410
- & stake_pool_address,
411
- & config. staker . pubkey ( ) ,
412
- & pool_withdraw_authority,
413
- & new_authority,
414
- & stake_pool. validator_list ,
415
- & validator_stake_account,
416
- & transient_stake_account,
417
- ) ?,
380
+ spl_stake_pool:: instruction:: remove_validator_from_pool_with_vote (
381
+ & stake_pool,
382
+ stake_pool_address,
383
+ vote_account,
384
+ new_authority,
385
+ ) ,
418
386
] ,
419
387
Some ( & config. fee_payer . pubkey ( ) ) ,
420
388
) ;
@@ -441,28 +409,15 @@ fn command_increase_validator_stake(
441
409
}
442
410
443
411
let stake_pool = get_stake_pool ( & config. rpc_client , stake_pool_address) ?;
444
- let pool_withdraw_authority =
445
- find_withdraw_authority_program_address ( & spl_stake_pool:: id ( ) , stake_pool_address) . 0 ;
446
- let ( transient_stake_address, _) = find_transient_stake_program_address (
447
- & spl_stake_pool:: id ( ) ,
448
- & vote_account,
412
+ let instruction = spl_stake_pool:: instruction:: increase_validator_stake_with_vote (
413
+ & stake_pool,
449
414
stake_pool_address,
415
+ vote_account,
416
+ lamports,
450
417
) ;
451
418
452
- let mut transaction = Transaction :: new_with_payer (
453
- & [ spl_stake_pool:: instruction:: increase_validator_stake (
454
- & spl_stake_pool:: id ( ) ,
455
- & stake_pool_address,
456
- & config. staker . pubkey ( ) ,
457
- & pool_withdraw_authority,
458
- & stake_pool. validator_list ,
459
- & stake_pool. reserve_stake ,
460
- & transient_stake_address,
461
- & vote_account,
462
- lamports,
463
- ) ] ,
464
- Some ( & config. fee_payer . pubkey ( ) ) ,
465
- ) ;
419
+ let mut transaction =
420
+ Transaction :: new_with_payer ( & [ instruction] , Some ( & config. fee_payer . pubkey ( ) ) ) ;
466
421
467
422
let ( recent_blockhash, fee_calculator) = config. rpc_client . get_recent_blockhash ( ) ?;
468
423
check_fee_payer_balance ( config, fee_calculator. calculate_fee ( & transaction. message ( ) ) ) ?;
@@ -486,29 +441,15 @@ fn command_decrease_validator_stake(
486
441
}
487
442
488
443
let stake_pool = get_stake_pool ( & config. rpc_client , stake_pool_address) ?;
489
- let pool_withdraw_authority =
490
- find_withdraw_authority_program_address ( & spl_stake_pool:: id ( ) , stake_pool_address) . 0 ;
491
- let ( validator_stake_address, _) =
492
- find_stake_program_address ( & spl_stake_pool:: id ( ) , & vote_account, stake_pool_address) ;
493
- let ( transient_stake_address, _) = find_transient_stake_program_address (
494
- & spl_stake_pool:: id ( ) ,
495
- & vote_account,
444
+ let instruction = spl_stake_pool:: instruction:: decrease_validator_stake_with_vote (
445
+ & stake_pool,
496
446
stake_pool_address,
447
+ vote_account,
448
+ lamports,
497
449
) ;
498
450
499
- let mut transaction = Transaction :: new_with_payer (
500
- & [ spl_stake_pool:: instruction:: decrease_validator_stake (
501
- & spl_stake_pool:: id ( ) ,
502
- & stake_pool_address,
503
- & config. staker . pubkey ( ) ,
504
- & pool_withdraw_authority,
505
- & stake_pool. validator_list ,
506
- & validator_stake_address,
507
- & transient_stake_address,
508
- lamports,
509
- ) ] ,
510
- Some ( & config. fee_payer . pubkey ( ) ) ,
511
- ) ;
451
+ let mut transaction =
452
+ Transaction :: new_with_payer ( & [ instruction] , Some ( & config. fee_payer . pubkey ( ) ) ) ;
512
453
513
454
let ( recent_blockhash, fee_calculator) = config. rpc_client . get_recent_blockhash ( ) ?;
514
455
check_fee_payer_balance ( config, fee_calculator. calculate_fee ( & transaction. message ( ) ) ) ?;
@@ -745,41 +686,12 @@ fn command_update(
745
686
746
687
let validator_list = get_validator_list ( & config. rpc_client , & stake_pool. validator_list ) ?;
747
688
748
- let vote_accounts: Vec < Pubkey > = validator_list
749
- . validators
750
- . iter ( )
751
- . map ( |item| item. vote_account_address )
752
- . collect ( ) ;
753
-
754
- println ! ( "Updating stake pool..." ) ;
755
- let ( withdraw_authority, _) =
756
- find_withdraw_authority_program_address ( & spl_stake_pool:: id ( ) , & stake_pool_address) ;
757
-
758
- let mut instructions: Vec < Instruction > = vec ! [ ] ;
759
- let mut start_index = 0 ;
760
- for accounts_chunk in vote_accounts. chunks ( MAX_VALIDATORS_TO_UPDATE ) {
761
- instructions. push ( spl_stake_pool:: instruction:: update_validator_list_balance (
762
- & spl_stake_pool:: id ( ) ,
763
- stake_pool_address,
764
- & withdraw_authority,
765
- & stake_pool. validator_list ,
766
- & stake_pool. reserve_stake ,
767
- & accounts_chunk,
768
- start_index,
769
- no_merge,
770
- ) ) ;
771
- start_index += MAX_VALIDATORS_TO_UPDATE as u32 ;
772
- }
773
-
774
- instructions. push ( spl_stake_pool:: instruction:: update_stake_pool_balance (
775
- & spl_stake_pool:: id ( ) ,
689
+ let instructions = spl_stake_pool:: instruction:: update_stake_pool (
690
+ & stake_pool,
691
+ & validator_list,
776
692
stake_pool_address,
777
- & withdraw_authority,
778
- & stake_pool. validator_list ,
779
- & stake_pool. reserve_stake ,
780
- & stake_pool. manager_fee_account ,
781
- & stake_pool. pool_mint ,
782
- ) ) ;
693
+ no_merge,
694
+ ) ;
783
695
784
696
// TODO: A faster solution would be to send all the `update_validator_list_balance` instructions concurrently
785
697
for instruction in instructions {
@@ -1014,7 +926,7 @@ fn command_withdraw(
1014
926
& stake_pool. pool_mint ,
1015
927
& spl_token:: id ( ) ,
1016
928
withdraw_account. pool_amount ,
1017
- ) ? ) ;
929
+ ) ) ;
1018
930
}
1019
931
1020
932
let mut transaction =
@@ -1066,7 +978,7 @@ fn command_set_manager(
1066
978
& config. manager . pubkey ( ) ,
1067
979
& new_manager,
1068
980
& new_fee_receiver,
1069
- ) ? ] ,
981
+ ) ] ,
1070
982
Some ( & config. fee_payer . pubkey ( ) ) ,
1071
983
) ;
1072
984
@@ -1090,7 +1002,7 @@ fn command_set_staker(
1090
1002
& stake_pool_address,
1091
1003
& config. manager . pubkey ( ) ,
1092
1004
& new_staker,
1093
- ) ? ] ,
1005
+ ) ] ,
1094
1006
Some ( & config. fee_payer . pubkey ( ) ) ,
1095
1007
) ;
1096
1008
0 commit comments