Repository navigation
fix(proof): verify a limit-cut proof that reveals a bound key after the cut - #1009
PastaPastaPasta wants to merge 5 commits into
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 31 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (19)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughGroveDB now selects limit-reached proof-tail verification behavior by Grove version. V1–V3 retain the prior behavior, while V4 enables the updated behavior. Proof verification and indexed-proof replay receive version information, and regression tests cover limit-cut proofs. ChangesLimit-cut proof verification
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant GroveDBProofVerifier
participant execute_proof_for_grove_version
participant MerkProofVerifier
GroveDBProofVerifier->>execute_proof_for_grove_version: proof bytes, limit, direction, GroveVersion
execute_proof_for_grove_version->>MerkProofVerifier: verify using version-selected proof-tail behavior
MerkProofVerifier-->>GroveDBProofVerifier: verification result
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk remains in the supplied evidence: V4 enables the revised limit-cut behavior, while earlier versions retain their existing semantics. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change broadens proof acceptance only under an explicit protocol version while preserving result limits and proof-integrity checks. No introduced security bypass was identified. Production version activation and downstream trust assumptions were not established by this review. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 83a8d1b) · triage: critical · Phase 2 only (no Phase 1 for this repository) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (no Phase 1 for this repository)
Static verification at head e152ca7 confirms the V1-only repair preserves pre-limit completeness checks, stream ordering, root reconstruction, and V0 behavior; no blocking defect was identified. One in-scope performance suggestion is confirmed: value-bearing tail nodes repeatedly scan the entire query. No local builds or tests were run; the supplied CI snapshot shows formatting and linting passing, with all three Ubuntu test shards still in progress.
🟡 1 suggestion(s)
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:
normalbygpt-6.1-sol(effort low) — The production change in merk/src/proofs/query/verify.rs is a small, contained proof-verification guard with extensive tests, so it does not meet the large-or-intricate requirement for critical despite touching cryptographic proof acceptance. - 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 high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `merk/src/proofs/query/verify.rs`:
- [SUGGESTION] merk/src/proofs/query/verify.rs:217-218: Avoid rescanning every query item for every tail value
After the limit is reached, `self.items.iter().any(...)` restarts a full membership scan for every value-bearing tail node, introducing O(tail_nodes × query_items) work. For example, an ascending query containing `Key(0)` followed by many keys above the tree's maximum, verified at limit 1 against a fully revealed tree, scans every query item for every remaining value. This proof can reconstruct the authentic root and was previously accepted: the directional iterator remained at the next requested key, so each tail node exited after one lower-bound comparison. The 50,000-operation proof cap does not prevent this multiplicative comparison cost. Use an ordered membership lookup or a monotonic tail cursor that advances through query items without performing completeness checks, while preserving rejection of matching values beyond the limit.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1009 +/- ##
===========================================
- Coverage 93.18% 93.09% -0.09%
===========================================
Files 336 336
Lines 105653 106501 +848
===========================================
+ Hits 98449 99149 +700
- Misses 7204 7352 +148
🚀 New features to boost your workflow:
|
|
Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
Verified the supplied Phase-2 findings against head d7ea73f. The independent tail cursor fixes the prior multiplicative scan, but the new acceptance behavior also applies to historical GROVE_V3 verification without the feature gate required by the repository's versioning contract. Validation was static only; the supplied exact-head CI snapshot has pending or queued policy checks and no completed build/test evidence.
🔴 1 blocking
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:
normalbygpt-6.1-sol(effort low) — The diff changes cryptographic proof acceptance in merk/src/proofs/query/verify.rs::execute_proof, but the production change is small and contained rather than 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 high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `merk/src/proofs/query/verify.rs`:
- [BLOCKING] merk/src/proofs/query/verify.rs:222-223: Gate the new tail acceptance independently of the V1 proof format
This condition enables the relaxed tail verification for existing protocol snapshots, not just a new activation. GROVE_V3 already selects `prove_query_non_serialized: 1`, and `verify_layer_proof_v1` passes `PROOF_VERSION_LATEST`, which remains 1, without consulting a feature slot for this behavior. At the PR base, reaching the limit resets `in_range`, and a subsequent boundary key behind a hidden node can fail the lower-bound check. This new early return accepts that same stream. Consequently, identical proof bytes, query, limit, and GROVE_V3 produce different acceptance outcomes in old and upgraded verifiers.
Unchanged generation and preservation of previously accepted results do not preserve historical acceptance. `grovedb-version/src/version/v4.rs:315–318` explicitly requires a feature gate for fixes that alter released accepted/rejected outcomes; its axis-descent and sum-budget documentation also distinguishes the V1 envelope from protocol activation. Add a tail-verification feature slot, retain the historical behavior for existing snapshots, and enable the relaxation in the new activation snapshot. Thread the selection through GroveDB and applicable Merk entry points with fail-closed dispatch. Add a regression using the same authentic limit-cut proof to demonstrate historical rejection under GROVE_V3 and acceptance under the newly enabled snapshot.
|
Waiting for bot review — coderabbitai not yet · thepastaclaw 1 thread unresolved — resolve it. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The version gate and monotonic tail cursor resolve both prior findings at 3d217d7. One in-scope blocker remains: bounded-axis proof generation replays its secondary proof through the historical verifier, so affected honest proofs still fail before the newly gated verification path can consume them. Validation was static only; diff whitespace checks passed, but the supplied exact-head CI snapshot does not establish completed build or test results.
🔴 1 blocking | 🟡 4 suggestion(s)
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); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The intricate changes in merk/src/proofs/query/verify.rs alter cryptographic proof acceptance after a query limit is reached, with version-gated dispatch across multiple GroveDB verification paths. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `grovedb/src/operations/proof/verify.rs`:
- [BLOCKING] grovedb/src/operations/proof/verify.rs:1158-1164: Apply the gated semantics to the axis prover's replay too
Bounded-axis verification now selects the new tail rule, but its production generator still cannot produce an affected payload. `indexed_axis/generate.rs::build_axis_descent_payload` generates the bounded secondary proof and calls `build_row_target_chains`, whose line 64 replays it with `execute_proof(..., 0)`. That call always retains historical tail checks, including under GROVE_V4.
A concrete affected layout is a batch-built PSIT containing sums 0 through 19, with distinct nonempty primary keys except an empty primary key at sum 10. Empty keys pass the indexed-primary length validation. An ascending bounded query over sums [2, 9] with limit 3 lowers to an exclusive upper bound equal to the sum-10 secondary key. The sorted batch builds that key as the root; after yielding sums 2, 3 and 4, the proof includes hidden nodes before revealing this boundary. The replay therefore reaches the historical "Cannot verify lower bound" rejection and aborts `prove_query`, although the new verifier accepts the secondary stream.
Use the caller's GroveVersion and V1 proof semantics for this V1 payload replay, matching the consumer here, and add an end-to-end bounded-axis regression for this layout. This changes a current V1 caller, not frozen V0 proof verification.
In `merk/src/proofs/query/verify.rs`:
- [SUGGESTION] merk/src/proofs/query/verify.rs:127-128: Make the provided version-aware trait method fail closed
The concrete Query override dispatches on `execute_proof_limit_reached_tail` and rejects unknown versions, but the newly provided trait method ignores GroveVersion. A downstream wrapper implementing the existing trait methods inherits an entry point that silently uses historical behavior for slot 1 and can accept proofs for unsupported slot 2. This contradicts the version-aware method's documented selection contract and makes behavior depend on whether the receiver is Query or a delegating implementation.
Preserve source compatibility with a default method that delegates only for slot 0 and returns `UnknownVersionMismatch` for slots it cannot implement. Implementations supporting slot 1 can override it. Add a regression with a delegating implementation that inherits the default. In-repository GroveDB callers use Query's protected override, so this is a public-API safety suggestion rather than a demonstrated live-node divergence.
- [SUGGESTION] merk/src/proofs/query/verify.rs:217-223: Isolate the historical and relaxed verifier implementations
Feature-slot versions 0 and 1 now execute the same modified verifier body, selected by `accept_limit_reached_tail`. The false branch preserves historical checks today, but AGENTS.md lines 12–13 explicitly require separate version-owned functions and prohibit version-specific behavior in shared implementation bodies. Future changes to this body would affect both generations and require proving the released generation unchanged again.
Dispatch the historical and activated behavior to separate generation-owned implementations, retaining the historical entry point and isolating the new V1-tail behavior in the activated implementation. Keep frozen V0 semantics unchanged. This is an implementation-isolation suggestion; no current historical acceptance divergence was found.
- [SUGGESTION] merk/src/proofs/query/verify.rs:1863-1879: Cover value-bearing tail nodes at exact item bounds
The new tail-cursor regressions cover interior matches and gaps, but do not exercise value-bearing tail keys equal to a singleton Key or an inclusive range endpoint. Those cases directly protect the advancement predicates at lines 318–325: changing the ascending comparison from `<` to `<=` would skip Key(5), yet the current matched-tail examples at 4, 12 and 1 would still reject correctly.
Extend the hand-built streams to reject a tail value at Key(5) in both directions and at inclusive range endpoints, and to accept unmatched values at exclusive endpoints. The current comparisons are correct; this is targeted coverage for the newly introduced cursor, not a reported verification defect.
In `grovedb-version/src/version/merk_versions.rs`:
- [SUGGESTION] grovedb-version/src/version/merk_versions.rs:82: Document the source-breaking version-table field addition
`MerkProofVersions` is a public exhaustive struct. Adding this required field breaks existing downstream literals such as `MerkProofVersions { prove_count_offset_on_range: 0 }` and exhaustive destructuring. Deriving Default and providing a default trait method do not preserve those callers' source compatibility.
The new changelog entry describes protocol activation but omits the Rust API break, whereas neighboring version-table additions explicitly identify their breaking impact. Add a breaking-API note explaining that callers must initialize `execute_proof_limit_reached_tail` to 0 for historical behavior, use struct-update defaults, or select an appropriate snapshot. Account for this source incompatibility in the eventual package release. No additional protocol gate is needed for the struct-schema addition.
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
Independent static review of the complete diff at 5ea1f13 found no actionable in-scope defects, and all seven prior findings are fixed. The GROVE_V4-only tail rule preserves historical verification, retains ordering and pre-limit completeness checks, and is consistently selected by applicable V1 consumers and indexed-axis prover replay. No builds or tests were run; the supplied exact-head CI snapshot shows change detection and security audit queued and policy reconciliation pending, so build/test completion remains unconfirmed.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
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); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The intricate changes to execute_query_proof_v1 in merk/src/proofs/query/verify.rs alter authenticated proof acceptance rules, including post-limit value rejection and query-bound validation, and introduce version-dependent verification across multiple GroveDB proof paths. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Bots are done — your move: post |
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The complete diff at the specified head preserves historical verification, gates the relaxed tail rule to GROVE_V4, and applies that selection consistently to the affected consumers and indexed-axis prover replay. All seven prior findings are fixed, with no remaining actionable in-scope findings. Validation was static only; the supplied exact-head CI snapshot reports passing Ubuntu tests, linting, formatting, security audit, and coverage checks, while PR Hygiene remains pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
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); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The intricate changes to merk/src/proofs/query/verify.rs alter cryptographic proof acceptance in execute_query_proof_v1 and introduce consensus-relevant version dispatch across multiple GroveDB verification paths. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Bots are done — your move: post |
1099cfc to
ecd45eb
Compare
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
…he cut Once its limit runs out the prover hides the rest of the walk, but it can still reveal a key it passed (an exclusive range end, or a later query item's bound) behind the nodes it hid. The verifier checked that key as a range bound and rejected the honest proof with "Cannot verify lower bound of queried range", even at the prover's own limit. It is the norm for subtrees written in one batch, so GroveDB's own `prove_query` / `verify_query` disagreed for most limit-cut queries over an exclusive bound, including subqueries whose outer layer the limit cuts. Once the limit is reached the walk is complete, so the V1 verifier no longer checks later nodes as range bounds. A node carrying a value the query matches is still rejected as a result past the limit. Every proof accepted before is still accepted with the same result. Proof generation and V0 verification are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
After the limit, each node carrying a value rescanned every query item to see whether it matched, so a long tail over a query with many items cost tail nodes x items comparisons, which the proof op cap does not bound. Keys after the limit come in strict walk order, so a cursor over the items only moves forward and the whole tail costs one pass. It is kept apart from the verifier's own item iterator, whose position records how far the walk proved the query. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
GROVE_V3 is live and already verifies V1 proofs, so accepting a limit-cut proof it rejects would let upgraded and older verifiers disagree on the same proof. Gate the change through a new slot, `merk_versions.proof.execute_proof_limit_reached_tail`: 0 for grove v1..v3, keeping the released rejection, and 1 for GROVE_V4. `QueryProofVerify::execute_proof_for_grove_version` dispatches on the slot and refuses unknown versions; it has a default body, so existing implementations keep compiling. `execute_proof` keeps the released behaviour. GroveDB's V1 path-query, carrier, axis-descent, sum-budget and indexed-axis verifiers pass their grove version. The same limit-cut proof is now pinned as rejected under GROVE_V3 and accepted under GROVE_V4, at the merk and GroveDB levels. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The indexed-axis prover replays its secondary proof to build row chains and replayed it with the released rules, so under GROVE_V4 a limit-cut bounded read whose secondary proof reveals a boundary key aborted `prove_query` although the verifier accepts the stream. The replay now selects its behaviour from the same version slot as the verifier. Also from review: - split the verifier into version-owned functions: version 0 is the released body verbatim, version 1 adds the tail rule; - the default `execute_proof_for_grove_version` body serves only version 0 and refuses others instead of silently using the old rule; - cover tail values on item bounds and the fail-closed default; - note the `MerkProofVersions` field addition in the changelog. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The indexed-axis prover replay only ran its version-1 branch in tests, since axis reads exist from GROVE_V4. Exercise the other two with a GROVE_V4 snapshot whose slot is set to 0 (the released replay rejects the limit-cut proof and aborts `prove_query`) and to 2 (refused as an unknown version), on the same batch-written provable-sum indexed tree. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ecd45eb to
83a8d1b
Compare
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The complete PR diff preserves historical verification and confines relaxed limit-cut tail acceptance to GROVE_V4, with consistent version selection in the affected verifiers and axis-prover replay. Independent source inspection confirms that all seven prior findings are fixed, with no remaining actionable in-scope issues. This was a static review only; the supplied exact-head CI snapshot shows successful formatting, linting, and security audit checks, while all three Ubuntu test shards remain in progress.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
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); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The intricate changes in merk/src/proofs/query/verify.rs alter cryptographic proof acceptance in execute_query_proof_v1 and introduce version-dependent verification across multiple GroveDB proof paths. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
This is Claude. Closing in favor of #1012, at the maintainer's request. This PR found the problem: an honest limit-cut proof fails at its own limit with "Cannot verify lower bound of queried range". #1012 fixes it in the merk prover, where it starts. When the limit runs out, From the V1 envelope on ( Every verifier in this PR's test matrix that still has the released code accepts the new shape. So #1012 needs:
Clients verify these proofs once the node serving them is upgraded. V0 proofs (grove v1/v2) keep their shape. Your GroveDB tests are ported in #1012 and pass under GROVE_V3 and the latest version: every cutting limit over batch-written subtrees, the subquery outer layer, and the indexed-axis bounded read. One thing #1012 doesn't cover: nodes that haven't upgraded still produce the old shape. If clients should accept those proofs too, this PR's verifier tolerance could come back as a smaller follow-up. |
Issue being fixed or feature implemented
An honest V1 proof that its limit cut short can fail to verify, even when the verifier uses the prover's own limit:
Once its limit runs out, the prover hides the rest of the walk. It can still reveal a key it passed on the way, though (an exclusive range end, or a later query item's bound), behind the nodes it hid. The verifier checks that key as a range bound. The node before it is hidden, so the check fails.
It depends on the tree's shape, and the common case is the bad one:
GroveDb::apply_batch, which is how Dash Platform writes,prove_query→verify_queryondevelopfails for 24/27, 54/57 and 144/147 limit-cut queries over 20, 40 and 100 items.Affected shapes:
Range,RangeTo,RangeAfterTo);RangeAfter,RangeAfterTo);Found while testing #1008.
What was done?
The rule. Once a V1 proof's limit is reached, the walk is complete and no later node can be a result. So later nodes are no longer checked as range bounds:
Keys after the limit come in strict walk order, so the match check uses its own forward cursor over the query items: the whole tail costs one pass over the items, not one scan per node. The cursor is kept apart from the verifier's main item iterator, whose position records how far the walk proved the query.
Everything that makes the result correct is decided before the limit is reached, and none of it changes: the first item's bound check, rejecting hidden nodes inside a range, the transitions between items, and key ordering. The end-of-proof absence check was already skipped once the limit is reached. For queries built through
insert_item, every proof accepted before is still accepted with the same result.Gated on the grove version. GROVE_V3 is live and already verifies V1 proofs, so accepting proofs it rejects would let upgraded and older verifiers disagree. The rule is behind a new slot,
merk_versions.proof.execute_proof_limit_reached_tail: 0 for grove v1..v3 (the released rejection) and 1 for GROVE_V4, documented in GROVE_V4's gate list.QueryProofVerify::execute_proof_for_grove_versiondispatches on the slot and refuses unknown versions. It has a default body, so existing implementations keep compiling.execute_proofkeeps the released behaviour.execute_query_proof_v0is the released body verbatim, andexecute_query_proof_v1adds the tail rule.execute_proof_for_grove_versionhas a default body that serves only version 0 and refuses others, so existing implementations keep compiling but don't silently verify GROVE_V4 with the old rule.verify_layer_proof_v1), the carrier aggregate outer walk, axis descent, sum-budget windows and indexed-axis ranges.prove_queryon a limit-cut bounded read the verifier accepts.Proof generation is unchanged. V0 verification (
proof_version = 0) is frozen and unchanged.How Has This Been Tested?
merklimit_reached_tail_tests:limitmatches, on batch-built merks of 20 and 40 keys. Shapes covered:Range,RangeToandRangeAfterToascending;RangeAfterandRangeAfterTodescending; aKey/Range/Key/RangeFrommix;execute_proofand under GROVE_V3, accepted under GROVE_V4, and an unknown slot version is refused;Key, inclusive and exclusive bounds;grovedblimit_cut_exclusive_bound_proof_tests, all on batch-written subtrees:prove_query→verify_queryat every cutting limit over 20 and 100 items;a subquery whose outer layer the limit cuts.
the same limit-cut proof, made under GROVE_V3, is rejected when verified under GROVE_V3 and accepted under GROVE_V4;
a bounded axis read over a batch-written provable-sum indexed tree, whose secondary proof the limit cuts at a boundary key, proves and verifies (before the replay fix,
prove_queryaborted).The first two fail on
developand pass here.Full suites:
cargo test -p grovedb-merk --all-featuresandcargo test -p grovedb --all-featurespass.cargo clippy -p grovedb-merk -p grovedb --all-features --tests -- -D warningsis clean, andcargo check -p grovedb --no-default-features --features verifybuilds.Independent adversarial review with a throwaway fuzz harness, comparing
developand this branch in one binary:None.min(limit, total)matches and the right remaining limit.developaccepts but this branch rejects. 148k proofsdeveloprejected are now accepted, every one returning the correct result. Of 87,990 honest limit-cut cases,developfails 529 and this branch 47; all 47 also fail ondevelopand are the adjacent-items issue below.Separate pre-existing issues the fuzz found (unchanged here, they fail on
developtoo)[RangeTo(..5), RangeFrom(5..)]is not merged byinsert_item. The prover doesn't count key 5 against the limit but emits it as a result, so any limit of 6 or more fails with "Proof returns more data than limit".[RangeAfterTo(15..16), RangeAfterToInclusive(23..=23), RangeAfterTo(38..51), RangeAfter(87..)]ascending fails with "Cannot verify lower bound" on one batch-built tree even withlimit = None.Breaking Changes
None. Under GROVE_V1..V3 verification is unchanged. Under GROVE_V4, for queries built through
insert_item, it accepts a superset of what it accepted before, with the same results.QueryProofVerifygains a method with a default body, so existing implementations keep compiling. Code buildingMerkProofVersionsby hand must set the newexecute_proof_limit_reached_tailfield (noted in the changelog). Proof generation is unchanged.Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
83a8d1b/skip-botsproceeds without the ones not yet reported/self-reviewedCHANGELOG.md,grovedb-version/src/version/merk_versions.rs,grovedb-version/src/version/v1.rsand 16 more) — QuantumExplorerWhen every box is checked the
PR Hygienecheck passes and this can merge.Summary by CodeRabbit