Skip to content

Conversation

lklimek
Copy link
Contributor

@lklimek lklimek commented Mar 12, 2025

Issue being fixed or feature implemented

What was done?

How Has This Been Tested?

Breaking Changes

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features
    • Enhanced identity management with the ability to retrieve and verify identities using non-unique public key hashes, including flexible pagination and proof capabilities.
    • Expanded API support for fetching identities based on non-unique public key parameters, improving security and versatility in identity queries.
    • Introduced new methods and modules for querying identities, proving identities, and verifying identity IDs related to non-unique public key hashes.
    • Streamlined naming conventions and endpoint consistency for a clearer, more intuitive identity retrieval experience.

Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

Walkthrough

The changes add support for handling identity queries based on non-unique public key hashes. New RPC methods, request and response types, and query modules have been implemented across the system. The gRPC client and SDK were updated to support the new request, and corresponding fetching, proving, and verification logic were added or renamed in backend modules. Versioning structures were also updated to reflect these changes.

Changes

File(s) Change Summary
packages/dapi-grpc/build.rs
packages/dapi-grpc/protos/platform/v0/platform.proto
Expanded identity request support by adding "GetIdentityByNonUniquePublicKeyHashRequest" and its response. Updated the VERSIONED_REQUESTS array and comments in build.rs, and introduced a new RPC method with corresponding messages in platform.proto.
packages/rs-dapi-client/src/transport/grpc.rs Added a new gRPC macro invocation to implement the get_identity_by_non_unique_public_key_hash request.
packages/rs-drive-abci/src/query/identity_based_queries/* Introduced new modules (e.g., identity_by_non_unique_public_key_hash) and methods for querying identities using a non-unique public key hash. Renamed existing methods to use “unique” where appropriate, and extended the async service endpoint in QueryService.
packages/rs-drive/src/drive/identity/fetch/*
packages/rs-drive/src/drive/identity/fetch/prove/*
packages/rs-drive/src/drive/identity/identity_and_non_unique_public_key_hash_double_proof.rs
Added new modules for fetching and proving identities by non-unique public key hash. Introduced methods such as fetch_full_identity_by_non_unique_public_key_hash and prove_full_identity_by_non_unique_public_key_hash, and a new struct (IdentityAndNonUniquePublicKeyHashDoubleProof). Also, renamed methods for unique public key hash verification.
packages/rs-drive/src/verify/identity/* Updated and added verification methods to distinguish between unique and non-unique public key hash identities, including renaming methods to better reflect their semantics.
packages/rs-platform-version/src/version/* Renamed fields from “public_key_hash” to “unique_public_key_hash” and added new fields for non-unique public key hash methods in version structs, updating version bounds accordingly.
packages/rs-sdk/src/platform/types/identity.rs
packages/rs-sdk/tests/fetch/identity.rs
Added support for NonUniquePublicKeyHashQuery by updating the delegate enum and introducing a new query struct, along with an asynchronous test to validate fetching identities with non-unique public keys.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant SDK
    participant QueryService
    participant Platform
    participant Drive

    Client->>SDK: Send non-unique public key hash query
    SDK->>QueryService: get_identity_by_non_unique_public_key_hash(request)
    QueryService->>Platform: query_identity_by_non_unique_public_key_hash(request)
    Platform->>Drive: fetch or prove identity based on non-unique public key hash
    Drive-->>Platform: Return identity data or proof
    Platform-->>QueryService: Build response with identity info
    QueryService-->>SDK: Return response
    SDK-->>Client: Deliver response
Loading

Suggested labels

js-sdk

Suggested reviewers

  • QuantumExplorer
  • shumkov

Poem

In the code of night, I hop along,
Adding new hashes, both robust and strong.
Non-unique keys now lead the dance,
In every module, every chance.
With bytes and proofs we bound,
A bunny’s joy in code is found!
(_/)(•ㅅ•) ϞϞ🕊

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c572be and 8fefab2.

📒 Files selected for processing (1)
  • packages/rs-sdk/tests/fetch/identity.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/rs-sdk/tests/fetch/identity.rs
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Rust packages (drive) / Formatting
  • GitHub Check: Rust packages (drive) / Unused dependencies
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Unused dependencies
  • GitHub Check: Rust packages (dpp) / Formatting
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (rs-dapi-client) / Tests
  • GitHub Check: Rust packages (rs-dapi-client) / Check each feature
  • GitHub Check: Rust packages (rs-dapi-client) / Linting
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (wasm-dpp) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build JS packages / Build JS

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lklimek
Copy link
Contributor Author

lklimek commented Mar 12, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (13)
packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs (1)

41-41: Function name updated but documentation needs to be aligned

The function name has been updated to include "unique" in the name, which clarifies the function's purpose. However, the function documentation still refers to the old naming convention without the "unique" qualifier.

Consider updating the documentation comments in lines 12-39 to reflect the new function name. For example, line 20-21 should be updated from:

/// The function first verifies the identity ID associated with the given public key hash
/// by calling `verify_identity_id_by_public_key_hash()`. It then uses this identity ID to verify

to:

/// The function first verifies the identity ID associated with the given unique public key hash
/// by calling `verify_identity_id_by_unique_public_key_hash()`. It then uses this identity ID to verify
packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs (1)

69-69: Remove or replace the debug print
The println!() call may be leftover. Consider using structured logging or removing it.

- println!("hex {}", hex::encode(&identity_proof));
+ // Consider using a logging macro or removing if unneeded
packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs (1)

38-64: Consider validating the proof’s content or length before dispatch.

While version-based dispatch is a sound approach, adding simple checks (e.g., ensuring the proof slice is not empty) can catch incorrect usage earlier. Stating assumptions and preconditions explicitly at the start of this method can help strengthen defensive programming practices.

packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs (1)

54-78: Add a preflight check for the proof’s validity.

Before calling the version-specific handler, consider verifying that the provided proof is structurally valid (e.g., correct fields are present). Guarding at this abstraction level might prevent deeper code paths from being triggered with invalid data, reducing debugging overhead.

packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs (1)

49-75: Consider enhancing error reports with context on missing identities.

When generating a proof for a public key hash that does not map to any identity, consider providing an explicit error or logging detail. This could inform callers or log systems where the gap is (e.g., “No identity found for provided public key hash”), expediting troubleshooting.

packages/rs-drive/src/drive/identity/fetch/queries/mod.rs (1)

94-109: Consider bounding or verifying the result set.

While this method generates a PathQuery for a non-unique public key hash, it uses new_range_full() when after is not supplied. This could potentially retrieve multiple identities sharing the same hash. If only one result is expected, consider adding an explicit limit or verifying that no unexpected multiple matches occur.

packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs (1)

1-71: Revisit version bounds reference for non-unique queries.

Lines 37-38 reference identity_by_unique_public_key_hash when checking version bounds, yet this file implements querying by a non-unique hash. If there’s a separate version bound for non-unique features, it might be preferable to reference that for clarity. Otherwise, if it’s intentional to reuse the same bounds, consider adding a clarifying comment.

packages/dapi-grpc/protos/platform/v0/platform.proto (2)

625-632: Document the expected input size.
While the protobuf definition for public_key_hash is valid, consider adding a clarifying comment that it is expected to be 20 bytes to prevent confusion.


634-652: Consider improving proof handling.
Using identity_proof_bytes in addition to grovedb_identity_public_key_hash_proof is labeled a “hack.” Consider consolidating them or more clearly naming this field to avoid confusion in future maintenance.

packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs (1)

105-193: Add more negative test coverage for start_after.
The existing tests thoroughly check invalid key-hash lengths and missing entries. Consider adding a test case to confirm the error behavior when an invalid start_after length is provided, ensuring full coverage of this field.

packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs (1)

30-52: Check limit usage for multiple matching identities.
The code sets limit to 1, which discards additional identities. Confirm that ignoring the possibility of multiple matches is desired. If it’s not, consider returning all matching identities.

packages/rs-drive-proof-verifier/src/proof.rs (1)

351-442: New proof handling for non-unique public key hashes.
This implementation follows the established pattern for identity proofs, adapted for non-unique key hashes. Verify:

  • Whether multiple identities sharing the same key hash are handled (beyond the first match).
  • That the after parameter is tested, especially for edge cases with and without an initial offset.
packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs (1)

17-19: Doc comments updated for new parameters.
The mention of limit and platform_version is helpful. Consider adding a brief note clarifying how after is used for pagination or skipping.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94661af and 445d22b.

📒 Files selected for processing (47)
  • packages/dapi-grpc/build.rs (3 hunks)
  • packages/dapi-grpc/protos/platform/v0/platform.proto (2 hunks)
  • packages/rs-dapi-client/src/transport/grpc.rs (1 hunks)
  • packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs (1 hunks)
  • packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/mod.rs (3 hunks)
  • packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/v0/mod.rs (4 hunks)
  • packages/rs-drive-abci/src/query/identity_based_queries/mod.rs (1 hunks)
  • packages/rs-drive-abci/src/query/service.rs (2 hunks)
  • packages/rs-drive-abci/tests/strategy_tests/query.rs (1 hunks)
  • packages/rs-drive-proof-verifier/src/proof.rs (4 hunks)
  • packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs (4 hunks)
  • packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs (2 hunks)
  • packages/rs-drive/src/drive/identity/fetch/prove/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_id_by_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_ids_by_unique_public_key_hashes/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/fetch/queries/mod.rs (3 hunks)
  • packages/rs-drive/src/drive/identity/identity_and_non_unique_public_key_hash_double_proof.rs (1 hunks)
  • packages/rs-drive/src/drive/identity/mod.rs (1 hunks)
  • packages/rs-drive/src/drive/mod.rs (2 hunks)
  • packages/rs-drive/src/verify/identity/mod.rs (1 hunks)
  • packages/rs-drive/src/verify/identity/verify_full_identities_by_public_key_hashes/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs (1 hunks)
  • packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/mod.rs (2 hunks)
  • packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs (1 hunks)
  • packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/mod.rs (2 hunks)
  • packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/verify/identity/verify_identity_ids_by_unique_public_key_hashes/mod.rs (2 hunks)
  • packages/rs-drive/src/verify/identity/verify_identity_ids_by_unique_public_key_hashes/v0/mod.rs (1 hunks)
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs (1 hunks)
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs (1 hunks)
  • packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/mod.rs (2 hunks)
  • packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/v1.rs (2 hunks)
  • packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs (1 hunks)
  • packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs (1 hunks)
  • packages/rs-platform-version/src/version/mocks/v2_test.rs (1 hunks)
  • packages/rs-sdk/src/platform/types/identity.rs (3 hunks)
  • packages/rs-sdk/tests/fetch/identity.rs (1 hunks)
🔇 Additional comments (86)
packages/rs-drive/src/drive/identity/fetch/prove/mod.rs (1)

4-4: Appropriate module addition for non-unique public key hash functionality

The new module prove_full_identity_by_non_unique_public_key_hash is properly integrated into the existing module structure and aligns with the PR goal of retrieving identities using public key hashes.

packages/rs-drive/src/drive/identity/mod.rs (1)

43-45: Module addition follows proper conventions

The new module for handling non-unique public key hash proofs is correctly added with proper conditionals (#[cfg(any(feature = "server", feature = "verify"))]) and includes clear documentation describing its purpose.

packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_id_by_unique_public_key_hash/v0/mod.rs (1)

68-68: Method name update reflects specificity for unique public key hashes

Changing the method call to verify_identity_id_by_unique_public_key_hash properly reflects the specific functionality of working with unique public key hashes. This aligns with adding support for non-unique public key hashes elsewhere in the codebase.

packages/rs-drive/src/drive/identity/identity_and_non_unique_public_key_hash_double_proof.rs (1)

1-21: Well-structured and documented proof struct

The new IdentityAndNonUniquePublicKeyHashDoubleProof struct is well-designed with:

  • Clear documentation explaining its purpose and fields
  • Appropriate field types (optional identity proof and required identity-to-hash proof)
  • Proper member visibility (pub)

This struct provides the necessary data structure to support identity verification using non-unique public key hashes.

packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs (1)

70-70: Field renamed to clarify operation on unique public key hashes

The field has been appropriately renamed from identity_by_public_key_hash to identity_by_unique_public_key_hash to explicitly indicate that this operates on unique public key hashes. This change maintains consistency with other renaming operations across the codebase as part of the implementation for handling non-unique public key hashes.

packages/rs-drive/src/verify/identity/verify_identity_ids_by_unique_public_key_hashes/v0/mod.rs (2)

40-40: Function renamed to clarify operation on unique public key hashes

The function has been appropriately renamed from verify_identity_ids_by_public_key_hashes_v0 to verify_identity_ids_by_unique_public_key_hashes_v0 to explicitly indicate that this verifies identity IDs based on unique public key hashes. This rename is consistent with the PR's purpose of adding support for handling non-unique public key hashes.


40-96:

❓ Verification inconclusive

Verify function call sites are updated

The function rename needs to be reflected at all call sites to prevent compilation errors. Make sure all references to this function have been updated throughout the codebase.


🏁 Script executed:

#!/bin/bash
# Check if there are any remaining references to the old function name
rg "verify_identity_ids_by_public_key_hashes_v0" --type rust

Length of output: 60


Action Required: Manual Verification of Function Call Sites

The recent search for references to the outdated function name (verify_identity_ids_by_public_key_hashes_v0) returned no matches, which indicates that the renaming appears to be correctly applied. However, since the search output was empty—potentially due to low-quality inference—please manually verify that all call sites throughout the codebase are using the updated name (verify_identity_ids_by_unique_public_key_hashes_v0). Specifically:

  • Confirm that no lingering references to the old function name exist.
  • Ensure that all call sites have been updated and that the code compiles without issues.
packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs (1)

55-55: Field renamed to clarify operation on unique public key hashes

The field has been appropriately renamed from identity_by_public_key_hash to identity_by_unique_public_key_hash to maintain consistency with the changes in other files. This rename is part of the broader effort to distinguish between unique and non-unique public key hash operations.

packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/v0/mod.rs (3)

36-36: Function renamed to clarify operation on unique public key hashes

The function has been appropriately renamed from verify_identity_id_by_public_key_hash_v0 to verify_identity_id_by_unique_public_key_hash_v0 to indicate that it verifies a single identity ID based on a unique public key hash. This change is consistent with the PR's focus on supporting operations with non-unique public key hashes.


42-42:

✅ Verification successful

Verify related query function is updated

This line calls identity_id_by_unique_public_key_hash_query, which appears to be the renamed version of a previous function. Make sure this query function is properly implemented and that its name has been updated throughout the codebase.


🏁 Script executed:

#!/bin/bash
# Find the implementation of the query function
rg "identity_id_by_unique_public_key_hash_query" --type rust -A 5

Length of output: 4843


Query Function Naming Verified

I confirmed that the function identity_id_by_unique_public_key_hash_query is consistently updated and referenced throughout the codebase. Its implementation in packages/rs-drive/src/drive/identity/fetch/queries/mod.rs is correctly invoked in all related modules, including the verify and prove components. No further modifications are needed.


36-90:

✅ Verification successful

Verify function call sites are updated

The function rename needs to be reflected at all call sites to prevent compilation errors. Make sure all references to this function have been updated throughout the codebase.


🏁 Script executed:

#!/bin/bash
# Check if there are any remaining references to the old function name
rg "verify_identity_id_by_public_key_hash_v0" --type rust

Length of output: 57


Below is an updated review comment. To further ensure the call sites are correct, please run an additional check for the new function name as well:

Ensure all call sites use verify_identity_id_by_unique_public_key_hash_v0

Our earlier search for the old name (verify_identity_id_by_public_key_hash_v0) returned no matches, suggesting that the deprecated name is no longer used. However, since the command did not provide output, please manually verify (or run the new script above) that all references have been correctly updated to call the new function. This will help prevent any potential compilation issues.


🏁 Script executed:

#!/bin/bash
# Check if there are any remaining references to the updated function name
rg "verify_identity_id_by_unique_public_key_hash_v0" --type rust

Length of output: 508


Ensure all references to the renamed function are correct

The investigation confirms that no references to the old function name (verify_identity_id_by_public_key_hash_v0) remain. The search shows that the updated name (verify_identity_id_by_unique_public_key_hash_v0) is correctly used both in the call sites and in its definition:

  • packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/mod.rs calls the function.
  • packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/v0/mod.rs contains the function definition.

There are no outdated usages, so the renaming appears to be applied consistently across the codebase.

packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/mod.rs (2)

2-2: Good addition of the new module for non-unique public key hash functionality.

The addition of this module aligns well with the broader changes to support identity fetching by non-unique public key hashes across the system.


74-77: Parameters correctly updated to match new function signature.

The function call has been properly updated to include the new optional parameters and now uses platform_version instead of drive_version, maintaining consistency with other similar functions in the codebase.

packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_unique_public_key_hash/v0/mod.rs (1)

90-90: Improved method naming for clarity and consistency.

Renaming from verify_full_identity_by_public_key_hash to verify_full_identity_by_unique_public_key_hash provides better clarity about the method's purpose and maintains consistency with the naming convention used throughout the codebase.

packages/rs-platform-version/src/version/mocks/v2_test.rs (1)

203-203: Field name updated for better precision and consistency.

Renaming from identity_by_public_key_hash to identity_by_unique_public_key_hash in the DriveAbciQueryIdentityVersions structure makes the field name more precise and consistent with other similar changes in the codebase. This improves code clarity by explicitly indicating that this field relates to unique public key hashes.

packages/rs-drive-abci/tests/strategy_tests/query.rs (1)

269-269: Method name updated for clarity and consistency.

The method call has been properly renamed from verify_full_identity_by_public_key_hash to verify_full_identity_by_unique_public_key_hash, maintaining consistency with similar naming updates throughout the codebase. This change improves code clarity by explicitly indicating the method is for verifying identities with unique public key hashes.

packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs (1)

46-51: Function call updated to match new naming convention

The function call has been correctly updated to use the new naming convention with "unique" qualifier, maintaining consistency with the function name change above.

packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/v1.rs (2)

30-30: Added new field for fetching identity by non-unique public key hash

The addition of this field is consistent with the PR's objective to implement functionality for retrieving identities using public key hashes.


62-62: Added new field for proving identity by non-unique public key hash

The addition of this field complements the fetch functionality by providing proof capabilities for non-unique public key hashes.

packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/mod.rs (4)

35-35: Path updated to use new naming convention

The path has been correctly updated to reflect the new naming convention.


44-45: Error message updated to use new naming convention

The error message has been correctly updated to match the new feature name.


55-59: Function call updated to use new naming convention

The function call has been correctly updated to reference the function with the "unique" qualifier.


6-10:

❓ Verification inconclusive

Import statements still use old naming convention

While the function and feature path references have been updated to include "unique", the import statements still use the old naming convention without the "unique" qualifier.

This suggests that either:

  1. The gRPC proto definitions haven't been updated, or
  2. The generated code hasn't been regenerated after proto updates.

This inconsistency could lead to runtime errors or confusion for developers. Either update the import statements to match the new naming convention or ensure that the proto definitions are correctly aligned with the implementation.


🏁 Script executed:

#!/bin/bash
# Check if the proto files have been updated to match the new naming convention

# Look for both old and new proto definitions
echo "Checking for old proto definitions:"
rg -A 2 "GetIdentityByPublicKeyHashRequest" packages/dapi-grpc/protos/

echo "Checking for new proto definitions:"
rg -A 2 "GetIdentityByUniquePublicKeyHashRequest" packages/dapi-grpc/protos/

Length of output: 1372


Action Required: Align Naming Conventions Between Code and Proto Definitions

It appears that the file
packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/mod.rs
still imports identifiers using the old naming (e.g., get_identity_by_public_key_hash_request::Version) even though the surrounding code and file/directory naming imply a move toward a “unique” naming scheme.

  • Findings:

    • The grep for GetIdentityByPublicKeyHashRequest in packages/dapi-grpc/protos/ shows that the proto definitions remain using the old naming convention.
    • No proto definitions were found for GetIdentityByUniquePublicKeyHashRequest, which confirms that the gRPC proto definitions have not been updated to reflect the new naming.
  • Recommendation:

    • Either: Update the gRPC proto definitions (and regenerate the associated code) to include the “unique” qualifier so that the imports and feature naming are aligned.
    • Or: Revisit the naming in the implementation (and possibly the file/directory names) so that they remain consistent with the current proto definitions and generated code.

Please verify the intended design in this part of the codebase and adjust accordingly.

packages/rs-drive-abci/src/query/identity_based_queries/identity_by_unique_public_key_hash/v0/mod.rs (4)

17-17: Function renamed to clarify uniqueness constraint

The function has been renamed from query_identity_by_public_key_hash_v0 to query_identity_by_unique_public_key_hash_v0 to explicitly indicate that it works with unique public key hashes. This change improves clarity and is part of the broader feature implementation.


94-95: Updated function call to match renamed method

The test code has been updated to use the renamed function, maintaining consistency throughout the codebase.


114-115: Updated function call to match renamed method

The test code has been updated to use the renamed function, maintaining consistency throughout the codebase.


134-135: Updated function call to match renamed method

The test code has been updated to use the renamed function, maintaining consistency throughout the codebase.

packages/rs-drive-abci/src/query/identity_based_queries/mod.rs (1)

6-7: Added modules for specialized public key hash handling

The single module identity_by_public_key_hash has been replaced with two specialized modules:

  • identity_by_non_unique_public_key_hash
  • identity_by_unique_public_key_hash

This change supports the new feature for retrieving identities by non-unique public key hashes, providing a clear separation of concerns.

packages/rs-drive/src/verify/identity/verify_identity_ids_by_unique_public_key_hashes/mod.rs (4)

39-40: Method renamed to clarify uniqueness constraint

The method has been renamed from verify_identity_ids_by_public_key_hashes to verify_identity_ids_by_unique_public_key_hashes to explicitly indicate that it works with unique public key hashes. This improves clarity and maintains consistency with other renamed methods.


52-53: Updated internal method reference

Internal reference to the method has been updated to match the renamed method.


54-55: Updated versioned method call

The versioned method call has been updated to match the renamed method.


61-62: Updated error message to match renamed method

The error message has been updated to reflect the renamed method, maintaining consistency in error reporting.

packages/rs-dapi-client/src/transport/grpc.rs (1)

493-500: Added support for retrieving identities by non-unique public key hash

This addition implements the TransportRequest trait for the new GetIdentityByNonUniquePublicKeyHashRequest and corresponding response types, enabling the gRPC client to handle requests for identity retrieval based on non-unique public key hashes. This is a key component of the new feature.

The implementation follows the established pattern used for other similar requests in the codebase.

packages/rs-drive/src/verify/identity/verify_identity_id_by_unique_public_key_hash/mod.rs (4)

36-41: Function renamed for enhanced clarity.

The function has been renamed from verify_identity_id_by_public_key_hash to verify_identity_id_by_unique_public_key_hash to explicitly indicate that it works with unique public key hashes. This naming change improves code clarity by distinguishing it from operations that work with non-unique public key hashes.


47-48: Method path updated to reflect new function name.

The method path in the platform version check has been correctly updated to use the new function name.


49-54: Function call correctly updated.

The internal function call has been properly updated to use the new v0 function name.


56-57: Error message updated for consistency.

The error message has been updated to reflect the new method name, which maintains consistency throughout the codebase.

packages/rs-drive/src/drive/identity/fetch/prove/prove_identity_ids_by_unique_public_key_hashes/v0/mod.rs (1)

92-97: Updated function call to use renamed method.

The call to verify_identity_ids_by_public_key_hashes has been correctly updated to verify_identity_ids_by_unique_public_key_hashes, maintaining consistency with the renaming pattern across the codebase.

packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/mod.rs (3)

39-43: Function renamed for enhanced clarity.

The function has been renamed from verify_full_identity_by_public_key_hash to verify_full_identity_by_unique_public_key_hash to explicitly indicate that it works with unique public key hashes.


51-55: Internal function call correctly updated.

The internal function call has been properly updated to the new v0 function name.


57-58: Error message updated for consistency.

The error message has been updated to reflect the new method name, maintaining consistency throughout the codebase.

packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/mod.rs (2)

98-99: Added support for fetching identities by non-unique public key hash.

A new field fetch_full_identity_by_non_unique_public_key_hash has been added to support fetching full identities using non-unique public key hashes. This enhances the system's capabilities for handling different types of public key hashes.


137-138: Added support for proving identities by non-unique public key hash.

A new field prove_full_identity_by_non_unique_public_key_hash has been added to support proving full identities using non-unique public key hashes. This complements the fetching capability and completes the feature implementation.

packages/dapi-grpc/build.rs (3)

66-66: Updated VERSIONED_REQUESTS array size properly

The array size in the constant definition has been correctly increased from 34 to 35 to accommodate the new request type.


78-78: New request type added successfully

The addition of GetIdentityByNonUniquePublicKeyHashRequest to the VERSIONED_REQUESTS array properly registers this request type for version tracking.


108-110: Helpful documentation added for custom proof handling

Good clarification about why GetIdentityByNonUniquePublicKeyHashResponse is excluded from versioned responses. The comment clearly explains it requires custom proof handling.

packages/rs-drive-abci/src/query/service.rs (2)

31-31: Correctly imported new request and response types

The necessary types for the new functionality have been properly imported.


415-425: Well-implemented new query method

The implementation of get_identity_by_non_unique_public_key_hash follows the established pattern in the codebase:

  1. Using the same method signature as other similar methods
  2. Properly utilizing the handle_blocking_query helper
  3. Passing the correct method reference and logging identifier

The method will integrate seamlessly with the existing query framework.

packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/mod.rs (3)

1-9: Good module organization and imports

The module structure and imports follow the project's conventions, including proper error handling and necessary dependencies.


10-24: Well-documented function

The function includes comprehensive documentation with:

  • A clear description of its purpose
  • Explanation of version dispatching
  • Detailed parameter descriptions
  • Return value documentation

This level of documentation helps maintainability and follows project standards.


25-52: Solid implementation with proper version handling

The function properly:

  1. Accepts appropriate parameters (public key hash, pagination options, transaction, platform version)
  2. Uses the version dispatching pattern consistently with other similar functions
  3. Handles unknown versions with descriptive error messages
  4. Returns the expected result type (Option)

The implementation is consistent with other version-aware methods in the codebase.

packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs (2)

24-25: Successfully renamed methods for clarity

The method names have been updated to clearly indicate they work with unique public key hashes:

  • verify_identity_id_by_public_key_hashverify_identity_id_by_unique_public_key_hash
  • verify_identity_ids_by_public_key_hashesverify_identity_ids_by_unique_public_key_hashes

This renaming enhances API clarity by being explicit about the uniqueness constraint.


31-32: Added new verification methods for non-unique keys

The two new verification methods for non-unique public key hashes complete the feature implementation:

  • verify_full_identity_by_non_unique_public_key_hash
  • verify_identity_id_by_non_unique_public_key_hash

These methods are initialized with version 0, consistent with other methods in this structure.

packages/rs-drive/src/drive/mod.rs (2)

264-269: Enablement under 'server' or 'verify' features looks correct
These lines appropriately widen the compilation scope to both "server" and "verify" features. The logic returning a simple static path appears fine.


281-287: Similar enablement for sub-tree path
No issues apparent with this added scope. The function signature and path construction are consistent with established patterns.

packages/rs-drive/src/verify/identity/verify_full_identities_by_public_key_hashes/v0/mod.rs (1)

51-56: Clarify whether public key hashes are unique or non-unique
The function is named verify_full_identities_by_public_key_hashes_v0, yet it calls verify_identity_ids_by_unique_public_key_hashes. Verify that strictly unique key hashes are intended.

packages/rs-sdk/src/platform/types/identity.rs (3)

12-12: New import for non-unique hash requests
Import statement is straightforward and correct.


35-36: Added enum variant for non-unique public key hash
Expanding the delegate enum with GetIdentityByNonUniquePublicKeyHash variants is consistent with the rest of the code.


79-108: Check keyhash length
This struct uses a 32-byte key hash, while other areas reference 20-byte hashes. If 32 bytes is intentional for non-unique keys, clarify this difference in documentation.

packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs (1)

14-50: Well-documented approach
The inline documentation is thorough and understandable, explaining proof usage and error handling. Good job.

packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/mod.rs (1)

13-37: Great documentation and parameter descriptions.

The doc comments provide a clear overview of the method’s purpose and usage. Including the meaning of each parameter, potential errors, and version handling is excellent for maintainability and clarity.

packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/mod.rs (1)

16-53: Good thorough documentation.

The descriptive comments unify expectations about the parameters, return values, and version constraints, promoting clarity for future maintainers and users of this API.

packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/mod.rs (1)

11-48: Well-structured doc comments.

The explanation of arguments and the expected proof content improves understanding. This clarity will help consumers interact accurately with the function and handle the returned proof appropriately.

packages/rs-drive/src/drive/identity/fetch/queries/mod.rs (2)

3-3: Confirm consistent usage of imported function.

The newly added import non_unique_key_hashes_tree_path_vec looks correctly referenced later in the file. No immediate concerns.


234-249: Ensure identity match consistency.

The merged query returns the full identity and also queries by non-unique public key hash. In scenarios where multiple identities share the hash, consider verifying that the returned identity_id matches the expected single identity in downstream logic.

Would you like to confirm downstream usage to ensure that mismatched results are handled properly?

packages/rs-drive/src/verify/identity/mod.rs (2)

3-4: Modules renamed to differentiate between unique and non-unique.

The addition of verify_full_identity_by_non_unique_public_key_hash and verify_full_identity_by_unique_public_key_hash appears consistent with broader naming.


10-12: Ensure correct separation of functionality.

Declaring separate modules for verify_identity_id_by_non_unique_public_key_hash, verify_identity_id_by_unique_public_key_hash, and verify_identity_ids_by_unique_public_key_hashes clarifies different verification pathways. No issues noted.

packages/rs-drive/src/verify/identity/verify_identity_id_by_non_unique_public_key_hash/v0/mod.rs (1)

1-70: Confirm single-result limit is intended.

This verification function sets a limit of one result for a non-unique key hash. Since multiple identities can theoretically share the same non-unique hash, confirm whether returning only the first match is desired.

Would you like a verification script or inline check to confirm that no downstream logic relies on multiple matching identities for the same hash?

packages/dapi-grpc/protos/platform/v0/platform.proto (1)

36-37: New RPC definition looks consistent.
The addition of getIdentityByNonUniquePublicKeyHash aligns with the existing pattern for identity-based RPC methods and follows naming conventions.

packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs (2)

1-16: Imports appear well-organized.
There are no immediate issues with these imports, and they seem consistent with the rest of the module’s usage.


17-46: Overall function structure is clear.
This function logically handles both public_key_hash and start_after checks, sets up either a proof or a fetched identity, then wraps the result in a QueryValidationResult. The approach cleanly separates proof vs. non-proof requests.

packages/rs-drive/src/drive/identity/fetch/prove/prove_full_identity_by_non_unique_public_key_hash/v0/mod.rs (2)

9-55: Method implements proof generation correctly.
The function correctly retrieves the first identity matching the provided non-unique key, builds proofs, and handles the no-result scenario by returning None. This design is straightforward and aligns with the rest of the Drive module.


56-220: Tests are robust and demonstrate correct functionality.
Both tests confirm behavior with multiple identities sharing a key and confirm proof correctness. This helps ensure the method behaves as expected in various usage scenarios.

packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_full_identity_by_non_unique_public_key_hash/v0/mod.rs (1)

13-28: Return behavior may be partial if multiple identities share the key hash.
This function fetches only one identity (the first match) for a potentially non-unique public key hash. Verify that returning a single identity is intentional rather than returning all associated identities.

packages/rs-drive-proof-verifier/src/proof.rs (3)

13-14: Imported requests appear consistent.
Adding get_identity_by_non_unique_public_key_hash_request aligns with the new functionality.


36-36: New import for double-proof structure.
Bringing in IdentityAndNonUniquePublicKeyHashDoubleProof supports the newly introduced verification logic.


330-344: Ensure unique key hash verification call is correct.
The code calls verify_full_identity_by_unique_public_key_hash. Confirm this aligns with the updated approach for unique key hashes and that all relevant usage sites are updated accordingly.

packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/mod.rs (4)

5-5: New import for Drive operations.
Usage of LowLevelDriveOperation is aligned with the rest of the module.


7-7: Platform version import is correct.
Inclusion of platform_version ensures consistent version-specific logic in this file.


27-33: Extended arguments for additional query options.
Introducing limit and after expands functionality for partial or paginated fetches. Confirm the calling code handles these Option parameters safely.


55-85: Operations-based variant parallels the main fetch method.
Mirrors the same version-check logic while allowing collection of drive operations. If this becomes more widely used, ensure future version handling is in place.

packages/rs-drive/src/drive/identity/fetch/fetch_by_public_key_hashes/fetch_identity_ids_by_non_unique_public_key_hash/v0/mod.rs (4)

11-11: Appropriate platform version integration

The dependency on PlatformVersion has been properly added and the parameter change from drive_version to platform_version has been consistently applied throughout the file. This is a good practice for maintaining version compatibility across the system.

Also applies to: 22-22, 31-31


19-20: Well-implemented pagination parameters

The addition of limit and after parameters provides essential pagination functionality for handling potentially large result sets. These parameters are consistently passed through from the public method to the operations method.

Also applies to: 27-28, 39-40


46-55: Properly implemented pagination logic

The pagination logic correctly handles the after parameter by using QueryItem::RangeAfter when specified, otherwise defaulting to QueryItem::RangeFull. The limit is also appropriately applied to the query. This implementation follows best practices for efficient database querying with pagination.


61-61: Consistent version handling

The code correctly uses the drive component from the platform version, ensuring that the appropriate version-specific functionality is used for database operations.

packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs (1)

45-46:

❓ Verification inconclusive

Well-structured addition of non-unique public key hash verification methods

The addition of methods for handling non-unique public key hashes is well-structured and follows the established pattern in the codebase. These new feature version fields align with the pagination-enabled fetch methods implemented in the first file.

Please ensure that these new methods are properly initialized in the version configuration to avoid potential null reference issues.


🏁 Script executed:

#!/bin/bash
# Check how these new feature versions are initialized in the platform version configurations
rg -A 5 "DriveVerifyIdentityMethodVersions" --type rust | grep -E "verify_full_identity_by_non_unique_public_key_hash|verify_identity_id_by_non_unique_public_key_hash"

Length of output: 167


ACTION REQUIRED: Manually Verify Feature Version Initialization

The new fields for handling non-unique public key hash verification are well-structured and align with the codebase’s established patterns. However, an automated search for their initialization in the platform version configurations did not return any results. Please manually verify that both

verify_full_identity_by_non_unique_public_key_hash
verify_identity_id_by_non_unique_public_key_hash

are properly initialized in all relevant version configuration files to avoid any potential null reference issues.

Comment on lines 49 to 50
.verify_full_identity_by_public_key_hash
{
Copy link
Contributor

@coderabbitai coderabbitai bot Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistency between renamed function and method path.

While the function has been renamed to verify_full_identity_by_unique_public_key_hash, the method path still references the old name verify_full_identity_by_public_key_hash. This inconsistency could lead to runtime errors or unexpected behavior.

match platform_version
    .drive
    .methods
    .verify
    .identity
-    .verify_full_identity_by_public_key_hash
+    .verify_full_identity_by_unique_public_key_hash
{
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.verify_full_identity_by_public_key_hash
{
match platform_version
.drive
.methods
.verify
.identity
.verify_full_identity_by_unique_public_key_hash
{

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QuantumExplorer or @shumkov , is it safe to rename field in DriveVerifyIdentityMethodVersions ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@lklimek lklimek changed the title Feat/get identities by public key hashes feat(sdk): get identities by non-unique public key hashes Mar 13, 2025
@lklimek lklimek marked this pull request as ready for review March 13, 2025 14:43
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs (1)

105-219: Add a positive test case to validate a successful identity retrieval.

Your current tests cover invalid inputs, identity not found, and proof absence scenarios, but do not confirm the behavior when an actual identity exists and is successfully retrieved. Adding this test would strengthen test coverage and help ensure correct functionality for normal (non-error) use cases.

packages/rs-sdk/src/platform/types/identity.rs (2)

79-84: Add explanatory documentation for the new struct.

While the struct name is self-descriptive, adding doc comments would help clarify use cases and expected behaviors, especially regarding the difference from unique public key hash queries.


88-90: Handle scenarios where proofs are not required or document rationale for the unimplemented state.

Currently, the code calls unimplemented! if prove == false. If future scenarios need queries without proofs, consider implementing partial handling or returning a descriptive error/early exit message to guide integrators.

packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs (1)

27-28: Consider unifying naming of the 'after' parameter with 'start_after'.

Throughout the codebase, similar functionality refers to this parameter as start_after. Consistent naming helps reduce confusion and align with the rest of the query logic.

packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs (1)

30-31: Align the naming to reflect non-unique public key hash usage.

The TODO highlights a potential mismatch in naming. Consider renaming or adding a new field instead of reusing “identity_by_unique_public_key_hash” to avoid confusion and improve clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 445d22b and 78dd427.

📒 Files selected for processing (16)
  • packages/dapi-grpc/build.rs (3 hunks)
  • packages/rs-dapi-client/src/transport/grpc.rs (1 hunks)
  • packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/mod.rs (1 hunks)
  • packages/rs-drive-abci/src/query/identity_based_queries/identity_by_non_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive-proof-verifier/src/proof.rs (28 hunks)
  • packages/rs-drive-verify-c-binding/src/lib.rs (3 hunks)
  • packages/rs-drive/Cargo.toml (2 hunks)
  • packages/rs-drive/src/drive/identity/fetch/queries/mod.rs (3 hunks)
  • packages/rs-drive/src/verify/identity/verify_full_identity_by_non_unique_public_key_hash/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs (2 hunks)
  • packages/rs-platform-version/Cargo.toml (1 hunks)
  • packages/rs-sdk/src/error.rs (1 hunks)
  • packages/rs-sdk/src/platform/query.rs (1 hunks)
  • packages/rs-sdk/src/platform/tokens/token_status.rs (1 hunks)
  • packages/rs-sdk/src/platform/types/identity.rs (3 hunks)
  • packages/rs-sdk/tests/fetch/identity.rs (2 hunks)
✅ Files skipped from review due to trivial changes (6)
  • packages/rs-sdk/src/platform/tokens/token_status.rs
  • packages/rs-sdk/src/error.rs
  • packages/rs-sdk/src/platform/query.rs
  • packages/rs-platform-version/Cargo.toml
  • packages/rs-drive/Cargo.toml
  • packages/rs-drive-verify-c-binding/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/rs-dapi-client/src/transport/grpc.rs
  • packages/rs-sdk/tests/fetch/identity.rs
  • packages/dapi-grpc/build.rs
  • packages/rs-drive/src/verify/identity/verify_full_identity_by_unique_public_key_hash/v0/mod.rs
  • packages/rs-drive/src/drive/identity/fetch/queries/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (rs-dapi-client) / Tests
  • GitHub Check: Rust packages (rs-dapi-client) / Check each feature
  • GitHub Check: Rust packages (rs-dapi-client) / Linting
  • GitHub Check: Rust packages (dapi-grpc) / Linting
  • GitHub Check: Rust packages (dapi-grpc) / Check each feature
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (dapi-grpc) / Tests
  • GitHub Check: Rust packages (drive-abci) / Linting
  • GitHub Check: Rust packages (drive-abci) / Check each feature
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
🔇 Additional comments (7)
packages/rs-drive-proof-verifier/src/proof.rs (7)

18-21: Good organization of imports

The expanded import group nicely contains all the related GRPC request and response types, including the new non-unique public key hash related types. The organization makes the code more maintainable.


42-42: Appropriate import for new proof type

The IdentityAndNonUniquePublicKeyHashDoubleProof import matches the functionality being added for handling non-unique public key hash verification.


329-334: Method rename properly distinguishes between unique and non-unique keys

The implementation now uses verify_full_identity_by_unique_public_key_hash instead of verify_full_identity_by_public_key_hash, which provides a clear separation between unique and non-unique public key hash verification flows.


342-432: Well-structured implementation for non-unique public key hash verification

The implementation for retrieving identities by non-unique public key hash is comprehensive and properly structured. It handles:

  1. Different proof structure with appropriate error handling
  2. Extraction and validation of public key hash and optional start_after parameter
  3. Construction of a specialized IdentityAndNonUniquePublicKeyHashDoubleProof
  4. Proper verification flow with both Drive and Tenderdash proofs

A few observations:

  • The code includes a commented line (359) that explains the different proof structure, which is helpful for maintainers
  • Error handling is detailed with specific messages for different failure cases
  • The implementation appropriately handles the pagination parameter (start_after) for scenarios where multiple identities match the same public key hash

379-397: Good parameter validation with clear error messages

The code thoroughly validates input parameters with descriptive error messages:

  1. Public key hash length validation
  2. Optional start_after parameter validation

This ensures proper input sanitization before processing the request.


401-408: Well-structured conversion to specialized proof type

The code properly constructs the IdentityAndNonUniquePublicKeyHashDoubleProof from the response, handling the different structure of proofs for non-unique public key hashes.


418-426: Comprehensive error mapping

The error handling uses pattern matching to specifically handle GroveDB errors with detailed context (including proof bytes, height, and time), while letting other error types pass through the standard conversion mechanism.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/rs-drive/src/drive/identity/fetch/queries/mod.rs (1)

235-250: Enhance documentation for clarity on non-unique key behavior

While the method follows the same pattern as full_identity_with_public_key_hash_query, the documentation could be improved to better explain how it handles non-uniqueness - specifically whether it returns multiple identity matches or just one, and how the after parameter affects pagination through results.

Consider updating the documentation to:

-    /// This query gets the full identity and the public key hash
+    /// This query gets the full identity and the non-unique public key hash
+    /// 
+    /// For non-unique public key hashes, multiple identities may share the same hash.
+    /// The `after` parameter can be used for pagination through the results.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78dd427 and dbad665.

📒 Files selected for processing (2)
  • packages/rs-drive/src/drive/identity/fetch/queries/mod.rs (3 hunks)
  • packages/rs-sdk/tests/fetch/identity.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (dpp) / Formatting
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dapi-grpc) / Tests
  • GitHub Check: Rust packages (dapi-grpc) / Linting
  • GitHub Check: Rust packages (dapi-grpc) / Check each feature
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build JS packages / Build JS
🔇 Additional comments (2)
packages/rs-sdk/tests/fetch/identity.rs (1)

120-177: Test implementation now correctly tests the new functionality

The test now properly validates fetching identities by non-unique public key hash, which is an improvement over the previous implementation. It correctly loops through each public key of an identity, fetches associated identities using the non-unique public key hash, and verifies that at least one identity is found.

Some suggestions for further improvement:

  1. Verify that the original identity is among the fetched results
  2. Consider adding a more descriptive comment explaining what makes public keys "non-unique"
  3. If possible, consider implementing a method to fetch all matching identities at once rather than using pagination in the test
         let mut count = 0;
+        let mut found_original_identity = false;
         while let Some(found) = Identity::fetch(&sdk, query)
             .await
             .expect("fetch identities by non-unique key hash")
         {
             count += 1;
+            if found.id() == identity.id() {
+                found_original_identity = true;
+            }
             tracing::debug!(
                 ?found,
                 ?key_hash,
                 ?count,
                 "fetched identities by non-unique public key hash"
             );

             query = NonUniquePublicKeyHashQuery {
                 key_hash,
                 after: Some(*found.id().as_bytes()),
             };
         }
         assert_ne!(
             count, 0,
             "no identities found by non-unique public key hash"
         );
+        assert!(
+            found_original_identity,
+            "original identity should be found among results"
+        );
packages/rs-drive/src/drive/identity/fetch/queries/mod.rs (1)

94-110: Address the TODO comment on line 105

The TODO comment "why not limit 1?" suggests an unresolved design question about query limiting. For non-unique public key hashes, it's important to consider whether all matching identities should be returned (current implementation) or just the first one (which would justify setting limit to 1).

The decision impacts performance and behavior. Please clarify the intended behavior - do you expect multiple identity IDs to be returned from a single non-unique public key hash, or should only the first result be returned?

Additionally, consider documenting the after parameter more clearly to explain its pagination purpose and expected value format.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/rs-sdk/tests/fetch/identity.rs (1)

120-181: Test implementation has been significantly improved

The test function now correctly tests the new functionality for fetching identities by non-unique public key hash. The implementation:

  1. Fetches an existing identity
  2. Filters for non-unique public keys
  3. Tests each non-unique key by fetching identities associated with it
  4. Properly implements pagination with the after parameter
  5. Verifies that at least one identity is returned for each non-unique key

This addresses the previous feedback and provides good test coverage for the new feature.

One suggestion for future improvement: consider verifying that the original identity is included in the results, which would provide additional validation of the functionality.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbad665 and 8e484e8.

📒 Files selected for processing (2)
  • packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs (1 hunks)
  • packages/rs-sdk/tests/fetch/identity.rs (2 hunks)
🔇 Additional comments (1)
packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs (1)

111-114: Well implemented addition of non-unique keys for identity testing

The changes properly implement test data generation for the new feature of retrieving identities by non-unique public key hashes. By creating a single non_unique_key with a fixed seed and adding it to all identities, you've ensured that multiple identities will share the same public key hash, which is exactly what's needed to test the new query functionality.

The code is well-commented, making the intent clear. This approach creates consistent test data that can be reliably used across test runs due to the fixed seed.

Also applies to: 122-124

@lklimek lklimek changed the base branch from v2.0-dev to feat/getIdentitiesByPublicKeyHashes1 March 17, 2025 14:29
@lklimek lklimek changed the base branch from feat/getIdentitiesByPublicKeyHashes1 to v2.0-dev March 17, 2025 15:03
@QuantumExplorer
Copy link
Member

replaced by #2507

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants