Skip to content

feat(platform): add the getIdentityKeysRemainingBudgets query - #4802

Merged
QuantumExplorer merged 6 commits into
v4.2-devfrom
feat/identity-key-remaining-budget-query
Sep 17, 2026
Merged

QuantumExplorer merged 6 commits into
v4.2-devfrom
feat/identity-key-remaining-budget-query

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Sep 17, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

#4798 (merged) lets an AUTHENTICATION key carry a budget. What is left of it lives in Drive, next to the immutable key, and nothing could read it: a client only learned that a key was spent by being refused (20015 / 40218). This was the first follow-up listed in #4798.

This adds getIdentityKeysRemainingBudgets, proved and unproved, from Drive up to js-evo-sdk.

What was done?

The query

  • Request: identity_id, key_ids (at least one, none repeated, at most max_returned_elements), prove.
  • Response: one entry per requested key id. remaining_budget is set for a key with a budget (0 means spent) and unset for a key without a budget or a key that does not exist. The query reads the budgets subtree only; getIdentityKeys tells the last two apart.
  • The answer is the state of the last committed block, so it is an upper bound on what the next transition can spend, not a reservation.

Drive (rs-drive)

  • identity_keys_remaining_budgets_query: path [Identities, identity_id, IdentityTreeKeyBudgets], one query item per key id, limited to their count.
  • fetch_identity_keys_remaining_budgets, prove_identity_keys_remaining_budgets (new keys.budget slots, None before protocol version 14, which is what refuses the query there), and verify_identity_keys_remaining_budgets (verify feature, verify_query_with_absence_proof, generic over FromIterator<(KeyID, Option<Credits>)>).
  • "No budget" is provable in every shape state can have: an entry, an absent entry in an existing subtree, and an absent subtree (an identity that never had a budgeted key; the subtree is created lazily).

Node and transport

  • platform.proto rpc and messages, dapi-grpc build lists, .github/grpc-queries-cache.json, regenerated clients (purely additive: two messages and the rpc).
  • rs-drive-abci: query_identity_keys_remaining_budgets v0 and the service method. Argument errors are InvalidArgument / InvalidLimit, never internal errors.
  • rs-dapi routing and metrics allowlist, rs-dapi-client transport.

Clients

  • rs-drive-proof-verifier: IdentityKeysRemainingBudgets(RetrievedObjects<KeyID, Credits>), FromProof and FromUnproved.
  • rs-sdk: IdentityKeysRemainingBudgetsQuery { identity_id, key_ids }, Fetch and FetchUnproved, mock support.
  • wasm-sdk: getIdentityKeysRemainingBudgets(identityId, keyIds) and ...WithProofInfo, returning Map<number, bigint | null> with every requested key present. Key ids that are not whole numbers a key id can hold are refused instead of being wrapped into another key's id.
  • js-evo-sdk: sdk.identities.keysRemainingBudgets and keysRemainingBudgetsWithProof.

Docs: a "Reading What Is Left" section (with a diagram of the three proof outcomes) in book/src/data-model/key-limits.md, the protocol reference, the DAPI endpoint list and the wasm-sdk README. Also fixes a stale budget field name in the Drive module header left over from the total_budget rename in #4798.

Not included: Swift and Kotlin bindings, and SDK key selection that skips a spent or expired key (it now has the query it needs).

How Has This Been Tested?

  • rs-drive drive::identity::key::budget (remaining_budgets_query): budgeted keys next to unbudgeted ones, a missing subtree, a nonexistent identity, fetch and prove agree, a proof never verifies to an answer that is not in state, and a value forged inside a proof no longer verifies against the state root. cargo test -p drive --lib -- drive::identity:: (306 pass).
  • rs-drive-abci handler tests: answers and proofs for a seeded identity, the argument refusals, and the protocol version 13 refusal. cargo test -p drive-abci --lib -- query:: (714 pass).
  • rs-drive-proof-verifier: request parsing and the unproved mapping (--all-features, 303 pass).
  • rs-sdk: a mock round trip that keeps Some(0) and None apart (--features mocks,offline-testing); a network test against unbudgeted keys is ignored offline until vectors are recorded, since no identity on the test network holds a budgeted key yet.
  • js-evo-sdk: facade unit specs added.
  • Full suites of rs-dapi, rs-dapi-client, dapi-grpc, platform-version.
  • cargo fmt --all -- --check, cargo clippy ... --all-targets -- -D warnings over the touched Rust crates, cargo clippy -p wasm-sdk --target wasm32-unknown-unknown, cargo check --workspace --all-targets.
  • Not run locally: JS lint, build and unit tests (no node_modules in this checkout), and the wasm-sdk functional tests.

Breaking Changes

None. A new query; nothing in consensus changes. The Drive methods behind it are inactive before protocol version 14.

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added queries to retrieve remaining signing budgets for multiple identity keys.
    • Results distinguish remaining credits, spent keys (0), and keys without budgets or nonexistent keys.
    • Added optional proof-enabled responses for verified results.
    • Added support across Rust, WebAssembly, JavaScript, and platform API clients.
  • Documentation

    • Documented query parameters, validation, proof behavior, SDK usage, and committed-state semantics.
  • Tests

    • Added coverage for validation, budget results, absence handling, and proof verification.

QuantumExplorer and others added 6 commits September 17, 2026 23:13
…y keys

One identity, several key ids, the remaining budget of each or none. The
path query is shared by the prover and the verifier and is available to the
verify-only build. A key without a budget, an identity that was never given
a budgeted key (no subtree) and an identity that does not exist all prove as
absent.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
One identity and at least one key id, not repeated and at most
max_returned_elements of them; answers the remaining budget of each key, or
none for a key without a budget, with or without a proof. Before protocol
version 14 it answers with an error rather than failing internally.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Routes getIdentityKeysRemainingBudgets through rs-dapi, adds the gRPC transport,
the proved and unproved response parsing, and IdentityKeysRemainingBudgets with
Fetch and FetchUnproved in the Rust SDK, mock support included.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Adds getIdentityKeysRemainingBudgets (and its proof info variant) to wasm-sdk,
identities.keysRemainingBudgets to js-evo-sdk, and documents the query in the
key limits chapter, the protocol reference and the DAPI endpoint list.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ader

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…Budgets

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

📖 Book Preview built successfully.

Download the preview from the workflow artifacts.
To view locally: download the artifact, unzip, and open index.html.

Updated at 2026-09-17T16:15:55.102Z

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: fe4abeb2-a279-4e7e-b2ac-3fe5492220a5

📥 Commits

Reviewing files that changed from the base of the PR and between 772f3d6 and db7c216.

📒 Files selected for processing (62)
  • .github/grpc-queries-cache.json
  • book/src/data-model/key-limits.md
  • docs/protocol/authentication-key-limits.md
  • packages/dapi-grpc/build.rs
  • packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js
  • packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java
  • packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js
  • packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m
  • packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py
  • packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb.js
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js
  • packages/dapi-grpc/protos/platform/v0/platform.proto
  • packages/dapi/doc/endpoints/index.md
  • packages/js-evo-sdk/src/identities/facade.ts
  • packages/js-evo-sdk/tests/unit/facades/identities.spec.ts
  • packages/rs-dapi-client/src/transport/grpc.rs
  • packages/rs-dapi/src/metrics.rs
  • packages/rs-dapi/src/services/platform_service/mod.rs
  • packages/rs-drive-abci/src/query/identity_based_queries/keys_remaining_budgets/mod.rs
  • packages/rs-drive-abci/src/query/identity_based_queries/keys_remaining_budgets/v0/mod.rs
  • packages/rs-drive-abci/src/query/identity_based_queries/mod.rs
  • packages/rs-drive-abci/src/query/service.rs
  • packages/rs-drive-proof-verifier/src/proof.rs
  • packages/rs-drive-proof-verifier/src/proof/identity_keys_remaining_budgets.rs
  • packages/rs-drive-proof-verifier/src/types.rs
  • packages/rs-drive-proof-verifier/src/types/identity_keys_remaining_budgets.rs
  • packages/rs-drive-proof-verifier/src/unproved.rs
  • packages/rs-drive/src/drive/identity/fetch/queries/mod.rs
  • packages/rs-drive/src/drive/identity/key/budget/fetch_identity_keys_remaining_budgets/mod.rs
  • packages/rs-drive/src/drive/identity/key/budget/fetch_identity_keys_remaining_budgets/v0/mod.rs
  • packages/rs-drive/src/drive/identity/key/budget/mod.rs
  • packages/rs-drive/src/drive/identity/key/budget/prove_identity_keys_remaining_budgets/mod.rs
  • packages/rs-drive/src/drive/identity/key/budget/prove_identity_keys_remaining_budgets/v0/mod.rs
  • packages/rs-drive/src/drive/identity/mod.rs
  • packages/rs-drive/src/verify/identity/mod.rs
  • packages/rs-drive/src/verify/identity/verify_identity_keys_remaining_budgets/mod.rs
  • packages/rs-drive/src/verify/identity/verify_identity_keys_remaining_budgets/v0/mod.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v0.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/v1.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/v2.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs
  • packages/rs-platform-version/src/version/mocks/v2_test.rs
  • packages/rs-sdk/src/mock/requests.rs
  • packages/rs-sdk/src/mock/sdk.rs
  • packages/rs-sdk/src/platform.rs
  • packages/rs-sdk/src/platform/identity_keys_remaining_budgets.rs
  • packages/rs-sdk/src/platform/query.rs
  • packages/rs-sdk/tests/fetch/identity_keys_remaining_budgets.rs
  • packages/rs-sdk/tests/fetch/mod.rs
  • packages/wasm-sdk/README.md
  • packages/wasm-sdk/src/queries/identity.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Identity key remaining-budgets query

Layer / File(s) Summary
Protocol contract and generated bindings
packages/dapi-grpc/protos/..., packages/dapi-grpc/clients/..., packages/dapi-grpc/build.rs
Added the versioned request, response, result entries, proof option, and unary RPC. Regenerated Java, Node.js, Objective-C, Python, and web bindings.
Drive lookup, proof generation, and verification
packages/rs-drive/..., packages/rs-platform-version/...
Added budget-path queries, fetch and proof methods, absence-proof verification, version slots, and Drive tests.
ABCI query validation and service wiring
packages/rs-drive-abci/..., packages/rs-dapi/..., packages/rs-dapi-client/...
Added request validation, protocol gating, fetch and proof response paths, service delegation, transport mapping, endpoint metrics, and endpoint documentation.
Proof verifier and Rust SDK support
packages/rs-drive-proof-verifier/..., packages/rs-sdk/...
Added proof and unproved response decoding, the IdentityKeysRemainingBudgets type, Rust SDK query traits, mock support, and fetch tests.
WASM and JavaScript SDK APIs
packages/wasm-sdk/..., packages/js-evo-sdk/...
Added map and proof-metadata APIs. WASM validates key IDs and maps absent budgets to null. JavaScript facade methods forward both query forms.
Documentation and query metadata
.github/..., book/..., docs/...
Documented query semantics, validation, proofs, committed-state results, protocol slots, SDK coverage, and remaining SDK limitations.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to db7c2

No concrete merge-blocking issue remains; the generated client follows the repository’s lint exclusion policy.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.16% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 74 functions across 46 files. (13 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding the getIdentityKeysRemainingBudgets query to the platform.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 62.16% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 74 functions across 46 files. (13 skipped: 8 unsupported, 4 too large, 1 over the file limit.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts

Parsing error: Unexpected token :

packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts

Parsing error: Unexpected token PlatformbroadcastStateTransition


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.

@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 17, 2026
@thepastaclaw

thepastaclaw commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

🕓 Queued for automated review — 7th in line, estimated start in ~5 h (commit db7c216)
Estimated review time once started: ~1.4 h (two-phase automated review; median of recent runs).

  • Request priority review — click to move this review to the front of the queue.

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Approved

@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.87097% with 131 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.22%. Comparing base (772f3d6) to head (db7c216).

Files with missing lines Patch % Lines
...ifier/src/proof/identity_keys_remaining_budgets.rs 0.00% 46 Missing ⚠️
...entity_based_queries/keys_remaining_budgets/mod.rs 0.00% 41 Missing ⚠️
...y/verify_identity_keys_remaining_budgets/v0/mod.rs 68.00% 16 Missing ⚠️
...udget/fetch_identity_keys_remaining_budgets/mod.rs 82.75% 5 Missing ⚠️
...udget/prove_identity_keys_remaining_budgets/mod.rs 82.75% 5 Missing ⚠️
...tity/verify_identity_keys_remaining_budgets/mod.rs 80.00% 5 Missing ⚠️
...s/rs-drive/src/drive/identity/fetch/queries/mod.rs 73.33% 4 Missing ⚠️
...ages/rs-drive/src/drive/identity/key/budget/mod.rs 96.96% 4 Missing ⚠️
...ity_based_queries/keys_remaining_budgets/v0/mod.rs 98.97% 2 Missing ⚠️
packages/rs-drive/src/drive/identity/mod.rs 86.66% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.2-dev    #4802      +/-   ##
============================================
- Coverage     77.57%   77.22%   -0.35%     
============================================
  Files          2935     2945      +10     
  Lines        422359   425884    +3525     
============================================
+ Hits         327637   328891    +1254     
- Misses        94722    96993    +2271     
Components Coverage Δ
dpp 75.96% <ø> (+0.19%) ⬆️
drive 79.04% <87.23%> (-0.12%) ⬇️
drive-abci 76.61% <81.85%> (-1.19%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 86.60% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 27.11% <14.81%> (-0.69%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@QuantumExplorer
QuantumExplorer merged commit 8ffbe97 into v4.2-dev Sep 17, 2026
23 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/identity-key-remaining-budget-query branch September 17, 2026 16:27
@thephez thephez added the dapi-endpoint DAPI endpoint addition or modification label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dapi-endpoint DAPI endpoint addition or modification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants