Skip to content

Commit

Permalink
feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-aptos committed Oct 15, 2024
1 parent cb1087a commit 94d1b68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions aptos-move/framework/move-stdlib/src/natives/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,26 @@ use move_vm_types::{
use smallvec::{smallvec, SmallVec};
use std::collections::VecDeque;

use super::mem::get_feature_not_available_error;

/// The generic type supplied to aggregator snapshots is not supported.
pub const EINDEX_OUT_OF_BOUNDS: u64 = 0x03_0001;

/***************************************************************************************************
* native fun vector_move<T>(from: &mut vector<T>, removal_position: u64, length: u64, to: &mut vector<T>, insert_position: u64)
* native fun range_move<T>(from: &mut vector<T>, removal_position: u64, length: u64, to: &mut vector<T>, insert_position: u64)
*
* gas cost: VECTOR_RANGE_MOVE_BASE + EINDEX_OUT_OF_BOUNDS * num_elements_to_move
* gas cost: VECTOR_RANGE_MOVE_BASE + VECTOR_RANGE_MOVE_PER_INDEX_MOVED * num_elements_to_move
*
**************************************************************************************************/
fn native_range_move(
context: &mut SafeNativeContext,
ty_args: Vec<Type>,
mut args: VecDeque<Value>,
) -> SafeNativeResult<SmallVec<[Value; 1]>> {
if !context.get_feature_flags().is_native_memory_operations_enabled() {
return Err(get_feature_not_available_error());

Check warning on line 43 in aptos-move/framework/move-stdlib/src/natives/vector.rs

View check run for this annotation

Codecov / codecov/patch

aptos-move/framework/move-stdlib/src/natives/vector.rs#L43

Added line #L43 was not covered by tests
}

context.charge(VECTOR_RANGE_MOVE_BASE)?;

let map_err = |_| SafeNativeError::Abort {
Expand Down
3 changes: 3 additions & 0 deletions third_party/move/move-vm/types/src/values/values_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2482,6 +2482,9 @@ impl VectorRef {
) -> PartialVMResult<()> {
let from_c = self.0.container();
let to_c = to_self.0.container();

// potentially unnecessary as native call should've checked the types already
// (unlike other vector functions that are bytecodes)
check_elem_layout(type_param, from_c)?;
check_elem_layout(type_param, to_c)?;

Expand Down

0 comments on commit 94d1b68

Please sign in to comment.