From 37b5ea497ce5e775cbebb037c04005febf2532f2 Mon Sep 17 00:00:00 2001 From: fominok Date: Fri, 4 Oct 2024 13:16:49 +0200 Subject: [PATCH] chore: bump GroveDB dependency (#2196) Co-authored-by: Quantum Explorer --- Cargo.lock | 37 +++--- packages/rs-drive/Cargo.toml | 12 +- .../mod.rs | 107 +++++++++--------- .../v0/mod.rs | 60 +++++----- packages/rs-platform-version/Cargo.toml | 2 +- 5 files changed, 109 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6a05f5b530..819f2b9922 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2064,9 +2064,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "grovedb" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77097f0a4cc70c4a69fa400f633c5f18739e446eaed05269a3d76e17fa4d33d2" +checksum = "7d91e8f87926c834c7338d0c69a48816c043e0cddf0062a8a567483db2fb1e24" dependencies = [ "axum 0.7.5", "bincode", @@ -2092,15 +2092,16 @@ dependencies = [ "tempfile", "thiserror", "tokio", + "tokio-util", "tower-http", "zip-extensions", ] [[package]] name = "grovedb-costs" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0487d63a68621b910567a911b3708a8246501ae1912fa2f1920474dcb28a207" +checksum = "360f7c8d3b20beafcbf3cde8754bbcfd201ae2a30ec7594a4b9678fd2fa3c7a8" dependencies = [ "integer-encoding", "intmap", @@ -2109,9 +2110,9 @@ dependencies = [ [[package]] name = "grovedb-epoch-based-storage-flags" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53eb4b99b056e34bcceef2d604c883aee40daa688ceb7ec558456e10bef27c64" +checksum = "acec1b6962d99d7b079c0fd1532cd3a2c83a3d659ffd9fcf02edda4599334bb4" dependencies = [ "grovedb-costs", "hex", @@ -2122,9 +2123,9 @@ dependencies = [ [[package]] name = "grovedb-merk" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daedc296cac3093d244cbda0a11a5ef378bd4f747fcbe45b6cbed040c78cfb36" +checksum = "72057865f239fdd24f92eaa8668acc0d618da168f330546577a62eda1701210e" dependencies = [ "bincode", "blake3", @@ -2148,15 +2149,15 @@ dependencies = [ [[package]] name = "grovedb-path" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3552accddbfe6e586853f50a102d665efc0449a63504e5e2113389be924f98c" +checksum = "5d96cc6106e5ca88e548d66f130b877b664da78be226dfdba555fc210f8508f4" [[package]] name = "grovedb-storage" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868d74460c6205563e7bc72549f3fa057ed8bd0f83d96e04b2286ca0a216149" +checksum = "e1c9b59bc9fa7123b8485f87f88a886dd109e7aff5f34a29a3812cb64eb897ff" dependencies = [ "blake3", "grovedb-costs", @@ -2174,9 +2175,9 @@ dependencies = [ [[package]] name = "grovedb-version" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d62bd20c621681dfd8aa6ca128702de775c67560c1fe412f380c5278d5c48ba" +checksum = "f4be0c1a1ef97068fe93212e7b6f349e0b44a9fc90063c8c28e110cfb8c2fcb2" dependencies = [ "thiserror", "versioned-feature-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2184,9 +2185,9 @@ dependencies = [ [[package]] name = "grovedb-visualize" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6cd92c3a11055b1d841d071f801517b98575f9704f5a757a016fe83d35a37b8" +checksum = "5865f4335eb99644512a7d80d6b1698ba1099a8268fdfd3ffb1a3a32dcb4af28" dependencies = [ "hex", "itertools 0.12.1", @@ -2194,9 +2195,9 @@ dependencies = [ [[package]] name = "grovedbg-types" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003e5066965932dbb617e5966df5f73a066eb721579840b30ddd46bf04311fc8" +checksum = "921b9a29facf9d3f0de667cd1da083a34695ede9e7bfacd74bb5bd29f8f7c178" dependencies = [ "serde", "serde_with 3.9.0", diff --git a/packages/rs-drive/Cargo.toml b/packages/rs-drive/Cargo.toml index 50915b06e2..94938455c5 100644 --- a/packages/rs-drive/Cargo.toml +++ b/packages/rs-drive/Cargo.toml @@ -51,12 +51,12 @@ enum-map = { version = "2.0.3", optional = true } intmap = { version = "2.0.0", features = ["serde"], optional = true } chrono = { version = "0.4.35", optional = true } itertools = { version = "0.11.0", optional = true } -grovedb = { version = "2.0.3", optional = true, default-features = false } -grovedb-costs = { version = "2.0.3", optional = true } -grovedb-path = { version = "2.0.3" } -grovedb-storage = { version = "2.0.3", optional = true } -grovedb-version = { version = "2.0.3"} -grovedb-epoch-based-storage-flags = { version = "2.0.3"} +grovedb = { version = "2.1.0", optional = true, default-features = false } +grovedb-costs = { version = "2.1.0", optional = true } +grovedb-path = { version = "2.1.0" } +grovedb-storage = { version = "2.1.0", optional = true } +grovedb-version = { version = "2.1.0"} +grovedb-epoch-based-storage-flags = { version = "2.1.0"} [dev-dependencies] criterion = "0.3.5" diff --git a/packages/rs-drive/src/util/grove_operations/grove_insert_if_not_exists_return_existing_element/mod.rs b/packages/rs-drive/src/util/grove_operations/grove_insert_if_not_exists_return_existing_element/mod.rs index 8c5455a038..6727b72014 100644 --- a/packages/rs-drive/src/util/grove_operations/grove_insert_if_not_exists_return_existing_element/mod.rs +++ b/packages/rs-drive/src/util/grove_operations/grove_insert_if_not_exists_return_existing_element/mod.rs @@ -1,54 +1,53 @@ -//todo: uncomment once version 2.1 of GroveDB is released. -// mod v0; -// -// use crate::drive::Drive; -// use crate::error::drive::DriveError; -// use crate::error::Error; -// use crate::fees::op::LowLevelDriveOperation; -// use dpp::version::drive_versions::DriveVersion; -// use grovedb::{Element, TransactionArg}; -// use grovedb_path::SubtreePath; -// -// impl Drive { -// /// Inserts an element into groveDB only if the specified path and key do not exist. -// /// This operation costs are then stored in `drive_operations`. -// /// -// /// # Parameters -// /// * `path`: The groveDB hierarchical authenticated structure path where the new element is to be inserted. -// /// * `key`: The key where the new element should be inserted in the subtree. -// /// * `element`: The element to be inserted. -// /// * `transaction`: The groveDB transaction associated with this operation. -// /// * `drive_operations`: A vector to collect the costs of operations for later computation. In this case, -// /// it collects the cost of this insert operation if the path and key did not exist. -// /// * `platform_version`: The platform version to select the correct function version to run. -// /// -// /// # Returns -// /// * `Ok(true)` if the insertion was successful. -// /// * `Ok(false)` if the path and key already existed. -// /// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions. -// pub fn grove_insert_if_not_exists_return_existing_element>( -// &self, -// path: SubtreePath<'_, B>, -// key: &[u8], -// element: Element, -// transaction: TransactionArg, -// drive_operations: Option<&mut Vec>, -// drive_version: &DriveVersion, -// ) -> Result, Error> { -// match drive_version.grove_methods.basic.grove_insert_if_not_exists { -// 0 => self.grove_insert_if_not_exists_return_existing_element_v0( -// path, -// key, -// element, -// transaction, -// drive_operations, -// drive_version, -// ), -// version => Err(Error::Drive(DriveError::UnknownVersionMismatch { -// method: "grove_insert_if_not_exists_return_existing_element".to_string(), -// known_versions: vec![0], -// received: version, -// })), -// } -// } -// } +mod v0; + +use crate::drive::Drive; +use crate::error::drive::DriveError; +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; +use dpp::version::drive_versions::DriveVersion; +use grovedb::{Element, TransactionArg}; +use grovedb_path::SubtreePath; + +impl Drive { + /// Inserts an element into groveDB only if the specified path and key do not exist. + /// This operation costs are then stored in `drive_operations`. + /// + /// # Parameters + /// * `path`: The groveDB hierarchical authenticated structure path where the new element is to be inserted. + /// * `key`: The key where the new element should be inserted in the subtree. + /// * `element`: The element to be inserted. + /// * `transaction`: The groveDB transaction associated with this operation. + /// * `drive_operations`: A vector to collect the costs of operations for later computation. In this case, + /// it collects the cost of this insert operation if the path and key did not exist. + /// * `platform_version`: The platform version to select the correct function version to run. + /// + /// # Returns + /// * `Ok(true)` if the insertion was successful. + /// * `Ok(false)` if the path and key already existed. + /// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions. + pub fn grove_insert_if_not_exists_return_existing_element>( + &self, + path: SubtreePath<'_, B>, + key: &[u8], + element: Element, + transaction: TransactionArg, + drive_operations: Option<&mut Vec>, + drive_version: &DriveVersion, + ) -> Result, Error> { + match drive_version.grove_methods.basic.grove_insert_if_not_exists { + 0 => self.grove_insert_if_not_exists_return_existing_element_v0( + path, + key, + element, + transaction, + drive_operations, + drive_version, + ), + version => Err(Error::Drive(DriveError::UnknownVersionMismatch { + method: "grove_insert_if_not_exists_return_existing_element".to_string(), + known_versions: vec![0], + received: version, + })), + } + } +} diff --git a/packages/rs-drive/src/util/grove_operations/grove_insert_if_not_exists_return_existing_element/v0/mod.rs b/packages/rs-drive/src/util/grove_operations/grove_insert_if_not_exists_return_existing_element/v0/mod.rs index 5030cd6cc5..69b55ba2d7 100644 --- a/packages/rs-drive/src/util/grove_operations/grove_insert_if_not_exists_return_existing_element/v0/mod.rs +++ b/packages/rs-drive/src/util/grove_operations/grove_insert_if_not_exists_return_existing_element/v0/mod.rs @@ -1,30 +1,30 @@ -// use crate::drive::Drive; -// use crate::error::Error; -// use crate::fees::op::LowLevelDriveOperation; -// use crate::util::grove_operations::push_drive_operation_result_optional; -// use grovedb::{Element, TransactionArg}; -// use grovedb_path::SubtreePath; -// use platform_version::version::drive_versions::DriveVersion; -// -// impl Drive { -// /// Pushes the `OperationCost` of inserting an element in groveDB where the path key does not yet exist -// /// to `drive_operations`. -// pub(crate) fn grove_insert_if_not_exists_return_existing_element_v0>( -// &self, -// path: SubtreePath<'_, B>, -// key: &[u8], -// element: Element, -// transaction: TransactionArg, -// drive_operations: Option<&mut Vec>, -// drive_version: &DriveVersion, -// ) -> Result { -// let cost_context = self.grove.insert_if_not_exists_return_existing_element( -// path, -// key, -// element, -// transaction, -// &drive_version.grove_version, -// ); -// push_drive_operation_result_optional(cost_context, drive_operations) -// } -// } +use crate::drive::Drive; +use crate::error::Error; +use crate::fees::op::LowLevelDriveOperation; +use crate::util::grove_operations::push_drive_operation_result_optional; +use grovedb::{Element, TransactionArg}; +use grovedb_path::SubtreePath; +use platform_version::version::drive_versions::DriveVersion; + +impl Drive { + /// Pushes the `OperationCost` of inserting an element in groveDB where the path key does not yet exist + /// to `drive_operations`. + pub(crate) fn grove_insert_if_not_exists_return_existing_element_v0>( + &self, + path: SubtreePath<'_, B>, + key: &[u8], + element: Element, + transaction: TransactionArg, + drive_operations: Option<&mut Vec>, + drive_version: &DriveVersion, + ) -> Result, Error> { + let cost_context = self.grove.insert_if_not_exists_return_existing_element( + path, + key, + element, + transaction, + &drive_version.grove_version, + ); + push_drive_operation_result_optional(cost_context, drive_operations) + } +} diff --git a/packages/rs-platform-version/Cargo.toml b/packages/rs-platform-version/Cargo.toml index 01b8e5380a..546704554d 100644 --- a/packages/rs-platform-version/Cargo.toml +++ b/packages/rs-platform-version/Cargo.toml @@ -11,7 +11,7 @@ license = "MIT" thiserror = { version = "1.0.63" } bincode = { version = "2.0.0-rc.3"} versioned-feature-core = { git = "https://github.com/dashpay/versioned-feature-core", version = "1.0.0" } -grovedb-version = { version = "2.0.3"} +grovedb-version = { version = "2.1.0"} once_cell = "1.19.0" [features]