diff --git a/src/lib.rs b/src/lib.rs index 644d2406f..8ef563610 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -313,6 +313,7 @@ static SUPPORTED_FEATURES: &[u64] = feature_list![ require_static_nonce_account, enable_vote_address_leader_schedule, enshrine_slashing_program, + // stricter_abi_and_runtime_constraints // NOT supported in fd ]; // If `TOGGLE_DIRECT_MAPPING=1` is set, the direct mapping feature will be inverted, testing with and without direct mapping. diff --git a/src/vm_interp.rs b/src/vm_interp.rs index 5e27d785b..32446f564 100644 --- a/src/vm_interp.rs +++ b/src/vm_interp.rs @@ -195,6 +195,9 @@ pub fn execute_vm_interp(syscall_context: SyscallContext) -> Option Option Option Option { direct_mapping = !direct_mapping; } }; + let stricter_abi_and_runtime_constraints = invoke_ctx + .get_feature_set() + .stricter_abi_and_runtime_constraints; let mask_out_rent_epoch_in_vm_serialization = invoke_ctx .get_feature_set() .mask_out_rent_epoch_in_vm_serialization; @@ -183,9 +186,18 @@ pub fn execute_vm_syscall(input: SyscallContext) -> Option { .transaction_context .get_current_instruction_context() .unwrap(); + // Memory regions. + // In Agave all memory regions are AlignedMemory:: == AlignedMemory::<16>, + // i.e. they're all 16-byte aligned in the host. + // The memory regions are: + // 1. program rodata + // 2. stack + // 3. heap + // 4. input data aka accounts + // The stack gap size is 0 iff direct mapping is enabled. let (_aligned_memory, input_memory_regions, acc_metadatas) = serialize_parameters( &caller_instr_ctx, - false, + stricter_abi_and_runtime_constraints, direct_mapping, mask_out_rent_epoch_in_vm_serialization, ) @@ -209,24 +221,6 @@ pub fn execute_vm_syscall(input: SyscallContext) -> Option { return None; } - // Memory regions. - // In Agave all memory regions are AlignedMemory:: == AlignedMemory::<16>, - // i.e. they're all 16-byte aligned in the host. - // The memory regions are: - // 1. program rodata - // 2. stack - // 3. heap - // 4. input data aka accounts - // The stack gap is size is 0 iff direct mapping is enabled. - // There's some extra quirks: - // - heap size is MIN_HEAP_FRAME_BYTES..=MAX_HEAP_FRAME_BYTES - // - input data (at least when direct mapping is off) is 1 single map of all - // serialized accounts (and each account is serialized to a multiple of 16 bytes) - // In this implementation, however: - // - heap can be smaller than MIN_HEAP_FRAME_BYTES - // - input data is made of multiple regions, and regions don't necessarily have - // length multiple of 16, i.e. virtual addresses may be unaligned - // These differences allow us to test more edge cases. let mut invoke_ctx = invoke_context.borrow_mut(); let config = invoke_ctx .program_cache_for_tx_batch @@ -286,7 +280,7 @@ pub fn execute_vm_syscall(input: SyscallContext) -> Option { sbpf_version, invoke_ctx .transaction_context - .access_violation_handler(false, direct_mapping), + .access_violation_handler(stricter_abi_and_runtime_constraints, direct_mapping), ) else { cleanup_static_ptrs( transaction_context_ptr, @@ -301,7 +295,7 @@ pub fn execute_vm_syscall(input: SyscallContext) -> Option { invoke_ctx .set_syscall_context(solana_program_runtime::invoke_context::SyscallContext { allocator: solana_program_runtime::invoke_context::BpfAllocator::new(vm_ctx.heap_max), - accounts_metadata: acc_metadatas, // TODO: accounts metadata for direct mapping support + accounts_metadata: acc_metadatas, trace_log: Vec::new(), }) .unwrap();