Repository navigation
fix(merk): opaque proof nodes must stay childless (#853) - #873
Merged
Merged
Conversation
`Node::Hash`, `HashWithCount`, `HashWithSum` and `HashWithCountAndSum` compute their hash from embedded fields only, ignoring any children the `Parent`/`Child` ops hang beneath them in the reconstructed proof tree. The query verifier consumes pushes in push order and the chunk restorer walks the reconstructed tree, so a prover could park a forged `KV` under a collapsed `Hash` leaf: the forged row was emitted as a query result (or written to storage during restore) while the root hash still matched the honest tree. `Tree::attach` now refuses to attach anything beneath an opaque node, so every consumer of `execute` (query verification, chunk restore, branch proofs, aggregate verifiers) inherits the rule. The aggregate verifiers' own leaf-shape checks are kept as defense in depth. No version gate: honest provers never emit an opaque node with children, so no legitimate proof changes acceptance. Tests: forged row under a `Hash` node in a query proof (both sides), forged `KV` under a `Hash` boundary in a restore chunk, `attach` unit tests; the existing shape-walk tests that spliced children under opaque leaves now accept the earlier `attach` rejection, and the resource-limit tests build their synthetic chains from `KVHash` instead of `Hash`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Contributor
|
Warning Review limit reachedNext included review available in 34 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 (8)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #873 +/- ##
===========================================
- Coverage 92.58% 92.54% -0.04%
===========================================
Files 297 297
Lines 92293 92380 +87
===========================================
+ Hits 85448 85494 +46
- Misses 6845 6886 +41
🚀 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.
Fixes #853.
Problem
Node::Hash,HashWithCount,HashWithSumandHashWithCountAndSumcompute their hash from embedded fields only.Tree::attachnevertheless letParent/Childops hang children beneath them, and nothing rejected the resulting shape:KVparked under a collapsedHashleaf was emitted as a result row while the root hash still matched the honest tree;Both were reproduced at runtime (new tests fail on
develop): a proof for the honest 3-node tree[3] <- [5] -> [7]verifies against the honest root while claiming key3holds"forged".Fix
Tree::attachnow refuses to attach anything beneath an opaque node (Tree::is_opaque), so every consumer ofexecuteinherits the rule: query verification, chunk restore, branch proofs and the aggregate verifiers. The aggregate verifiers' own leaf-shape checks are retained as defense in depth.No version gate: honest provers never emit an opaque node with children, so no legitimate proof changes acceptance. The merk
executepath is shared by V0 and V1 and no wire format changes.Tests
test_forged_row_under_hash_node_is_rejected/..._right_hash_node_...: forged row under aHashnode in a query proof.test_forged_kv_under_hash_boundary_node_is_rejected: forgedKVunder aHashboundary in a restore chunk; nothing reaches storage.attach_to_opaque_node_is_rejected/attach_to_kvhash_node_is_allowed.attachrejection; the proof resource-limit tests build their synthetic chains fromKVHashinstead ofHash.Docs: recorded the invariant in
docs/merk-deep-dive.mdand the book's proof-system chapter.Local run: merk 726/726, grovedb 2994/2994, rest of workspace 2201/2201 (all-features minus
grovedbg, whose build script needs network here). Clippy under a local clippy 1.97 reports lints in files this PR does not touch (CI's toolchain is clean); no lints in the changed regions.🤖 Generated with Claude Code