@@ -222,35 +222,41 @@ fn stake_is_inactive_without_history(stake: &stake::state::Stake, epoch: Epoch)
222
222
&& stake. delegation . deactivation_epoch == epoch)
223
223
}
224
224
225
- /// Roughly checks if a stake account is deactivating or inactive
226
- fn check_if_stake_is_deactivating_or_inactive (
225
+ /// Roughly checks if a stake account is deactivating
226
+ fn check_if_stake_deactivating (
227
227
account_info : & AccountInfo ,
228
228
vote_account_address : & Pubkey ,
229
+ epoch : Epoch ,
229
230
) -> Result < ( ) , ProgramError > {
230
231
let ( _, stake) = get_stake_state ( account_info) ?;
231
- if stake. delegation . deactivation_epoch == Epoch :: MAX {
232
+ if stake. delegation . deactivation_epoch != epoch {
232
233
msg ! (
233
- "Existing stake {} delegated to {} is activating or active " ,
234
+ "Existing stake {} delegated to {} not deactivated in epoch {} " ,
234
235
account_info. key,
235
- vote_account_address
236
+ vote_account_address,
237
+ epoch,
236
238
) ;
237
239
Err ( StakePoolError :: WrongStakeState . into ( ) )
238
240
} else {
239
241
Ok ( ( ) )
240
242
}
241
243
}
242
244
243
- /// Roughly checks if a stake account is activating or active
244
- fn check_if_stake_is_activating_or_active (
245
+ /// Roughly checks if a stake account is activating
246
+ fn check_if_stake_activating (
245
247
account_info : & AccountInfo ,
246
248
vote_account_address : & Pubkey ,
249
+ epoch : Epoch ,
247
250
) -> Result < ( ) , ProgramError > {
248
251
let ( _, stake) = get_stake_state ( account_info) ?;
249
- if stake. delegation . deactivation_epoch != Epoch :: MAX {
252
+ if stake. delegation . deactivation_epoch != Epoch :: MAX
253
+ || stake. delegation . activation_epoch != epoch
254
+ {
250
255
msg ! (
251
- "Existing stake {} delegated to {} is deactivating or inactive " ,
256
+ "Existing stake {} delegated to {} not activated in epoch {} " ,
252
257
account_info. key,
253
- vote_account_address
258
+ vote_account_address,
259
+ epoch,
254
260
) ;
255
261
Err ( StakePoolError :: WrongStakeState . into ( ) )
256
262
} else {
@@ -1349,9 +1355,10 @@ impl Processor {
1349
1355
) ;
1350
1356
return Err ( ProgramError :: InvalidSeeds ) ;
1351
1357
}
1352
- check_if_stake_is_deactivating_or_inactive (
1358
+ check_if_stake_deactivating (
1353
1359
transient_stake_account_info,
1354
1360
& vote_account_address,
1361
+ clock. epoch ,
1355
1362
) ?;
1356
1363
}
1357
1364
@@ -1600,9 +1607,10 @@ impl Processor {
1600
1607
) ;
1601
1608
return Err ( ProgramError :: InvalidSeeds ) ;
1602
1609
}
1603
- check_if_stake_is_activating_or_active (
1610
+ check_if_stake_activating (
1604
1611
transient_stake_account_info,
1605
1612
vote_account_address,
1613
+ clock. epoch ,
1606
1614
) ?;
1607
1615
}
1608
1616
@@ -2053,9 +2061,10 @@ impl Processor {
2053
2061
destination_transient_stake_seed,
2054
2062
& stake_pool. lockup ,
2055
2063
) ?;
2056
- check_if_stake_is_activating_or_active (
2064
+ check_if_stake_activating (
2057
2065
destination_transient_stake_account_info,
2058
2066
vote_account_address,
2067
+ clock. epoch ,
2059
2068
) ?;
2060
2069
Self :: stake_merge (
2061
2070
stake_pool_info. key ,
0 commit comments