@@ -340,12 +340,10 @@ fn create_stake_account<'a>(
340
340
stake_account_info : AccountInfo < ' a > ,
341
341
stake_account_signer_seeds : & [ & [ u8 ] ] ,
342
342
system_program_info : AccountInfo < ' a > ,
343
+ stake_space : usize ,
343
344
) -> Result < ( ) , ProgramError > {
344
345
invoke_signed (
345
- & system_instruction:: allocate (
346
- stake_account_info. key ,
347
- std:: mem:: size_of :: < stake:: state:: StakeState > ( ) as u64 ,
348
- ) ,
346
+ & system_instruction:: allocate ( stake_account_info. key , stake_space as u64 ) ,
349
347
& [ stake_account_info. clone ( ) , system_program_info. clone ( ) ] ,
350
348
& [ stake_account_signer_seeds] ,
351
349
) ?;
@@ -1036,10 +1034,10 @@ impl Processor {
1036
1034
] ;
1037
1035
1038
1036
// Fund the stake account with the minimum + rent-exempt balance
1039
- let space = std:: mem:: size_of :: < stake:: state:: StakeState > ( ) ;
1037
+ let stake_space = std:: mem:: size_of :: < stake:: state:: StakeState > ( ) ;
1040
1038
let stake_minimum_delegation = stake:: tools:: get_minimum_delegation ( ) ?;
1041
1039
let required_lamports = minimum_delegation ( stake_minimum_delegation)
1042
- . saturating_add ( rent. minimum_balance ( space ) ) ;
1040
+ . saturating_add ( rent. minimum_balance ( stake_space ) ) ;
1043
1041
1044
1042
// Check that we're not draining the reserve totally
1045
1043
let reserve_stake = try_from_slice_unchecked :: < stake:: state:: StakeState > (
@@ -1064,6 +1062,7 @@ impl Processor {
1064
1062
stake_info. clone ( ) ,
1065
1063
stake_account_signer_seeds,
1066
1064
system_program_info. clone ( ) ,
1065
+ stake_space,
1067
1066
) ?;
1068
1067
// split into validator stake account
1069
1068
Self :: stake_split (
@@ -1342,8 +1341,9 @@ impl Processor {
1342
1341
) ?;
1343
1342
}
1344
1343
1344
+ let stake_space = std:: mem:: size_of :: < stake:: state:: StakeState > ( ) ;
1345
1345
let stake_minimum_delegation = stake:: tools:: get_minimum_delegation ( ) ?;
1346
- let stake_rent = rent. minimum_balance ( std :: mem :: size_of :: < stake :: state :: StakeState > ( ) ) ;
1346
+ let stake_rent = rent. minimum_balance ( stake_space ) ;
1347
1347
let current_minimum_lamports =
1348
1348
stake_rent. saturating_add ( minimum_delegation ( stake_minimum_delegation) ) ;
1349
1349
if lamports < current_minimum_lamports {
@@ -1389,6 +1389,7 @@ impl Processor {
1389
1389
ephemeral_stake_account_info. clone ( ) ,
1390
1390
ephemeral_stake_account_signer_seeds,
1391
1391
system_program_info. clone ( ) ,
1392
+ stake_space,
1392
1393
) ?;
1393
1394
1394
1395
// split into ephemeral stake account
@@ -1454,6 +1455,7 @@ impl Processor {
1454
1455
transient_stake_account_info. clone ( ) ,
1455
1456
transient_stake_account_signer_seeds,
1456
1457
system_program_info. clone ( ) ,
1458
+ stake_space,
1457
1459
) ?;
1458
1460
1459
1461
// split into transient stake account
@@ -1609,7 +1611,8 @@ impl Processor {
1609
1611
return Err ( StakePoolError :: ValidatorNotFound . into ( ) ) ;
1610
1612
}
1611
1613
1612
- let stake_rent = rent. minimum_balance ( std:: mem:: size_of :: < stake:: state:: StakeState > ( ) ) ;
1614
+ let stake_space = std:: mem:: size_of :: < stake:: state:: StakeState > ( ) ;
1615
+ let stake_rent = rent. minimum_balance ( stake_space) ;
1613
1616
let stake_minimum_delegation = stake:: tools:: get_minimum_delegation ( ) ?;
1614
1617
let current_minimum_delegation = minimum_delegation ( stake_minimum_delegation) ;
1615
1618
if lamports < current_minimum_delegation {
@@ -1664,6 +1667,7 @@ impl Processor {
1664
1667
ephemeral_stake_account_info. clone ( ) ,
1665
1668
ephemeral_stake_account_signer_seeds,
1666
1669
system_program_info. clone ( ) ,
1670
+ stake_space,
1667
1671
) ?;
1668
1672
1669
1673
// split into ephemeral stake account
@@ -1732,6 +1736,7 @@ impl Processor {
1732
1736
transient_stake_account_info. clone ( ) ,
1733
1737
transient_stake_account_signer_seeds,
1734
1738
system_program_info. clone ( ) ,
1739
+ stake_space,
1735
1740
) ?;
1736
1741
1737
1742
// split into transient stake account
@@ -1839,7 +1844,8 @@ impl Processor {
1839
1844
}
1840
1845
1841
1846
let rent = Rent :: get ( ) ?;
1842
- let stake_rent = rent. minimum_balance ( std:: mem:: size_of :: < stake:: state:: StakeState > ( ) ) ;
1847
+ let stake_space = std:: mem:: size_of :: < stake:: state:: StakeState > ( ) ;
1848
+ let stake_rent = rent. minimum_balance ( stake_space) ;
1843
1849
let stake_minimum_delegation = stake:: tools:: get_minimum_delegation ( ) ?;
1844
1850
let current_minimum_delegation = minimum_delegation ( stake_minimum_delegation) ;
1845
1851
@@ -1942,6 +1948,7 @@ impl Processor {
1942
1948
source_transient_stake_account_info. clone ( ) ,
1943
1949
source_transient_stake_account_signer_seeds,
1944
1950
system_program_info. clone ( ) ,
1951
+ stake_space,
1945
1952
) ?;
1946
1953
1947
1954
Self :: stake_split (
@@ -1973,6 +1980,7 @@ impl Processor {
1973
1980
ephemeral_stake_account_info. clone ( ) ,
1974
1981
ephemeral_stake_account_signer_seeds,
1975
1982
system_program_info. clone ( ) ,
1983
+ stake_space,
1976
1984
) ?;
1977
1985
Self :: stake_redelegate (
1978
1986
stake_pool_info. key ,
@@ -2077,6 +2085,7 @@ impl Processor {
2077
2085
destination_transient_stake_account_info. clone ( ) ,
2078
2086
destination_transient_stake_account_signer_seeds,
2079
2087
system_program_info. clone ( ) ,
2088
+ stake_space,
2080
2089
) ?;
2081
2090
Self :: stake_split (
2082
2091
stake_pool_info. key ,
0 commit comments