Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: spent asset lock estimated fees, and misc #1993

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,30 @@ impl Drive {
/// - The layer might potentially have max elements.
/// - Each item in this layer has a size of 36, which represents the size of an outpoint.
///
/// # Notes
///
/// The todo comment suggests that there may be inaccuracies in the current function logic. Ensure to verify
/// the correctness of the provided logic and assumptions before relying on this function in production.
pub(crate) fn add_estimation_costs_for_adding_asset_lock_v0(
estimated_costs_only_with_layer_info: &mut HashMap<KeyInfoPath, EstimatedLayerInformation>,
) {
//todo: verify (this is wrong)
// DataContract_Documents 64
// / \
// Identities 32 Balances 96
// / \ / \
// Token_Balances 16 Pools 48 WithdrawalTransactions 80 Votes 112
// / \ / / / \
// NUPKH->I 8 UPKH->I 24 PreFundedSpecializedBalances 40 -> SpentAssetLockTransactions 72 <- Misc 104 Versions 120

// we have constructed the top layer so contract/documents tree are at the top
// since balance will be on layer 2, updating will mean we will update 1 sum tree
// and 1 normal tree, hence we should give an equal weight to both
// since SpentAssetLockTransactions will be on layer 3, updating will mean we will update 1 sum tree
// and 2 normal tree, hence we should give an equal weight to both
estimated_costs_only_with_layer_info.insert(
KeyInfoPath::from_known_path([]),
EstimatedLayerInformation {
is_sum_tree: false,
estimated_layer_count: EstimatedLevel(1, false),
estimated_layer_count: EstimatedLevel(3, false),
estimated_layer_sizes: AllSubtrees(
1,
12, // 32 + 1 + 1 / 3
SomeSumTrees {
sum_trees_weight: 1,
non_sum_trees_weight: 1,
non_sum_trees_weight: 2,
},
None,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ use crate::drive::system::misc_path_vec;
use grovedb::EstimatedSumTrees::SomeSumTrees;
use std::collections::HashMap;

// DataContract_Documents 64
// / \
// Identities 32 Balances 96
// / \ / \
// Token_Balances 16 Pools 48 WithdrawalTransactions 80 Votes 112
// / \ / / / \
// NUPKH->I 8 UPKH->I 24 PreFundedSpecializedBalances 40 SpentAssetLockTransactions 72 -> Misc 104 <- Versions 120

impl Drive {
/// Adds estimation costs for total system credits update.
///
Expand All @@ -19,34 +27,32 @@ impl Drive {
pub(super) fn add_estimation_costs_for_total_system_credits_update_v0(
estimated_costs_only_with_layer_info: &mut HashMap<KeyInfoPath, EstimatedLayerInformation>,
) {
//todo: verify (this is wrong)
// we have constructed the top layer so contract/documents tree are at the top
// since balance will be on layer 2, updating will mean we will update 1 sum tree
// and 1 normal tree, hence we should give an equal weight to both
// since balance will be on layer 3, updating will mean we will update 1 sum tree
// and 2 normal trees, hence we should give an equal weight to both
estimated_costs_only_with_layer_info.insert(
KeyInfoPath::from_known_path([]),
EstimatedLayerInformation {
is_sum_tree: false,
estimated_layer_count: EstimatedLevel(1, false),
estimated_layer_count: EstimatedLevel(3, false),
estimated_layer_sizes: AllSubtrees(
1,
12, // about 32 + 1 + 1 / 3
SomeSumTrees {
sum_trees_weight: 1,
non_sum_trees_weight: 1,
non_sum_trees_weight: 2,
},
None,
),
},
);

//todo : verify this
// we then need to insert the contract layer
estimated_costs_only_with_layer_info.insert(
KeyInfoPath::from_known_owned_path(misc_path_vec()),
EstimatedLayerInformation {
is_sum_tree: true,
estimated_layer_count: ApproximateElements(0),
estimated_layer_sizes: AllItems(1, 64, None),
is_sum_tree: false,
estimated_layer_count: ApproximateElements(1),
estimated_layer_sizes: AllItems(1, 8, None),
},
);
}
Expand Down
Loading