|  | 
| 18 | 18 |             state::{Authorized, Lockup, Meta, StakeAuthorize, StakeStateV2}, | 
| 19 | 19 |             tools::{acceptable_reference_epoch_credits, eligible_for_deactivate_delinquent}, | 
| 20 | 20 |         }, | 
| 21 |  | -        system_program, | 
| 22 | 21 |         sysvar::{epoch_rewards::EpochRewards, stake_history::StakeHistorySysvar, Sysvar}, | 
| 23 | 22 |         vote::{program as solana_vote_program, state::VoteState}, | 
| 24 | 23 |     }, | 
| @@ -59,11 +58,6 @@ fn set_stake_state(stake_account_info: &AccountInfo, new_state: &StakeStateV2) - | 
| 59 | 58 |         .map_err(|_| ProgramError::InvalidAccountData) | 
| 60 | 59 | } | 
| 61 | 60 | 
 | 
| 62 |  | -fn deallocate_stake_account(stake_account_info: &AccountInfo) -> ProgramResult { | 
| 63 |  | -    stake_account_info.assign(&system_program::id()); | 
| 64 |  | -    stake_account_info.realloc(0, false) | 
| 65 |  | -} | 
| 66 |  | - | 
| 67 | 61 | // dont call this "move" because we have an instruction MoveLamports | 
| 68 | 62 | fn relocate_lamports( | 
| 69 | 63 |     source_account_info: &AccountInfo, | 
| @@ -586,9 +580,9 @@ impl Processor { | 
| 586 | 580 |             _ => return Err(ProgramError::InvalidAccountData), | 
| 587 | 581 |         } | 
| 588 | 582 | 
 | 
| 589 |  | -        // Deinitialize state upon zero balance | 
|  | 583 | +        // Truncate state upon zero balance | 
| 590 | 584 |         if split_lamports == source_lamport_balance { | 
| 591 |  | -            deallocate_stake_account(source_stake_account_info)?; | 
|  | 585 | +            source_stake_account_info.realloc(0, false)?; | 
| 592 | 586 |         } | 
| 593 | 587 | 
 | 
| 594 | 588 |         relocate_lamports( | 
| @@ -672,8 +666,8 @@ impl Processor { | 
| 672 | 666 |                 return Err(ProgramError::InsufficientFunds); | 
| 673 | 667 |             } | 
| 674 | 668 | 
 | 
| 675 |  | -            // Deinitialize state upon zero balance | 
| 676 |  | -            deallocate_stake_account(source_stake_account_info)?; | 
|  | 669 | +            // Truncate state upon zero balance | 
|  | 670 | +            source_stake_account_info.realloc(0, false)?; | 
| 677 | 671 |         } else { | 
| 678 | 672 |             // a partial withdrawal must not deplete the reserve | 
| 679 | 673 |             let withdraw_lamports_and_reserve = checked_add(withdraw_lamports, reserve)?; | 
| @@ -789,8 +783,8 @@ impl Processor { | 
| 789 | 783 |             set_stake_state(destination_stake_account_info, &merged_state)?; | 
| 790 | 784 |         } | 
| 791 | 785 | 
 | 
| 792 |  | -        // Source is about to be drained, deinitialize its state | 
| 793 |  | -        deallocate_stake_account(source_stake_account_info)?; | 
|  | 786 | +        // Source is about to be drained, truncate its state | 
|  | 787 | +        source_stake_account_info.realloc(0, false)?; | 
| 794 | 788 | 
 | 
| 795 | 789 |         // Drain the source stake account | 
| 796 | 790 |         relocate_lamports( | 
|  | 
0 commit comments