88 stable_log,
99 sysvar_cache:: SysvarCache ,
1010 } ,
11- agave_feature_set:: {
12- lift_cpi_caller_restriction, remove_accounts_executable_flag_checks, FeatureSet ,
13- } ,
1411 solana_account:: { create_account_shared_data_for_test, AccountSharedData } ,
1512 solana_clock:: Slot ,
1613 solana_epoch_schedule:: EpochSchedule ,
4441 } ,
4542} ;
4643
44+ #[ derive( Clone , Copy , Default ) ]
45+ pub struct RuntimeFeatures {
46+ pub lift_cpi_caller_restriction : Option < Slot > ,
47+ pub move_precompile_verification_to_svm : Option < Slot > ,
48+ pub remove_accounts_executable_flag_checks : Option < Slot > ,
49+ pub bpf_account_data_direct_mapping : Option < Slot > ,
50+ pub enable_bpf_loader_set_authority_checked_ix : Option < Slot > ,
51+ pub enable_loader_v4 : Option < Slot > ,
52+ pub deplete_cu_meter_on_vm_failure : Option < Slot > ,
53+ pub abort_on_invalid_curve : Option < Slot > ,
54+ pub blake3_syscall_enabled : Option < Slot > ,
55+ pub curve25519_syscall_enabled : Option < Slot > ,
56+ pub disable_deploy_of_alloc_free_syscall : Option < Slot > ,
57+ pub disable_fees_sysvar : Option < Slot > ,
58+ pub disable_sbpf_v0_execution : Option < Slot > ,
59+ pub enable_alt_bn128_compression_syscall : Option < Slot > ,
60+ pub enable_alt_bn128_syscall : Option < Slot > ,
61+ pub enable_big_mod_exp_syscall : Option < Slot > ,
62+ pub enable_get_epoch_stake_syscall : Option < Slot > ,
63+ pub enable_poseidon_syscall : Option < Slot > ,
64+ pub enable_sbpf_v1_deployment_and_execution : Option < Slot > ,
65+ pub enable_sbpf_v2_deployment_and_execution : Option < Slot > ,
66+ pub enable_sbpf_v3_deployment_and_execution : Option < Slot > ,
67+ pub get_sysvar_syscall_enabled : Option < Slot > ,
68+ pub last_restart_slot_sysvar : Option < Slot > ,
69+ pub reenable_sbpf_v0_execution : Option < Slot > ,
70+ pub remaining_compute_units_syscall_enabled : Option < Slot > ,
71+ pub remove_bpf_loader_incorrect_program_id : Option < Slot > ,
72+ pub move_stake_and_move_lamports_ixs : Option < Slot > ,
73+ pub stake_raise_minimum_delegation_to_1_sol : Option < Slot > ,
74+ pub deprecate_legacy_vote_ixs : Option < Slot > ,
75+ pub mask_out_rent_epoch_in_vm_serialization : Option < Slot > ,
76+ pub simplify_alt_bn128_syscall_error_codes : Option < Slot > ,
77+ pub fix_alt_bn128_multiplication_input_length : Option < Slot > ,
78+ pub loosen_cpi_size_restriction : Option < Slot > ,
79+ pub increase_tx_account_lock_limit : Option < Slot > ,
80+ pub disable_rent_fees_collection : Option < Slot > ,
81+ }
82+
83+ impl RuntimeFeatures {
84+ pub fn all_enabled ( ) -> Self {
85+ Self {
86+ lift_cpi_caller_restriction : Some ( 0 ) ,
87+ move_precompile_verification_to_svm : Some ( 0 ) ,
88+ remove_accounts_executable_flag_checks : Some ( 0 ) ,
89+ bpf_account_data_direct_mapping : Some ( 0 ) ,
90+ enable_bpf_loader_set_authority_checked_ix : Some ( 0 ) ,
91+ enable_loader_v4 : Some ( 0 ) ,
92+ deplete_cu_meter_on_vm_failure : Some ( 0 ) ,
93+ abort_on_invalid_curve : Some ( 0 ) ,
94+ blake3_syscall_enabled : Some ( 0 ) ,
95+ curve25519_syscall_enabled : Some ( 0 ) ,
96+ disable_deploy_of_alloc_free_syscall : Some ( 0 ) ,
97+ disable_fees_sysvar : Some ( 0 ) ,
98+ disable_sbpf_v0_execution : Some ( 0 ) ,
99+ enable_alt_bn128_compression_syscall : Some ( 0 ) ,
100+ enable_alt_bn128_syscall : Some ( 0 ) ,
101+ enable_big_mod_exp_syscall : Some ( 0 ) ,
102+ enable_get_epoch_stake_syscall : Some ( 0 ) ,
103+ enable_poseidon_syscall : Some ( 0 ) ,
104+ enable_sbpf_v1_deployment_and_execution : Some ( 0 ) ,
105+ enable_sbpf_v2_deployment_and_execution : Some ( 0 ) ,
106+ enable_sbpf_v3_deployment_and_execution : Some ( 0 ) ,
107+ get_sysvar_syscall_enabled : Some ( 0 ) ,
108+ last_restart_slot_sysvar : Some ( 0 ) ,
109+ reenable_sbpf_v0_execution : Some ( 0 ) ,
110+ remaining_compute_units_syscall_enabled : Some ( 0 ) ,
111+ remove_bpf_loader_incorrect_program_id : Some ( 0 ) ,
112+ move_stake_and_move_lamports_ixs : Some ( 0 ) ,
113+ stake_raise_minimum_delegation_to_1_sol : Some ( 0 ) ,
114+ deprecate_legacy_vote_ixs : Some ( 0 ) ,
115+ mask_out_rent_epoch_in_vm_serialization : Some ( 0 ) ,
116+ simplify_alt_bn128_syscall_error_codes : Some ( 0 ) ,
117+ fix_alt_bn128_multiplication_input_length : Some ( 0 ) ,
118+ loosen_cpi_size_restriction : Some ( 0 ) ,
119+ increase_tx_account_lock_limit : Some ( 0 ) ,
120+ disable_rent_fees_collection : Some ( 0 ) ,
121+ }
122+ }
123+ }
124+
47125pub type BuiltinFunctionWithContext = BuiltinFunction < InvokeContext < ' static > > ;
48126
49127/// Adapter so we can unify the interfaces of built-in programs and syscalls
@@ -147,15 +225,15 @@ pub struct EnvironmentConfig<'a> {
147225 pub blockhash : Hash ,
148226 pub blockhash_lamports_per_signature : u64 ,
149227 epoch_stake_callback : & ' a dyn InvokeContextCallback ,
150- pub feature_set : Arc < FeatureSet > ,
228+ pub feature_set : Arc < RuntimeFeatures > ,
151229 sysvar_cache : & ' a SysvarCache ,
152230}
153231impl < ' a > EnvironmentConfig < ' a > {
154232 pub fn new (
155233 blockhash : Hash ,
156234 blockhash_lamports_per_signature : u64 ,
157235 epoch_stake_callback : & ' a dyn InvokeContextCallback ,
158- feature_set : Arc < FeatureSet > ,
236+ feature_set : Arc < RuntimeFeatures > ,
159237 sysvar_cache : & ' a SysvarCache ,
160238 ) -> Self {
161239 Self {
@@ -426,9 +504,7 @@ impl<'a> InvokeContext<'a> {
426504
427505 // Find and validate executables / program accounts
428506 let callee_program_id = instruction. program_id ;
429- let program_account_index = if self
430- . get_feature_set ( )
431- . is_active ( & lift_cpi_caller_restriction:: id ( ) )
507+ let program_account_index = if self . get_feature_set ( ) . lift_cpi_caller_restriction . is_some ( )
432508 {
433509 self . transaction_context
434510 . find_index_of_program_account ( & callee_program_id)
@@ -446,9 +522,10 @@ impl<'a> InvokeContext<'a> {
446522 let borrowed_program_account = instruction_context
447523 . try_borrow_instruction_account ( self . transaction_context , program_account_index) ?;
448524 #[ allow( deprecated) ]
449- if ! self
525+ if self
450526 . get_feature_set ( )
451- . is_active ( & remove_accounts_executable_flag_checks:: id ( ) )
527+ . remove_accounts_executable_flag_checks
528+ . is_none ( )
452529 && !borrowed_program_account. is_executable ( )
453530 {
454531 ic_msg ! ( self , "Account {} is not executable" , callee_program_id) ;
@@ -521,7 +598,8 @@ impl<'a> InvokeContext<'a> {
521598 * borrowed_root_account. get_key ( )
522599 } else if self
523600 . get_feature_set ( )
524- . is_active ( & remove_accounts_executable_flag_checks:: id ( ) )
601+ . remove_accounts_executable_flag_checks
602+ . is_some ( )
525603 {
526604 if bpf_loader_deprecated:: check_id ( owner_id)
527605 || bpf_loader:: check_id ( owner_id)
@@ -646,17 +724,32 @@ impl<'a> InvokeContext<'a> {
646724 }
647725
648726 /// Get the current feature set.
649- pub fn get_feature_set ( & self ) -> & FeatureSet {
727+ pub fn get_feature_set ( & self ) -> & RuntimeFeatures {
650728 & self . environment_config . feature_set
651729 }
652730
653731 /// Set feature set.
654732 ///
655733 /// Only use for tests and benchmarks.
656- pub fn mock_set_feature_set ( & mut self , feature_set : Arc < FeatureSet > ) {
734+ #[ cfg( feature = "dev-context-only-utils" ) ]
735+ pub fn mock_set_feature_set ( & mut self , feature_set : Arc < RuntimeFeatures > ) {
657736 self . environment_config . feature_set = feature_set;
658737 }
659738
739+ pub fn is_stake_raise_minimum_delegation_to_1_sol_active ( & self ) -> bool {
740+ self . environment_config
741+ . feature_set
742+ . stake_raise_minimum_delegation_to_1_sol
743+ . is_some ( )
744+ }
745+
746+ pub fn is_deprecate_legacy_vote_ixs_active ( & self ) -> bool {
747+ self . environment_config
748+ . feature_set
749+ . deprecate_legacy_vote_ixs
750+ . is_some ( )
751+ }
752+
660753 /// Get cached sysvars
661754 pub fn get_sysvar_cache ( & self ) -> & SysvarCache {
662755 self . environment_config . sysvar_cache
@@ -738,14 +831,13 @@ macro_rules! with_mock_invoke_context {
738831 $transaction_accounts: expr $( , ) ?
739832 ) => {
740833 use {
741- agave_feature_set:: FeatureSet ,
742834 solana_log_collector:: LogCollector ,
743835 solana_svm_callback:: InvokeContextCallback ,
744836 solana_type_overrides:: sync:: Arc ,
745837 $crate:: {
746838 __private:: { Hash , ReadableAccount , Rent , TransactionContext } ,
747839 execution_budget:: { SVMTransactionExecutionBudget , SVMTransactionExecutionCost } ,
748- invoke_context:: { EnvironmentConfig , InvokeContext } ,
840+ invoke_context:: { EnvironmentConfig , InvokeContext , RuntimeFeatures } ,
749841 loaded_programs:: ProgramCacheForTxBatch ,
750842 sysvar_cache:: SysvarCache ,
751843 } ,
@@ -783,7 +875,7 @@ macro_rules! with_mock_invoke_context {
783875 Hash :: default ( ) ,
784876 0 ,
785877 & MockInvokeContextCallback { } ,
786- Arc :: new( FeatureSet :: all_enabled( ) ) ,
878+ Arc :: new( RuntimeFeatures :: all_enabled( ) ) ,
787879 & sysvar_cache,
788880 ) ;
789881 let mut program_cache_for_tx_batch = ProgramCacheForTxBatch :: default ( ) ;
0 commit comments