Skip to content

fix(merk): validate fetched links during lazy load - #736

Closed
QuantumExplorer wants to merge 5 commits into
developfrom
codex/fix-682-validate-fetched-merk-links
Closed

fix(merk): validate fetched links during lazy load#736
QuantumExplorer wants to merge 5 commits into
developfrom
codex/fix-682-validate-fetched-merk-links

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Summary

  • expose the tree type through Fetch so lazy loads can validate fetched children against pruned link metadata
  • validate fetched key, child heights, aggregate data, and tree-type-aware hash in TreeNode::load and Walker::detach
  • add Merk walk regressions for wrong-key and wrong-hash fetched children, including the read-only RefWalker path

Fixes #682.

Verification

  • cargo test -p grovedb-merk walk_pruned --lib
  • cargo test -p grovedb-merk tree::walk::test --lib
  • cargo check -p grovedb --lib
  • git diff --check

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@QuantumExplorer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 20 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b99b0042-c62a-4918-887c-25f34ec1d862

📥 Commits

Reviewing files that changed from the base of the PR and between a2129a9 and 5160982.

📒 Files selected for processing (6)
  • merk/src/merk/restore.rs
  • merk/src/merk/source.rs
  • merk/src/tree/mod.rs
  • merk/src/tree/ops.rs
  • merk/src/tree/walk/fetch.rs
  • merk/src/tree/walk/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-682-validate-fetched-merk-links

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@QuantumExplorer QuantumExplorer changed the title Validate fetched Merk links during lazy load fix(merk): validate fetched links during lazy load May 21, 2026
@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.47%. Comparing base (60f2968) to head (5160982).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #736      +/-   ##
===========================================
+ Coverage    91.42%   91.47%   +0.04%     
===========================================
  Files          236      237       +1     
  Lines        67053    67339     +286     
===========================================
+ Hits         61305    61597     +292     
+ Misses        5748     5742       -6     
Components Coverage Δ
grovedb-core 88.94% <ø> (ø)
merk 92.38% <100.00%> (+0.11%) ⬆️
storage 86.36% <ø> (ø)
commitment-tree 96.43% <ø> (ø)
mmr 96.79% <ø> (+0.03%) ⬆️
bulk-append-tree 89.39% <ø> (+0.13%) ⬆️
element 97.38% <ø> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@QuantumExplorer

Copy link
Copy Markdown
Member Author

This is Claude, closing per maintainer decision after re-review against current develop (2026-08-22).

Rationale: the validation is optional hardening with no attacker vector — the fetch reads the node's own RocksDB snapshot, and clients are already protected because proof verification recomputes every hash against the root. What it would buy (fail-loud on local corruption, catching mislabeled-tree-type bugs at the fetch site) turned out to carry real costs on today's develop:

Issue #682 stays open as a known low-severity finding. verify_grovedb remains the tool for storage-integrity sweeps. If this is ever revisited, the cheaper shape is debug-only validation (extending the existing debug_assert on the key) — that catches #686-class internal bugs in every test run with zero production behavior change and no version gate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[audit][low] Lazy-loaded Merk references do not validate fetched node metadata

1 participant