Skip to content

refactor(drive-abci): share the v1 document-query wire decoders - #4618

Open
PastaPastaPasta wants to merge 1 commit into
v4.2-devfrom
refactor/platform-query-wire-and-dpp-bounds
Open

refactor(drive-abci): share the v1 document-query wire decoders#4618
PastaPastaPasta wants to merge 1 commit into
v4.2-devfrom
refactor/platform-query-wire-and-dpp-bounds

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 8, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

First of three PRs replacing the transport-free-embedder series (#4464, #4478, #4389, #4433, #4416), rebuilt after a review of that stack found it duplicating code the workspace already has and carrying two remotely triggerable aborts in the C++ bridge. This PR is the server-side half; the SDK verification/builders and the C++ crate follow in stacked PRs. The dpp decode-bounds fix that was originally stacked here is now #4629, so it can land independently.

The v1 getDocuments wire decode becomes a shared crate. A client that verifies a proof against the request it actually sent must reconstruct the query exactly as the server did. Today that decode lives only inside rs-drive-abci, so the earlier client-side PR carried a byte-for-byte copy with a "keep in lockstep" comment. Supersedes #4464, re-derived from the current server file (which had grown the time-range decoders since #4464 was cut).

What was done?

  • New packages/rs-platform-query-wire (platform-query-wire): the wire-proto → drive-type decoders for getDocuments v1 (where / order-by / having / select / time-range clauses), moved verbatim from rs-drive-abci/src/query/document_query/v1/conversions.rs, with a neutral DecodeError { InvalidArgument, Unsupported }.
  • The crate enables no drive features of its own beyond a verify default and a server passthrough. rs-drive-abci opts out of defaults and takes server, so the consensus binary gains no proof-verification code from this crate (cargo tree -p drive-abci -e normal,features -i drive shows no verify edge, same as before). Client verifiers take the default.
  • rs-drive-abci maps DecodeError onto QueryError through a From impl in error/query.rs, matching the six #[from] conversions already there. The v1 handler, routing and dispatch code call the shared decoders directly; the former adapter module is deleted. A unit test pins the variant mapping and message preservation, so a later reclassification in the shared crate cannot silently change what clients see.
  • Workspace, Dockerfile COPY --parents, package filters (triggering on dapi-grpc changes as well as drive), the transport-free CI cut (cargo check -p platform-query-wire --locked and the banned-crate loop), and the nextest package allowlist gain the new crate.

How Has This Been Tested?

  • cargo test -p drive-abci --lib -- query::document_query::v1 error::query: 106 passed (the server's own decode tests now exercise the shared crate directly).
  • cargo check -p platform-query-wire --locked (default verify) and --no-default-features --features server: both clean.
  • cargo clippy -p drive-abci -p platform-query-wire --all-targets --all-features -- -D warnings, cargo fmt --check, cargo machete: clean.

Breaking Changes

None. Server error strings are unchanged.

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 shared query decoding support for getDocuments query clauses, including WHERE, ORDER BY, HAVING, and SELECT.
    • Improved consistency between server-side processing and client-side query verification.
  • Bug Fixes

    • Malformed query input now produces clearer invalid-argument errors.
    • Well-formed but unsupported query features are reported distinctly, improving validation feedback.
  • Documentation

    • Added documentation describing supported query decoding behavior and error handling.

@coderabbitai

coderabbitai Bot commented Sep 8, 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: c9705803-17cc-4b63-ad22-cc4e34803174

📥 Commits

Reviewing files that changed from the base of the PR and between f712cf6 and 3da51c3.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (15)
  • .github/package-filters/rs-packages-direct.yml
  • .github/package-filters/rs-packages-no-workflows.yml
  • .github/package-filters/rs-packages.yml
  • .github/workflows/tests-rs-workspace.yml
  • Cargo.toml
  • Dockerfile
  • packages/rs-drive-abci/Cargo.toml
  • packages/rs-drive-abci/src/error/query.rs
  • packages/rs-drive-abci/src/query/document_query/v1/dispatch/chained.rs
  • packages/rs-drive-abci/src/query/document_query/v1/dispatch/composite.rs
  • packages/rs-drive-abci/src/query/document_query/v1/mod.rs
  • packages/rs-platform-query-wire/Cargo.toml
  • packages/rs-platform-query-wire/README.md
  • packages/rs-platform-query-wire/src/lib.rs
  • packages/rs-platform-query-wire/src/proto_conversions.rs

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


📝 Walkthrough

Walkthrough

The pull request adds the platform-query-wire crate for shared query proto decoding. Drive ABCI adopts its conversion functions and error mapping. Workspace membership, Docker builds, package filters, and Rust workflow checks now include the crate.

Changes

Platform query wire integration

Layer / File(s) Summary
Shared wire decoding contract
packages/rs-platform-query-wire/*
The new crate exposes query proto conversion functions and returns DecodeError::InvalidArgument or DecodeError::Unsupported.
Drive ABCI query integration
packages/rs-drive-abci/Cargo.toml, packages/rs-drive-abci/src/error/query.rs, packages/rs-drive-abci/src/query/document_query/v1/*
Drive ABCI uses the shared conversion module and maps DecodeError values to existing query error and validation result types.
Workspace and build integration
Cargo.toml, Dockerfile, .github/package-filters/*, .github/workflows/tests-rs-workspace.yml
Workspace registration, Docker build contexts, package filters, dependency triggers, native dependency checks, and coverage tests include platform-query-wire.

Priority: ➖ Normal — Schedule the shared query-decoder change because it alters the Drive ABCI validation boundary and adds bounded deserialization across the workspace.

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

Merge Risk: ⚪ Minimal · up to 3da51

This change centralizes v1 query wire decoding, preserves query error behavior, and bounds deserialization allocations. No concrete current-head merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant QueryWire as platform_query_wire
  participant DriveABCI as rs-drive-abci
  participant Validation as QueryValidationResult
  QueryWire->>DriveABCI: Decode query clauses
  QueryWire-->>DriveABCI: Return DecodeError
  DriveABCI->>Validation: Convert and wrap error
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 86.36% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 6 files. (9 skipped: 9 …
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 and concisely describes the main change: sharing the v1 document-query wire decoders through a refactor of drive-abci.
✨ 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 refactor/platform-query-wire-and-dpp-bounds

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.

@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.78431% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.30%. Comparing base (658aec5) to head (3da51c3).
⚠️ Report is 13 commits behind head on v4.2-dev.

Files with missing lines Patch % Lines
...es/rs-platform-query-wire/src/proto_conversions.rs 75.00% 10 Missing ⚠️
.../src/query/document_query/v1/dispatch/composite.rs 0.00% 4 Missing ⚠️
...s/rs-drive-abci/src/query/document_query/v1/mod.rs 20.00% 4 Missing ⚠️
...ci/src/query/document_query/v1/dispatch/chained.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.2-dev    #4618      +/-   ##
============================================
- Coverage     87.72%   87.30%   -0.42%     
============================================
  Files          2762     2795      +33     
  Lines        360146   364721    +4575     
============================================
+ Hits         315922   318433    +2511     
- Misses        44224    46288    +2064     
Components Coverage Δ
dpp 89.08% <ø> (ø)
drive 86.57% <ø> (ø)
drive-abci 89.36% <9.09%> (-0.12%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.92% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 42.76% <ø> (-6.30%) ⬇️
🚀 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.

@PastaPastaPasta PastaPastaPasta added the ready for final review Ready for the final review. If AI was involved in producing this PR, it has already had a reviewer. label Sep 8, 2026
…atform-query-wire

Pure move: the wire-proto -> drive-type decoders for the v1 getDocuments surface now live in a new packages/rs-platform-query-wire micro-crate (crate name platform-query-wire) behind a neutral DecodeError { InvalidArgument, Unsupported }, and drive-abci's v1/conversions.rs becomes a thin adapter mapping DecodeError onto its QueryError surface with the exact same message strings (including the aggregate ORDER BY arm, which maps Unsupported onto QuerySyntaxError::Unsupported). No behavior change to server request decoding.

The decode of a wire request into a rich query is an equivalence contract at a trust boundary: a client-side proof verifier must interpret a request exactly as the server does, or a proof could verify against a different query than the server answered. Hosting the shared decoders in a neutral crate lets both rs-drive-abci and (in a follow-up) the client-side SDK decoders run the same functions, without making the consensus server depend on SDK-branded code: the new crate's dependencies (dapi-grpc platform+client without transport, dpp, drive/verify, thiserror) are a strict subset of what drive-abci already carries.
@thepastaclaw

thepastaclaw commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 3da51c3) · triage: critical

@PastaPastaPasta
PastaPastaPasta force-pushed the refactor/platform-query-wire-and-dpp-bounds branch from ffb791d to 3da51c3 Compare September 8, 2026 13:40
@PastaPastaPasta PastaPastaPasta changed the title refactor(drive-abci): share the v1 document-query wire decoders and bound dpp document field reads refactor(drive-abci): share the v1 document-query wire decoders Sep 8, 2026
@PastaPastaPasta PastaPastaPasta removed the ready for final review Ready for the final review. If AI was involved in producing this PR, it has already had a reviewer. label Sep 8, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

Verified the supplied findings against head 3da51c3. The decoder extraction preserves behavior and server error mapping; no blocking defects were confirmed. One documentation nit remains: references in neighboring crates still point to the deleted decoder module.

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); reviewer 3: glm-5.3-flash (agent: phase1-reviewer, role: security-auditor); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

Review provenance

  • Triage: critical by gpt-6-astra (effort low) — The extraction changes the dependency and error-conversion boundaries of remotely supplied document-query decoding in drive-abci, where a regression could alter server query semantics, proof-verification consistency, or consensus-binary feature composition.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort max); agent phase1-reviewer, glm-5.3-flash — rust-quality (completed, effort max); agent phase1-reviewer, glm-5.3-flash — security-auditor (completed, effort max); agent phase1-reviewer
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer

💬 1 nitpick(s)

1 additional finding(s) omitted (not in diff).

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-drive/src/query/having.rs`:
- [NITPICK] packages/rs-drive/src/query/having.rs:31: Update cross-references to the relocated wire decoders
  This refactor deletes `rs-drive-abci/src/query/document_query/v1/conversions.rs`, but this comment and `packages/rs-drive/src/query/projection.rs:16` still identify it as the wire-decoding layer. The encoding documentation in `packages/dash-platform-queries/src/documents/document_query.rs:1317,1331` likewise references the deleted file's value decoders. Update these four references to `rs-platform-query-wire/src/proto_conversions.rs` so readers can locate the shared decoding implementation and its nesting-limit contract. These are documentation-only changes and require no new dependency.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • New crate's default-feature clippy (-D warnings) fails on pre-existing unused import in rs-drive — Out of scope and tooling-detectable. The parent commit already contains the unconditional DocumentPropertyType import, its use inside a server-gated function, and a verify-only dependency from drive-proof-verifier. This PR neither introduces nor worsens that feature-cut warning. Its stated clippy command explicitly uses --all-features; it does not claim standalone default-feature clippy passes.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.

@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Disposition (not closing yet): QuantumExplorer's suggestion to use the SDK was prototyped and passes Core's requirements, so the Core GUI now consumes dash-sdk directly through #4633 (stacked on #4631 and #4632). With the SDK building the request and retaining the rich query, Core no longer needs to reverse-decode wire requests, which was this crate's consumer. I found no other consumer of platform-query-wire. The dpp bound fix is carried by #4629 independently. Details and the full map in dashpay/dash#7512.


🤖 Posted autonomously by Claude on behalf of pasta.

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