4
4
pub mod serialization;
5
5
pub mod syscalls;
6
6
7
+ #[ cfg( feature = "svm-internal" ) ]
8
+ use qualifier_attr:: qualifiers;
7
9
use {
8
10
solana_account:: WritableAccount ,
9
11
solana_bincode:: limited_deserialize,
@@ -42,19 +44,20 @@ use {
42
44
verifier:: RequisiteVerifier ,
43
45
vm:: { ContextObject , EbpfVm } ,
44
46
} ,
45
- solana_sdk_ids:: {
46
- bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, loader_v4, native_loader,
47
- } ,
47
+ solana_sdk_ids:: { bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, native_loader} ,
48
48
solana_system_interface:: { instruction as system_instruction, MAX_PERMITTED_DATA_LENGTH } ,
49
49
solana_transaction_context:: { IndexOfAccount , InstructionContext , TransactionContext } ,
50
50
solana_type_overrides:: sync:: { atomic:: Ordering , Arc } ,
51
51
std:: { cell:: RefCell , mem, rc:: Rc } ,
52
- syscalls:: { create_program_runtime_environment_v1 , morph_into_deployment_environment_v1} ,
52
+ syscalls:: morph_into_deployment_environment_v1,
53
53
} ;
54
54
55
- pub const DEFAULT_LOADER_COMPUTE_UNITS : u64 = 570 ;
56
- pub const DEPRECATED_LOADER_COMPUTE_UNITS : u64 = 1_140 ;
57
- pub const UPGRADEABLE_LOADER_COMPUTE_UNITS : u64 = 2_370 ;
55
+ #[ cfg_attr( feature = "svm-internal" , qualifiers( pub ) ) ]
56
+ const DEFAULT_LOADER_COMPUTE_UNITS : u64 = 570 ;
57
+ #[ cfg_attr( feature = "svm-internal" , qualifiers( pub ) ) ]
58
+ const DEPRECATED_LOADER_COMPUTE_UNITS : u64 = 1_140 ;
59
+ #[ cfg_attr( feature = "svm-internal" , qualifiers( pub ) ) ]
60
+ const UPGRADEABLE_LOADER_COMPUTE_UNITS : u64 = 2_370 ;
58
61
59
62
thread_local ! {
60
63
pub static MEMORY_POOL : RefCell <VmMemoryPool > = RefCell :: new( VmMemoryPool :: new( ) ) ;
@@ -106,7 +109,7 @@ pub fn load_program_from_bytes(
106
109
/// Directly deploy a program using a provided invoke context.
107
110
/// This function should only be invoked from the runtime, since it does not
108
111
/// provide any account loads or checks.
109
- pub fn deploy_program_internal (
112
+ pub fn deploy_program (
110
113
log_collector : Option < Rc < RefCell < LogCollector > > > ,
111
114
program_cache_for_tx_batch : & mut ProgramCacheForTxBatch ,
112
115
program_runtime_environment : ProgramRuntimeEnvironment ,
@@ -181,7 +184,7 @@ macro_rules! deploy_program {
181
184
// This will never fail since the epoch schedule is already configured.
182
185
InstructionError :: ProgramEnvironmentSetupFailure
183
186
} ) ?;
184
- let load_program_metrics = deploy_program_internal (
187
+ let load_program_metrics = $crate :: deploy_program (
185
188
$invoke_context. get_log_collector( ) ,
186
189
$invoke_context. program_cache_for_tx_batch,
187
190
environments. program_runtime_v1. clone( ) ,
@@ -220,13 +223,6 @@ fn write_program_data(
220
223
Ok ( ( ) )
221
224
}
222
225
223
- pub fn check_loader_id ( id : & Pubkey ) -> bool {
224
- bpf_loader:: check_id ( id)
225
- || bpf_loader_deprecated:: check_id ( id)
226
- || bpf_loader_upgradeable:: check_id ( id)
227
- || loader_v4:: check_id ( id)
228
- }
229
-
230
226
/// Only used in macro, do not use directly!
231
227
pub fn calculate_heap_cost ( heap_size : u32 , heap_cost : u64 ) -> u64 {
232
228
const KIBIBYTE : u64 = 1024 ;
@@ -242,7 +238,8 @@ pub fn calculate_heap_cost(heap_size: u32, heap_cost: u64) -> u64 {
242
238
}
243
239
244
240
/// Only used in macro, do not use directly!
245
- pub fn create_vm < ' a , ' b > (
241
+ #[ cfg_attr( feature = "svm-internal" , qualifiers( pub ) ) ]
242
+ fn create_vm < ' a , ' b > (
246
243
program : & ' a Executable < InvokeContext < ' b > > ,
247
244
regions : Vec < MemoryRegion > ,
248
245
accounts_metadata : Vec < SerializedAccountMetadata > ,
@@ -397,7 +394,8 @@ declare_builtin_function!(
397
394
}
398
395
) ;
399
396
400
- pub fn process_instruction_inner (
397
+ #[ cfg_attr( feature = "svm-internal" , qualifiers( pub ) ) ]
398
+ pub ( crate ) fn process_instruction_inner (
401
399
invoke_context : & mut InvokeContext ,
402
400
) -> Result < u64 , Box < dyn std:: error:: Error > > {
403
401
let log_collector = invoke_context. get_log_collector ( ) ;
@@ -1370,7 +1368,8 @@ fn common_close_account(
1370
1368
Ok ( ( ) )
1371
1369
}
1372
1370
1373
- pub fn execute < ' a , ' b : ' a > (
1371
+ #[ cfg_attr( feature = "svm-internal" , qualifiers( pub ) ) ]
1372
+ fn execute < ' a , ' b : ' a > (
1374
1373
executable : & ' a Executable < InvokeContext < ' static > > ,
1375
1374
invoke_context : & ' a mut InvokeContext < ' b > ,
1376
1375
) -> Result < ( ) , Box < dyn std:: error:: Error > > {
@@ -1571,13 +1570,27 @@ pub fn execute<'a, 'b: 'a>(
1571
1570
execute_or_deserialize_result
1572
1571
}
1573
1572
1574
- pub mod test_utils {
1573
+ #[ cfg_attr( feature = "svm-internal" , qualifiers( pub ) ) ]
1574
+ mod test_utils {
1575
+ #[ cfg( feature = "svm-internal" ) ]
1575
1576
use {
1576
- super :: * , solana_account:: ReadableAccount , solana_program:: loader_v4:: LoaderV4State ,
1577
+ super :: * , crate :: syscalls:: create_program_runtime_environment_v1,
1578
+ solana_account:: ReadableAccount , solana_program:: loader_v4,
1579
+ solana_program:: loader_v4:: LoaderV4State ,
1577
1580
solana_program_runtime:: loaded_programs:: DELAY_VISIBILITY_SLOT_OFFSET ,
1578
1581
} ;
1579
1582
1580
- pub fn load_all_invoked_programs ( invoke_context : & mut InvokeContext ) {
1583
+ #[ cfg( feature = "svm-internal" ) ]
1584
+ fn check_loader_id ( id : & Pubkey ) -> bool {
1585
+ bpf_loader:: check_id ( id)
1586
+ || bpf_loader_deprecated:: check_id ( id)
1587
+ || bpf_loader_upgradeable:: check_id ( id)
1588
+ || loader_v4:: check_id ( id)
1589
+ }
1590
+
1591
+ #[ cfg( feature = "svm-internal" ) ]
1592
+ #[ cfg_attr( feature = "svm-internal" , qualifiers( pub ) ) ]
1593
+ fn load_all_invoked_programs ( invoke_context : & mut InvokeContext ) {
1581
1594
let mut load_program_metrics = LoadProgramMetrics :: default ( ) ;
1582
1595
let program_runtime_environment = create_program_runtime_environment_v1 (
1583
1596
invoke_context. get_feature_set ( ) ,
0 commit comments