feat(platform): add GetShieldedNotesCount query for sync progress - #3769
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue being fixed or feature implemented
Wallets have no cheap way to learn the total number of notes in the
shielded pool. During a shielded sync the client streams note chunks
but can't show a determinate progress bar because it doesn't know the
denominator (total notes) until it has fetched everything.
This adds a query returning the current leaf count of the shielded
notes commitment tree (= total notes). A wallet calls it once at the
start of a sync to seed a progress-bar denominator
(
notes_total → mmr_chunks_total → percentage).Extracted as a standalone PR from the broader shielded-sync work so it
can land and deploy independently — the interleaved-streaming and
dual-progress-bar changes depend on this query existing on-chain.
What was done?
GetShieldedNotesCount, wired end-to-end and proved (mirrors itssibling
GetShieldedPoolState):platform.proto): request carriesprove: bool; responseis
oneof result { uint64 total_notes_count; Proof proof }. Plusdapi-grpc codegen registration (added to
VERSIONED_RESPONSES) andregenerated JS/web/nodejs/java/objc/python clients.
query::shielded::notes_count(+ v0) withproved/unproved branches and tests; gRPC route in
service.rs.verify_shielded_notes_count(+ round-trip tests)and its
verify_shielded_notes_countFeatureVersion slot.notes_countquery slot (v0/v1/v2_test all(0,0,0)); no protocol bump.drive_method!arm.ShieldedNotesCount(pub u64)+FromProof.Fetch+FetchCurrent(proved),Queryhonoringprove, and helperplatform::types::shielded::fetch_shielded_notes_count(&sdk).Why it's provable
The on-chain notes tree is an
Element::CommitmentTree(total_count, chunk_power, flags).total_countis the element's first field and its serialized bytes are hashed into
the Merk value hash, so the app/root hash binds it — grovedb's own
comment: "total_count and height … are already authenticated by the
Merk value hash." The proved path issues a single-key PathQuery at the
shielded pool path (no subquery), so GroveDB returns the serialized
CommitmentTreeelement and the verifier decodestotal_count(field0) against the verified root. Same mechanism
GetShieldedPoolStateusesfor its stored balance.
How Has This Been Tested?
cargo check -p drive -p drive-abci -p dash-sdk -p drive-proof-verifier— clean.cargo test -p drive-abci --lib query::shielded::notes_count— 3 passed(none-version → decoding error; unproved → value; proved → proof).
cargo test -p drive --lib verify::shielded::verify_shielded_notes_count— 3 passed (round-trip: 0 on fresh state, N after inserts).cargo test -p drive-proof-verifier --lib shielded_notes_count— 1 passed.cargo fmt --all --check— clean.yarn workspace @dashevo/dapi-grpc build.Breaking Changes
None. Additive query; new version slots initialized to
0/(0,0,0),no protocol-version bump. Existing clients unaffected; nodes must deploy
this build to answer the new query.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
Summary by CodeRabbit
getShieldedNotesCountendpoint to query the total count of shielded notes in the platform.