From 0ea5c2533b31f0c5cda8617fcb85b74af61a06b6 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Fri, 15 May 2020 17:49:44 +0800 Subject: [PATCH 1/2] Correct old comment stating lockup gates stake authorize ixs --- programs/stake/src/stake_state.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/programs/stake/src/stake_state.rs b/programs/stake/src/stake_state.rs index e869debfef7733..7346acd5f110fc 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 From ff2ad84714e4e9ca1224e5bf8440496a6328bf89 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Fri, 15 May 2020 18:11:18 +0800 Subject: [PATCH 2/2] Delete dead stake code --- programs/stake/src/stake_state.rs | 48 ------------------------------- 1 file changed, 48 deletions(-) diff --git a/programs/stake/src/stake_state.rs b/programs/stake/src/stake_state.rs index 7346acd5f110fc..e29514c5a37347 100644 --- a/programs/stake/src/stake_state.rs +++ b/programs/stake/src/stake_state.rs @@ -150,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)] @@ -946,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());