-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.1: Enable rolling update of "Permit paying oneself" / "No longer a…
…llow create-account to add funds to an existing account" (#10394) automerge
- Loading branch information
Showing
4 changed files
with
1,663 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use crate::{ | ||
legacy_system_instruction_processor0, message_processor::ProcessInstruction, | ||
system_instruction_processor, | ||
}; | ||
use solana_sdk::{clock::Epoch, genesis_config::OperatingMode, pubkey::Pubkey, system_program}; | ||
|
||
pub struct BuiltinProgram { | ||
pub name: String, | ||
pub id: Pubkey, | ||
pub process_instruction: ProcessInstruction, | ||
} | ||
impl BuiltinProgram { | ||
pub fn new(name: &str, id: Pubkey, process_instruction: ProcessInstruction) -> Self { | ||
Self { | ||
name: name.to_string(), | ||
id, | ||
process_instruction, | ||
} | ||
} | ||
} | ||
|
||
pub(crate) fn new_system_program_activation_epoch(operating_mode: OperatingMode) -> Epoch { | ||
match operating_mode { | ||
OperatingMode::Development => 0, | ||
OperatingMode::Preview => 1_000_000, | ||
OperatingMode::Stable => 1_000_000, | ||
} | ||
} | ||
|
||
/// All builtin programs that should be active at the given (operating_mode, epoch) | ||
pub fn get_builtin_programs(operating_mode: OperatingMode, epoch: Epoch) -> Vec<BuiltinProgram> { | ||
vec![ | ||
if epoch < new_system_program_activation_epoch(operating_mode) { | ||
BuiltinProgram::new( | ||
"system_program", | ||
system_program::id(), | ||
legacy_system_instruction_processor0::process_instruction, | ||
) | ||
} else { | ||
BuiltinProgram::new( | ||
"system_program", | ||
system_program::id(), | ||
system_instruction_processor::process_instruction, | ||
) | ||
}, | ||
BuiltinProgram::new( | ||
"config_program", | ||
solana_config_program::id(), | ||
solana_config_program::config_processor::process_instruction, | ||
), | ||
BuiltinProgram::new( | ||
"stake_program", | ||
solana_stake_program::id(), | ||
solana_stake_program::stake_instruction::process_instruction, | ||
), | ||
BuiltinProgram::new( | ||
"vote_program", | ||
solana_vote_program::id(), | ||
solana_vote_program::vote_instruction::process_instruction, | ||
), | ||
] | ||
} | ||
|
||
/// Builtin programs that activate at the given (operating_mode, epoch) | ||
pub fn get_epoch_activated_builtin_programs( | ||
operating_mode: OperatingMode, | ||
epoch: Epoch, | ||
) -> Option<Vec<BuiltinProgram>> { | ||
if epoch == new_system_program_activation_epoch(operating_mode) { | ||
Some(vec![BuiltinProgram::new( | ||
"system_program", | ||
system_program::id(), | ||
system_instruction_processor::process_instruction, | ||
)]) | ||
} else { | ||
None | ||
} | ||
} |
Oops, something went wrong.