From fc6a8e7ef6bada6de3e1474b91ed3040d005579d Mon Sep 17 00:00:00 2001 From: Igor Date: Tue, 21 Jan 2025 18:56:36 -0800 Subject: [PATCH 1/2] Change big_ordered_map::Node to enum for easier maintanability --- .../aptos-framework/doc/big_ordered_map.md | 28 ++++++++++----- .../datastructures/big_ordered_map.move | 34 ++++++++++--------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/aptos-move/framework/aptos-framework/doc/big_ordered_map.md b/aptos-move/framework/aptos-framework/doc/big_ordered_map.md index 2a32bfce29e72..a2081292b1bf0 100644 --- a/aptos-move/framework/aptos-framework/doc/big_ordered_map.md +++ b/aptos-move/framework/aptos-framework/doc/big_ordered_map.md @@ -26,7 +26,7 @@ They are waiting for Move improvement that will allow references to be part of t allowing cleaner iterator APIs. -- [Struct `Node`](#0x1_big_ordered_map_Node) +- [Enum `Node`](#0x1_big_ordered_map_Node) - [Enum `Child`](#0x1_big_ordered_map_Child) - [Enum `IteratorPtr`](#0x1_big_ordered_map_IteratorPtr) - [Enum `BigOrderedMap`](#0x1_big_ordered_map_BigOrderedMap) @@ -99,7 +99,7 @@ allowing cleaner iterator APIs. -## Struct `Node` +## Enum `Node` A node of the BigOrderedMap. @@ -109,11 +109,19 @@ Basically - Leaf node is a single-resource OrderedMap, containing as much key/va So Leaf node contains multiple values, not just one. -
struct Node<K: store, V: store> has store
+
enum Node<K: store, V: store> has store
 
+
+Variants + + +
+V1 + +
Fields @@ -146,6 +154,10 @@ So Leaf node contains multiple values, not just one. +
+ +
+
@@ -1592,7 +1604,7 @@ Borrow a node mutably, given an index. Works for both root (i.e. inline) node an
fun destroy_empty_node<K: store, V: store>(self: Node<K, V>) {
-    let Node { children, is_leaf: _, prev: _, next: _ } = self;
+    let Node::V1 { children, is_leaf: _, prev: _, next: _ } = self;
     assert!(children.is_empty(), error::invalid_argument(EMAP_NOT_EMPTY));
     children.destroy_empty();
 }
@@ -1618,7 +1630,7 @@ Borrow a node mutably, given an index. Works for both root (i.e. inline) node an
 
 
 
fun new_node<K: store, V: store>(is_leaf: bool): Node<K, V> {
-    Node {
+    Node::V1 {
         is_leaf: is_leaf,
         children: ordered_map::new(),
         prev: NULL_INDEX,
@@ -1647,7 +1659,7 @@ Borrow a node mutably, given an index. Works for both root (i.e. inline) node an
 
 
 
fun new_node_with_children<K: store, V: store>(is_leaf: bool, children: OrderedMap<K, Child<V>>): Node<K, V> {
-    Node {
+    Node::V1 {
         is_leaf: is_leaf,
         children: children,
         prev: NULL_INDEX,
@@ -2275,7 +2287,7 @@ Given a path to node (excluding the node itself), which is currently stored unde
     // But append to the node with smaller keys, as ordered_map::append is more efficient when adding to the end.
     let (key_to_remove, reserved_slot_to_remove) = if (sibling_index == next) {
         // destroying larger sibling node, keeping sibling_slot.
-        let Node { children: sibling_children, is_leaf: _, prev: _, next: sibling_next } = sibling_node;
+        let Node::V1 { children: sibling_children, is_leaf: _, prev: _, next: sibling_next } = sibling_node;
         let key_to_remove = *children.new_end_iter().iter_prev(children).iter_borrow_key(children);
         children.append_disjoint(sibling_children);
         node.next = sibling_next;
@@ -2300,7 +2312,7 @@ Given a path to node (excluding the node itself), which is currently stored unde
         (key_to_remove, node_slot)
     } else {
         // destroying larger current node, keeping node_slot
-        let Node { children: node_children, is_leaf: _, prev: _, next: node_next } = node;
+        let Node::V1 { children: node_children, is_leaf: _, prev: _, next: node_next } = node;
         let key_to_remove = *sibling_children.new_end_iter().iter_prev(sibling_children).iter_borrow_key(sibling_children);
         sibling_children.append_disjoint(node_children);
         sibling_node.next = node_next;
diff --git a/aptos-move/framework/aptos-framework/sources/datastructures/big_ordered_map.move b/aptos-move/framework/aptos-framework/sources/datastructures/big_ordered_map.move
index f92bbe100493c..e193ab50d74bf 100644
--- a/aptos-move/framework/aptos-framework/sources/datastructures/big_ordered_map.move
+++ b/aptos-move/framework/aptos-framework/sources/datastructures/big_ordered_map.move
@@ -78,17 +78,19 @@ module aptos_std::big_ordered_map {
     /// Leaf node will have all children be Child::Leaf.
     /// Basically - Leaf node is a single-resource OrderedMap, containing as much key/value entries, as can fit.
     /// So Leaf node contains multiple values, not just one.
-    struct Node has store {
-        // Whether this node is a leaf node.
-        is_leaf: bool,
-        // The children of the nodes.
-        // When node is inner node, K represents max_key within the child subtree, and values are Child::Inner.
-        // When the node is leaf node, K represents key of the leaf, and values are Child::Leaf.
-        children: OrderedMap>,
-        // The node index of its previous node at the same level, or `NULL_INDEX` if it doesn't have a previous node.
-        prev: u64,
-        // The node index of its next node at the same level, or `NULL_INDEX` if it doesn't have a next node.
-        next: u64,
+    enum Node has store {
+        V1 {
+            // Whether this node is a leaf node.
+            is_leaf: bool,
+            // The children of the nodes.
+            // When node is inner node, K represents max_key within the child subtree, and values are Child::Inner.
+            // When the node is leaf node, K represents key of the leaf, and values are Child::Leaf.
+            children: OrderedMap>,
+            // The node index of its previous node at the same level, or `NULL_INDEX` if it doesn't have a previous node.
+            prev: u64,
+            // The node index of its next node at the same level, or `NULL_INDEX` if it doesn't have a next node.
+            next: u64,
+        }
     }
 
     /// Contents of a child node.
@@ -585,13 +587,13 @@ module aptos_std::big_ordered_map {
     }
 
     fun destroy_empty_node(self: Node) {
-        let Node { children, is_leaf: _, prev: _, next: _ } = self;
+        let Node::V1 { children, is_leaf: _, prev: _, next: _ } = self;
         assert!(children.is_empty(), error::invalid_argument(EMAP_NOT_EMPTY));
         children.destroy_empty();
     }
 
     fun new_node(is_leaf: bool): Node {
-        Node {
+        Node::V1 {
             is_leaf: is_leaf,
             children: ordered_map::new(),
             prev: NULL_INDEX,
@@ -600,7 +602,7 @@ module aptos_std::big_ordered_map {
     }
 
     fun new_node_with_children(is_leaf: bool, children: OrderedMap>): Node {
-        Node {
+        Node::V1 {
             is_leaf: is_leaf,
             children: children,
             prev: NULL_INDEX,
@@ -1028,7 +1030,7 @@ module aptos_std::big_ordered_map {
         // But append to the node with smaller keys, as ordered_map::append is more efficient when adding to the end.
         let (key_to_remove, reserved_slot_to_remove) = if (sibling_index == next) {
             // destroying larger sibling node, keeping sibling_slot.
-            let Node { children: sibling_children, is_leaf: _, prev: _, next: sibling_next } = sibling_node;
+            let Node::V1 { children: sibling_children, is_leaf: _, prev: _, next: sibling_next } = sibling_node;
             let key_to_remove = *children.new_end_iter().iter_prev(children).iter_borrow_key(children);
             children.append_disjoint(sibling_children);
             node.next = sibling_next;
@@ -1053,7 +1055,7 @@ module aptos_std::big_ordered_map {
             (key_to_remove, node_slot)
         } else {
             // destroying larger current node, keeping node_slot
-            let Node { children: node_children, is_leaf: _, prev: _, next: node_next } = node;
+            let Node::V1 { children: node_children, is_leaf: _, prev: _, next: node_next } = node;
             let key_to_remove = *sibling_children.new_end_iter().iter_prev(sibling_children).iter_borrow_key(sibling_children);
             sibling_children.append_disjoint(node_children);
             sibling_node.next = node_next;

From c8d87ad6228dd189b5f031e4513edc3796a80f3c Mon Sep 17 00:00:00 2001
From: Igor 
Date: Wed, 22 Jan 2025 16:31:23 -0800
Subject: [PATCH 2/2] update new_with_config and allocate_spare_slots api to
 BigOrderedMap

---
 .../aptos-framework/doc/big_ordered_map.md    |  38 +++-
 .../doc/permissioned_delegation.md            |   2 +-
 .../doc/permissioned_signer.md                |   2 +-
 .../account/permissioned_delegation.move      |   2 +-
 .../datastructures/big_ordered_map.move       |  66 ++++---
 .../sources/permissioned_signer.move          |   2 +-
 .../doc/storage_slots_allocator.md            | 110 ++++-------
 .../storage_slots_allocator.move              |  43 ++---
 .../src/raw_module_data.rs                    | 180 +++++++++---------
 .../sources/maps_example.move                 |   2 +-
 10 files changed, 218 insertions(+), 229 deletions(-)

diff --git a/aptos-move/framework/aptos-framework/doc/big_ordered_map.md b/aptos-move/framework/aptos-framework/doc/big_ordered_map.md
index a2081292b1bf0..83415aaeb25cd 100644
--- a/aptos-move/framework/aptos-framework/doc/big_ordered_map.md
+++ b/aptos-move/framework/aptos-framework/doc/big_ordered_map.md
@@ -35,6 +35,7 @@ allowing cleaner iterator APIs.
 -  [Function `new_with_config`](#0x1_big_ordered_map_new_with_config)
 -  [Function `new_from`](#0x1_big_ordered_map_new_from)
 -  [Function `destroy_empty`](#0x1_big_ordered_map_destroy_empty)
+-  [Function `allocate_spare_slots`](#0x1_big_ordered_map_allocate_spare_slots)
 -  [Function `add`](#0x1_big_ordered_map_add)
 -  [Function `upsert`](#0x1_big_ordered_map_upsert)
 -  [Function `remove`](#0x1_big_ordered_map_remove)
@@ -543,7 +544,7 @@ it is required to use new_with_config, to explicitly select automatic or specifi
         error::invalid_argument(EINVALID_CONFIG_PARAMETER)
     );
 
-    new_with_config(0, 0, false, 0)
+    new_with_config(0, 0, false)
 }
 
@@ -565,7 +566,7 @@ If keys or values have variable size, and first element could be non-representat it is important to compute and pass inner_max_degree and leaf_max_degree based on the largest element you want to be able to insert. -
public fun new_with_config<K: store, V: store>(inner_max_degree: u16, leaf_max_degree: u16, reuse_slots: bool, num_to_preallocate: u32): big_ordered_map::BigOrderedMap<K, V>
+
public fun new_with_config<K: store, V: store>(inner_max_degree: u16, leaf_max_degree: u16, reuse_slots: bool): big_ordered_map::BigOrderedMap<K, V>
 
@@ -574,16 +575,15 @@ it is important to compute and pass inner_max_degree and leaf_max_degree based o Implementation -
public fun new_with_config<K: store, V: store>(inner_max_degree: u16, leaf_max_degree: u16, reuse_slots: bool, num_to_preallocate: u32): BigOrderedMap<K, V> {
+
public fun new_with_config<K: store, V: store>(inner_max_degree: u16, leaf_max_degree: u16, reuse_slots: bool): BigOrderedMap<K, V> {
     assert!(inner_max_degree == 0 || (inner_max_degree >= DEFAULT_INNER_MIN_DEGREE && (inner_max_degree as u64) <= MAX_DEGREE), error::invalid_argument(EINVALID_CONFIG_PARAMETER));
     assert!(leaf_max_degree == 0 || (leaf_max_degree >= DEFAULT_LEAF_MIN_DEGREE && (leaf_max_degree as u64) <= MAX_DEGREE), error::invalid_argument(EINVALID_CONFIG_PARAMETER));
-    assert!(reuse_slots || num_to_preallocate == 0, error::invalid_argument(EINVALID_CONFIG_PARAMETER));
 
     // Assert that storage_slots_allocator special indices are aligned:
     assert!(storage_slots_allocator::is_null_index(NULL_INDEX), error::invalid_state(EINTERNAL_INVARIANT_BROKEN));
     assert!(storage_slots_allocator::is_special_unused_index(ROOT_INDEX), error::invalid_state(EINTERNAL_INVARIANT_BROKEN));
 
-    let nodes = storage_slots_allocator::new(storage_slots_allocator::new_config(reuse_slots, num_to_preallocate));
+    let nodes = storage_slots_allocator::new(reuse_slots);
 
     let self = BigOrderedMap::BPlusTreeMap {
         root: new_node(/*is_leaf=*/true),
@@ -658,6 +658,34 @@ Destroys the map if it's empty, otherwise aborts.
 
 
 
+
+
+
+
+## Function `allocate_spare_slots`
+
+Map was created with reuse_slots=true, you can allocate spare slots, to pay storage fee now, to
+allow future insertions to not require any storage slot creation - making their gas more predictable
+and better bounded/fair.
+(otherwsie, unlucky inserts create new storage slots and are charge more for it)
+
+
+
public fun allocate_spare_slots<K: store, V: store>(self: &mut big_ordered_map::BigOrderedMap<K, V>, num_to_allocate: u64)
+
+ + + +
+Implementation + + +
public fun allocate_spare_slots<K: store, V: store>(self: &mut BigOrderedMap<K, V>, num_to_allocate: u64) {
+    self.nodes.allocate_spare_slots(num_to_allocate)
+}
+
+ + +
diff --git a/aptos-move/framework/aptos-framework/doc/permissioned_delegation.md b/aptos-move/framework/aptos-framework/doc/permissioned_delegation.md index fccff1c7917f3..35e746440bff2 100644 --- a/aptos-move/framework/aptos-framework/doc/permissioned_delegation.md +++ b/aptos-move/framework/aptos-framework/doc/permissioned_delegation.md @@ -279,7 +279,7 @@ let addr = signer::address_of(master); if (!exists<RegisteredDelegations>(addr)) { move_to(master, RegisteredDelegations { - delegations: big_ordered_map::new_with_config(50, 20, false, 0) + delegations: big_ordered_map::new_with_config(50, 20, false) }); }; let handles = &mut borrow_global_mut<RegisteredDelegations>(addr).delegations; diff --git a/aptos-move/framework/aptos-framework/doc/permissioned_signer.md b/aptos-move/framework/aptos-framework/doc/permissioned_signer.md index 9fb317115c7f3..dc2b749182e19 100644 --- a/aptos-move/framework/aptos-framework/doc/permissioned_signer.md +++ b/aptos-move/framework/aptos-framework/doc/permissioned_signer.md @@ -736,7 +736,7 @@ initialize permission storage by putting an empty storage under the address. move_to( &create_signer(permissions_storage_addr), // Each key is ~100bytes, the value is 12 bytes. - PermissionStorage::V1 { perms: big_ordered_map::new_with_config(40, 35, false, 0) } + PermissionStorage::V1 { perms: big_ordered_map::new_with_config(40, 35, false) } ); }
diff --git a/aptos-move/framework/aptos-framework/sources/account/permissioned_delegation.move b/aptos-move/framework/aptos-framework/sources/account/permissioned_delegation.move index 12050706211d1..a631a443619b5 100644 --- a/aptos-move/framework/aptos-framework/sources/account/permissioned_delegation.move +++ b/aptos-move/framework/aptos-framework/sources/account/permissioned_delegation.move @@ -59,7 +59,7 @@ module aptos_framework::permissioned_delegation { let addr = signer::address_of(master); if (!exists(addr)) { move_to(master, RegisteredDelegations { - delegations: big_ordered_map::new_with_config(50, 20, false, 0) + delegations: big_ordered_map::new_with_config(50, 20, false) }); }; let handles = &mut borrow_global_mut(addr).delegations; diff --git a/aptos-move/framework/aptos-framework/sources/datastructures/big_ordered_map.move b/aptos-move/framework/aptos-framework/sources/datastructures/big_ordered_map.move index e193ab50d74bf..6d1fd915b1727 100644 --- a/aptos-move/framework/aptos-framework/sources/datastructures/big_ordered_map.move +++ b/aptos-move/framework/aptos-framework/sources/datastructures/big_ordered_map.move @@ -156,7 +156,7 @@ module aptos_std::big_ordered_map { error::invalid_argument(EINVALID_CONFIG_PARAMETER) ); - new_with_config(0, 0, false, 0) + new_with_config(0, 0, false) } /// Returns a new BigOrderedMap with the provided max degree consts (the maximum # of children a node can have, both inner and leaf). @@ -167,16 +167,15 @@ module aptos_std::big_ordered_map { /// `entry_size * leaf_max_degree <= MAX_NODE_BYTES` /// If keys or values have variable size, and first element could be non-representative in size (i.e. smaller than future ones), /// it is important to compute and pass inner_max_degree and leaf_max_degree based on the largest element you want to be able to insert. - public fun new_with_config(inner_max_degree: u16, leaf_max_degree: u16, reuse_slots: bool, num_to_preallocate: u32): BigOrderedMap { + public fun new_with_config(inner_max_degree: u16, leaf_max_degree: u16, reuse_slots: bool): BigOrderedMap { assert!(inner_max_degree == 0 || (inner_max_degree >= DEFAULT_INNER_MIN_DEGREE && (inner_max_degree as u64) <= MAX_DEGREE), error::invalid_argument(EINVALID_CONFIG_PARAMETER)); assert!(leaf_max_degree == 0 || (leaf_max_degree >= DEFAULT_LEAF_MIN_DEGREE && (leaf_max_degree as u64) <= MAX_DEGREE), error::invalid_argument(EINVALID_CONFIG_PARAMETER)); - assert!(reuse_slots || num_to_preallocate == 0, error::invalid_argument(EINVALID_CONFIG_PARAMETER)); // Assert that storage_slots_allocator special indices are aligned: assert!(storage_slots_allocator::is_null_index(NULL_INDEX), error::invalid_state(EINTERNAL_INVARIANT_BROKEN)); assert!(storage_slots_allocator::is_special_unused_index(ROOT_INDEX), error::invalid_state(EINTERNAL_INVARIANT_BROKEN)); - let nodes = storage_slots_allocator::new(storage_slots_allocator::new_config(reuse_slots, num_to_preallocate)); + let nodes = storage_slots_allocator::new(reuse_slots); let self = BigOrderedMap::BPlusTreeMap { root: new_node(/*is_leaf=*/true), @@ -208,6 +207,14 @@ module aptos_std::big_ordered_map { nodes.destroy_empty(); } + /// Map was created with reuse_slots=true, you can allocate spare slots, to pay storage fee now, to + /// allow future insertions to not require any storage slot creation - making their gas more predictable + /// and better bounded/fair. + /// (otherwsie, unlucky inserts create new storage slots and are charge more for it) + public fun allocate_spare_slots(self: &mut BigOrderedMap, num_to_allocate: u64) { + self.nodes.allocate_spare_slots(num_to_allocate) + } + // ======================= Section with Modifiers ========================= /// Inserts the key/value into the BigOrderedMap. @@ -1241,7 +1248,8 @@ module aptos_std::big_ordered_map { #[test] fun test_small_example() { - let map = new_with_config(5, 3, true, 2); + let map = new_with_config(5, 3, true); + map.allocate_spare_slots(2); map.print_map(); map.validate_map(); add(&mut map, 1, 1); map.print_map(); map.validate_map(); add(&mut map, 2, 2); map.print_map(); map.validate_map(); @@ -1280,7 +1288,7 @@ module aptos_std::big_ordered_map { #[test] fun test_for_each() { - let map = new_with_config(4, 3, false, 0); + let map = new_with_config(4, 3, false); map.add_all(vector[1, 3, 6, 2, 9, 5, 7, 4, 8], vector[1, 3, 6, 2, 9, 5, 7, 4, 8]); let expected = vector[1, 2, 3, 4, 5, 6, 7, 8, 9]; @@ -1294,7 +1302,7 @@ module aptos_std::big_ordered_map { #[test] fun test_variable_size() { - let map = new_with_config, vector>(0, 0, false, 0); + let map = new_with_config, vector>(0, 0, false); map.print_map(); map.validate_map(); add(&mut map, vector[1], vector[1]); map.print_map(); map.validate_map(); add(&mut map, vector[2], vector[2]); map.print_map(); map.validate_map(); @@ -1321,7 +1329,8 @@ module aptos_std::big_ordered_map { } #[test] fun test_deleting_and_creating_nodes() { - let map = new_with_config(4, 3, true, 2); + let map = new_with_config(4, 3, true); + map.allocate_spare_slots(2); for (i in 0..25) { map.upsert(i, i); @@ -1368,7 +1377,8 @@ module aptos_std::big_ordered_map { #[test] fun test_iterator() { - let map = new_with_config(5, 5, true, 2); + let map = new_with_config(5, 5, true); + map.allocate_spare_slots(2); let data = vector[1, 7, 5, 8, 4, 2, 6, 3, 9, 0]; while (data.length() != 0) { @@ -1392,7 +1402,8 @@ module aptos_std::big_ordered_map { #[test] fun test_find() { - let map = new_with_config(5, 5, true, 2); + let map = new_with_config(5, 5, true); + map.allocate_spare_slots(2); let data = vector[11, 1, 7, 5, 8, 2, 6, 3, 0, 10]; map.add_all(data, data); @@ -1414,7 +1425,8 @@ module aptos_std::big_ordered_map { #[test] fun test_lower_bound() { - let map = new_with_config(5, 5, true, 2); + let map = new_with_config(5, 5, true); + map.allocate_spare_slots(2); let data = vector[11, 1, 7, 5, 8, 2, 6, 3, 12, 10]; map.add_all(data, data); @@ -1444,7 +1456,7 @@ module aptos_std::big_ordered_map { #[test] fun test_contains() { - let map = new_with_config(4, 3, false, 0); + let map = new_with_config(4, 3, false); let data = vector[3, 1, 9, 7, 5]; map.add_all(vector[3, 1, 9, 7, 5], vector[3, 1, 9, 7, 5]); @@ -1459,21 +1471,21 @@ module aptos_std::big_ordered_map { #[test] #[expected_failure(abort_code = 0x1000B, location = Self)] /// EINVALID_CONFIG_PARAMETER fun test_inner_max_degree_too_large() { - let map = new_with_config(4097, 0, false, 0); + let map = new_with_config(4097, 0, false); map.destroy_and_validate(); } #[test] #[expected_failure(abort_code = 0x1000B, location = Self)] /// EINVALID_CONFIG_PARAMETER fun test_inner_max_degree_too_small() { - let map = new_with_config(3, 0, false, 0); + let map = new_with_config(3, 0, false); map.destroy_and_validate(); } #[test] #[expected_failure(abort_code = 0x1000B, location = Self)] /// EINVALID_CONFIG_PARAMETER fun test_leaf_max_degree_too_small() { - let map = new_with_config(0, 2, false, 0); + let map = new_with_config(0, 2, false); map.destroy_and_validate(); } @@ -1497,7 +1509,7 @@ module aptos_std::big_ordered_map { #[test] #[expected_failure(abort_code = 0x10001, location = Self)] /// EKEY_ALREADY_EXISTS fun test_abort_add_existing_value_to_non_leaf() { - let map = new_with_config(4, 4, false, 0); + let map = new_with_config(4, 4, false); map.add_all(vector_range(1, 10), vector_range(1, 10)); map.add(3, 3); map.destroy_and_validate(); @@ -1514,7 +1526,7 @@ module aptos_std::big_ordered_map { #[test] #[expected_failure(abort_code = 0x10002, location = aptos_std::ordered_map)] /// EKEY_NOT_FOUND fun test_abort_remove_missing_value_to_non_leaf() { - let map = new_with_config(4, 4, false, 0); + let map = new_with_config(4, 4, false); map.add_all(vector_range(1, 10), vector_range(1, 10)); map.remove(&4); map.remove(&4); @@ -1524,7 +1536,7 @@ module aptos_std::big_ordered_map { #[test] #[expected_failure(abort_code = 0x10002, location = Self)] /// EKEY_NOT_FOUND fun test_abort_remove_largest_missing_value_to_non_leaf() { - let map = new_with_config(4, 4, false, 0); + let map = new_with_config(4, 4, false); map.add_all(vector_range(1, 10), vector_range(1, 10)); map.remove(&11); map.destroy_and_validate(); @@ -1549,7 +1561,7 @@ module aptos_std::big_ordered_map { #[test] #[expected_failure(abort_code = 0x1000E, location = Self)] /// EBORROW_MUT_REQUIRES_CONSTANT_KV_SIZE fun test_abort_borrow_mut_requires_constant_kv_size() { - let map = new_with_config(0, 0, false, 0); + let map = new_with_config(0, 0, false); map.add(1, vector[1]); map.borrow_mut(&1); map.destroy_and_validate(); @@ -1582,7 +1594,7 @@ module aptos_std::big_ordered_map { #[test] #[expected_failure(abort_code = 0x1000E, location = Self)] /// EBORROW_MUT_REQUIRES_CONSTANT_KV_SIZE fun test_abort_iter_borrow_mut_requires_constant_kv_size() { - let map = new_with_config(0, 0, false, 0); + let map = new_with_config(0, 0, false); map.add(1, vector[1]); map.new_begin_iter().iter_borrow_mut(&mut map); map.destroy_and_validate(); @@ -1614,7 +1626,7 @@ module aptos_std::big_ordered_map { #[test] #[expected_failure(abort_code = 0x1000D, location = Self)] /// EARGUMENT_BYTES_TOO_LARGE fun test_adding_key_too_large() { - let map = new_with_config(0, 0, false, 0); + let map = new_with_config(0, 0, false); map.add(vector[1], 1); map.add(vector_range(0, 57), 1); map.destroy_and_validate(); @@ -1623,7 +1635,7 @@ module aptos_std::big_ordered_map { #[test] #[expected_failure(abort_code = 0x1000D, location = Self)] /// EARGUMENT_BYTES_TOO_LARGE fun test_adding_value_too_large() { - let map = new_with_config(0, 0, false, 0); + let map = new_with_config(0, 0, false); map.add(1, vector[1]); map.add(2, vector_range(0, 107)); map.destroy_and_validate(); @@ -1631,7 +1643,10 @@ module aptos_std::big_ordered_map { #[test_only] inline fun comparison_test(repeats: u64, inner_max_degree: u16, leaf_max_degree: u16, reuse_slots: bool, next_1: ||u64, next_2: ||u64) { - let big_map = new_with_config(inner_max_degree, leaf_max_degree, reuse_slots, if (reuse_slots) {4} else {0}); + let big_map = new_with_config(inner_max_degree, leaf_max_degree, reuse_slots); + if (reuse_slots) { + big_map.allocate_spare_slots(4); + }; let small_map = ordered_map::new(); for (i in 0..repeats) { let is_insert = if (2 * i < repeats) { @@ -1721,7 +1736,10 @@ module aptos_std::big_ordered_map { fun test_large_data_set_helper(inner_max_degree: u16, leaf_max_degree: u16, reuse_slots: bool) { use std::vector; - let map = new_with_config(inner_max_degree, leaf_max_degree, reuse_slots, if (reuse_slots) {4} else {0}); + let map = new_with_config(inner_max_degree, leaf_max_degree, reuse_slots); + if (reuse_slots) { + map.allocate_spare_slots(4); + }; let data = ordered_map::large_dataset(); let shuffled_data = ordered_map::large_dataset_shuffled(); diff --git a/aptos-move/framework/aptos-framework/sources/permissioned_signer.move b/aptos-move/framework/aptos-framework/sources/permissioned_signer.move index 8e752e723138d..2a0bb6ad65c31 100644 --- a/aptos-move/framework/aptos-framework/sources/permissioned_signer.move +++ b/aptos-move/framework/aptos-framework/sources/permissioned_signer.move @@ -240,7 +240,7 @@ module aptos_framework::permissioned_signer { move_to( &create_signer(permissions_storage_addr), // Each key is ~100bytes, the value is 12 bytes. - PermissionStorage::V1 { perms: big_ordered_map::new_with_config(40, 35, false, 0) } + PermissionStorage::V1 { perms: big_ordered_map::new_with_config(40, 35, false) } ); } diff --git a/aptos-move/framework/aptos-stdlib/doc/storage_slots_allocator.md b/aptos-move/framework/aptos-stdlib/doc/storage_slots_allocator.md index c421dfe6cf7d7..27a6ecec349a0 100644 --- a/aptos-move/framework/aptos-stdlib/doc/storage_slots_allocator.md +++ b/aptos-move/framework/aptos-stdlib/doc/storage_slots_allocator.md @@ -23,14 +23,13 @@ for example: - [Enum `Link`](#0x1_storage_slots_allocator_Link) -- [Enum `StorageSlotsAllocatorConfig`](#0x1_storage_slots_allocator_StorageSlotsAllocatorConfig) - [Enum `StorageSlotsAllocator`](#0x1_storage_slots_allocator_StorageSlotsAllocator) - [Struct `ReservedSlot`](#0x1_storage_slots_allocator_ReservedSlot) - [Struct `StoredSlot`](#0x1_storage_slots_allocator_StoredSlot) - [Constants](#@Constants_0) - [Function `new`](#0x1_storage_slots_allocator_new) -- [Function `new_default_config`](#0x1_storage_slots_allocator_new_default_config) -- [Function `new_config`](#0x1_storage_slots_allocator_new_config) +- [Function `allocate_spare_slots`](#0x1_storage_slots_allocator_allocate_spare_slots) +- [Function `get_num_spare_slot_count`](#0x1_storage_slots_allocator_get_num_spare_slot_count) - [Function `add`](#0x1_storage_slots_allocator_add) - [Function `remove`](#0x1_storage_slots_allocator_remove) - [Function `destroy_empty`](#0x1_storage_slots_allocator_destroy_empty) @@ -52,7 +51,8 @@ for example: - [Specification](#@Specification_1) -
use 0x1::option;
+
use 0x1::error;
+use 0x1::option;
 use 0x1::table_with_length;
 
@@ -114,51 +114,6 @@ Data stored in an individual slot - - - - - - - - -## Enum `StorageSlotsAllocatorConfig` - - - -
enum StorageSlotsAllocatorConfig has copy, drop
-
- - - -
-Variants - - -
-V1 - - -
-Fields - - -
-
-should_reuse: bool -
-
- -
-
-num_to_preallocate: u32 -
-
- -
-
- -
@@ -293,6 +248,15 @@ and there is unique owner for each slot. ## Constants + + + + +
const ECANNOT_HAVE_SPARES_WITHOUT_REUSE: u64 = 2;
+
+ + + @@ -335,7 +299,7 @@ and there is unique owner for each slot. -
public fun new<T: store>(config: storage_slots_allocator::StorageSlotsAllocatorConfig): storage_slots_allocator::StorageSlotsAllocator<T>
+
public fun new<T: store>(should_reuse: bool): storage_slots_allocator::StorageSlotsAllocator<T>
 
@@ -344,21 +308,14 @@ and there is unique owner for each slot. Implementation -
public fun new<T: store>(config: StorageSlotsAllocatorConfig): StorageSlotsAllocator<T> {
-    let result = StorageSlotsAllocator::V1 {
+
public fun new<T: store>(should_reuse: bool): StorageSlotsAllocator<T> {
+    StorageSlotsAllocator::V1 {
         slots: option::none(),
         new_slot_index: FIRST_INDEX,
-        should_reuse: config.should_reuse,
+        should_reuse,
         reuse_head_index: NULL_INDEX,
         reuse_spare_count: 0,
-    };
-
-    for (i in 0..config.num_to_preallocate) {
-        let slot_index = result.next_slot_index();
-        result.maybe_push_to_reuse_queue(slot_index);
-    };
-
-    result
+    }
 }
 
@@ -366,13 +323,13 @@ and there is unique owner for each slot.
- + -## Function `new_default_config` +## Function `allocate_spare_slots` -
public fun new_default_config(): storage_slots_allocator::StorageSlotsAllocatorConfig
+
public fun allocate_spare_slots<T: store>(self: &mut storage_slots_allocator::StorageSlotsAllocator<T>, num_to_allocate: u64)
 
@@ -381,11 +338,12 @@ and there is unique owner for each slot. Implementation -
public fun new_default_config(): StorageSlotsAllocatorConfig {
-    StorageSlotsAllocatorConfig::V1 {
-        should_reuse: false,
-        num_to_preallocate: 0,
-    }
+
public fun allocate_spare_slots<T: store>(self: &mut StorageSlotsAllocator<T>, num_to_allocate: u64) {
+    assert!(self.should_reuse, error::invalid_argument(ECANNOT_HAVE_SPARES_WITHOUT_REUSE));
+    for (i in 0..num_to_allocate) {
+        let slot_index = self.next_slot_index();
+        self.maybe_push_to_reuse_queue(slot_index);
+    };
 }
 
@@ -393,13 +351,13 @@ and there is unique owner for each slot. - + -## Function `new_config` +## Function `get_num_spare_slot_count` -
public fun new_config(should_reuse: bool, num_to_preallocate: u32): storage_slots_allocator::StorageSlotsAllocatorConfig
+
public fun get_num_spare_slot_count<T: store>(self: &storage_slots_allocator::StorageSlotsAllocator<T>): u32
 
@@ -408,11 +366,9 @@ and there is unique owner for each slot. Implementation -
public fun new_config(should_reuse: bool, num_to_preallocate: u32): StorageSlotsAllocatorConfig {
-    StorageSlotsAllocatorConfig::V1 {
-        should_reuse,
-        num_to_preallocate,
-    }
+
public fun get_num_spare_slot_count<T: store>(self: &StorageSlotsAllocator<T>): u32 {
+    assert!(self.should_reuse, error::invalid_argument(ECANNOT_HAVE_SPARES_WITHOUT_REUSE));
+    self.reuse_spare_count
 }
 
diff --git a/aptos-move/framework/aptos-stdlib/sources/data_structures/storage_slots_allocator.move b/aptos-move/framework/aptos-stdlib/sources/data_structures/storage_slots_allocator.move index c608052582fa6..e77b409f76351 100644 --- a/aptos-move/framework/aptos-stdlib/sources/data_structures/storage_slots_allocator.move +++ b/aptos-move/framework/aptos-stdlib/sources/data_structures/storage_slots_allocator.move @@ -16,10 +16,12 @@ /// * inlining some nodes /// * having a fee-payer for any storage creation operations module aptos_std::storage_slots_allocator { + use std::error; use aptos_std::table_with_length::{Self, TableWithLength}; use std::option::{Self, Option}; const EINVALID_ARGUMENT: u64 = 1; + const ECANNOT_HAVE_SPARES_WITHOUT_REUSE: u64 = 2; const EINTERNAL_INVARIANT_BROKEN: u64 = 7; const NULL_INDEX: u64 = 0; @@ -38,13 +40,6 @@ module aptos_std::storage_slots_allocator { } } - enum StorageSlotsAllocatorConfig has copy, drop { - V1 { - should_reuse: bool, - num_to_preallocate: u32, - } - } - enum StorageSlotsAllocator has store { // V1 is sequential - any two operations on the StorageSlotsAllocator will conflict. // In general, StorageSlotsAllocator is invoked on less frequent operations, so @@ -72,35 +67,27 @@ module aptos_std::storage_slots_allocator { slot_index: u64, } - public fun new(config: StorageSlotsAllocatorConfig): StorageSlotsAllocator { - let result = StorageSlotsAllocator::V1 { + public fun new(should_reuse: bool): StorageSlotsAllocator { + StorageSlotsAllocator::V1 { slots: option::none(), new_slot_index: FIRST_INDEX, - should_reuse: config.should_reuse, + should_reuse, reuse_head_index: NULL_INDEX, reuse_spare_count: 0, - }; - - for (i in 0..config.num_to_preallocate) { - let slot_index = result.next_slot_index(); - result.maybe_push_to_reuse_queue(slot_index); - }; - - result + } } - public fun new_default_config(): StorageSlotsAllocatorConfig { - StorageSlotsAllocatorConfig::V1 { - should_reuse: false, - num_to_preallocate: 0, - } + public fun allocate_spare_slots(self: &mut StorageSlotsAllocator, num_to_allocate: u64) { + assert!(self.should_reuse, error::invalid_argument(ECANNOT_HAVE_SPARES_WITHOUT_REUSE)); + for (i in 0..num_to_allocate) { + let slot_index = self.next_slot_index(); + self.maybe_push_to_reuse_queue(slot_index); + }; } - public fun new_config(should_reuse: bool, num_to_preallocate: u32): StorageSlotsAllocatorConfig { - StorageSlotsAllocatorConfig::V1 { - should_reuse, - num_to_preallocate, - } + public fun get_num_spare_slot_count(self: &StorageSlotsAllocator): u32 { + assert!(self.should_reuse, error::invalid_argument(ECANNOT_HAVE_SPARES_WITHOUT_REUSE)); + self.reuse_spare_count } public fun add(self: &mut StorageSlotsAllocator, val: T): StoredSlot { diff --git a/crates/transaction-workloads-lib/src/raw_module_data.rs b/crates/transaction-workloads-lib/src/raw_module_data.rs index c849871ad2e5e..414a1482fdf48 100644 --- a/crates/transaction-workloads-lib/src/raw_module_data.rs +++ b/crates/transaction-workloads-lib/src/raw_module_data.rs @@ -276,11 +276,11 @@ pub static MODULES_SIMPLE: Lazy>> = Lazy::new(|| { vec![ pub static PACKAGE_FRAMEWORK_USECASES_METADATA: Lazy> = Lazy::new(|| { vec![ 17, 70, 114, 97, 109, 101, 119, 111, 114, 107, 85, 115, 101, 99, 97, 115, 101, 115, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 64, 55, 50, 67, 54, 52, 50, 51, 50, - 56, 48, 65, 52, 56, 53, 70, 54, 53, 53, 57, 50, 65, 69, 55, 55, 70, 65, - 66, 54, 70, 50, 49, 65, 51, 49, 53, 54, 49, 51, 54, 50, 57, 57, 49, 67, - 56, 69, 52, 53, 51, 67, 55, 56, 51, 68, 70, 49, 70, 70, 50, 69, 51, 49, - 65, 50, 215, 1, 31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 165, 144, 187, 142, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 64, 57, 68, 67, 68, 67, 65, 52, 48, + 51, 55, 68, 53, 53, 56, 70, 54, 52, 69, 68, 48, 56, 69, 50, 53, 57, 66, + 69, 66, 66, 70, 52, 68, 69, 50, 51, 56, 66, 49, 54, 56, 52, 49, 66, 54, + 69, 50, 56, 48, 57, 55, 70, 65, 70, 53, 48, 65, 67, 57, 54, 56, 68, 51, + 67, 55, 215, 1, 31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 165, 144, 187, 142, 194, 64, 12, 69, 251, 249, 10, 107, 182, 38, 236, 15, 108, 193, 238, 138, 150, 6, 170, 8, 33, 51, 49, 33, 100, 176, 163, 241, 240, 144, 16, 255, 78, 44, 30, 130, 22, 100, 23, 215, 246, 189, 167, 112, 217, 97, 104, 177, 166, 185, 99, 220, 18, 252, @@ -515,8 +515,8 @@ pub static MODULE_FRAMEWORK_USECASES_FUNGIBLE_ASSET_EXAMPLE: Lazy> = Laz pub static MODULE_FRAMEWORK_USECASES_MAPS_EXAMPLE: Lazy> = Lazy::new(|| { vec![ 161, 28, 235, 11, 7, 0, 0, 10, 10, 1, 0, 8, 2, 8, 36, 3, 44, 90, - 4, 134, 1, 18, 5, 152, 1, 173, 1, 7, 197, 2, 142, 2, 8, 211, 4, 64, - 16, 147, 5, 31, 10, 178, 5, 27, 12, 205, 5, 191, 7, 0, 0, 1, 4, 1, + 4, 134, 1, 18, 5, 152, 1, 172, 1, 7, 196, 2, 142, 2, 8, 210, 4, 64, + 16, 146, 5, 31, 10, 177, 5, 27, 12, 204, 5, 186, 7, 0, 0, 1, 4, 1, 7, 1, 10, 0, 1, 8, 0, 1, 3, 4, 2, 4, 0, 4, 0, 0, 5, 8, 0, 2, 6, 7, 2, 0, 0, 0, 0, 0, 8, 8, 0, 3, 9, 7, 2, 0, 0, 0, 0, 0, 11, 0, 1, 0, 1, 1, 12, 3, 4, 2, 4, 4, 1, 1, @@ -525,91 +525,91 @@ pub static MODULE_FRAMEWORK_USECASES_MAPS_EXAMPLE: Lazy> = Lazy::new(|| 1, 2, 14, 12, 7, 2, 2, 0, 1, 0, 17, 9, 1, 0, 1, 3, 16, 1, 14, 2, 4, 4, 1, 3, 13, 15, 1, 2, 4, 4, 1, 3, 14, 16, 17, 2, 4, 4, 1, 1, 2, 2, 2, 3, 2, 5, 2, 6, 2, 7, 2, 9, 2, 10, - 2, 11, 2, 5, 6, 12, 3, 3, 13, 13, 0, 2, 3, 3, 4, 13, 13, 1, - 14, 1, 11, 1, 2, 9, 0, 9, 1, 3, 7, 11, 1, 2, 9, 0, 9, 1, - 9, 0, 9, 1, 2, 7, 11, 1, 2, 9, 0, 9, 1, 6, 9, 0, 1, 9, - 1, 10, 11, 1, 2, 3, 3, 3, 3, 3, 1, 3, 1, 3, 3, 3, 3, 6, - 12, 3, 3, 1, 11, 3, 2, 9, 0, 9, 1, 3, 7, 11, 3, 2, 9, 0, - 9, 1, 9, 0, 9, 1, 2, 7, 11, 3, 2, 9, 0, 9, 1, 6, 9, 0, - 10, 11, 3, 2, 3, 3, 3, 3, 3, 1, 3, 1, 3, 3, 3, 1, 11, 5, - 2, 9, 0, 9, 1, 3, 7, 11, 5, 2, 9, 0, 9, 1, 9, 0, 9, 1, - 2, 7, 11, 5, 2, 9, 0, 9, 1, 6, 9, 0, 2, 9, 0, 9, 1, 10, - 11, 5, 2, 3, 3, 3, 3, 3, 1, 3, 1, 3, 3, 3, 12, 109, 97, 112, - 115, 95, 101, 120, 97, 109, 112, 108, 101, 21, 66, 105, 103, 79, 114, 100, 101, 114, - 101, 100, 77, 97, 112, 82, 101, 115, 111, 117, 114, 99, 101, 5, 118, 97, 108, 117, - 101, 13, 66, 105, 103, 79, 114, 100, 101, 114, 101, 100, 77, 97, 112, 15, 98, 105, - 103, 95, 111, 114, 100, 101, 114, 101, 100, 95, 109, 97, 112, 18, 79, 114, 100, 101, - 114, 101, 100, 77, 97, 112, 82, 101, 115, 111, 117, 114, 99, 101, 10, 79, 114, 100, - 101, 114, 101, 100, 77, 97, 112, 11, 111, 114, 100, 101, 114, 101, 100, 95, 109, 97, - 112, 17, 83, 105, 109, 112, 108, 101, 77, 97, 112, 82, 101, 115, 111, 117, 114, 99, - 101, 9, 83, 105, 109, 112, 108, 101, 77, 97, 112, 10, 115, 105, 109, 112, 108, 101, - 95, 109, 97, 112, 31, 116, 101, 115, 116, 95, 97, 100, 100, 95, 114, 101, 109, 111, - 118, 101, 95, 98, 105, 103, 95, 111, 114, 100, 101, 114, 101, 100, 95, 109, 97, 112, - 15, 110, 101, 119, 95, 119, 105, 116, 104, 95, 99, 111, 110, 102, 105, 103, 3, 97, - 100, 100, 6, 114, 101, 109, 111, 118, 101, 27, 116, 101, 115, 116, 95, 97, 100, 100, - 95, 114, 101, 109, 111, 118, 101, 95, 111, 114, 100, 101, 114, 101, 100, 95, 109, 97, - 112, 3, 110, 101, 119, 26, 116, 101, 115, 116, 95, 97, 100, 100, 95, 114, 101, 109, - 111, 118, 101, 95, 115, 105, 109, 112, 108, 101, 95, 109, 97, 112, 0, 0, 0, 0, + 2, 11, 2, 5, 6, 12, 3, 3, 13, 13, 0, 2, 3, 3, 3, 13, 13, 1, + 1, 11, 1, 2, 9, 0, 9, 1, 3, 7, 11, 1, 2, 9, 0, 9, 1, 9, + 0, 9, 1, 2, 7, 11, 1, 2, 9, 0, 9, 1, 6, 9, 0, 1, 9, 1, + 10, 11, 1, 2, 3, 3, 3, 3, 3, 1, 3, 1, 3, 3, 3, 3, 6, 12, + 3, 3, 1, 11, 3, 2, 9, 0, 9, 1, 3, 7, 11, 3, 2, 9, 0, 9, + 1, 9, 0, 9, 1, 2, 7, 11, 3, 2, 9, 0, 9, 1, 6, 9, 0, 10, + 11, 3, 2, 3, 3, 3, 3, 3, 1, 3, 1, 3, 3, 3, 1, 11, 5, 2, + 9, 0, 9, 1, 3, 7, 11, 5, 2, 9, 0, 9, 1, 9, 0, 9, 1, 2, + 7, 11, 5, 2, 9, 0, 9, 1, 6, 9, 0, 2, 9, 0, 9, 1, 10, 11, + 5, 2, 3, 3, 3, 3, 3, 1, 3, 1, 3, 3, 3, 12, 109, 97, 112, 115, + 95, 101, 120, 97, 109, 112, 108, 101, 21, 66, 105, 103, 79, 114, 100, 101, 114, 101, + 100, 77, 97, 112, 82, 101, 115, 111, 117, 114, 99, 101, 5, 118, 97, 108, 117, 101, + 13, 66, 105, 103, 79, 114, 100, 101, 114, 101, 100, 77, 97, 112, 15, 98, 105, 103, + 95, 111, 114, 100, 101, 114, 101, 100, 95, 109, 97, 112, 18, 79, 114, 100, 101, 114, + 101, 100, 77, 97, 112, 82, 101, 115, 111, 117, 114, 99, 101, 10, 79, 114, 100, 101, + 114, 101, 100, 77, 97, 112, 11, 111, 114, 100, 101, 114, 101, 100, 95, 109, 97, 112, + 17, 83, 105, 109, 112, 108, 101, 77, 97, 112, 82, 101, 115, 111, 117, 114, 99, 101, + 9, 83, 105, 109, 112, 108, 101, 77, 97, 112, 10, 115, 105, 109, 112, 108, 101, 95, + 109, 97, 112, 31, 116, 101, 115, 116, 95, 97, 100, 100, 95, 114, 101, 109, 111, 118, + 101, 95, 98, 105, 103, 95, 111, 114, 100, 101, 114, 101, 100, 95, 109, 97, 112, 15, + 110, 101, 119, 95, 119, 105, 116, 104, 95, 99, 111, 110, 102, 105, 103, 3, 97, 100, + 100, 6, 114, 101, 109, 111, 118, 101, 27, 116, 101, 115, 116, 95, 97, 100, 100, 95, + 114, 101, 109, 111, 118, 101, 95, 111, 114, 100, 101, 114, 101, 100, 95, 109, 97, 112, + 3, 110, 101, 119, 26, 116, 101, 115, 116, 95, 97, 100, 100, 95, 114, 101, 109, 111, + 118, 101, 95, 115, 105, 109, 112, 108, 101, 95, 109, 97, 112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 171, 205, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 171, 205, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 20, 99, 111, 109, 112, 105, 108, 97, 116, 105, 111, 110, - 95, 109, 101, 116, 97, 100, 97, 116, 97, 9, 0, 3, 50, 46, 48, 3, 50, 46, - 49, 0, 2, 1, 2, 11, 1, 2, 3, 3, 2, 2, 1, 2, 11, 3, 2, 3, - 3, 4, 2, 1, 2, 11, 5, 2, 3, 3, 0, 1, 4, 0, 8, 116, 11, 3, - 11, 4, 9, 73, 0, 0, 0, 0, 56, 0, 12, 5, 6, 210, 4, 0, 0, 0, - 0, 0, 0, 12, 6, 6, 210, 4, 0, 0, 0, 0, 0, 0, 12, 7, 6, 0, - 0, 0, 0, 0, 0, 0, 0, 12, 8, 9, 12, 9, 5, 16, 5, 47, 10, 9, - 4, 113, 11, 8, 6, 1, 0, 0, 0, 0, 0, 0, 0, 22, 12, 8, 10, 8, - 10, 1, 35, 3, 27, 5, 47, 10, 6, 12, 10, 13, 5, 10, 10, 11, 10, 56, - 1, 11, 6, 6, 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, 6, 10, 6, 6, - 64, 66, 15, 0, 0, 0, 0, 0, 36, 3, 42, 5, 14, 11, 6, 6, 64, 66, - 15, 0, 0, 0, 0, 0, 23, 12, 6, 5, 14, 6, 0, 0, 0, 0, 0, 0, - 0, 0, 12, 10, 9, 12, 11, 11, 2, 12, 12, 5, 55, 5, 105, 10, 11, 4, - 110, 11, 10, 6, 1, 0, 0, 0, 0, 0, 0, 0, 22, 12, 10, 10, 10, 10, - 12, 35, 3, 66, 5, 105, 10, 6, 12, 13, 13, 5, 10, 13, 11, 13, 56, 1, - 10, 7, 12, 14, 13, 5, 14, 14, 56, 2, 1, 11, 6, 6, 177, 30, 4, 0, - 0, 0, 0, 0, 22, 12, 6, 10, 6, 6, 64, 66, 15, 0, 0, 0, 0, 0, - 36, 3, 87, 5, 91, 11, 6, 6, 64, 66, 15, 0, 0, 0, 0, 0, 23, 12, - 6, 11, 7, 6, 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, 7, 10, 7, 6, - 64, 66, 15, 0, 0, 0, 0, 0, 36, 3, 100, 5, 53, 11, 7, 6, 64, 66, - 15, 0, 0, 0, 0, 0, 23, 12, 7, 5, 53, 11, 0, 11, 5, 18, 0, 45, - 0, 2, 8, 12, 11, 5, 61, 8, 12, 9, 5, 22, 4, 1, 4, 0, 13, 112, - 56, 3, 12, 3, 6, 210, 4, 0, 0, 0, 0, 0, 0, 12, 4, 6, 210, 4, - 0, 0, 0, 0, 0, 0, 12, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 12, - 6, 9, 12, 7, 5, 12, 5, 43, 10, 7, 4, 109, 11, 6, 6, 1, 0, 0, - 0, 0, 0, 0, 0, 22, 12, 6, 10, 6, 10, 1, 35, 3, 23, 5, 43, 10, - 4, 12, 8, 13, 3, 10, 8, 11, 8, 56, 4, 11, 4, 6, 177, 30, 4, 0, - 0, 0, 0, 0, 22, 12, 4, 10, 4, 6, 64, 66, 15, 0, 0, 0, 0, 0, - 36, 3, 38, 5, 10, 11, 4, 6, 64, 66, 15, 0, 0, 0, 0, 0, 23, 12, - 4, 5, 10, 6, 0, 0, 0, 0, 0, 0, 0, 0, 12, 8, 9, 12, 9, 11, - 2, 12, 10, 5, 51, 5, 101, 10, 9, 4, 106, 11, 8, 6, 1, 0, 0, 0, - 0, 0, 0, 0, 22, 12, 8, 10, 8, 10, 10, 35, 3, 62, 5, 101, 10, 4, - 12, 11, 13, 3, 10, 11, 11, 11, 56, 4, 10, 5, 12, 12, 13, 3, 14, 12, - 56, 5, 1, 11, 4, 6, 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, 4, 10, - 4, 6, 64, 66, 15, 0, 0, 0, 0, 0, 36, 3, 83, 5, 87, 11, 4, 6, - 64, 66, 15, 0, 0, 0, 0, 0, 23, 12, 4, 11, 5, 6, 177, 30, 4, 0, - 0, 0, 0, 0, 22, 12, 5, 10, 5, 6, 64, 66, 15, 0, 0, 0, 0, 0, - 36, 3, 96, 5, 49, 11, 5, 6, 64, 66, 15, 0, 0, 0, 0, 0, 23, 12, - 5, 5, 49, 11, 0, 11, 3, 18, 1, 45, 1, 2, 8, 12, 9, 5, 57, 8, - 12, 7, 5, 18, 8, 1, 4, 0, 18, 113, 56, 6, 12, 3, 6, 210, 4, 0, - 0, 0, 0, 0, 0, 12, 4, 6, 210, 4, 0, 0, 0, 0, 0, 0, 12, 5, - 6, 0, 0, 0, 0, 0, 0, 0, 0, 12, 6, 9, 12, 7, 5, 12, 5, 43, - 10, 7, 4, 110, 11, 6, 6, 1, 0, 0, 0, 0, 0, 0, 0, 22, 12, 6, - 10, 6, 10, 1, 35, 3, 23, 5, 43, 10, 4, 12, 8, 13, 3, 10, 8, 11, - 8, 56, 7, 11, 4, 6, 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, 4, 10, - 4, 6, 64, 66, 15, 0, 0, 0, 0, 0, 36, 3, 38, 5, 10, 11, 4, 6, - 64, 66, 15, 0, 0, 0, 0, 0, 23, 12, 4, 5, 10, 6, 0, 0, 0, 0, - 0, 0, 0, 0, 12, 8, 9, 12, 9, 11, 2, 12, 10, 5, 51, 5, 102, 10, - 9, 4, 107, 11, 8, 6, 1, 0, 0, 0, 0, 0, 0, 0, 22, 12, 8, 10, - 8, 10, 10, 35, 3, 62, 5, 102, 10, 4, 12, 11, 13, 3, 10, 11, 11, 11, - 56, 7, 10, 5, 12, 12, 13, 3, 14, 12, 56, 8, 1, 1, 11, 4, 6, 177, - 30, 4, 0, 0, 0, 0, 0, 22, 12, 4, 10, 4, 6, 64, 66, 15, 0, 0, - 0, 0, 0, 36, 3, 84, 5, 88, 11, 4, 6, 64, 66, 15, 0, 0, 0, 0, - 0, 23, 12, 4, 11, 5, 6, 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, 5, - 10, 5, 6, 64, 66, 15, 0, 0, 0, 0, 0, 36, 3, 97, 5, 49, 11, 5, - 6, 64, 66, 15, 0, 0, 0, 0, 0, 23, 12, 5, 5, 49, 11, 0, 11, 3, - 18, 2, 45, 2, 2, 8, 12, 9, 5, 57, 8, 12, 7, 5, 18, 0, + 0, 0, 0, 0, 1, 20, 99, 111, 109, 112, 105, 108, 97, 116, 105, 111, 110, 95, + 109, 101, 116, 97, 100, 97, 116, 97, 9, 0, 3, 50, 46, 48, 3, 50, 46, 49, + 0, 2, 1, 2, 11, 1, 2, 3, 3, 2, 2, 1, 2, 11, 3, 2, 3, 3, + 4, 2, 1, 2, 11, 5, 2, 3, 3, 0, 1, 4, 0, 8, 115, 11, 3, 11, + 4, 9, 56, 0, 12, 5, 6, 210, 4, 0, 0, 0, 0, 0, 0, 12, 6, 6, + 210, 4, 0, 0, 0, 0, 0, 0, 12, 7, 6, 0, 0, 0, 0, 0, 0, 0, + 0, 12, 8, 9, 12, 9, 5, 15, 5, 46, 10, 9, 4, 112, 11, 8, 6, 1, + 0, 0, 0, 0, 0, 0, 0, 22, 12, 8, 10, 8, 10, 1, 35, 3, 26, 5, + 46, 10, 6, 12, 10, 13, 5, 10, 10, 11, 10, 56, 1, 11, 6, 6, 177, 30, + 4, 0, 0, 0, 0, 0, 22, 12, 6, 10, 6, 6, 64, 66, 15, 0, 0, 0, + 0, 0, 36, 3, 41, 5, 13, 11, 6, 6, 64, 66, 15, 0, 0, 0, 0, 0, + 23, 12, 6, 5, 13, 6, 0, 0, 0, 0, 0, 0, 0, 0, 12, 10, 9, 12, + 11, 11, 2, 12, 12, 5, 54, 5, 104, 10, 11, 4, 109, 11, 10, 6, 1, 0, + 0, 0, 0, 0, 0, 0, 22, 12, 10, 10, 10, 10, 12, 35, 3, 65, 5, 104, + 10, 6, 12, 13, 13, 5, 10, 13, 11, 13, 56, 1, 10, 7, 12, 14, 13, 5, + 14, 14, 56, 2, 1, 11, 6, 6, 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, + 6, 10, 6, 6, 64, 66, 15, 0, 0, 0, 0, 0, 36, 3, 86, 5, 90, 11, + 6, 6, 64, 66, 15, 0, 0, 0, 0, 0, 23, 12, 6, 11, 7, 6, 177, 30, + 4, 0, 0, 0, 0, 0, 22, 12, 7, 10, 7, 6, 64, 66, 15, 0, 0, 0, + 0, 0, 36, 3, 99, 5, 52, 11, 7, 6, 64, 66, 15, 0, 0, 0, 0, 0, + 23, 12, 7, 5, 52, 11, 0, 11, 5, 18, 0, 45, 0, 2, 8, 12, 11, 5, + 60, 8, 12, 9, 5, 21, 4, 1, 4, 0, 13, 112, 56, 3, 12, 3, 6, 210, + 4, 0, 0, 0, 0, 0, 0, 12, 4, 6, 210, 4, 0, 0, 0, 0, 0, 0, + 12, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 12, 6, 9, 12, 7, 5, 12, + 5, 43, 10, 7, 4, 109, 11, 6, 6, 1, 0, 0, 0, 0, 0, 0, 0, 22, + 12, 6, 10, 6, 10, 1, 35, 3, 23, 5, 43, 10, 4, 12, 8, 13, 3, 10, + 8, 11, 8, 56, 4, 11, 4, 6, 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, + 4, 10, 4, 6, 64, 66, 15, 0, 0, 0, 0, 0, 36, 3, 38, 5, 10, 11, + 4, 6, 64, 66, 15, 0, 0, 0, 0, 0, 23, 12, 4, 5, 10, 6, 0, 0, + 0, 0, 0, 0, 0, 0, 12, 8, 9, 12, 9, 11, 2, 12, 10, 5, 51, 5, + 101, 10, 9, 4, 106, 11, 8, 6, 1, 0, 0, 0, 0, 0, 0, 0, 22, 12, + 8, 10, 8, 10, 10, 35, 3, 62, 5, 101, 10, 4, 12, 11, 13, 3, 10, 11, + 11, 11, 56, 4, 10, 5, 12, 12, 13, 3, 14, 12, 56, 5, 1, 11, 4, 6, + 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, 4, 10, 4, 6, 64, 66, 15, 0, + 0, 0, 0, 0, 36, 3, 83, 5, 87, 11, 4, 6, 64, 66, 15, 0, 0, 0, + 0, 0, 23, 12, 4, 11, 5, 6, 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, + 5, 10, 5, 6, 64, 66, 15, 0, 0, 0, 0, 0, 36, 3, 96, 5, 49, 11, + 5, 6, 64, 66, 15, 0, 0, 0, 0, 0, 23, 12, 5, 5, 49, 11, 0, 11, + 3, 18, 1, 45, 1, 2, 8, 12, 9, 5, 57, 8, 12, 7, 5, 18, 8, 1, + 4, 0, 18, 113, 56, 6, 12, 3, 6, 210, 4, 0, 0, 0, 0, 0, 0, 12, + 4, 6, 210, 4, 0, 0, 0, 0, 0, 0, 12, 5, 6, 0, 0, 0, 0, 0, + 0, 0, 0, 12, 6, 9, 12, 7, 5, 12, 5, 43, 10, 7, 4, 110, 11, 6, + 6, 1, 0, 0, 0, 0, 0, 0, 0, 22, 12, 6, 10, 6, 10, 1, 35, 3, + 23, 5, 43, 10, 4, 12, 8, 13, 3, 10, 8, 11, 8, 56, 7, 11, 4, 6, + 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, 4, 10, 4, 6, 64, 66, 15, 0, + 0, 0, 0, 0, 36, 3, 38, 5, 10, 11, 4, 6, 64, 66, 15, 0, 0, 0, + 0, 0, 23, 12, 4, 5, 10, 6, 0, 0, 0, 0, 0, 0, 0, 0, 12, 8, + 9, 12, 9, 11, 2, 12, 10, 5, 51, 5, 102, 10, 9, 4, 107, 11, 8, 6, + 1, 0, 0, 0, 0, 0, 0, 0, 22, 12, 8, 10, 8, 10, 10, 35, 3, 62, + 5, 102, 10, 4, 12, 11, 13, 3, 10, 11, 11, 11, 56, 7, 10, 5, 12, 12, + 13, 3, 14, 12, 56, 8, 1, 1, 11, 4, 6, 177, 30, 4, 0, 0, 0, 0, + 0, 22, 12, 4, 10, 4, 6, 64, 66, 15, 0, 0, 0, 0, 0, 36, 3, 84, + 5, 88, 11, 4, 6, 64, 66, 15, 0, 0, 0, 0, 0, 23, 12, 4, 11, 5, + 6, 177, 30, 4, 0, 0, 0, 0, 0, 22, 12, 5, 10, 5, 6, 64, 66, 15, + 0, 0, 0, 0, 0, 36, 3, 97, 5, 49, 11, 5, 6, 64, 66, 15, 0, 0, + 0, 0, 0, 23, 12, 5, 5, 49, 11, 0, 11, 3, 18, 2, 45, 2, 2, 8, + 12, 9, 5, 57, 8, 12, 7, 5, 18, 0, ] }); diff --git a/testsuite/module-publish/src/packages/framework_usecases/sources/maps_example.move b/testsuite/module-publish/src/packages/framework_usecases/sources/maps_example.move index 698060c4fa8a4..cfbbadfa7147b 100644 --- a/testsuite/module-publish/src/packages/framework_usecases/sources/maps_example.move +++ b/testsuite/module-publish/src/packages/framework_usecases/sources/maps_example.move @@ -69,7 +69,7 @@ module 0xABCD::maps_example { } public entry fun test_add_remove_big_ordered_map(sender: &signer, len: u64, repeats: u64, inner_max_degree: u16, leaf_max_degree: u16) { - let map = big_ordered_map::new_with_config(inner_max_degree, leaf_max_degree, false, 0); + let map = big_ordered_map::new_with_config(inner_max_degree, leaf_max_degree, false); do_test_add_remove( len, repeats,