fix(proofs): version trailing-byte proof decoding#739
Conversation
📝 WalkthroughWalkthroughThis PR replaces unconditional trailing-byte rejection during proof deserialization with a version-aware policy flag. Version definitions add ChangesVersion-aware proof decoding
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
grovedb/src/operations/proof/mod.rs (1)
31-37:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winDoc comment still says trailing bytes are always rejected.
The comment now conflicts with the versioned policy (v1/v2 can accept trailing bytes, v3 rejects). Please update this block to describe conditional rejection.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@grovedb/src/operations/proof/mod.rs` around lines 31 - 37, Update the module doc comment in grovedb/src/operations/proof/mod.rs that currently states "trailing bytes beyond the encoded envelope are rejected" to explain the conditional behavior by version: state that v1/v2 proofs may accept trailing bytes while v3 (and later) enforces canonical decoding by rejecting any trailing bytes; keep the rationale about equality-bytes assumptions and note the versioned policy decision. Target the top-of-file doc block in this module (the proof decoding/canonicality paragraph) and amend the wording to mention v1/v2 vs v3 behavior explicitly.
🧹 Nitpick comments (2)
grovedb/src/operations/proof/aggregate_sum/mod.rs (2)
190-190: ⚡ Quick winConsider adding error context per coding guidelines.
The bare
?operator doesn't provide context about where the decode failure occurred. As per coding guidelines, wrap errors with context to aid debugging.Suggested fix
- let grovedb_proof = super::decode_grovedb_proof_versioned(proof, grove_version)?; + let grovedb_proof = super::decode_grovedb_proof_versioned(proof, grove_version) + .map_err(|e| Error::CorruptedData(format!("verify_aggregate_sum_query_per_key decode: {}", e)))?;As per coding guidelines: Wrap errors with context using
.map_err(|e| Error::CorruptedData(format!("context: {}", e)))pattern in Rust source files🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@grovedb/src/operations/proof/aggregate_sum/mod.rs` at line 190, The call to decode_grovedb_proof_versioned(proof, grove_version) uses the bare ? and should be wrapped with contextual error mapping; replace the bare `?` on the result used to assign grovedb_proof with `.map_err(|e| Error::CorruptedData(format!("decoding grovedb proof failed: {}", e)))?` (i.e., map the error from decode_grovedb_proof_versioned into Error::CorruptedData with a clear message) so failures include where the decode failed.
119-119: ⚡ Quick winConsider adding error context per coding guidelines.
The bare
?operator doesn't provide context about where the decode failure occurred. As per coding guidelines, wrap errors with context to aid debugging.Suggested fix
- let grovedb_proof = super::decode_grovedb_proof_versioned(proof, grove_version)?; + let grovedb_proof = super::decode_grovedb_proof_versioned(proof, grove_version) + .map_err(|e| Error::CorruptedData(format!("verify_aggregate_sum_query decode: {}", e)))?;As per coding guidelines: Wrap errors with context using
.map_err(|e| Error::CorruptedData(format!("context: {}", e)))pattern in Rust source files🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@grovedb/src/operations/proof/aggregate_sum/mod.rs` at line 119, The call to decode_grovedb_proof_versioned(proof, grove_version) uses a bare `?` and should be wrapped to add context; replace the `?` on that call so errors are mapped (e.g., via .map_err(|e| Error::CorruptedData(format!("decoding grovedb proof (versioned) failed: {}", e)))) to preserve the original error while adding the descriptive message — update the assignment to `grovedb_proof` accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@grovedb/src/operations/proof/mod.rs`:
- Around line 31-37: Update the module doc comment in
grovedb/src/operations/proof/mod.rs that currently states "trailing bytes beyond
the encoded envelope are rejected" to explain the conditional behavior by
version: state that v1/v2 proofs may accept trailing bytes while v3 (and later)
enforces canonical decoding by rejecting any trailing bytes; keep the rationale
about equality-bytes assumptions and note the versioned policy decision. Target
the top-of-file doc block in this module (the proof decoding/canonicality
paragraph) and amend the wording to mention v1/v2 vs v3 behavior explicitly.
---
Nitpick comments:
In `@grovedb/src/operations/proof/aggregate_sum/mod.rs`:
- Line 190: The call to decode_grovedb_proof_versioned(proof, grove_version)
uses the bare ? and should be wrapped with contextual error mapping; replace the
bare `?` on the result used to assign grovedb_proof with `.map_err(|e|
Error::CorruptedData(format!("decoding grovedb proof failed: {}", e)))?` (i.e.,
map the error from decode_grovedb_proof_versioned into Error::CorruptedData with
a clear message) so failures include where the decode failed.
- Line 119: The call to decode_grovedb_proof_versioned(proof, grove_version)
uses a bare `?` and should be wrapped to add context; replace the `?` on that
call so errors are mapped (e.g., via .map_err(|e|
Error::CorruptedData(format!("decoding grovedb proof (versioned) failed: {}",
e)))) to preserve the original error while adding the descriptive message —
update the assignment to `grovedb_proof` accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ddda047d-74dd-4a1d-9a3e-d62ddd713ea2
📒 Files selected for processing (11)
grovedb-version/src/version/grovedb_versions.rsgrovedb-version/src/version/v1.rsgrovedb-version/src/version/v2.rsgrovedb-version/src/version/v3.rsgrovedb/src/operations/proof/aggregate_count/mod.rsgrovedb/src/operations/proof/aggregate_count_and_sum/mod.rsgrovedb/src/operations/proof/aggregate_sum/mod.rsgrovedb/src/operations/proof/mod.rsgrovedb/src/operations/proof/verify.rsgrovedb/src/tests/proof_advanced_tests.rsgrovedb/src/tests/provable_count_provable_sum_tree_tests.rs
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #739 +/- ##
========================================
Coverage 91.43% 91.43%
========================================
Files 236 236
Lines 67114 67130 +16
========================================
+ Hits 61366 61382 +16
Misses 5748 5748
🚀 New features to boost your workflow:
|
Summary
Tests
Summary by CodeRabbit
New Features
Tests