Skip to content

fix(drive): accept MMR-aligned shielded note proof ranges#4201

Merged
QuantumExplorer merged 3 commits into
v4.1-devfrom
codex/fix-shielded-proof-chunk-alignment
Jul 23, 2026
Merged

fix(drive): accept MMR-aligned shielded note proof ranges#4201
QuantumExplorer merged 3 commits into
v4.1-devfrom
codex/fix-shielded-proof-chunk-alignment

Conversation

@llbartekll

@llbartekll llbartekll commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • validate shielded encrypted-note proof resume offsets against the on-chain MMR chunk size instead of the multi-chunk request limit
  • add a proof-based regression test for start index 2048 with an 8192-element request cap

Context

Wallet sync rewinds its encrypted-note watermark to a 2048-note MMR chunk boundary, while one request may fetch four chunks. The verifier previously treated the 8192-element request limit as the alignment unit and rejected the valid 2048 resume point, leaving shielded sync and balance recovery stuck.

Validation

  • cargo fmt --package drive -- --check
  • cargo test -p drive accepts_mmr_aligned_start_inside_multi_chunk_query_boundary --lib
  • ./packages/swift-sdk/build_ios.sh --target ios --target sim
  • xcodebuild dashwallet-dashpay Debug for arm64 iOS Simulator

Summary by CodeRabbit

  • Bug Fixes
    • Improved shielded notes verification when resuming from multi-chunk queries.
    • Resume points are now validated against the correct MMR chunk boundaries (not element-count alignment).
    • Added safety to prevent index overflow during range calculations, returning a clear corruption error when invalid.
  • Tests
    • Added coverage for aligned resume points inside multi-chunk requests.
    • Added coverage for rejecting chunk-aligned start points near the maximum index with the expected error.

@github-actions github-actions Bot added this to the v4.1.0 milestone Jul 22, 2026
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d5909da3-b642-4d9e-88b3-ea00392924d2

📥 Commits

Reviewing files that changed from the base of the PR and between 8e680ab and 1fd481e.

📒 Files selected for processing (1)
  • packages/rs-drive/src/verify/shielded/verify_shielded_encrypted_notes/v0/mod.rs

📝 Walkthrough

Walkthrough

The shielded encrypted notes verifier now aligns start_index to MMR chunk boundaries and uses checked arithmetic for inclusive range ends. Tests cover aligned resumes within multi-chunk requests and overflow rejection near u64::MAX.

Changes

Shielded notes verification

Layer / File(s) Summary
MMR-aligned resume validation
packages/rs-drive/src/verify/shielded/verify_shielded_encrypted_notes/v0/mod.rs
Resume validation uses the MMR chunk size, with coverage for aligned positions inside multi-chunk requests and correct total_count extraction.
Query range overflow protection
packages/rs-drive/src/verify/shielded/verify_shielded_encrypted_notes/v0/mod.rs
Inclusive end-index calculation now fails with a corruption error when the range exceeds u64::MAX, covered by a boundary test.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: shumkov, quantumexplorer

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: accepting MMR-aligned shielded note proof ranges.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-shielded-proof-chunk-alignment

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.

@llbartekll
llbartekll requested a review from shumkov July 22, 2026 13:25
@thepastaclaw

thepastaclaw commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — 2 ahead in queue (commit 8e680ab)
Queue position: 3/25 · 2 reviews active
ETA: start ~03:16 UTC · complete ~03:38 UTC (median 21m across 30 recent reviews; 2 slots)
Queued 13h 23m ago · Last checked: 2026-07-23 02:50 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In
`@packages/rs-drive/src/verify/shielded/verify_shielded_encrypted_notes/v0/mod.rs`:
- Around line 47-54: In the shielded notes verification flow around the
start_index alignment check and PathQuery construction, validate the inclusive
end index with checked arithmetic using start_index and limit - 1. If the
addition overflows, return the existing Drive corruption error before
constructing the PathQuery; otherwise use the checked result for the query
range.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 45f7a606-a0fa-4a43-b1b8-dea16c66b770

📥 Commits

Reviewing files that changed from the base of the PR and between 267e1cb and 8e680ab.

📒 Files selected for processing (1)
  • packages/rs-drive/src/verify/shielded/verify_shielded_encrypted_notes/v0/mod.rs

@QuantumExplorer
QuantumExplorer merged commit 551bf92 into v4.1-dev Jul 23, 2026
8 checks passed
@QuantumExplorer
QuantumExplorer deleted the codex/fix-shielded-proof-chunk-alignment branch July 23, 2026 02:30
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.

3 participants