Skip to content

Commit

Permalink
Merge branch 'v1.0-dev' into feat/systemDataContractsHaveNoOwner
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov authored Jul 24, 2024
2 parents 8e761c7 + 990bc35 commit 4666e0b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 27 deletions.
6 changes: 3 additions & 3 deletions packages/dashmate/configs/defaults/getBaseConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import path from 'path';
import semver from 'semver';

import fs from 'fs';
import Config from '../../src/config/Config.js';
import {
NETWORK_MAINNET,
PACKAGE_ROOT_DIR,
} from '../../src/constants.js';
import Config from '../../src/config/Config.js';

const { version } = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT_DIR, 'package.json'), 'utf8'));

Expand Down Expand Up @@ -98,7 +98,7 @@ export default function getBaseConfigFactory(homeDir) {
tenderdash: {
password: 'rpcpassword',
whitelist: [
'quoruminfo', 'quorumverify', 'quorumsign', 'masternodestatus', 'masternodelist',
'quoruminfo', 'quorumverify', 'quorumplatformsign', 'masternodestatus', 'masternodelist',
'ping', 'getnetworkinfo',
],
lowPriority: false,
Expand Down Expand Up @@ -301,7 +301,7 @@ export default function getBaseConfigFactory(homeDir) {
tenderdash: {
mode: 'full',
docker: {
image: 'dashpay/tenderdash:1.0.0',
image: 'dashpay/tenderdash:1.1.0-dev.1',
},
p2p: {
host: '0.0.0.0',
Expand Down
10 changes: 8 additions & 2 deletions packages/dashmate/configs/getConfigFileMigrationsFactory.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable no-param-reassign */
import fs from 'fs';
import path from 'path';
import lodash from 'lodash';
import path from 'path';

import {
NETWORK_LOCAL,
NETWORK_TESTNET,
NETWORK_MAINNET,
NETWORK_TESTNET,
SSL_PROVIDERS,
} from '../src/constants.js';

Expand Down Expand Up @@ -711,6 +711,12 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs)
delete options.platform.featureFlags;
delete options.platform.masternodeRewardShares;
delete options.platform.withdrawals;

// Update tenderdash image
options.platform.drive.tenderdash.docker.image = base.get('platform.drive.tenderdash.docker.image');

// Replace quorumsign with qurumplatformsign in Core RPC Tenderdash auth whitelist
options.core.rpc.users.tenderdash.whitelist = base.get('core.rpc.users.tenderdash.whitelist');
});
return configFile;
},
Expand Down
5 changes: 3 additions & 2 deletions packages/rs-drive-abci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ impl Cli {
) -> Result<(), String> {
match self.command {
Commands::Start => {
verify_grovedb(&config.db_path, false)?;

if config.drive.grovedb_verify_on_startup {
verify_grovedb(&config.db_path, false)?;
}
let core_rpc = DefaultCoreRPC::open(
config.core.consensus_rpc.url().as_str(),
config.core.consensus_rpc.username.clone(),
Expand Down
14 changes: 14 additions & 0 deletions packages/rs-drive/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use serde::{Deserialize, Serialize};
pub const DEFAULT_GROVE_BATCHING_CONSISTENCY_VERIFICATION_ENABLED: bool = false;
/// Boolean if GroveDB has_raw in enabled by default
pub const DEFAULT_GROVE_HAS_RAW_ENABLED: bool = true;
/// Boolean if verification of GroveDB should be run on startup
pub const DEFAULT_VERIFY_GROVE_ON_STARTUP: bool = false;
/// The default default query limit
pub const DEFAULT_QUERY_LIMIT: u16 = 100;
/// The default max query limit
Expand All @@ -31,6 +33,13 @@ pub struct DriveConfig {
#[cfg_attr(feature = "serde", serde(default = "default_has_raw_enabled"))]
pub has_raw_enabled: bool,

/// Boolean if GroveDB verification should happen on startup
#[cfg_attr(
feature = "serde",
serde(default = "default_grove_verify_on_startup_enabled")
)]
pub grovedb_verify_on_startup: bool,

/// The default returned count if no limit is set
#[cfg_attr(
feature = "serde",
Expand Down Expand Up @@ -146,6 +155,10 @@ fn default_has_raw_enabled() -> bool {
DEFAULT_GROVE_HAS_RAW_ENABLED
}

fn default_grove_verify_on_startup_enabled() -> bool {
DEFAULT_VERIFY_GROVE_ON_STARTUP
}

fn default_default_query_limit() -> u16 {
DEFAULT_QUERY_LIMIT
}
Expand Down Expand Up @@ -173,6 +186,7 @@ impl Default for DriveConfig {
batching_consistency_verification:
DEFAULT_GROVE_BATCHING_CONSISTENCY_VERIFICATION_ENABLED,
has_raw_enabled: DEFAULT_GROVE_HAS_RAW_ENABLED,
grovedb_verify_on_startup: DEFAULT_VERIFY_GROVE_ON_STARTUP,
default_query_limit: DEFAULT_QUERY_LIMIT,
epochs_per_era: DEFAULT_EPOCHS_PER_ERA,
max_query_limit: DEFAULT_MAX_QUERY_LIMIT,
Expand Down
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

0 comments on commit 4666e0b

Please sign in to comment.