diff --git a/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs b/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs index 32f966b7ec7285..801d44b6992c53 100644 --- a/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs +++ b/aptos-move/aptos-gas-schedule/src/gas_schedule/aptos_framework.rs @@ -322,8 +322,5 @@ crate::gas_schedule::macros::define_gas_parameters!( [object_exists_at_per_item_loaded: InternalGas, { 7.. => "object.exists_at.per_item_loaded" }, 1470], [string_utils_base: InternalGas, { 8.. => "string_utils.format.base" }, 1102], [string_utils_per_byte: InternalGasPerByte, { 8.. =>"string_utils.format.per_byte" }, 3], - - [cmp_compare_base: InternalGas, "cmp.base", 367], - [cmp_compare_per_abs_val_unit: InternalGasPerAbstractValueUnit, "cmp.per_abs_val_unit", 14], ] ); diff --git a/aptos-move/aptos-gas-schedule/src/gas_schedule/move_stdlib.rs b/aptos-move/aptos-gas-schedule/src/gas_schedule/move_stdlib.rs index 43b3551d7a1b12..7605fe6760aed0 100644 --- a/aptos-move/aptos-gas-schedule/src/gas_schedule/move_stdlib.rs +++ b/aptos-move/aptos-gas-schedule/src/gas_schedule/move_stdlib.rs @@ -47,5 +47,8 @@ crate::gas_schedule::macros::define_gas_parameters!( [mem_swap_base: InternalGas, { RELEASE_V1_22.. => "mem.swap.base" }, 367], [mem_swap_per_abs_val_unit: InternalGasPerAbstractValueUnit, { RELEASE_V1_22.. => "mem.swap.per_abs_val_unit"}, 14], + + [cmp_compare_base: InternalGas, { RELEASE_V1_22.. => "cmp.compare.base" }, 367], + [cmp_compare_per_abs_val_unit: InternalGasPerAbstractValueUnit, { RELEASE_V1_22.. => "cmp.cper_abs_val_unit"}, 14], ] ); diff --git a/aptos-move/e2e-move-tests/src/tests/code_publishing.data/pack_stdlib/sources/cmp.move b/aptos-move/e2e-move-tests/src/tests/code_publishing.data/pack_stdlib/sources/cmp.move new file mode 120000 index 00000000000000..638cf924ea5a89 --- /dev/null +++ b/aptos-move/e2e-move-tests/src/tests/code_publishing.data/pack_stdlib/sources/cmp.move @@ -0,0 +1 @@ +../../../../../../framework/move-stdlib/sources/cmp.move \ No newline at end of file diff --git a/aptos-move/e2e-move-tests/src/tests/code_publishing.data/pack_stdlib_incompat/sources/cmp.move b/aptos-move/e2e-move-tests/src/tests/code_publishing.data/pack_stdlib_incompat/sources/cmp.move new file mode 120000 index 00000000000000..638cf924ea5a89 --- /dev/null +++ b/aptos-move/e2e-move-tests/src/tests/code_publishing.data/pack_stdlib_incompat/sources/cmp.move @@ -0,0 +1 @@ +../../../../../../framework/move-stdlib/sources/cmp.move \ No newline at end of file diff --git a/aptos-move/framework/aptos-stdlib/doc/overview.md b/aptos-move/framework/aptos-stdlib/doc/overview.md index e906cc4642ff70..6176385db1d977 100644 --- a/aptos-move/framework/aptos-stdlib/doc/overview.md +++ b/aptos-move/framework/aptos-stdlib/doc/overview.md @@ -19,7 +19,6 @@ This is the reference documentation of the Aptos standard library. - [`0x1::bls12381_algebra`](bls12381_algebra.md#0x1_bls12381_algebra) - [`0x1::bn254_algebra`](bn254_algebra.md#0x1_bn254_algebra) - [`0x1::capability`](capability.md#0x1_capability) -- [`0x1::cmp`](cmp.md#0x1_cmp) - [`0x1::comparator`](comparator.md#0x1_comparator) - [`0x1::copyable_any`](copyable_any.md#0x1_copyable_any) - [`0x1::crypto_algebra`](crypto_algebra.md#0x1_crypto_algebra) diff --git a/aptos-move/framework/move-stdlib/doc/cmp.md b/aptos-move/framework/move-stdlib/doc/cmp.md index 7926221f2c35b0..2a50ec1e174c7d 100644 --- a/aptos-move/framework/move-stdlib/doc/cmp.md +++ b/aptos-move/framework/move-stdlib/doc/cmp.md @@ -10,8 +10,10 @@ - [Function `compare_impl`](#0x1_cmp_compare_impl) - [Function `compare`](#0x1_cmp_compare) - [Function `is_equal`](#0x1_cmp_is_equal) -- [Function `is_less_then`](#0x1_cmp_is_less_then) +- [Function `is_less_than`](#0x1_cmp_is_less_than) - [Function `is_less_or_equal`](#0x1_cmp_is_less_or_equal) +- [Function `is_greater_than`](#0x1_cmp_is_greater_than) +- [Function `is__greater_or_equal`](#0x1_cmp_is__greater_or_equal)
@@ -136,7 +138,7 @@ An int value: -
public fun is_equal(ordering: &cmp::Ordering): bool
+
public fun is_equal(self: &cmp::Ordering): bool
 
@@ -145,8 +147,8 @@ An int value: Implementation -
public fun is_equal(ordering: &Ordering): bool {
-    ordering.value == EQUAL
+
public fun is_equal(self: &Ordering): bool {
+    self.value == EQUAL
 }
 
@@ -154,13 +156,13 @@ An int value: - + -## Function `is_less_then` +## Function `is_less_than` -
public fun is_less_then(ordering: &cmp::Ordering): bool
+
public fun is_less_than(self: &cmp::Ordering): bool
 
@@ -169,8 +171,8 @@ An int value: Implementation -
public fun is_less_then(ordering: &Ordering): bool {
-    ordering.value == LESS_THAN
+
public fun is_less_than(self: &Ordering): bool {
+    self.value == LESS_THAN
 }
 
@@ -184,7 +186,7 @@ An int value: -
public fun is_less_or_equal(ordering: &cmp::Ordering): bool
+
public fun is_less_or_equal(self: &cmp::Ordering): bool
 
@@ -193,8 +195,56 @@ An int value: Implementation -
public fun is_less_or_equal(ordering: &Ordering): bool {
-    ordering.value != GREATER_THAN
+
public fun is_less_or_equal(self: &Ordering): bool {
+    self.value != GREATER_THAN
+}
+
+ + + + + + + +## Function `is_greater_than` + + + +
public fun is_greater_than(self: &cmp::Ordering): bool
+
+ + + +
+Implementation + + +
public fun is_greater_than(self: &Ordering): bool {
+    self.value == GREATER_THAN
+}
+
+ + + +
+ + + +## Function `is__greater_or_equal` + + + +
public fun is__greater_or_equal(self: &cmp::Ordering): bool
+
+ + + +
+Implementation + + +
public fun is__greater_or_equal(self: &Ordering): bool {
+    self.value != LESS_THAN
 }
 
diff --git a/aptos-move/framework/move-stdlib/doc/overview.md b/aptos-move/framework/move-stdlib/doc/overview.md index 649873e8ab2f5f..3c93f83875d107 100644 --- a/aptos-move/framework/move-stdlib/doc/overview.md +++ b/aptos-move/framework/move-stdlib/doc/overview.md @@ -16,6 +16,7 @@ For on overview of the Move language, see the [Move Book][move-book]. - [`0x1::acl`](acl.md#0x1_acl) - [`0x1::bcs`](bcs.md#0x1_bcs) - [`0x1::bit_vector`](bit_vector.md#0x1_bit_vector) +- [`0x1::cmp`](cmp.md#0x1_cmp) - [`0x1::error`](error.md#0x1_error) - [`0x1::features`](features.md#0x1_features) - [`0x1::fixed_point32`](fixed_point32.md#0x1_fixed_point32) diff --git a/aptos-move/framework/aptos-stdlib/sources/cmp.move b/aptos-move/framework/move-stdlib/sources/cmp.move similarity index 100% rename from aptos-move/framework/aptos-stdlib/sources/cmp.move rename to aptos-move/framework/move-stdlib/sources/cmp.move diff --git a/aptos-move/framework/src/natives/cmp.rs b/aptos-move/framework/move-stdlib/src/natives/cmp.rs similarity index 89% rename from aptos-move/framework/src/natives/cmp.rs rename to aptos-move/framework/move-stdlib/src/natives/cmp.rs index 00a1b8623cda1b..51db36529228bd 100644 --- a/aptos-move/framework/src/natives/cmp.rs +++ b/aptos-move/framework/move-stdlib/src/natives/cmp.rs @@ -7,7 +7,9 @@ //! Implementation of native functions for utf8 strings. -use aptos_gas_schedule::gas_params::natives::aptos_framework::{CMP_COMPARE_BASE, CMP_COMPARE_PER_ABS_VAL_UNIT}; +use aptos_gas_schedule::gas_params::natives::move_stdlib::{ + CMP_COMPARE_BASE, CMP_COMPARE_PER_ABS_VAL_UNIT, +}; use aptos_native_interface::{ RawSafeNative, SafeNativeBuilder, SafeNativeContext, SafeNativeError, SafeNativeResult, }; @@ -46,9 +48,9 @@ fn native_compare_impl( } let cost = CMP_COMPARE_BASE - + CMP_COMPARE_PER_ABS_VAL_UNIT - * (context.abs_val_size_dereferenced(&args[0]) - + context.abs_val_size_dereferenced(&args[1])); + + CMP_COMPARE_PER_ABS_VAL_UNIT + * (context.abs_val_size_dereferenced(&args[0]) + + context.abs_val_size_dereferenced(&args[1])); context.charge(cost)?; let ordering = args[0].compare(&args[1])?; diff --git a/aptos-move/framework/move-stdlib/src/natives/mod.rs b/aptos-move/framework/move-stdlib/src/natives/mod.rs index c773378cb2e71d..1ea4a32ebc93d4 100644 --- a/aptos-move/framework/move-stdlib/src/natives/mod.rs +++ b/aptos-move/framework/move-stdlib/src/natives/mod.rs @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 pub mod bcs; +pub mod cmp; pub mod hash; pub mod mem; pub mod signer; @@ -34,6 +35,7 @@ pub fn all_natives( builder.with_incremental_gas_charging(false, |builder| { add_natives!("bcs", bcs::make_all(builder)); + add_natives!("cmp", cmp::make_all(builder)); add_natives!("hash", hash::make_all(builder)); add_natives!("mem", mem::make_all(builder)); add_natives!("signer", signer::make_all(builder)); diff --git a/aptos-move/framework/src/natives/mod.rs b/aptos-move/framework/src/natives/mod.rs index 79466817e0b406..dcfc80407f9329 100644 --- a/aptos-move/framework/src/natives/mod.rs +++ b/aptos-move/framework/src/natives/mod.rs @@ -6,7 +6,6 @@ pub mod account; pub mod aggregator_natives; pub mod code; pub mod consensus_config; -pub mod cmp; pub mod create_signer; pub mod cryptography; pub mod debug; @@ -53,7 +52,6 @@ pub fn all_natives( } add_natives_from_module!("account", account::make_all(builder)); - add_natives_from_module!("cmp", cmp::make_all(builder)); add_natives_from_module!("create_signer", create_signer::make_all(builder)); add_natives_from_module!("ed25519", ed25519::make_all(builder)); add_natives_from_module!("crypto_algebra", cryptography::algebra::make_all(builder));