-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add instructions and processor for stake deactivate and withdraw #2
Add instructions and processor for stake deactivate and withdraw #2
Conversation
/// | ||
/// Expects 1 Accounts: | ||
/// 0 - Delegate StakeAccount | ||
Deactivate, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one of these at a time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
/// Deactivates the stake in the account | ||
/// | ||
/// Expects 1 Accounts: | ||
/// 0 - Delegate StakeAccount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need 2: the delegate and syscall::current
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if rest.len() != 0 { | ||
Err(InstructionError::InvalidInstructionData)?; | ||
} | ||
me.deactivate_stake(&syscall::current::from_keyed_account(&me)?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest.len() should be exactly 1 and current comes from &rest[0]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
}; | ||
if lamports > self.account.lamports.saturating_sub(staked) { | ||
return Err(InstructionError::InsufficientFunds); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also lower stake.stake to whatever remains in the account
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -284,6 +277,41 @@ mod tests { | |||
), | |||
Err(InstructionError::InvalidAccountData), | |||
); | |||
|
|||
// gets the deserialization checks in deactivate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure comments are correct
dcfc8da
to
38ce28a
Compare
these can land on master now |
Problem
Missing instruction for deactivating stake
Summary of Changes
Added code and tests
solana-labs#4357