Skip to content

Commit

Permalink
feat(platform)!: proofs v1 support (#1934)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer authored Jul 9, 2024
1 parent b1b3734 commit 0effb07
Show file tree
Hide file tree
Showing 345 changed files with 243 additions and 290 deletions.
283 changes: 152 additions & 131 deletions Cargo.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,6 @@ mod tests {
}

#[test]
#[ignore] // Currently will have an issue due to a grovedb bug
fn test_limit() {
let platform_version = PlatformVersion::latest();
let mut platform = TestPlatformBuilder::new()
Expand Down Expand Up @@ -2634,7 +2633,6 @@ mod tests {
}

#[test]
#[ignore] //needs to be fixed on grovedb side
fn test_proved_vote_state_query_request_with_limit_4_should_return_4_contenders() {
let platform_version = PlatformVersion::latest();
let mut platform = TestPlatformBuilder::new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ mod tests {
original_data_contract.id().to_buffer(),
start_at_ms,
Some(10),
Some(0),
None,
version,
)
.expect("To verify contract history");
Expand Down
8 changes: 4 additions & 4 deletions packages/rs-drive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ 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 = "a4326b7ec36a639e94eaac397663166846c83f52", optional = true, default-features = false }
grovedb-costs = { git = "https://github.com/dashpay/grovedb", rev = "a4326b7ec36a639e94eaac397663166846c83f52", optional = true }
grovedb-path = { git = "https://github.com/dashpay/grovedb", rev = "a4326b7ec36a639e94eaac397663166846c83f52" }
grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "a4326b7ec36a639e94eaac397663166846c83f52", optional = true }
grovedb = { git = "https://github.com/dashpay/grovedb", branch = "feat/proofV2", optional = true, default-features = false }
grovedb-costs = { git = "https://github.com/dashpay/grovedb", branch = "feat/proofV2", optional = true }
grovedb-path = { git = "https://github.com/dashpay/grovedb", branch = "feat/proofV2" }
grovedb-storage = { git = "https://github.com/dashpay/grovedb", branch = "feat/proofV2", optional = true }

[dev-dependencies]
criterion = "0.3.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Drive {
&[0],
&|element| {
if let Some(element) = element {
if element.is_tree() {
if element.is_basic_tree() {
// this is a contract that keeps history
Self::fetch_contract_with_history_latest_query(contract_id, true)
} else {
Expand All @@ -50,7 +50,6 @@ impl Drive {
Self::fetch_contract_query(contract_id, true)
}
},
false,
transaction,
&mut vec![],
&platform_version.drive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ impl Drive {

self.grove_get_proved_path_query(
&history_query,
false,
transaction,
&mut vec![],
&platform_version.drive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ impl Drive {

self.grove_get_proved_path_query(
&contracts_query,
true,
transaction,
&mut vec![],
&platform_version.drive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ impl Drive {

self.grove_get_proved_path_query(
&path_query,
false,
transaction,
&mut vec![],
&platform_version.drive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Drive {
batch_pause_height: None,
}),
|_, _, _| Ok(false),
|_, _, _| Err(GroveError::InternalError("not implemented")),
|_, _, _| Err(GroveError::InternalError("not implemented".to_string())),
);
push_drive_operation_result(cost_context, drive_operations)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ impl Drive {
pub fn grove_get_proved_path_query(
&self,
path_query: &PathQuery,
verbose: bool,
transaction: TransactionArg,
drive_operations: &mut Vec<LowLevelDriveOperation>,
drive_version: &DriveVersion,
Expand All @@ -39,7 +38,6 @@ impl Drive {
{
0 => self.grove_get_proved_path_query_v0(
path_query,
verbose,
transaction,
drive_operations,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ impl Drive {
pub(super) fn grove_get_proved_path_query_v0(
&self,
path_query: &PathQuery,
verbose: bool,
transaction: TransactionArg,
drive_operations: &mut Vec<LowLevelDriveOperation>,
) -> Result<Vec<u8>, Error> {
let CostContext { value, cost } =
self.grove
.get_proved_path_query(path_query, verbose, transaction);
.get_proved_path_query(path_query, None, transaction);
drive_operations.push(CalculatedCostOperation(cost));
value.map_err(Error::GroveDB)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl Drive {
root_path: SubtreePath<'_, B>,
key: &[u8],
path_query_resolver: &impl Fn(Option<Element>) -> PathQuery,
verbose: bool,
transaction: TransactionArg,
drive_operations: &mut Vec<LowLevelDriveOperation>,
drive_version: &DriveVersion,
Expand All @@ -44,7 +43,6 @@ impl Drive {
root_path,
key,
path_query_resolver,
verbose,
transaction,
drive_operations,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ impl Drive {
root_path: SubtreePath<B>,
key: &[u8],
path_query_resolver: &impl Fn(Option<Element>) -> PathQuery,
verbose: bool,
transaction: TransactionArg,
drive_operations: &mut Vec<LowLevelDriveOperation>,
) -> Result<Vec<u8>, Error> {
Expand All @@ -27,7 +26,7 @@ impl Drive {

let CostContext { value, cost } =
self.grove
.get_proved_path_query(&path_query, verbose, transaction);
.get_proved_path_query(&path_query, None, transaction);
drive_operations.push(CalculatedCostOperation(cost));
value.map_err(Error::GroveDB)
}
Expand Down
3 changes: 0 additions & 3 deletions packages/rs-drive/src/drive/identity/balance/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ impl Drive {
let balance_query = Self::balance_for_identity_id_query(identity_id);
self.grove_get_proved_path_query(
&balance_query,
false,
transaction,
&mut vec![],
drive_version,
Expand All @@ -33,7 +32,6 @@ impl Drive {
let balance_query = Self::balance_and_revision_for_identity_id_query(identity_id);
self.grove_get_proved_path_query(
&balance_query,
true,
transaction,
&mut vec![],
drive_version,
Expand All @@ -50,7 +48,6 @@ impl Drive {
let balance_query = Self::balances_for_identity_ids_query(identity_ids)?;
self.grove_get_proved_path_query(
&balance_query,
false,
transaction,
&mut vec![],
drive_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ impl Drive {
let identity_contract_path = Self::identity_contract_nonce_query(identity_id, contract_id);
self.grove_get_proved_path_query(
&identity_contract_path,
false,
transaction,
&mut vec![],
drive_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ impl Drive {
let nonce_query = Self::identity_nonce_query(identity_id);
self.grove_get_proved_path_query(
&nonce_query,
false,
transaction,
&mut vec![],
&platform_version.drive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ impl Drive {
let query = Self::full_identities_query(identity_ids)?;
self.grove_get_proved_path_query(
&query,
false,
transaction,
&mut drive_operations,
drive_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ impl Drive {
let path_query = PathQuery::merge(path_queries.iter().collect()).map_err(Error::GroveDB)?;
self.grove_get_proved_path_query(
&path_query,
true,
transaction,
&mut vec![],
&platform_version.drive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ impl Drive {
let query = Self::full_identity_query(&identity_id)?;
self.grove_get_proved_path_query(
&query,
false,
transaction,
&mut drive_operations,
drive_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ impl Drive {
Self::full_identity_with_public_key_hash_query(public_key_hash, identity_id)?;
self.grove_get_proved_path_query(
&query,
true,
transaction,
&mut vec![],
&platform_version.drive,
Expand All @@ -34,7 +33,6 @@ impl Drive {
let query = Self::identity_id_by_unique_public_key_hash_query(public_key_hash);
self.grove_get_proved_path_query(
&query,
false,
transaction,
&mut vec![],
&platform_version.drive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ impl Drive {
);
self.grove_get_proved_path_query(
&query,
false,
transaction,
&mut drive_operations,
drive_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ impl Drive {
let path_query = Self::identity_id_by_unique_public_key_hash_query(public_key_hash);
self.grove_get_proved_path_query(
&path_query,
false,
transaction,
&mut vec![],
drive_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ impl Drive {
let path_query = Self::identity_ids_by_unique_public_key_hash_query(public_key_hashes);
self.grove_get_proved_path_query(
&path_query,
false,
transaction,
&mut vec![],
&platform_version.drive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ impl Drive {
let identity_query = Self::fetch_identities_all_keys_query(self, identity_ids, limit)?;
self.grove_get_proved_path_query(
&identity_query,
false,
transaction,
&mut vec![],
drive_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ impl Drive {
let identity_query = key_request.into_path_query();
self.grove_get_proved_path_query(
&identity_query,
false,
transaction,
&mut vec![],
&platform_version.drive,
Expand Down
15 changes: 1 addition & 14 deletions packages/rs-drive/src/drive/initialization/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,12 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
)
.expect("expected to get root elements");
assert_eq!(proof.len(), 111); //it + left + right
assert_eq!(proof.len(), 112); //it + left + right

// Merk Level 1
let mut query = Query::new();
Expand All @@ -273,7 +272,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -295,7 +293,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -318,7 +315,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -340,7 +336,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -362,7 +357,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -384,7 +378,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -408,7 +401,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -432,7 +424,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -454,7 +445,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -476,7 +466,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -498,7 +487,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand All @@ -520,7 +508,6 @@ mod tests {
let proof = drive
.grove_get_proved_path_query(
&root_path_query,
false,
None,
&mut drive_operations,
drive_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ impl Drive {
let balance_query = PathQuery::new_single_key(balance_path, balance_id.to_vec());
self.grove_get_proved_path_query(
&balance_query,
false,
transaction,
&mut vec![],
&platform_version.drive,
Expand Down
Loading

0 comments on commit 0effb07

Please sign in to comment.