* Feature-gate stake program (#13394)
* Add legacy stake-program handling
* Strip out duplicative legacy code
* Add feature for stake-program-fix
* Feature-deploy new stake program
* Expand comment
(cherry picked from commit 1b1d9f6b0c
)
# Conflicts:
# runtime/src/builtins.rs
# runtime/src/feature_set.rs
* Fix conflicts
Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
86
programs/stake/src/legacy_stake_processor.rs
Normal file
86
programs/stake/src/legacy_stake_processor.rs
Normal file
@@ -0,0 +1,86 @@
|
||||
use crate::{config, legacy_stake_state::StakeAccount, stake_instruction::StakeInstruction};
|
||||
use log::*;
|
||||
use solana_sdk::{
|
||||
account::{get_signers, next_keyed_account, KeyedAccount},
|
||||
instruction::InstructionError,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
sysvar::{clock::Clock, rent::Rent, stake_history::StakeHistory, Sysvar},
|
||||
};
|
||||
|
||||
pub fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
keyed_accounts: &[KeyedAccount],
|
||||
data: &[u8],
|
||||
) -> Result<(), InstructionError> {
|
||||
trace!("process_instruction: {:?}", data);
|
||||
trace!("keyed_accounts: {:?}", keyed_accounts);
|
||||
|
||||
let signers = get_signers(keyed_accounts);
|
||||
|
||||
let keyed_accounts = &mut keyed_accounts.iter();
|
||||
let me = &next_keyed_account(keyed_accounts)?;
|
||||
|
||||
match limited_deserialize(data)? {
|
||||
StakeInstruction::Initialize(authorized, lockup) => me.initialize(
|
||||
&authorized,
|
||||
&lockup,
|
||||
&Rent::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
|
||||
),
|
||||
StakeInstruction::Authorize(authorized_pubkey, stake_authorize) => {
|
||||
me.authorize(&signers, &authorized_pubkey, stake_authorize)
|
||||
}
|
||||
StakeInstruction::AuthorizeWithSeed(args) => {
|
||||
let authority_base = next_keyed_account(keyed_accounts)?;
|
||||
me.authorize_with_seed(
|
||||
&authority_base,
|
||||
&args.authority_seed,
|
||||
&args.authority_owner,
|
||||
&args.new_authorized_pubkey,
|
||||
args.stake_authorize,
|
||||
)
|
||||
}
|
||||
StakeInstruction::DelegateStake => {
|
||||
let vote = next_keyed_account(keyed_accounts)?;
|
||||
|
||||
me.delegate(
|
||||
&vote,
|
||||
&Clock::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
|
||||
&StakeHistory::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
|
||||
&config::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
|
||||
&signers,
|
||||
)
|
||||
}
|
||||
StakeInstruction::Split(lamports) => {
|
||||
let split_stake = &next_keyed_account(keyed_accounts)?;
|
||||
me.split(lamports, split_stake, &signers)
|
||||
}
|
||||
StakeInstruction::Merge => {
|
||||
let source_stake = &next_keyed_account(keyed_accounts)?;
|
||||
me.merge(
|
||||
source_stake,
|
||||
&Clock::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
|
||||
&StakeHistory::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
|
||||
&signers,
|
||||
)
|
||||
}
|
||||
|
||||
StakeInstruction::Withdraw(lamports) => {
|
||||
let to = &next_keyed_account(keyed_accounts)?;
|
||||
me.withdraw(
|
||||
lamports,
|
||||
to,
|
||||
&Clock::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
|
||||
&StakeHistory::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
|
||||
next_keyed_account(keyed_accounts)?,
|
||||
keyed_accounts.next(),
|
||||
)
|
||||
}
|
||||
StakeInstruction::Deactivate => me.deactivate(
|
||||
&Clock::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
|
||||
&signers,
|
||||
),
|
||||
|
||||
StakeInstruction::SetLockup(lockup) => me.set_lockup(&lockup, &signers),
|
||||
}
|
||||
}
|
3406
programs/stake/src/legacy_stake_state.rs
Normal file
3406
programs/stake/src/legacy_stake_state.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,8 @@
|
||||
use solana_sdk::genesis_config::GenesisConfig;
|
||||
|
||||
pub mod config;
|
||||
pub mod legacy_stake_processor;
|
||||
pub mod legacy_stake_state;
|
||||
pub mod stake_instruction;
|
||||
pub mod stake_state;
|
||||
|
||||
|
Reference in New Issue
Block a user