Skip to content

Commit

Permalink
support for new grovedb
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Jan 10, 2025
1 parent 779114d commit ad720bf
Show file tree
Hide file tree
Showing 121 changed files with 408 additions and 407 deletions.
27 changes: 9 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ mod tests {
false,
false,
false,
false,
&mut vec![],
PlatformVersion::latest(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ impl DocumentsBatchTransitionMethodsV1 for BatchTransition {
}
}

#[cfg(feature = "state-transition-signing")]
fn new_token_destroy_frozen_funds_transition<S: Signer>(
token_id: Identifier,
owner_id: Identifier,
Expand Down Expand Up @@ -798,6 +799,7 @@ impl DocumentsBatchTransitionMethodsV1 for BatchTransition {
}
}

#[cfg(feature = "state-transition-signing")]
fn new_token_emergency_action_transition<S: Signer>(
token_id: Identifier,
owner_id: Identifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ impl DocumentsBatchTransitionMethodsV1 for BatchTransitionV1 {
Ok(state_transition)
}

#[cfg(feature = "state-transition-signing")]
fn new_token_destroy_frozen_funds_transition<S: Signer>(
token_id: Identifier,
owner_id: Identifier,
Expand Down Expand Up @@ -820,6 +821,7 @@ impl DocumentsBatchTransitionMethodsV1 for BatchTransitionV1 {
Ok(state_transition)
}

#[cfg(feature = "state-transition-signing")]
fn new_token_emergency_action_transition<S: Signer>(
token_id: Identifier,
owner_id: Identifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use dpp::block::block_info::BlockInfo;

use dpp::version::PlatformVersion;
use drive::drive::identity::withdrawals::paths::get_withdrawal_transactions_sum_tree_path_vec;
use drive::grovedb::{PathQuery, QueryItem, Transaction};
use drive::grovedb::{MaybeTree, PathQuery, QueryItem, Transaction};
use drive::util::grove_operations::BatchDeleteApplyType;

impl<C> Platform<C>
Expand Down Expand Up @@ -49,7 +49,7 @@ where
true,
// we know that we are not deleting a subtree
BatchDeleteApplyType::StatefulBatchDelete {
is_known_to_be_subtree_with_sum: Some((false, false)),
is_known_to_be_subtree_with_sum: Some(MaybeTree::NotTree),
},
Some(transaction),
&mut batch_operations,
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-drive-abci/tests/strategy_tests/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ impl NetworkStrategy {
contract,
token_id,
token_pos,
action: TokenEvent::Mint(amount, note),
action: TokenEvent::Mint(amount, recipient, note),
}) if current_identities.len() > 1 => {
let random_index = rng.gen_range(0..current_identities.len());
let random_identity_id = current_identities[random_index].id();
Expand Down
4 changes: 2 additions & 2 deletions packages/rs-drive-abci/tests/strategy_tests/token_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod tests {
contract: contract.clone(),
token_id,
token_pos: 0,
action: TokenEvent::Mint(1000, None),
action: TokenEvent::Mint(1000, identity2.id(), None),
};

let strategy = NetworkStrategy {
Expand Down Expand Up @@ -206,7 +206,7 @@ mod tests {
contract: contract.clone(),
token_id,
token_pos: 0,
action: TokenEvent::Mint(1000, None),
action: TokenEvent::Mint(1000, identity2.id(), None),
};

let strategy = NetworkStrategy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use dpp::version::PlatformVersion;
use drive::drive::identity::key::fetch::IdentityKeysRequest;
use drive::drive::Drive;
use drive::query::{SingleDocumentDriveQuery, SingleDocumentDriveQueryContestedStatus};
use drive::state_transition_action::batch::batched_transition::document_transition::{
BatchedTransitionAction, DocumentTransitionAction,
};
use drive::state_transition_action::batch::batched_transition::document_transition::DocumentTransitionAction;
use drive::state_transition_action::StateTransitionAction;
use drive_abci::execution::validation::state_transition::transformer::StateTransitionActionTransformerV0;
use drive_abci::platform_types::platform::PlatformRef;
Expand All @@ -29,6 +27,7 @@ use dpp::voting::votes::Vote;
use drive::drive::votes::resolved::vote_polls::ResolvedVotePoll;
use drive::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0;
use drive::drive::votes::resolved::votes::ResolvedVote;
use drive::state_transition_action::batch::batched_transition::BatchedTransitionAction;
use drive::state_transition_action::batch::batched_transition::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0;
use drive::state_transition_action::batch::batched_transition::document_transition::document_create_transition_action::{DocumentCreateTransitionActionAccessorsV0, DocumentFromCreateTransitionAction};
use drive::state_transition_action::batch::batched_transition::document_transition::document_purchase_transition_action::DocumentPurchaseTransitionActionAccessorsV0;
Expand Down
12 changes: 6 additions & 6 deletions packages/rs-drive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,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.13", optional = true }
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" }
grovedb = { git = "https://github.com/dashpay/grovedb", rev= "2417f7a72900cd3dca943ad52c979bc8abfdaa20", optional = true, default-features = false }
grovedb-costs = { git = "https://github.com/dashpay/grovedb", rev= "2417f7a72900cd3dca943ad52c979bc8abfdaa20", optional = true }
grovedb-path = { git = "https://github.com/dashpay/grovedb", rev= "2417f7a72900cd3dca943ad52c979bc8abfdaa20" }
grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev= "2417f7a72900cd3dca943ad52c979bc8abfdaa20", optional = true }
grovedb-version = { git = "https://github.com/dashpay/grovedb", rev= "2417f7a72900cd3dca943ad52c979bc8abfdaa20" }
grovedb-epoch-based-storage-flags = { git = "https://github.com/dashpay/grovedb", rev= "2417f7a72900cd3dca943ad52c979bc8abfdaa20" }

[dev-dependencies]
criterion = "0.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::drive::Drive;

use grovedb::batch::KeyInfoPath;
use grovedb::EstimatedLayerCount::{EstimatedLevel, PotentiallyAtMaxElements};
use grovedb::EstimatedLayerInformation;
use grovedb::EstimatedLayerSizes::{AllItems, AllSubtrees};
use grovedb::{EstimatedLayerInformation, TreeType};

use crate::drive::asset_lock::asset_lock_storage_path;
use grovedb::EstimatedSumTrees::SomeSumTrees;
Expand Down Expand Up @@ -61,7 +61,7 @@ impl Drive {
estimated_costs_only_with_layer_info.insert(
KeyInfoPath::from_known_path([]),
EstimatedLayerInformation {
is_sum_tree: false,
tree_type: TreeType::NormalTree,
estimated_layer_count: EstimatedLevel(3, false),
estimated_layer_sizes: AllSubtrees(
12, // 32 + 1 + 1 / 3
Expand All @@ -77,7 +77,7 @@ impl Drive {
estimated_costs_only_with_layer_info.insert(
KeyInfoPath::from_known_path(asset_lock_storage_path()),
EstimatedLayerInformation {
is_sum_tree: false,
tree_type: TreeType::NormalTree,
estimated_layer_count: PotentiallyAtMaxElements,
estimated_layer_sizes: AllItems(
36, //The size of an outpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use dpp::asset_lock::reduced_asset_lock_value::AssetLockValue;
use dpp::asset_lock::StoredAssetLockInfo;
use dpp::platform_value::Bytes36;
use dpp::serialization::PlatformDeserializable;
use grovedb::TransactionArg;
use grovedb::{TransactionArg, TreeType};

impl Drive {
/// Checks if a given `outpoint` is present as an asset lock in the transaction.
Expand Down Expand Up @@ -68,7 +68,7 @@ impl Drive {
StatefulDirectQuery
} else {
StatelessDirectQuery {
in_tree_using_sums: false,
in_tree_type: TreeType::NormalTree,
query_target: QueryTargetValue(36),
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use dpp::serialization::PlatformDeserializableWithPotentialValidationFromVersion

use dpp::version::PlatformVersion;
use grovedb::batch::KeyInfoPath;
use grovedb::{Element, EstimatedLayerInformation, TransactionArg};
use grovedb::{Element, EstimatedLayerInformation, TransactionArg, TreeType};
use std::borrow::Cow;
use std::collections::HashMap;

Expand Down Expand Up @@ -99,7 +99,7 @@ impl Drive {
DirectQueryType::StatefulDirectQuery
} else {
DirectQueryType::StatelessDirectQuery {
in_tree_using_sums: false,
in_tree_type: TreeType::NormalTree,
// we can ignore flags as this is just an approximation
// and it's doubtful that contracts will always be inserted at max size
query_target: QueryTargetValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use crate::util::type_constants::{DEFAULT_FLOAT_SIZE, DEFAULT_FLOAT_SIZE_U8};
use dpp::version::PlatformVersion;
use grovedb::batch::KeyInfoPath;
use grovedb::EstimatedLayerCount::{ApproximateElements, EstimatedLevel};
use grovedb::EstimatedLayerInformation;
use grovedb::EstimatedLayerSizes::{AllSubtrees, Mix};
use grovedb::EstimatedSumTrees::NoSumTrees;
use grovedb::{EstimatedLayerInformation, TreeType};
use std::collections::HashMap;

impl Drive {
Expand Down Expand Up @@ -61,7 +61,7 @@ impl Drive {
),
),
EstimatedLayerInformation {
is_sum_tree: false,
tree_type: TreeType::NormalTree,
estimated_layer_count: ApproximateElements(2),
estimated_layer_sizes: AllSubtrees(
ESTIMATED_AVERAGE_INDEX_NAME_SIZE,
Expand All @@ -80,7 +80,7 @@ impl Drive {
document_type_name.as_str(),
)),
EstimatedLayerInformation {
is_sum_tree: false,
tree_type: TreeType::NormalTree,
estimated_layer_count: EstimatedLevel(0, true),
estimated_layer_sizes: AllSubtrees(
ESTIMATED_AVERAGE_INDEX_NAME_SIZE,
Expand All @@ -103,7 +103,7 @@ impl Drive {
contract.id_ref().as_bytes(),
)),
EstimatedLayerInformation {
is_sum_tree: false,
tree_type: TreeType::NormalTree,
estimated_layer_count: ApproximateElements(AVERAGE_NUMBER_OF_UPDATES as u32),
estimated_layer_sizes: Mix {
subtrees_size: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use dpp::version::drive_versions::DriveVersion;
use grovedb::batch::key_info::KeyInfo;
use grovedb::batch::KeyInfoPath;
use grovedb::reference_path::ReferencePathType::SiblingReference;
use grovedb::{Element, EstimatedLayerInformation, TransactionArg};
use grovedb::{Element, EstimatedLayerInformation, TransactionArg, TreeType};
use std::collections::HashMap;

impl Drive {
Expand Down Expand Up @@ -64,8 +64,8 @@ impl Drive {
} else {
let apply_type = if estimated_costs_only_with_layer_info.is_some() {
BatchInsertTreeApplyType::StatelessBatchInsertTree {
is_sum_tree: false,
in_tree_using_sums: false,
tree_type: TreeType::NormalTree,
in_tree_type: TreeType::NormalTree,
flags_len: storage_flags
.as_ref()
.map(|flags| flags.to_element_flags().len())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use dpp::serialization::PlatformSerializableWithPlatformVersion;
use dpp::fee::default_costs::CachedEpochIndexFeeVersions;
use dpp::version::PlatformVersion;
use grovedb::batch::KeyInfoPath;
use grovedb::{Element, EstimatedLayerInformation, TransactionArg};
use grovedb::{Element, EstimatedLayerInformation, TransactionArg, TreeType};
use std::collections::{HashMap, HashSet};

impl Drive {
Expand Down Expand Up @@ -300,8 +300,8 @@ impl Drive {
BatchInsertTreeApplyType::StatefulBatchInsertTree
} else {
BatchInsertTreeApplyType::StatelessBatchInsertTree {
in_tree_using_sums: false,
is_sum_tree: false,
in_tree_type: TreeType::NormalTree,
tree_type: TreeType::NormalTree,
flags_len: element_flags
.as_ref()
.map(|e| e.len() as u32)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use dpp::fee::Credits;
use dpp::util::deserializer::ProtocolVersion;
use dpp::version::PlatformVersion;
use grovedb::batch::QualifiedGroveDbOp;
use grovedb::{Element, TransactionArg};
use grovedb::{Element, TransactionArg, TreeType};

/// Operations on Epochs
pub trait EpochOperations {
Expand Down Expand Up @@ -288,7 +288,11 @@ impl EpochOperations for Epoch {

/// Returns a groveDB op which deletes the epoch proposers tree.
fn delete_proposers_tree_operation(&self) -> QualifiedGroveDbOp {
QualifiedGroveDbOp::delete_tree_op(self.get_path_vec(), KEY_PROPOSERS.to_vec(), false)
QualifiedGroveDbOp::delete_tree_op(
self.get_path_vec(),
KEY_PROPOSERS.to_vec(),
TreeType::NormalTree,
)
}

/// Adds a groveDB op to the batch which deletes the given epoch proposers from the proposers tree.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use grovedb::batch::KeyInfoPath;

use grovedb::{Element, EstimatedLayerInformation, TransactionArg};
use grovedb::{Element, EstimatedLayerInformation, TransactionArg, TreeType};

use dpp::data_contract::document_type::DocumentTypeRef;

Expand Down Expand Up @@ -83,7 +83,7 @@ impl Drive {
&platform_version.drive,
)?;
DirectQueryType::StatelessDirectQuery {
in_tree_using_sums: false,
in_tree_type: TreeType::NormalTree,
query_target: QueryTargetValue(
document_type.estimated_size(platform_version)? as u32
),
Expand Down
Loading

0 comments on commit ad720bf

Please sign in to comment.