@@ -4,7 +4,7 @@ use crate::{
44 utils:: vm:: mem_regions,
55 utils:: vm:: HEAP_MAX ,
66 utils:: vm:: STACK_SIZE ,
7- InstrContext , TOGGLE_DIRECT_MAPPING ,
7+ InstrContext ,
88} ;
99use prost:: Message ;
1010use solana_compute_budget:: compute_budget:: SVMTransactionExecutionCost ;
@@ -149,12 +149,10 @@ pub fn execute_vm_syscall(input: SyscallContext) -> Option<SyscallEffects> {
149149 // TransactionContext::configure_next_instruction_for_tests() crashes if program_idx > 255
150150 return None ;
151151 }
152- let mut direct_mapping = false ;
153- unsafe {
154- if TOGGLE_DIRECT_MAPPING {
155- direct_mapping = !direct_mapping;
156- }
157- } ;
152+ let direct_mapping = invoke_ctx. get_feature_set ( ) . account_data_direct_mapping ;
153+ let stricter_abi_and_runtime_constraints = invoke_ctx
154+ . get_feature_set ( )
155+ . stricter_abi_and_runtime_constraints ;
158156 let mask_out_rent_epoch_in_vm_serialization = invoke_ctx
159157 . get_feature_set ( )
160158 . mask_out_rent_epoch_in_vm_serialization ;
@@ -183,9 +181,18 @@ pub fn execute_vm_syscall(input: SyscallContext) -> Option<SyscallEffects> {
183181 . transaction_context
184182 . get_current_instruction_context ( )
185183 . unwrap ( ) ;
184+ // Memory regions.
185+ // In Agave all memory regions are AlignedMemory::<HOST_ALIGN> == AlignedMemory::<16>,
186+ // i.e. they're all 16-byte aligned in the host.
187+ // The memory regions are:
188+ // 1. program rodata
189+ // 2. stack
190+ // 3. heap
191+ // 4. input data aka accounts
192+ // The stack gap size is 0 iff direct mapping is enabled.
186193 let ( _aligned_memory, input_memory_regions, acc_metadatas) = serialize_parameters (
187194 & caller_instr_ctx,
188- false ,
195+ stricter_abi_and_runtime_constraints ,
189196 direct_mapping,
190197 mask_out_rent_epoch_in_vm_serialization,
191198 )
@@ -209,24 +216,6 @@ pub fn execute_vm_syscall(input: SyscallContext) -> Option<SyscallEffects> {
209216 return None ;
210217 }
211218
212- // Memory regions.
213- // In Agave all memory regions are AlignedMemory::<HOST_ALIGN> == AlignedMemory::<16>,
214- // i.e. they're all 16-byte aligned in the host.
215- // The memory regions are:
216- // 1. program rodata
217- // 2. stack
218- // 3. heap
219- // 4. input data aka accounts
220- // The stack gap is size is 0 iff direct mapping is enabled.
221- // There's some extra quirks:
222- // - heap size is MIN_HEAP_FRAME_BYTES..=MAX_HEAP_FRAME_BYTES
223- // - input data (at least when direct mapping is off) is 1 single map of all
224- // serialized accounts (and each account is serialized to a multiple of 16 bytes)
225- // In this implementation, however:
226- // - heap can be smaller than MIN_HEAP_FRAME_BYTES
227- // - input data is made of multiple regions, and regions don't necessarily have
228- // length multiple of 16, i.e. virtual addresses may be unaligned
229- // These differences allow us to test more edge cases.
230219 let mut invoke_ctx = invoke_context. borrow_mut ( ) ;
231220 let config = invoke_ctx
232221 . program_cache_for_tx_batch
@@ -286,7 +275,7 @@ pub fn execute_vm_syscall(input: SyscallContext) -> Option<SyscallEffects> {
286275 sbpf_version,
287276 invoke_ctx
288277 . transaction_context
289- . access_violation_handler ( false , direct_mapping) ,
278+ . access_violation_handler ( stricter_abi_and_runtime_constraints , direct_mapping) ,
290279 ) else {
291280 cleanup_static_ptrs (
292281 transaction_context_ptr,
@@ -301,7 +290,7 @@ pub fn execute_vm_syscall(input: SyscallContext) -> Option<SyscallEffects> {
301290 invoke_ctx
302291 . set_syscall_context ( solana_program_runtime:: invoke_context:: SyscallContext {
303292 allocator : solana_program_runtime:: invoke_context:: BpfAllocator :: new ( vm_ctx. heap_max ) ,
304- accounts_metadata : acc_metadatas, // TODO: accounts metadata for direct mapping support
293+ accounts_metadata : acc_metadatas,
305294 trace_log : Vec :: new ( ) ,
306295 } )
307296 . unwrap ( ) ;
0 commit comments