Repository navigation
fix: accept empty append-layer selections in the V1 verifier; validate limit accounting (#865) - #875
Merged
Merged
Conversation
Contributor
|
Warning Review limit reachedNext included review available in 30 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
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 |
…e limit accounting (#865) The V1 verifier's bulk/commitment range extraction rejected a selection with no items (or only a key at u64::MAX) as "No valid range items", while the prover proves and charges that selection as empty — an honest proof failed to verify. Any empty span is now returned as an explicit empty selection: no values are extracted, no positions are expected, and nothing is charged, mirroring the prover. The span-based charge the audit describes predates #847: the generator already charges the normalized cardinality of the selected positions (a deduplicated set), so gaps in disjoint selections, out-of-range spans and reversed ranges charge nothing and the arithmetic saturates. The commitment-tree generator shares that path. This adds the runtime validation the audit left outstanding: for bulk and commitment layers beside a Merk sibling under a global limit, disjoint, empty, reversed, mixed and overlapping selections are proved, verified, and the sibling's remaining budget is checked to be limit minus matched rows at every limit and under both empty-layer prove options. A contrast test pins that limit 1 starves the sibling through the root Merk proof's key cap — identically for a plain empty Merk child — not through any charge by the layer. Co-Authored-By: Claude Fable 5.1 <[email protected]>
QuantumExplorer
force-pushed
the
claude/issue-865
branch
from
September 6, 2026 18:07
9c1a27f to
479d367
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #875 +/- ##
========================================
Coverage 92.58% 92.58%
========================================
Files 297 297
Lines 92299 92297 -2
========================================
+ Hits 85454 85455 +1
+ Misses 6845 6842 -3
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #865.
What the audit found
The bulk proof generator charged the shared limit for the bounding span of the selection, so gaps in a disjoint selection consumed budget, and empty or reversed selections could hit unsafe subtraction. The commitment-tree generator shares the path.
State on
developThe audited snapshot (
2fa0f133) predates #847. Since then the generator charges the normalized cardinality of the selected positions (a deduplicated set), so gaps, out-of-range spans and reversed ranges charge nothing, and the subtraction saturates. The commitment-tree generator delegates to the same function. The MMR and dense generators charge proved leaves/entries, so all four adapters agree with the verifier.What was still wrong
Running the audit's validation matrix surfaced one real prover/verifier divergence: a subquery with no items (or only a key at
u64::MAX, a position no tree can hold). The prover proves and charges it as empty; the verifier's range extraction rejected it as "No valid range items", so an honest proof failed to verify.Changes
extract_range_from_query_items(V1 verifier): an empty span is now returned as an explicit empty selection instead of an error, so the caller extracts no values, expects no positions and charges nothing, mirroring the prover. This only turns a rejection of honest proofs into acceptance; proof bytes and the prover are unchanged, so no version gate is needed (same treatment as the fix: follow-ups from the per-instance limits reviews (#844/#845) #847 verifier fixes).grovedb/src/tests/append_layer_limit_accounting_tests.rs— the outstanding runtime validation. For BulkAppendTree and CommitmentTree layers (ten entries across two completed chunks plus the dense buffer) beside a Merk sibling under a global limit, it proves and verifies disjoint, beyond-count, absent-key, reversed (RangeandRangeInclusive), mixed and overlapping selections at limits 1, 3, 6 and 50 under both empty-layer prove options, asserting the layer yields exactly the normalized selection and the sibling receives limit minus matched rows.limitkeys are proven, and the sibling is the second root key), identically for a plain empty Merk child, and that admitting both keys hands the sibling the whole budget when the selection is empty.Verification
cargo test -p grovedb --all-features: 3005 passed, 0 failed.--all-features --all-targets -D warnings) reports nothing in the changed files; the remaining hits are pre-existing in untouched test files under local clippy 1.97.🤖 Generated with Claude Code