feat(platform): add the getIdentityKeysRemainingBudgets query - #4802
Conversation
…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>
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-09-17T16:15:55.102Z |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (62)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughChangesIdentity key remaining-budgets query
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~60 minutes Change: Feature Merge Risk: ⚪ Minimal · up to 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)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation 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.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.tsParsing error: Unexpected token : packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.tsParsing 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. Comment |
|
🕓 Queued for automated review — 7th in line, estimated start in ~5 h (commit db7c216)
|
Codecov Report❌ Patch coverage is 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
🚀 New features to boost your workflow:
|
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
identity_id,key_ids(at least one, none repeated, at mostmax_returned_elements),prove.remaining_budgetis set for a key with a budget (0means spent) and unset for a key without a budget or a key that does not exist. The query reads the budgets subtree only;getIdentityKeystells the last two apart.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(newkeys.budgetslots,Nonebefore protocol version 14, which is what refuses the query there), andverify_identity_keys_remaining_budgets(verify feature,verify_query_with_absence_proof, generic overFromIterator<(KeyID, Option<Credits>)>).Node and transport
platform.protorpc and messages,dapi-grpcbuild lists,.github/grpc-queries-cache.json, regenerated clients (purely additive: two messages and the rpc).rs-drive-abci:query_identity_keys_remaining_budgetsv0 and the service method. Argument errors areInvalidArgument/InvalidLimit, never internal errors.rs-dapirouting and metrics allowlist,rs-dapi-clienttransport.Clients
rs-drive-proof-verifier:IdentityKeysRemainingBudgets(RetrievedObjects<KeyID, Credits>),FromProofandFromUnproved.rs-sdk:IdentityKeysRemainingBudgetsQuery { identity_id, key_ids },FetchandFetchUnproved, mock support.wasm-sdk:getIdentityKeysRemainingBudgets(identityId, keyIds)and...WithProofInfo, returningMap<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.keysRemainingBudgetsandkeysRemainingBudgetsWithProof.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 stalebudgetfield name in the Drive module header left over from thetotal_budgetrename 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-drivedrive::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-abcihandler 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 keepsSome(0)andNoneapart (--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.rs-dapi,rs-dapi-client,dapi-grpc,platform-version.cargo fmt --all -- --check,cargo clippy ... --all-targets -- -D warningsover the touched Rust crates,cargo clippy -p wasm-sdk --target wasm32-unknown-unknown,cargo check --workspace --all-targets.node_modulesin 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:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
0), and keys without budgets or nonexistent keys.Documentation
Tests