Skip to content

fix(drive): preserve typed proof query fields#4156

Merged
QuantumExplorer merged 1 commit into
v4.1-devfrom
codex/fix-contested-vote-offset
Jul 21, 2026
Merged

fix(drive): preserve typed proof query fields#4156
QuantumExplorer merged 1 commit into
v4.1-devfrom
codex/fix-contested-vote-offset

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

  • preserve checked pagination fields when converting identity-vote proof requests
  • decode WASM identity-vote queries into bounded Rust types instead of narrowing generic numeric values
  • validate JavaScript key-purpose values before converting them into proof-query discriminants

Compatibility

This changes only client-side request/proof-query reconstruction. It does not change consensus or require a protocol activation. Malformed or out-of-range request fields now fail before proof verification.

Validation

  • cargo test -p drive-proof-verifier --lib (242 passed)
  • cargo test -p wasm-drive-verify --lib (11 passed)
  • strict Clippy for both crates
  • native and wasm32-unknown-unknown builds
  • formatting and diff checks

Summary by CodeRabbit

  • Bug Fixes
    • Pagination offsets and limits are now preserved when converting vote queries.
    • Invalid or out-of-range pagination values are rejected instead of being truncated.
    • Identity key purposes now reject fractional, negative, non-finite, and out-of-range values.
    • Vote query decoding now correctly validates malformed optional fields and invalid identifiers.
    • Missing optional query fields now receive the appropriate defaults.

@github-actions github-actions Bot added this to the v4.1.0 milestone Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The changes add strict validation for JavaScript purpose values and query pagination, preserve pagination through gRPC conversions, and replace manual CBOR query traversal with typed deserialization and comprehensive boundary tests.

Changes

Query pagination handling

Layer / File(s) Summary
gRPC pagination conversion
packages/rs-drive-proof-verifier/src/from_request.rs
Request conversions validate offset and limit against u16 bounds, preserve optional pagination values, and test roundtrips and boundaries.
Typed CBOR query decoding
packages/wasm-drive-verify/src/voting/verify_identity_votes_given_proof.rs
CBOR queries deserialize through a typed wire structure with identifier, pagination, ordering, optional-field validation, and defaulting tests.

Purpose value validation

Layer / File(s) Summary
Strict purpose parsing
packages/wasm-drive-verify/src/identity/verify_identities_contract_keys.rs
JavaScript purpose numbers require finite, integral values within u8 bounds, with tests for valid discriminants and invalid inputs.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: shumkov, lklimek

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: preserving typed proof/query fields and validating them more strictly.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-contested-vote-offset

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.

@QuantumExplorer
QuantumExplorer marked this pull request as ready for review July 21, 2026 02:04
@thepastaclaw

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — 17 ahead in queue (commit 61e96e4)
Queue position: 18/27

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.43%. Comparing base (fc05d62) to head (61e96e4).
⚠️ Report is 1 commits behind head on v4.1-dev.

Files with missing lines Patch % Lines
...ckages/rs-drive-proof-verifier/src/from_request.rs 77.77% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.1-dev    #4156      +/-   ##
============================================
- Coverage     87.43%   87.43%   -0.01%     
============================================
  Files          2646     2646              
  Lines        333981   333994      +13     
============================================
+ Hits         292023   292033      +10     
- Misses        41958    41961       +3     
Components Coverage Δ
dpp 88.44% <ø> (ø)
drive 86.14% <ø> (ø)
drive-abci 89.51% <ø> (ø)
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.88% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 49.66% <77.77%> (+0.11%) ⬆️
🚀 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.

@thepastaclaw

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/wasm-drive-verify/src/voting/verify_identity_votes_given_proof.rs (1)

214-319: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Thorough boundary/defaulting tests for the typed decoder.

Coverage of pagination boundaries, malformed optional fields, and defaulting is solid. As noted above, all fixtures use json!(vec![u8; N]), which encodes bytes as a CBOR array of integers rather than a native CBOR byte string — consider adding one fixture that encodes identity_id/start_at as an actual CBOR byte string to close that gap, once the wire-format question above is resolved.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/wasm-drive-verify/src/voting/verify_identity_votes_given_proof.rs`
around lines 214 - 319, The typed decoder tests only cover byte arrays
represented as CBOR integer arrays, not native CBOR byte strings. After
resolving the wire-format decision, update the fixtures used by valid_query and
start_at coverage to include actual CBOR byte-string values for identity_id and
start_at, while preserving the existing boundary, malformed-field, and
defaulting assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/wasm-drive-verify/src/voting/verify_identity_votes_given_proof.rs`:
- Around line 214-319: The typed decoder tests only cover byte arrays
represented as CBOR integer arrays, not native CBOR byte strings. After
resolving the wire-format decision, update the fixtures used by valid_query and
start_at coverage to include actual CBOR byte-string values for identity_id and
start_at, while preserving the existing boundary, malformed-field, and
defaulting assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c09d5423-af90-420e-b6a2-842929fc566a

📥 Commits

Reviewing files that changed from the base of the PR and between fc05d62 and 61e96e4.

📒 Files selected for processing (3)
  • packages/rs-drive-proof-verifier/src/from_request.rs
  • packages/wasm-drive-verify/src/identity/verify_identities_contract_keys.rs
  • packages/wasm-drive-verify/src/voting/verify_identity_votes_given_proof.rs

@QuantumExplorer QuantumExplorer changed the title fix(proof-verifier): preserve typed query fields fix(drive): preserve typed proof query fields Jul 21, 2026

@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.

Reviewed

@QuantumExplorer
QuantumExplorer merged commit 2fa0dcf into v4.1-dev Jul 21, 2026
39 of 41 checks passed
@QuantumExplorer
QuantumExplorer deleted the codex/fix-contested-vote-offset branch July 21, 2026 05:24
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