Skip to content
Merged
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
72 changes: 36 additions & 36 deletions Cargo.lock

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

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ members = [

[workspace.dependencies]
bincode = { package = "grovedb-bincode", version = "=2.1.0" }
grovedb = { git = "https://github.com/dashpay/grovedb", rev = "a579d52fcf68c3cbd798c5a94e73afdc41b5f5a6", default-features = false }
grovedb-costs = { git = "https://github.com/dashpay/grovedb", rev = "a579d52fcf68c3cbd798c5a94e73afdc41b5f5a6" }
grovedb-path = { git = "https://github.com/dashpay/grovedb", rev = "a579d52fcf68c3cbd798c5a94e73afdc41b5f5a6" }
grovedb-query = { git = "https://github.com/dashpay/grovedb", rev = "a579d52fcf68c3cbd798c5a94e73afdc41b5f5a6" }
grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "a579d52fcf68c3cbd798c5a94e73afdc41b5f5a6" }
grovedb-version = { git = "https://github.com/dashpay/grovedb", rev = "a579d52fcf68c3cbd798c5a94e73afdc41b5f5a6" }
grovedb-epoch-based-storage-flags = { git = "https://github.com/dashpay/grovedb", rev = "a579d52fcf68c3cbd798c5a94e73afdc41b5f5a6" }
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "a579d52fcf68c3cbd798c5a94e73afdc41b5f5a6" }
dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "e4208c90786a6854bd498315bcb571ef24182c15" }
dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "e4208c90786a6854bd498315bcb571ef24182c15" }
dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "e4208c90786a6854bd498315bcb571ef24182c15" }
Expand Down
2 changes: 1 addition & 1 deletion book/src/drive/document-ranked-trees.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ Note that the fixture puts each shape on its **own document type**. That's not a
| Top / bottom K groups by sum of a property | `rankedSummable: true` on an index with `summable: "<prop>"` + `rangeSummable: true` |
| Top / bottom K groups by average of a property | `rankedAverageable: true` on an index with `averageable: "<prop>"` + `rangeAverageable: true` (or the count+sum longhand) |
| Two rankings on one index (e.g. by count *and* by average) | Both keywords. The tree is a PCPSIT carrying both axes in its TLV; you pay one secondary Merk per axis on every write. |
| A ranking filtered by another property (`top 5 restaurants in London`) | A **compound ranked index** with the filter property leading: `[city, restaurantId]` with the ranked flags. Each city gets its own secondary; the query pins the prefix with an equality `where` (`WHERE city == "London" GROUP BY restaurantId ORDER BY <agg> DESC LIMIT 5`). Equality pins select one prefix; at most one pin may be an `IN` (2..=10 distinct elements; a never-written element — or one whose deeper pinned path was never written — contributes an empty branch), which walks one secondary per element and merges by `(aggregate, encoded prefix, group key)`, proved in one branched `PathQuery` envelope (shared ancestors proved once, per-element authenticated absence) — entries then carry `in_key`. A single-element `IN` normalizes to the equality pin; a `null` pin stays legal on its own but cannot combine with an `IN` (null addresses its prefix through an empty path segment the branched proof cannot express); a non-zero `OFFSET` is rejected together with `IN`; and branched proofs are generated from committed state only. A range operator on the prefix stays rejected, and there is still no global cross-prefix ordering beyond that merge. |
| A ranking filtered by another property (`top 5 restaurants in London`) | A **compound ranked index** with the filter property leading: `[city, restaurantId]` with the ranked flags. Each city gets its own secondary; the query pins the prefix with an equality `where` (`WHERE city == "London" GROUP BY restaurantId ORDER BY <agg> DESC LIMIT 5`). Equality pins select one prefix; at most one pin may be an `IN` (2..=10 distinct elements; a never-written element — or one whose deeper pinned path was never written — contributes an empty branch), which walks one secondary per element and merges by `(aggregate, encoded prefix, group key)`, proved in one branched `PathQuery` envelope (shared ancestors proved once, per-element authenticated absence) — entries then carry `in_key`. A single `==` pin on a prefix no document has written yet (a `timeRange` window before its first document, a hashtag nobody has used) is likewise an authenticated **empty page**, at any `OFFSET`: GroveDB answers a single-path axis read over a path that does not exist with the traversal's empty result, the absence proved by the layers the walk emits rather than reported as an error. A single-element `IN` normalizes to the equality pin; a `null` pin stays legal on its own but cannot combine with an `IN` (null addresses its prefix through an empty path segment the branched proof cannot express); a non-zero `OFFSET` is rejected together with `IN`; and branched proofs are generated from committed state only. A range operator on the prefix stays rejected, and there is still no global cross-prefix ordering beyond that merge. |
| A ranking on a unique or contested index | Not available, and not meaningful: every group holds at most one document. |
| Range aggregates without ranking (the 4.0 surface) | Just the `range*` flags. Ranking is strictly additive — adding it never changes what a range query returns. |
| Nothing ranking-aware (default) | Don't set any `ranked*` flag. The terminal property-name tree keeps the type its range flags give it. |
Expand Down
4 changes: 3 additions & 1 deletion book/src/drive/time-range-ttl.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ buckets are drained **lazily, on write**: every state transition that
writes into the index continues draining the oldest expired bucket,
deepest-first, under a per-write operation budget. A fully drained
window is provably absent, exactly like a window that never held
documents. An expired window is **not queryable at all** — `byStart`
documents: a count over it proves zero, and a ranked or having-range
query pinned to it proves an empty page (see the ranked chapter's
pinned-prefix rules). An expired window is **not queryable at all** — `byStart`
rejects starts past the horizon, so the drainage lag is purely internal:
drainage only ever touches expired buckets, which makes every window a
query can address complete. Everything written under the index's
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-dpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ strum = { version = "0.26", features = ["derive"] }
json-schema-compatibility-validator = { path = '../rs-json-schema-compatibility-validator', optional = true }
once_cell = "1.19.0"
tracing = { version = "0.1.41" }
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "6816457d2b2df98653f286bf9a374f236a17748f", optional = true }
grovedb-commitment-tree = { workspace = true, optional = true }

[dev-dependencies]
tokio = { version = "1.40", features = ["full"] }
Expand Down
8 changes: 4 additions & 4 deletions packages/rs-drive-abci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ derive_more = { version = "1.0", features = ["from", "deref", "deref_mut"] }
async-trait = "0.1.77"
console-subscriber = { version = "0.4", optional = true }
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "0842b17583888e8f46c252a4ee84cdfd58e0546f", optional = true }
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "6816457d2b2df98653f286bf9a374f236a17748f" }
grovedb-commitment-tree = { workspace = true }
nonempty = "0.11"
# Shielded-pool snapshot needs raw RocksDB SstFileWriter + ingest_external_file_cf
# bindings, and blake3 for the snapshot-file checksum.
Expand All @@ -108,7 +108,7 @@ dpp = { path = "../rs-dpp", default-features = false, features = [
drive = { path = "../rs-drive", features = ["fixtures-and-mocks"] }
drive-proof-verifier = { path = "../rs-drive-proof-verifier" }
strategy-tests = { path = "../strategy-tests" }
grovedb-commitment-tree = { git = "https://github.com/dashpay/grovedb", rev = "6816457d2b2df98653f286bf9a374f236a17748f", features = ["client"] }
grovedb-commitment-tree = { workspace = true, features = ["client"] }
assert_matches = "1.5.0"
drive-abci = { path = ".", features = ["testing-config", "mocks", "shielded_test_data"] }
bls-signatures = { git = "https://github.com/dashpay/bls-signatures", rev = "0842b17583888e8f46c252a4ee84cdfd58e0546f" }
Expand All @@ -122,8 +122,8 @@ integer-encoding = { version = "4.0.0" }

# For dump_only_default_and_aux_cfs_under_shielded_subtree_prefix — same
# subtree-prefix algorithm grovedb uses internally.
grovedb-path = { git = "https://github.com/dashpay/grovedb", rev = "6816457d2b2df98653f286bf9a374f236a17748f" }
grovedb-storage = { git = "https://github.com/dashpay/grovedb", rev = "6816457d2b2df98653f286bf9a374f236a17748f" }
grovedb-path = { workspace = true }
grovedb-storage = { workspace = true }

[features]
default = ["bls-signatures"]
Expand Down
46 changes: 46 additions & 0 deletions packages/rs-drive-abci/src/query/document_query/v1/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5919,6 +5919,52 @@ mod time_range_proof_verification {
assert_hashtag_counts(&page.entries, &[("ibiza", 3), ("berlin", 1)]);
}

/// A window no document has landed in — every fresh window of a
/// `range == step` grid until its first post — ranks EMPTY through
/// the entry point, proof and all, rather than failing. The window's
/// bucket tree is created by the first write under it, so the pinned
/// path does not exist; grovedb answers the axis read over that
/// absent path with an empty page its proof's own layers
/// authenticate (grovedb #965), and the SDK verifies it at rank 0
/// against the signed root hash. Before that the prover refused ("a
/// single-path axis read must produce exactly one axis descent") and
/// every such request surfaced as an internal error. The window
/// starting four steps back covers `[start − 8h, start − 2h)`, which
/// none of the fixture's posts fall into.
#[test]
fn an_unwritten_window_ranks_empty_through_the_entry_point() {
let (platform, base_state, version) = setup_platform(None, Network::Testnet, None);
let (contract, state) = setup_ranked_trending(&platform, &base_state, version);
let unwritten_start_ms = NEWEST_BUCKET_START_MS - 8 * HOUR_MS;

let request = windowed_top_k_request(
contract.id().to_vec(),
by_start_selection(unwritten_start_ms),
);
let (proof, mtd, provider) = prove_and_sign(&platform, &state, request, version);

let (page, _mtd, _proof) =
<DocumentRankedEntries as FromProof<SdkDocumentQuery>>::maybe_from_proof_with_metadata(
windowed_top_k_query(
&contract,
TimeRangeSelector::ByStart {
start_ms: unwritten_start_ms,
},
),
signed_response(proof, &mtd),
Network::Testnet,
version,
&provider,
)
.expect("a correctly signed empty window must verify");
let page = page.expect("the ranked entry point always returns a page");
assert_eq!(page.starting_rank, 0);
assert!(
page.entries.is_empty(),
"an unwritten window is an authenticated empty leaderboard"
);
}

/// The window-binding property of the relative selectors, on the
/// ranked surface: re-signing the response over a one-step-later
/// metadata time makes the verifier re-derive a *different* bucket
Expand Down
Loading
Loading