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(drive-abci)!: fix wrong fields in dash top level domain #2065

Merged
merged 4 commits into from
Aug 21, 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
17 changes: 9 additions & 8 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
@@ -1,7 +1,7 @@
use crate::error::Error;
use crate::platform_types::platform::Platform;

use dpp::platform_value::{platform_value, BinaryData};
use dpp::platform_value::platform_value;
use dpp::ProtocolError;

use drive::dpp::identity::TimestampMillis;
Expand All @@ -16,9 +16,7 @@ use drive::dpp::system_data_contracts::SystemDataContract;
use drive::util::batch::{DataContractOperationType, DocumentOperationType, DriveOperation};

use dpp::prelude::CoreBlockHeight;
use dpp::system_data_contracts::dpns_contract::{
DPNS_DASH_TLD_DOCUMENT_ID, DPNS_DASH_TLD_PREORDER_SALT,
};
use dpp::system_data_contracts::dpns_contract::DPNS_DASH_TLD_DOCUMENT_ID;
use drive::query::TransactionArg;
use drive::util::object_size_info::{
DataContractInfo, DocumentInfo, DocumentTypeInfo, OwnedDocumentInfo,
Expand Down Expand Up @@ -126,9 +124,8 @@ impl<C> Platform<C> {
"normalizedLabel" : domain,
"parentDomainName" : "",
"normalizedParentDomainName" : "",
"preorderSalt" : BinaryData::new(DPNS_DASH_TLD_PREORDER_SALT.to_vec()),
"records" : {
"dashAliasIdentityId" : contract.owner_id(),
"identity" : contract.owner_id(),
},
"subdomainRules": {
"allowSubdomains": true,
Expand Down Expand Up @@ -205,7 +202,7 @@ mod tests {

assert_eq!(
hex::encode(root_hash),
"8163884a9eef0d3b306bd6f426806e7ff41d7b09f030c4ff2b79b3b4c646dfca"
"dc5b0d4be407428adda2315db7d782e64015cbe2d2b7df963f05622390dc3c9f"
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/rs-drive-abci/tests/strategy_tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ mod tests {
.unwrap()
.unwrap()
),
"d12cc15405f4a810c239539f06fe6eee9f2b2d1ad49055a5ca55882b5842baa4".to_string()
"975735252c11cea7ef3fbba86928077e37ebe1926972e6ae38e237ce0864100c".to_string()
)
}

Expand Down Expand Up @@ -1938,7 +1938,7 @@ mod tests {
.unwrap()
.unwrap()
),
"f55d96bb04c3e5e737c883a18538fc008a55aaf003ccd64d0e8dd3640b7fa888".to_string()
"0cc2c7a7749a0ce47a4abcd1f4db21d07734f96d09ffe08d6500a8d09a3455a1".to_string()
)
}

Expand Down Expand Up @@ -2073,7 +2073,7 @@ mod tests {
.unwrap()
.unwrap()
),
"a409bbb8c0522bab91eed208e058f1a35320b52efd42f289be14d874a4cab807".to_string()
"5a08b133a19b11b09eaba6763ad2893c2bcbcc645fb698298790bb5d26e551e0".to_string()
)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/rs-drive-abci/tests/strategy_tests/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use strategy_tests::operations::{
DocumentAction, DocumentOp, FinalizeBlockOperation, IdentityUpdateOp, OperationType,
};

use dpp::document::{DocumentV0Getters, DocumentV0Setters};
use dpp::document::DocumentV0Getters;
use dpp::fee::Credits;
use dpp::identity::{Identity, IdentityPublicKey, KeyID, KeyType, Purpose, SecurityLevel};
use dpp::serialization::PlatformSerializableWithPlatformVersion;
Expand Down Expand Up @@ -937,7 +937,7 @@ impl NetworkStrategy {
//todo: fix this into a search key request for the following
//let search_key_request = BTreeMap::from([(Purpose::AUTHENTICATION as u8, BTreeMap::from([(SecurityLevel::HIGH as u8, AllKeysOfKindRequest)]))]);

let mut random_new_document = document_type
let random_new_document = document_type
.random_document_with_rng(rng, platform_version)
.unwrap();
let request = IdentityKeysRequest {
Expand Down
10 changes: 5 additions & 5 deletions packages/rs-drive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ 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 = { git = "https://github.com/dashpay/grovedb", rev = "713ad96a0ca443f72fa15738e82df529be1becbb", optional = true, default-features = false }
grovedb-costs = { git = "https://github.com/dashpay/grovedb", rev = "713ad96a0ca443f72fa15738e82df529be1becbb", optional = true }
grovedb-path = { git = "https://github.com/dashpay/grovedb", rev = "713ad96a0ca443f72fa15738e82df529be1becbb" }
grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "713ad96a0ca443f72fa15738e82df529be1becbb", optional = true }
grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "713ad96a0ca443f72fa15738e82df529be1becbb"}
grovedb = { git = "https://github.com/dashpay/grovedb", rev = "2c14841e95b4222d489f0655c85238bc05267b91", optional = true, default-features = false }
grovedb-costs = { git = "https://github.com/dashpay/grovedb", rev = "2c14841e95b4222d489f0655c85238bc05267b91", optional = true }
grovedb-path = { git = "https://github.com/dashpay/grovedb", rev = "2c14841e95b4222d489f0655c85238bc05267b91" }
grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "2c14841e95b4222d489f0655c85238bc05267b91", optional = true }
grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "2c14841e95b4222d489f0655c85238bc05267b91"}

[dev-dependencies]
criterion = "0.3.5"
Expand Down
18 changes: 16 additions & 2 deletions packages/rs-drive/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,8 @@ mod tests {
use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters;

use dpp::prelude::Identifier;
use rand::prelude::StdRng;
use rand::SeedableRng;
use serde_json::json;
use std::borrow::Cow;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -2218,7 +2220,10 @@ mod tests {
#[test]
fn test_valid_query_drive_document_query() {
let platform_version = PlatformVersion::latest();
let contract = get_dpns_data_contract_fixture(None, 0, 1).data_contract_owned();
let mut rng = StdRng::seed_from_u64(5);
let contract =
get_dpns_data_contract_fixture(Some(Identifier::random_with_rng(&mut rng)), 0, 1)
.data_contract_owned();
let domain = contract
.document_type_for_name("domain")
.expect("expected to get domain");
Expand Down Expand Up @@ -2264,7 +2269,16 @@ mod tests {
.construct_path_query(None, platform_version)
.expect("expected to create path query");

println!("{}", path_query);
assert_eq!(path_query.to_string(), "PathQuery { path: [@, 0x1da29f488023e306ff9a680bc9837153fb0778c8ee9c934a87dc0de1d69abd3c, 0x01, domain, 0x7265636f7264732e6964656e74697479], query: SizedQuery { query: Query {\n items: [\n RangeTo(.. 8dc201fd7ad7905f8a84d66218e2b387daea7fe4739ae0e21e8c3ee755e6a2c0),\n ],\n default_subquery_branch: SubqueryBranch { subquery_path: [00], subquery: Query {\n items: [\n RangeFull,\n ],\n default_subquery_branch: SubqueryBranch { subquery_path: None subquery: None },\n left_to_right: false,\n} },\n conditional_subquery_branches: {\n Key(): SubqueryBranch { subquery_path: [00], subquery: Query {\n items: [\n RangeFull,\n ],\n default_subquery_branch: SubqueryBranch { subquery_path: None subquery: None },\n left_to_right: false,\n} },\n },\n left_to_right: false,\n}, limit: 6 } }");

// Serialize the PathQuery to a Vec<u8>
let encoded = bincode::encode_to_vec(&path_query, bincode::config::standard())
.expect("Failed to serialize PathQuery");

// Convert the encoded bytes to a hex string
let hex_string = hex::encode(encoded);

assert_eq!(hex_string, "050140201da29f488023e306ff9a680bc9837153fb0778c8ee9c934a87dc0de1d69abd3c010106646f6d61696e107265636f7264732e6964656e746974790105208dc201fd7ad7905f8a84d66218e2b387daea7fe4739ae0e21e8c3ee755e6a2c0010101000101030000000001010000010101000101030000000000010600");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-platform-version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "MIT"
thiserror = { version = "1.0.59" }
bincode = { version = "2.0.0-rc.3"}
versioned-feature-core = { git = "https://github.com/dashpay/versioned-feature-core", version = "1.0.0" }
grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "713ad96a0ca443f72fa15738e82df529be1becbb" }
grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "2c14841e95b4222d489f0655c85238bc05267b91" }
once_cell = "1.19.0"

[features]
Expand Down
Loading