8
8
stable_log,
9
9
sysvar_cache:: SysvarCache ,
10
10
} ,
11
- agave_feature_set:: {
12
- lift_cpi_caller_restriction, remove_accounts_executable_flag_checks, FeatureSet ,
13
- } ,
14
11
solana_account:: { create_account_shared_data_for_test, AccountSharedData } ,
15
12
solana_clock:: Slot ,
16
13
solana_epoch_schedule:: EpochSchedule ,
44
41
} ,
45
42
} ;
46
43
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
+
47
125
pub type BuiltinFunctionWithContext = BuiltinFunction < InvokeContext < ' static > > ;
48
126
49
127
/// Adapter so we can unify the interfaces of built-in programs and syscalls
@@ -147,15 +225,15 @@ pub struct EnvironmentConfig<'a> {
147
225
pub blockhash : Hash ,
148
226
pub blockhash_lamports_per_signature : u64 ,
149
227
epoch_stake_callback : & ' a dyn InvokeContextCallback ,
150
- pub feature_set : Arc < FeatureSet > ,
228
+ pub feature_set : Arc < RuntimeFeatures > ,
151
229
sysvar_cache : & ' a SysvarCache ,
152
230
}
153
231
impl < ' a > EnvironmentConfig < ' a > {
154
232
pub fn new (
155
233
blockhash : Hash ,
156
234
blockhash_lamports_per_signature : u64 ,
157
235
epoch_stake_callback : & ' a dyn InvokeContextCallback ,
158
- feature_set : Arc < FeatureSet > ,
236
+ feature_set : Arc < RuntimeFeatures > ,
159
237
sysvar_cache : & ' a SysvarCache ,
160
238
) -> Self {
161
239
Self {
@@ -426,9 +504,7 @@ impl<'a> InvokeContext<'a> {
426
504
427
505
// Find and validate executables / program accounts
428
506
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 ( )
432
508
{
433
509
self . transaction_context
434
510
. find_index_of_program_account ( & callee_program_id)
@@ -446,9 +522,10 @@ impl<'a> InvokeContext<'a> {
446
522
let borrowed_program_account = instruction_context
447
523
. try_borrow_instruction_account ( self . transaction_context , program_account_index) ?;
448
524
#[ allow( deprecated) ]
449
- if ! self
525
+ if self
450
526
. get_feature_set ( )
451
- . is_active ( & remove_accounts_executable_flag_checks:: id ( ) )
527
+ . remove_accounts_executable_flag_checks
528
+ . is_none ( )
452
529
&& !borrowed_program_account. is_executable ( )
453
530
{
454
531
ic_msg ! ( self , "Account {} is not executable" , callee_program_id) ;
@@ -521,7 +598,8 @@ impl<'a> InvokeContext<'a> {
521
598
* borrowed_root_account. get_key ( )
522
599
} else if self
523
600
. get_feature_set ( )
524
- . is_active ( & remove_accounts_executable_flag_checks:: id ( ) )
601
+ . remove_accounts_executable_flag_checks
602
+ . is_some ( )
525
603
{
526
604
if bpf_loader_deprecated:: check_id ( owner_id)
527
605
|| bpf_loader:: check_id ( owner_id)
@@ -646,17 +724,32 @@ impl<'a> InvokeContext<'a> {
646
724
}
647
725
648
726
/// Get the current feature set.
649
- pub fn get_feature_set ( & self ) -> & FeatureSet {
727
+ pub fn get_feature_set ( & self ) -> & RuntimeFeatures {
650
728
& self . environment_config . feature_set
651
729
}
652
730
653
731
/// Set feature set.
654
732
///
655
733
/// 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 > ) {
657
736
self . environment_config . feature_set = feature_set;
658
737
}
659
738
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
+
660
753
/// Get cached sysvars
661
754
pub fn get_sysvar_cache ( & self ) -> & SysvarCache {
662
755
self . environment_config . sysvar_cache
@@ -738,14 +831,13 @@ macro_rules! with_mock_invoke_context {
738
831
$transaction_accounts: expr $( , ) ?
739
832
) => {
740
833
use {
741
- agave_feature_set:: FeatureSet ,
742
834
solana_log_collector:: LogCollector ,
743
835
solana_svm_callback:: InvokeContextCallback ,
744
836
solana_type_overrides:: sync:: Arc ,
745
837
$crate:: {
746
838
__private:: { Hash , ReadableAccount , Rent , TransactionContext } ,
747
839
execution_budget:: { SVMTransactionExecutionBudget , SVMTransactionExecutionCost } ,
748
- invoke_context:: { EnvironmentConfig , InvokeContext } ,
840
+ invoke_context:: { EnvironmentConfig , InvokeContext , RuntimeFeatures } ,
749
841
loaded_programs:: ProgramCacheForTxBatch ,
750
842
sysvar_cache:: SysvarCache ,
751
843
} ,
@@ -783,7 +875,7 @@ macro_rules! with_mock_invoke_context {
783
875
Hash :: default ( ) ,
784
876
0 ,
785
877
& MockInvokeContextCallback { } ,
786
- Arc :: new( FeatureSet :: all_enabled( ) ) ,
878
+ Arc :: new( RuntimeFeatures :: all_enabled( ) ) ,
787
879
& sysvar_cache,
788
880
) ;
789
881
let mut program_cache_for_tx_batch = ProgramCacheForTxBatch :: default ( ) ;
0 commit comments