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

Commit 23edeaa

Browse files
gariousmergify-bot
authored andcommitted
Don't subject authorizing a new stake authority to lockup (#9434)
(cherry picked from commit 31ebdbc)
1 parent 747deba commit 23edeaa

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

programs/stake/src/stake_state.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ impl Meta {
151151
) -> Result<(), InstructionError> {
152152
// verify that lockup has expired or that the authorization
153153
// is *also* signed by the custodian
154-
if self.lockup.is_in_force(clock, signers) {
154+
if stake_authorize == StakeAuthorize::Withdrawer && self.lockup.is_in_force(clock, signers)
155+
{
155156
return Err(StakeError::LockupInForce.into());
156157
}
157158
self.authorized
@@ -948,23 +949,28 @@ mod tests {
948949
meta.authorize(&staker, StakeAuthorize::Staker, &signers, &clock),
949950
Ok(())
950951
);
951-
// verify lockup check
952+
// verify staker not subject to lockup, but withdrawer is
952953
meta.lockup.epoch = 1;
953954
assert_eq!(
954955
meta.authorize(&staker, StakeAuthorize::Staker, &signers, &clock),
956+
Ok(())
957+
);
958+
// verify lockup check
959+
assert_eq!(
960+
meta.authorize(&staker, StakeAuthorize::Withdrawer, &signers, &clock),
955961
Err(StakeError::LockupInForce.into())
956962
);
957963
// verify lockup check defeated by custodian
958964
signers.insert(custodian);
959965
assert_eq!(
960-
meta.authorize(&staker, StakeAuthorize::Staker, &signers, &clock),
966+
meta.authorize(&staker, StakeAuthorize::Withdrawer, &signers, &clock),
961967
Ok(())
962968
);
963969
// verify lock expiry
964970
signers.remove(&custodian);
965971
clock.epoch = 1;
966972
assert_eq!(
967-
meta.authorize(&staker, StakeAuthorize::Staker, &signers, &clock),
973+
meta.authorize(&staker, StakeAuthorize::Withdrawer, &signers, &clock),
968974
Ok(())
969975
);
970976
}

0 commit comments

Comments
 (0)