feat(wasm-sdk): composite document queries on the JS surface - #4605
feat(wasm-sdk): composite document queries on the JS surface#4605QuantumExplorer wants to merge 3 commits into
Conversation
|
🕓 Ready for review — 12 ahead in queue (commit aba6959) |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
`GetDocumentsRequestV1.sub_queries` (field 14): each entry is a typed sub-query (contract, document type, fixed where/order clauses, limit, DOCUMENTS or COUNT) with an optional binding `<field> IN <values>` whose values the node derives from the page's, or an earlier sub-query's, proven documents. Presence selects composite mode: the request's own clauses describe the page; `chained` and `sub_queries` are mutually exclusive. `ResultData.composite` (variant 7) carries the page and one result per sub-query (documents, or count entries keyed by the bound value) for the no-proof path; the proof path is the single merged proof in the standard envelope, verified client-side by re-deriving the whole composition from the proven page. drive-abci intercepts composite requests before select routing (`dispatch/composite.rs`): the page limit is required (1..=max), every SQL-shaped knob, cursor and time-range clause is refused, each distinct sub-query contract is fetched once, and drive's shape validation surfaces as client-attributable query errors. Old nodes ignore the field and serve a page-only proof, which the verifier refuses. Existing V1 request literals gain the new field; the serde default keeps mock vectors captured before it wire-compatible. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The client half of composite document queries (a page plus the sub-queries derived from it, answered as ONE merged proof): - dash-platform-queries: `CompositeDocumentQuery` (page + `CompositeSubQuery` list with kind, fixed clauses, per-value limit and binding), the V1 wire encoder (refuses V0, a zero page limit, cursors, offsets, projections, grouping and time ranges), the rich-to-drive conversion mirroring the server's limit contract, and `FromProof<CompositeDocumentQuery> for CompositeDocuments`. - rs-drive-proof-verifier: `CompositeDocuments` plus `verify_composite_documents_tenderdash_proof`, which composes rs-drive's merged-proof verification with the tenderdash root binding; `CompositeSubQueryResult` re-exported at the crate root. - rs-sdk: `Query` impls, `impl Fetch for CompositeDocuments`, the mock round-trip, and the `platform` re-exports. - rs-drive-abci: a `composite_trust_boundary` suite running the SDK entry points against server-generated proofs: wire encoding, end-to-end FromProof (page, like counts, quoted-post join, cross-contract profile lookup with a proven absence), a wrong quorum key, tampered metadata, and a page-only proof presented for the composite query. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- wasm-sdk: `getCompositeDocuments` and `getCompositeDocumentsWithProofInfo`. The query is the page plus `subQueries` (optional contract, document type, `documents` or `counts`, fixed clauses, per-value limit, and a `bind` naming the page or an earlier documents sub-query); the result is the page and one discriminated sub-result per sub-query, counts keyed by the bound value's base58 identifier. Sub-query contracts go through the same cache as the page's. - js-evo-sdk: `documents.composite` / `documents.compositeWithProof` and a README section with the feed-page example. - platform-test-suite: a composite case next to the chained one (page, like counts from the countable index, the viewer's likes through the byLiker terminal). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
c80c6c7 to
aba6959
Compare
8e2fddc to
5f69b2c
Compare
Replaces #4601, which GitHub closed as merged when a mistaken force-push briefly collapsed the stack's branches onto one commit. Same branch, same content, same base.
Issue being fixed or feature implemented
Last platform PR of the composite document query series (Yappr feed: one merged proof per feed page instead of 15 to 19 round trips). Stack:
sub_queries, drive-abci dispatch)What was done?
getCompositeDocuments(query)andgetCompositeDocumentsWithProofInfo(query), mirroring the chained surface. The query object is the page (dataContractId,documentType,where,orderBy, a requiredlimit) plussubQueries, each with an optionaldataContractId(defaults to the page's),documentType,kind: 'documents' | 'counts', fixedwhere/orderBy, an optional per-valuelimit, and an optionalbind: { source?: 'page' | index, sourceProperty, field }. Sub-query contracts are fetched through the same contract cache as the page's. The result is{ pageDocuments, subResults }, each sub-result a discriminated union:{ kind: 'documents', documents }or{ kind: 'counts', counts: Map<base58 id, bigint> }. TypeScript declarations ride the usual custom section.parse_order_clausebecomes crate-visible next toparse_where_clause.sdk.documents.composite(query)andsdk.documents.compositeWithProof(query), plus a README section with the feed-page example and the four sub-query shapes.dashposts page, one like count per post from the countable[hashtag, postId]index, and the viewer's own likes through thebyLikerterminal (value-bounded, no limit).Usage:
How Has This Been Tested?
cargo test -p wasm-sdk(native): 103 tests green;cargo clippy -p wasm-sdk --testsclean apart from the pre-existing rs-driveDocumentPropertyTypeunused import under verify-only features.import-x/no-unresolvedondashis the usual uninstalled-workspace noise, not a finding).Breaking Changes
None. New methods only.
Checklist
🤖 Generated with Claude Code