From b762319fc5154c87b165b8a47c43d400028a0b9c Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Fri, 15 May 2020 22:02:20 +0800 Subject: [PATCH] Correct comment stating lockup gates stake authorize ixs (#10063) * Correct old comment stating lockup gates stake authorize ixs * Delete dead stake code --- programs/stake/src/stake_state.rs | 55 ++----------------------------- 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/programs/stake/src/stake_state.rs b/programs/stake/src/stake_state.rs index e869debfe..e29514c5a 100644 --- a/programs/stake/src/stake_state.rs +++ b/programs/stake/src/stake_state.rs @@ -99,14 +99,11 @@ pub enum StakeAuthorize { #[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone, Copy)] pub struct Lockup { - /// UnixTimestamp at which this stake will allow withdrawal, or - /// changes to authorized staker or withdrawer, unless the + /// UnixTimestamp at which this stake will allow withdrawal, unless the /// transaction is signed by the custodian pub unix_timestamp: UnixTimestamp, - /// epoch height at which this stake will allow withdrawal, or - /// changes to authorized staker or withdrawer, unless the + /// epoch height at which this stake will allow withdrawal, unless the /// transaction is signed by the custodian - /// to the custodian pub epoch: Epoch, /// custodian signature on a transaction exempts the operation from /// lockup constraints @@ -153,21 +150,6 @@ impl Meta { } Ok(()) } - - pub fn authorize_withdraw( - &mut self, - authority: &Pubkey, - signers: &HashSet, - clock: &Clock, - ) -> 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) { - return Err(StakeError::LockupInForce.into()); - } - self.authorized - .authorize(signers, authority, StakeAuthorize::Withdrawer) - } } #[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy)] @@ -949,39 +931,6 @@ mod tests { ); } - #[test] - fn test_meta_authorize_withdraw() { - let staker = Pubkey::new_rand(); - let custodian = Pubkey::new_rand(); - let mut meta = Meta { - authorized: Authorized::auto(&staker), - lockup: Lockup { - epoch: 0, - unix_timestamp: 0, - custodian, - }, - ..Meta::default() - }; - // verify sig check - let mut signers = HashSet::new(); - signers.insert(staker); - let mut clock = Clock::default(); - - // verify lockup check - meta.lockup.epoch = 1; - assert_eq!( - meta.authorize_withdraw(&staker, &signers, &clock), - Err(StakeError::LockupInForce.into()) - ); - // verify lockup check defeated by custodian - signers.insert(custodian); - assert_eq!(meta.authorize_withdraw(&staker, &signers, &clock), Ok(())); - // verify lock expiry - signers.remove(&custodian); - clock.epoch = 1; - assert_eq!(meta.authorize_withdraw(&staker, &signers, &clock), Ok(())); - } - #[test] fn test_stake_state_stake_from_fail() { let mut stake_account = Account::new(0, std::mem::size_of::(), &id());