Skip to content

Conversation

pauldelucia
Copy link
Member

@pauldelucia pauldelucia commented Oct 16, 2025

Issue being fixed or feature implemented

Fetch specific identity keys via Identity ID + Key IDs with optional limit and offset.

What was done?

Created an IdentityKeysQuery struct and implemented query on it.

How Has This Been Tested?

DET

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

    • Added the ability to request specific identity public keys by ID, with optional pagination (limit & offset).
    • Public API expanded to expose targeted identity-key fetching for client use.
  • Tests

    • Added a test verifying fetching a subset of identity keys returns exactly the requested keys and no extras.
    • Added corresponding test vector data to support the new test.

Copy link

github-actions bot commented Oct 16, 2025

✅ gRPC Query Coverage Report

================================================================================
gRPC Query Coverage Report - NEW QUERIES ONLY
================================================================================

Total queries in proto: 47
Previously known queries: 47
New queries found: 0


================================================================================
Summary:
--------------------------------------------------------------------------------
No new queries found

Total known queries: 47
  - Implemented: 44
  - Not implemented: 2
  - Excluded: 1

Not implemented queries:
  - getConsensusParams
  - getTokenPreProgrammedDistributions

Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Walkthrough

Adds a public IdentityKeysQuery to request specific identity keys by key IDs (with optional limit/offset); it implements Query to produce a proof-based proto::GetIdentityKeysRequest using the SpecificKeys variant and is exported from the platform module.

Changes

Cohort / File(s) Summary
Query type implementation
packages/rs-sdk/src/platform/query.rs
Adds IdentityKeysQuery (fields: identity_id: Identifier, key_ids: Vec<KeyID>, limit: Option<u32>, offset: Option<u32>), new, with_limit, with_offset, and impl Query<proto::GetIdentityKeysRequest> which builds a GetIdentityKeysRequest with SpecificKeys (converting key IDs to u32) when prove == true (returns an error for non-proof queries).
Public API export
packages/rs-sdk/src/platform.rs
Re-exports IdentityKeysQuery from the query module, expanding the public platform API surface.
Tests
packages/rs-sdk/tests/fetch/identity.rs
Adds test_identity_public_keys_specific_read which selects up to two key IDs, issues an IdentityKeysQuery for them, and asserts returned keys match the requested subset and count.
Test vectors
packages/rs-sdk/tests/vectors/test_identity_public_keys_specific_read/...quorum_pubkey-106-*.json
Adds a JSON test vector containing a single 128-character hex quorum public key string used by the new test.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant IdentityKeysQuery
  participant QueryImpl as Query<proto::GetIdentityKeysRequest>
  participant Proto as proto::GetIdentityKeysRequest

  Client->>IdentityKeysQuery: IdentityKeysQuery::new(identity_id, key_ids)
  Client->>QueryImpl: query(prove = true)
  QueryImpl->>IdentityKeysQuery: read identity_id, key_ids, limit, offset
  QueryImpl->>Proto: build GetIdentityKeysRequest { SpecificKeys(key_ids -> u32), pagination? }
  Proto-->>Client: return proof GetIdentityKeysRequest

  alt prove == false
    Client->>QueryImpl: query(prove = false)
    QueryImpl-->>Client: return Error (non-proof queries not supported)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through fields and IDs tonight,
Picked two bright keys by soft starlight,
I stitched a proofed request with care,
Sent only what you asked to share,
A nibble, a hop — request is fair.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feat(rs-sdk): identity keys query" directly and clearly describes the main change in the changeset. The PR introduces a new IdentityKeysQuery type to fetch specific identity keys by Identity ID and Key IDs, and the title accurately captures this feature addition using concise, descriptive language. The title follows conventional commit format, is free of vague terms or noise, and provides sufficient clarity for a developer scanning commit history to understand the core change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/proof-data-sdk

📜 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 736a488 and 043730c.

📒 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. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • 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: Rust packages (dash-sdk) / Formatting
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Build JS packages / Build JS

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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/src/platform/query.rs (1)

187-237: Well-structured query type following existing patterns.

The IdentityKeysQuery struct and its builder methods follow the established patterns in this file consistently. The documentation is clear and includes a helpful example.

Optional: Consider validating that key_ids is not empty in the constructor to provide earlier feedback:

 pub fn new(identity_id: Identifier, key_ids: Vec<KeyID>) -> Self {
+    assert!(!key_ids.is_empty(), "key_ids cannot be empty");
     Self {
         identity_id,
         key_ids,
         limit: None,
         offset: None,
     }
 }

However, this validation may be intentionally deferred to the backend or a higher layer.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 855135d and d5bffe2.

📒 Files selected for processing (1)
  • packages/rs-sdk/src/platform/query.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Format Rust code with cargo fmt
Run Clippy linter for Rust code

Files:

  • packages/rs-sdk/src/platform/query.rs
packages/rs-*/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

packages/rs-*/**/*.rs: Use rustfmt defaults for Rust code (format via cargo fmt --all)
Keep Rust code clippy-clean (cargo clippy)
Name Rust modules in snake_case
Use PascalCase for Rust types
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/rs-sdk/src/platform/query.rs
🧠 Learnings (1)
📓 Common learnings
Learnt from: thephez
PR: dashpay/platform#2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.
🧬 Code graph analysis (1)
packages/rs-sdk/src/platform/query.rs (1)
packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts (5)
  • KeyRequestType (812-837)
  • SpecificKeys (870-884)
  • GetIdentityKeysRequest (937-952)
  • Version (5599-5618)
  • GetIdentityKeysRequestV0 (959-991)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • 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 JS packages / Build JS
  • GitHub Check: Swift SDK and Example build (warnings as errors)
🔇 Additional comments (2)
packages/rs-sdk/src/platform/query.rs (2)

26-26: LGTM!

The new imports (SpecificKeys and KeyID) are necessary for the IdentityKeysQuery implementation and are placed appropriately with related imports.

Also applies to: 34-34


239-264: Type compatibility verified—no issues found.

The implementation correctly handles type conversion. KeyID is a u32 type alias, and SpecificKeys.key_ids expects Vec<u32> (from the protobuf definition repeated uint32 key_ids). The .into_iter().collect() at line 256 correctly transforms the collection without any type inference issues.

Copy link
Contributor

@lklimek lklimek left a comment

Choose a reason for hiding this comment

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

Please add a test

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)

125-125: Consider test naming convention (optional).

The coding guidelines suggest naming tests starting with "should …", but this test follows the existing test_ prefix pattern used throughout the file. While consistency with the current codebase is valuable, you may want to verify whether the guidelines apply strictly to Rust tests or are primarily for JS/TS tests.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5bffe2 and 61b2668.

📒 Files selected for processing (2)
  • packages/rs-sdk/tests/fetch/identity.rs (2 hunks)
  • packages/rs-sdk/tests/vectors/test_identity_public_keys_specific_read/quorum_pubkey-106-1f0a25d463a2912cd31dd4f91b899a143d6ae990bb9bc89cb34f7c5db8b1b705.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
packages/**/tests/**

📄 CodeRabbit inference engine (AGENTS.md)

Place unit and integration tests alongside each package in packages//tests

Files:

  • packages/rs-sdk/tests/vectors/test_identity_public_keys_specific_read/quorum_pubkey-106-1f0a25d463a2912cd31dd4f91b899a143d6ae990bb9bc89cb34f7c5db8b1b705.json
  • packages/rs-sdk/tests/fetch/identity.rs
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Format Rust code with cargo fmt
Run Clippy linter for Rust code

Files:

  • packages/rs-sdk/tests/fetch/identity.rs
packages/rs-*/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

packages/rs-*/**/*.rs: Use rustfmt defaults for Rust code (format via cargo fmt --all)
Keep Rust code clippy-clean (cargo clippy)
Name Rust modules in snake_case
Use PascalCase for Rust types
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/rs-sdk/tests/fetch/identity.rs
packages/**/tests/**/*.{js,ts,jsx,tsx,rs}

📄 CodeRabbit inference engine (AGENTS.md)

packages/**/tests/**/*.{js,ts,jsx,tsx,rs}: Name tests descriptively, starting with “should …”
Unit/integration tests must not perform network calls; mock dependencies instead

Files:

  • packages/rs-sdk/tests/fetch/identity.rs
🧠 Learnings (1)
📚 Learning: 2024-10-30T11:19:59.163Z
Learnt from: lklimek
PR: dashpay/platform#2277
File: packages/rs-sdk/tests/fetch/config.rs:233-233
Timestamp: 2024-10-30T11:19:59.163Z
Learning: In the Rust SDK's `rs-sdk/tests` integration tests (e.g., in `packages/rs-sdk/tests/fetch/config.rs`), we cannot create objects during tests because there is no support for object creation in this context. Therefore, hardcoded values for test identities must be used.

Applied to files:

  • packages/rs-sdk/tests/fetch/identity.rs
🧬 Code graph analysis (1)
packages/rs-sdk/tests/fetch/identity.rs (2)
packages/rs-drive-proof-verifier/src/proof.rs (2)
  • identity (509-513)
  • identity (515-519)
packages/rs-sdk/src/platform/types/identity.rs (8)
  • query (40-51)
  • query (62-76)
  • query (87-106)
  • query (110-123)
  • query (127-142)
  • query (148-165)
  • query (169-181)
  • query (185-198)
🪛 Biome (2.1.2)
packages/rs-sdk/tests/vectors/test_identity_public_keys_specific_read/quorum_pubkey-106-1f0a25d463a2912cd31dd4f91b899a143d6ae990bb9bc89cb34f7c5db8b1b705.json

[error] 1-1: String values must be double quoted.

(parse)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (dash-sdk) / 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: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
🔇 Additional comments (3)
packages/rs-sdk/tests/fetch/identity.rs (2)

2-2: LGTM: Imports are appropriate.

The new imports support the specific identity keys query functionality:

  • IdentityKeysQuery for building the query
  • IdentityPublicKeys for offline test mocking
  • BTreeSet for efficient membership checking

All imports are properly used and the cfg attribute correctly limits IdentityPublicKeys to offline-testing scenarios.

Also applies to: 8-10


126-212: LGTM: Test logic is thorough and correct.

The test properly validates the specific key fetch functionality:

  • Safely handles edge cases (identities with 1-3+ keys via take(3))
  • Validates both presence and correctness of fetched keys
  • Ensures no unrequested keys are returned
  • Properly configures mocks for offline testing

The validation strategy is comprehensive, checking count, individual key correctness, and absence of unexpected keys.

packages/rs-sdk/tests/vectors/test_identity_public_keys_specific_read/quorum_pubkey-106-1f0a25d463a2912cd31dd4f91b899a143d6ae990bb9bc89cb34f7c5db8b1b705.json (1)

1-1: The file format is intentional and consistent with the project's test vector framework.

The script output confirms that files named quorum_pubkey-*.json throughout the test vectors directory contain raw hex strings without JSON formatting. This is not an error but an established pattern in the codebase. Per the project's documented learnings, test vector .json files may intentionally not follow standard JSON format—this is acceptable within the testing framework.

The file in question follows the same pattern as 80+ other similar test vector files and should not be modified.

Likely an incorrect or invalid review comment.

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)

123-148: Test setup and key selection logic are sound.

The test follows the established patterns in this file and correctly fetches all keys before selecting a subset. The take(3) safely handles identities with fewer keys.

Minor: Redundant assertion (lines 145-148).

Since line 139 already asserts all_public_keys is not empty, and requested_key_ids is derived from all_public_keys.keys(), the assertion on lines 145-148 is guaranteed to pass and can be removed.

-    assert!(
-        !requested_key_ids.is_empty(),
-        "expected to select at least one key id"
-    );
-
     let query = IdentityKeysQuery::new(identity_id, requested_key_ids.clone());
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61b2668 and 736a488.

📒 Files selected for processing (1)
  • packages/rs-sdk/tests/fetch/identity.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Format Rust code with cargo fmt
Run Clippy linter for Rust code

Files:

  • packages/rs-sdk/tests/fetch/identity.rs
packages/rs-*/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

packages/rs-*/**/*.rs: Use rustfmt defaults for Rust code (format via cargo fmt --all)
Keep Rust code clippy-clean (cargo clippy)
Name Rust modules in snake_case
Use PascalCase for Rust types
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/rs-sdk/tests/fetch/identity.rs
packages/**/tests/**

📄 CodeRabbit inference engine (AGENTS.md)

Place unit and integration tests alongside each package in packages//tests

Files:

  • packages/rs-sdk/tests/fetch/identity.rs
packages/**/tests/**/*.{js,ts,jsx,tsx,rs}

📄 CodeRabbit inference engine (AGENTS.md)

packages/**/tests/**/*.{js,ts,jsx,tsx,rs}: Name tests descriptively, starting with “should …”
Unit/integration tests must not perform network calls; mock dependencies instead

Files:

  • packages/rs-sdk/tests/fetch/identity.rs
🧠 Learnings (1)
📚 Learning: 2024-10-30T11:19:59.163Z
Learnt from: lklimek
PR: dashpay/platform#2277
File: packages/rs-sdk/tests/fetch/config.rs:233-233
Timestamp: 2024-10-30T11:19:59.163Z
Learning: In the Rust SDK's `rs-sdk/tests` integration tests (e.g., in `packages/rs-sdk/tests/fetch/config.rs`), we cannot create objects during tests because there is no support for object creation in this context. Therefore, hardcoded values for test identities must be used.

Applied to files:

  • packages/rs-sdk/tests/fetch/identity.rs
🧬 Code graph analysis (1)
packages/rs-sdk/tests/fetch/identity.rs (1)
packages/rs-drive-proof-verifier/src/proof.rs (2)
  • identity (509-513)
  • identity (515-519)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • 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: Rust crates security audit
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Swift SDK and Example build (warnings as errors)
🔇 Additional comments (3)
packages/rs-sdk/tests/fetch/identity.rs (3)

2-2: LGTM!

The new imports are necessary and properly scoped. The IdentityKeysQuery supports the new query functionality, and the conditional IdentityPublicKeys import is appropriately cfg-gated for offline testing.

Also applies to: 7-10


150-169: LGTM!

The query construction and offline-testing mock setup are correct. The expected subset is properly built by mapping requested key IDs to their corresponding values from the full key set, and the mock is appropriately feature-gated.


171-212: Excellent verification logic!

The test performs comprehensive validation:

  • Verifies count matches requested key IDs (lines 175-179)
  • Confirms each fetched key matches the expected key from the full set (lines 183-199)
  • Ensures no unrequested keys are included (lines 201-211)

The use of BTreeSet for efficient membership checks and proper Option handling with .and_then(|value| value.as_ref()) demonstrate careful implementation.

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