Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/package-filters/rs-packages-direct.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ simple-signer:
strategy-tests:
- packages/strategy-tests/**

platform-query-wire:
- packages/rs-platform-query-wire/**

drive-abci:
- packages/rs-drive-abci/**

Expand Down
22 changes: 14 additions & 8 deletions .github/package-filters/rs-packages-no-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,25 @@ strategy-tests: &strategy-tests
- *simple-signer
- *drive

dapi-grpc: &dapi_grpc
- packages/rs-platform-version/**
- packages/rs-dash-platform-macros/**
- packages/dapi-grpc/src/**
- packages/dapi-grpc/protos/**
- packages/dapi-grpc/build.rs
- packages/dapi-grpc/Cargo.toml

platform-query-wire: &platform_query_wire
- packages/rs-platform-query-wire/**
- *drive
- *dapi_grpc

drive-abci:
- packages/rs-drive-abci/**
- *drive
- *simple-signer
- *strategy-tests
- *platform_query_wire

dash-async: &dash_async
- packages/rs-dash-async/**
Expand All @@ -106,14 +120,6 @@ rs-sdk-trusted-context-provider: &sdk_trusted_context_provider
- *context_provider
- *dpp

dapi-grpc: &dapi_grpc
- packages/rs-platform-version/**
- packages/rs-dash-platform-macros/**
- packages/dapi-grpc/src/**
- packages/dapi-grpc/protos/**
- packages/dapi-grpc/build.rs
- packages/dapi-grpc/Cargo.toml

rs-dapi:
- packages/rs-dapi/**
- *dapi_grpc
Expand Down
25 changes: 16 additions & 9 deletions .github/package-filters/rs-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,28 @@ strategy-tests: &strategy-tests
- *simple-signer
- *drive

dapi-grpc: &dapi_grpc
- .github/workflows/tests*
- packages/rs-platform-version/**
- packages/rs-dash-platform-macros/**
- packages/dapi-grpc/src/**
- packages/dapi-grpc/protos/**
- packages/dapi-grpc/build.rs
- packages/dapi-grpc/Cargo.toml

platform-query-wire: &platform_query_wire
- .github/workflows/tests*
- packages/rs-platform-query-wire/**
- *drive
- *dapi_grpc

drive-abci:
- .github/workflows/tests*
- packages/rs-drive-abci/**
- *drive
- *simple-signer
- *strategy-tests
- *platform_query_wire

dash-async: &dash_async
- .github/workflows/tests*
Expand All @@ -126,15 +142,6 @@ rs-sdk-trusted-context-provider: &sdk_trusted_context_provider
- *context_provider
- *dpp

dapi-grpc: &dapi_grpc
- .github/workflows/tests*
- packages/rs-platform-version/**
- packages/rs-dash-platform-macros/**
- packages/dapi-grpc/src/**
- packages/dapi-grpc/protos/**
- packages/dapi-grpc/build.rs
- packages/dapi-grpc/Cargo.toml

rs-dapi-client: &dapi_client
- .github/workflows/tests*
- packages/rs-dapi-client/**
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/tests-rs-workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,14 @@ jobs:
cargo check -p dapi-grpc --no-default-features --features core,platform,client --locked
cargo check -p drive-proof-verifier --locked
cargo check -p dash-platform-queries --locked
cargo check -p platform-query-wire --locked
# Native graphs: assert the networking transport stack stays out.
# `tonic` itself is present (dapi-grpc's generated client types) but
# without its transport feature — which is exactly what the absence
# of hyper/rustls/tower proves. tokio is deliberately NOT asserted
# absent: dash-context-provider depends on dash-async, which uses it
# on native targets, and that edge predates the queries-crate split.
for native_package in drive-proof-verifier dash-platform-queries; do
for native_package in platform-query-wire drive-proof-verifier dash-platform-queries; do
for banned in hyper rustls tower; do
if cargo tree -p "$native_package" -e normal -i "$banned" 2>/dev/null | grep -q .; then
echo "::error::$banned leaked into $native_package's dependency tree"
Expand Down Expand Up @@ -344,6 +345,7 @@ jobs:
--package rs-dapi-client \
--package platform-serialization \
--package dapi-grpc \
--package platform-query-wire \
--package json-schema-compatibility-validator \
--package dashpay-contract \
--package dpns-contract \
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"packages/rs-dash-platform-macros",
"packages/rs-dpp",
"packages/rs-drive",
"packages/rs-platform-query-wire",
"packages/rs-platform-value",
"packages/rs-platform-serialization",
"packages/rs-platform-serialization-derive",
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ COPY --parents \
packages/rs-platform-serialization-derive \
packages/rs-platform-version \
packages/rs-platform-versioning \
packages/rs-platform-query-wire \
packages/rs-platform-value-convertible \
packages/rs-platform-wallet-ffi \
packages/rs-drive-abci \
Expand Down Expand Up @@ -515,6 +516,7 @@ COPY --parents \
packages/rs-platform-serialization-derive \
packages/rs-platform-version \
packages/rs-platform-versioning \
packages/rs-platform-query-wire \
packages/rs-platform-value-convertible \
packages/rs-platform-wallet-ffi \
packages/rs-drive-abci \
Expand Down Expand Up @@ -681,6 +683,7 @@ COPY --parents \
packages/rs-platform-serialization-derive \
packages/rs-platform-version \
packages/rs-platform-versioning \
packages/rs-platform-query-wire \
packages/rs-platform-value-convertible \
packages/rs-platform-wallet-ffi \
packages/rs-unified-sdk-ffi \
Expand Down Expand Up @@ -939,6 +942,7 @@ COPY --parents \
packages/rs-platform-serialization-derive \
packages/rs-platform-version \
packages/rs-platform-versioning \
packages/rs-platform-query-wire \
packages/rs-platform-value-convertible \
packages/rs-platform-wallet-ffi \
packages/rs-drive-abci \
Expand Down
3 changes: 3 additions & 0 deletions packages/rs-drive-abci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ dapi-grpc = { path = "../dapi-grpc", default-features = false, features = [
"server",
"platform",
] }
platform-query-wire = { path = "../rs-platform-query-wire", default-features = false, features = [
"server",
] }
tracing-subscriber = { version = "0.3.22", default-features = false, features = [
"env-filter",
"ansi",
Expand Down
47 changes: 47 additions & 0 deletions packages/rs-drive-abci/src/error/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use dpp::ProtocolError;
use drive::error::proof::ProofError;
use drive::error::query::QuerySyntaxError as SyntaxError;
use drive::error::Error as DriveError;
use platform_query_wire::proto_conversions::DecodeError as WireDecodeError;
use prost::DecodeError;
use tenderdash_abci::proto::abci::ResponseException;

Expand Down Expand Up @@ -71,10 +72,56 @@ pub enum QueryError {
ResourceExhausted(String),
}

/// Wire-decode failures from the shared `platform-query-wire` decoders.
/// `InvalidArgument` is malformed wire input; `Unsupported` is a well-formed
/// shape the decoder deliberately refuses (e.g. `ORDER BY` on aggregate
/// keys) and surfaces as `QuerySyntaxError::Unsupported`, the same variant
/// the v1 handler's `not_yet_implemented` path uses. Both carry the message
/// string through unchanged.
impl From<WireDecodeError> for QueryError {
fn from(error: WireDecodeError) -> Self {
match error {
WireDecodeError::InvalidArgument(msg) => QueryError::InvalidArgument(msg),
WireDecodeError::Unsupported(msg) => QueryError::Query(SyntaxError::Unsupported(msg)),
}
}
}

impl From<QueryError> for ResponseException {
fn from(value: QueryError) -> Self {
Self {
error: value.to_string(),
}
}
}

#[cfg(test)]
mod tests {
use super::*;

/// The shared decoder's two variants map onto distinct `QueryError`
/// surfaces and the message text is preserved verbatim. A decoder that
/// later reclassifies a malformed shape as `Unsupported` (or vice versa)
/// changes what clients see, so the mapping is pinned here.
#[test]
fn wire_decode_error_mapping_preserves_variant_and_message() {
let invalid: QueryError = WireDecodeError::InvalidArgument("bad where".to_string()).into();
assert!(
matches!(&invalid, QueryError::InvalidArgument(msg) if msg == "bad where"),
"unexpected: {invalid:?}"
);

let unsupported: QueryError = WireDecodeError::Unsupported(
"ORDER BY on aggregate keys is not yet implemented".to_string(),
)
.into();
assert!(
matches!(
&unsupported,
QueryError::Query(SyntaxError::Unsupported(msg))
if msg == "ORDER BY on aggregate keys is not yet implemented"
),
"unexpected: {unsupported:?}"
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::error::query::QueryError;
use crate::error::Error;
use crate::platform_types::platform::Platform;
use crate::platform_types::platform_state::PlatformState;
use crate::query::document_query::v1::conversions;
use crate::query::response_metadata::CheckpointUsed;
use crate::query::QueryValidationResult;
use dapi_grpc::platform::v0::get_documents_request::get_documents_request_v1::{
Expand All @@ -36,6 +35,7 @@ use dpp::version::PlatformVersion;
use drive::error::query::QuerySyntaxError;
use drive::query::DriveDocumentQuery;
use drive::util::grove_operations::GroveDBToUse;
use platform_query_wire::proto_conversions as conversions;

impl<C> Platform<C> {
/// Serve a chained-mode v1 request. Runs before select routing:
Expand Down Expand Up @@ -120,11 +120,11 @@ impl<C> Platform<C> {

let where_clauses = match conversions::where_clauses_from_proto(proto_where_clauses) {
Ok(c) => c,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
};
let order_by_clauses = match conversions::order_clauses_from_proto(proto_order_by) {
Ok(c) => c,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
};

let (_, contract_fetch_info) = check_validation_result_with_data!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use crate::error::query::QueryError;
use crate::error::Error;
use crate::platform_types::platform::Platform;
use crate::platform_types::platform_state::PlatformState;
use crate::query::document_query::v1::conversions;
use crate::query::response_metadata::CheckpointUsed;
use crate::query::QueryValidationResult;
use dapi_grpc::platform::v0::get_documents_request::get_documents_request_v1::{
Expand Down Expand Up @@ -41,6 +40,7 @@ use drive::query::{
SubQueryResult, MAX_SUB_QUERIES,
};
use drive::util::grove_operations::GroveDBToUse;
use platform_query_wire::proto_conversions as conversions;
use std::sync::Arc;

/// A sub-query's wire fields decoded into drive's typed forms, before
Expand Down Expand Up @@ -152,11 +152,11 @@ impl<C> Platform<C> {

let where_clauses = match conversions::where_clauses_from_proto(proto_where_clauses) {
Ok(c) => c,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
};
let order_by_clauses = match conversions::order_clauses_from_proto(proto_order_by) {
Ok(c) => c,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
};

// Every contract the composition touches, fetched once: the
Expand Down Expand Up @@ -211,11 +211,11 @@ impl<C> Platform<C> {
};
let where_clauses = match conversions::where_clauses_from_proto(proto.where_clauses) {
Ok(c) => c,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
};
let order_by = match conversions::order_clauses_from_proto(proto.order_by) {
Ok(c) => c,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
};
let binding = proto.bind.map(|bind| SubQueryBinding {
source: match bind.source {
Expand Down
12 changes: 6 additions & 6 deletions packages/rs-drive-abci/src/query/document_query/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
//! `platform.proto` for the full supported / rejected shape table.

mod compute_aggregate_mode_and_check_limit;
mod conversions;
mod dispatch;
mod routing;

Expand Down Expand Up @@ -68,6 +67,7 @@ use dpp::version::PlatformVersion;
use drive::drive::contract::DataContractFetchInfo;
use drive::error::query::QuerySyntaxError;
use drive::query::{resolve_time_range_bucket_clause, CountMode, SelectProjection};
pub(super) use platform_query_wire::proto_conversions as conversions;
use std::sync::Arc;

/// Build a `QuerySyntaxError::Unsupported` carrying a stable
Expand Down Expand Up @@ -332,7 +332,7 @@ impl<C> Platform<C> {

let mut where_clauses = match conversions::where_clauses_from_proto(normal_proto) {
Ok(c) => c,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
};
let mut resolved_time_ranges: Vec<ResolvedTimeRange> = Vec::new();
// The contract fetched for time-range resolution, handed to the
Expand Down Expand Up @@ -375,7 +375,7 @@ impl<C> Platform<C> {
let (field, selector, grid) =
match conversions::time_range_clause_from_proto(proto_wc) {
Ok(parsed) => parsed,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
};
match resolve_time_range_bucket_clause(
&field,
Expand Down Expand Up @@ -403,11 +403,11 @@ impl<C> Platform<C> {
}
let order_by_clauses = match conversions::order_clauses_from_proto(proto_order_by) {
Ok(c) => c,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
};
let having_clauses = match conversions::having_clauses_from_proto(having) {
Ok(c) => c,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
};

// `selects` is `repeated Select` on the wire. Empty
Expand All @@ -430,7 +430,7 @@ impl<C> Platform<C> {
let select = match proto_selects.into_iter().next() {
Some(s) => match conversions::select_from_proto(s) {
Ok(s) => s,
Err(e) => return Ok(QueryValidationResult::new_with_error(e)),
Err(e) => return Ok(QueryValidationResult::new_with_error(e.into())),
},
None => SelectProjection::documents(),
};
Expand Down
Loading
Loading