Repository navigation
fix(proof): check the tree type when verifying a count-offset page - #1036
Conversation
The prover serves a page with a non-zero offset only from a ProvableCountTree, a ProvableCountSumTree or a ProvableCountProvableSumTree. The verifier now applies the same rule: in the V1 walk it checks the proved row of the tree the page reads and returns the prover's InvalidQuery error for any other tree type, including an empty one. The check is not gated by grove version: the prover has always refused these trees, so no proof it produces changes verdict. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 03a7c08) · triage: low · Phase 2 only (no Phase 1 for this repository) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1036 +/- ##
===========================================
- Coverage 93.36% 93.26% -0.10%
===========================================
Files 366 366
Lines 113016 112498 -518
===========================================
- Hits 105512 104922 -590
- Misses 7504 7576 +72
🚀 New features to boost your workflow:
|
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (no Phase 1 for this repository)
Static verification of head 03a7c08 confirms that the shared V1 verifier now enforces the prover's existing host-type restriction, including empty and nested hosts, without changing proof generation or parent-child authentication. No actionable findings remain. Current CI shows all three Ubuntu test shards, linting, formatting, and security audit passing; the review and PR Hygiene checks remain pending.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — The production diff adds a small, localized tree-type validation to an existing verifier loop, with focused regression tests, and is not large or intricate enough to qualify as critical. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer
|
Bots are done — your move: post |
Basic explanation
What this does: A query can ask for a page of rows that starts after an offset ("skip 5, give me the next 3"). GroveDB only produces proofs for such a page when the tree being paged counts its rows in a provable way (
ProvableCountTree,ProvableCountSumTree,ProvableCountProvableSumTree). The side that produces the proof enforced that rule; the side that checks the proof did not. This PR makes the checking side apply the same rule.Value: The prover and the verifier now agree on which trees an offset page can be read from, and they report the same error. A client that verifies an offset page against any other tree type gets a clear
InvalidQueryerror instead of a result that depends on the proof bytes.Risks: Low. No proof the prover produces changes verdict, because the prover has always refused these trees. One result changes for callers: verifying an offset query against an empty tree of another type returned
Okwith no rows and now returnsInvalidQuery, which is what the prover already answered for the same query. Proof verification is not part of block execution, so there is no consensus impact.Issue being fixed or feature implemented
check_count_offset_target_tree_typeandprove_count_offset_layer_v1accept a query with a non-zero offset only when the tree it reads is aProvableCountTree, aProvableCountSumTreeor aProvableCountProvableSumTree. A page is a statement about counts, so the counts it is checked against have to be the ones the tree commits to.The verifier's envelope gate carried a comment saying the tree-type check happened later in the V1 walk, but the walk had no such check: the count-offset dispatch ran on whatever tree the path led to.
What was done?
validate_count_offset_hostingrovedb/src/operations/proof/verify.rs. For a query with a non-zero offset, the V1 walk calls it on every proved row; when the row is the tree the page reads (the last segment of the query path, under the matching parent path), its element must be one of the three tree types above. Any other element returns the prover's own error text.verify_query,verify_query_raw,verify_subset_query, and the recursion into lower layers) goes through this row loop, so the check covers all of them.Before and after
hostis any tree that is not one of the three types above (Tree,SumTree,BigSumTree,CountTree,CountSumTree,ProvableSumTree).proofis the proof of the same range without an offset.hostOk((root_hash, vec![]))Err(InvalidQuery("count-offset paginated queries are only valid against ..."))Err(InvalidProof(..))from the page verifier, which never looked at the tree's typeErr(InvalidQuery("count-offset paginated queries are only valid against ..."))A
ProvableCountTreenext to such a tree is unaffected: offset 1, limit 3 over rowsa..estill verifies and returnsb,c,d.How Has This Been Tested?
Three new tests in
grovedb/src/tests/count_offset_paginated_tests.rs:verifier_refuses_offset_on_populated_non_count_hostsverifier_refuses_offset_on_empty_non_count_hostsverifier_refuses_offset_on_nested_provable_sum_treeThey cover the six tree types listed above, with rows and empty, on
GROVE_V4and the latest grove version, throughverify_query_raw,verify_queryandverify_subset_query. Each case first shows that the prover refuses the offset query and that the proof verifies for the query without an offset. The nested test puts the tree one level down and checks that a siblingProvableCountTreestill serves an offset page.With the new call disabled, all three tests fail; with it, they pass.
Also run locally:
cargo test -p grovedb --lib count_offset_paginated_tests(56 passed)cargo test -p grovedb --lib offset(142 passed)cargo test -p grovedb --lib proof(749 passed)cargo clippy -p grovedb --all-targets(clean)cargo check -p grovedb --no-default-features --features verifyBreaking Changes
None for consensus. For callers of the verifier: an offset query against an empty tree that is not a provable count tree now returns
InvalidQueryinstead ofOkwith no rows.Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
03a7c08/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit