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

Don't subject authorizing a new stake authority to lockup #9434

Merged
merged 1 commit into from
Apr 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions programs/stake/src/stake_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ impl Meta {
) -> Result<(), InstructionError> {
// verify that lockup has expired or that the authorization
// is *also* signed by the custodian
if self.lockup.is_in_force(clock, signers) {
if stake_authorize == StakeAuthorize::Withdrawer && self.lockup.is_in_force(clock, signers)
{
return Err(StakeError::LockupInForce.into());
}
self.authorized
Expand Down Expand Up @@ -948,23 +949,28 @@ mod tests {
meta.authorize(&staker, StakeAuthorize::Staker, &signers, &clock),
Ok(())
);
// verify lockup check
// verify staker not subject to lockup, but withdrawer is
meta.lockup.epoch = 1;
assert_eq!(
meta.authorize(&staker, StakeAuthorize::Staker, &signers, &clock),
Ok(())
);
// verify lockup check
assert_eq!(
meta.authorize(&staker, StakeAuthorize::Withdrawer, &signers, &clock),
Err(StakeError::LockupInForce.into())
);
// verify lockup check defeated by custodian
signers.insert(custodian);
assert_eq!(
meta.authorize(&staker, StakeAuthorize::Staker, &signers, &clock),
meta.authorize(&staker, StakeAuthorize::Withdrawer, &signers, &clock),
Ok(())
);
// verify lock expiry
signers.remove(&custodian);
clock.epoch = 1;
assert_eq!(
meta.authorize(&staker, StakeAuthorize::Staker, &signers, &clock),
meta.authorize(&staker, StakeAuthorize::Withdrawer, &signers, &clock),
Ok(())
);
}
Expand Down