Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zcash_client_sqlite: Add methods for fixing broken note commitment trees. #1709

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nuttycom
Copy link
Contributor

This functionality is needed in order to make it possible for wallets that have corrupted note commitment tree state to recover from that situation.

Copy link

codecov bot commented Mar 8, 2025

Codecov Report

Attention: Patch coverage is 0% with 121 lines in your changes missing coverage. Please review.

Project coverage is 53.96%. Comparing base (35c9af8) to head (b006e39).

Files with missing lines Patch % Lines
zcash_client_sqlite/src/wallet/common.rs 0.00% 53 Missing ⚠️
zcash_client_sqlite/src/wallet/commitment_tree.rs 0.00% 25 Missing ⚠️
zcash_client_sqlite/src/wallet.rs 0.00% 21 Missing ⚠️
zcash_client_sqlite/src/lib.rs 0.00% 17 Missing ⚠️
zcash_client_sqlite/src/wallet/sapling.rs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1709      +/-   ##
==========================================
- Coverage   54.27%   53.96%   -0.31%     
==========================================
  Files         179      179              
  Lines       21253    21374     +121     
==========================================
  Hits        11535    11535              
- Misses       9718     9839     +121     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nuttycom nuttycom force-pushed the bug/shardtree_pruning branch from 71c9eb6 to f39a932 Compare March 12, 2025 15:19
@str4d
Copy link
Contributor

str4d commented Mar 13, 2025

This appears to work: the Nil node in my buggy repo gets replaced, and then merged into its parent due to the subtree being ephemeral.

However, the branch it is within does not get fully merged, because the act of re-scanning the previously-scanned range causes a frontier to be inserted, which marks the leaf just before the re-scanned range as Reference and thus not to be pruned. We will never mark that node as anything else because the block prior to the re-scanned range is itself already scanned (and thus we won't be inserting any scanned blocks that will overlap with and replace the Reference marking).

I suspect the solution here is to check the scan status of the block containing the frontier when inserting it, and only marking the frontier as Reference when we need to keep it around. Alternatively we could just not insert the frontier at all in this scenario?

@nuttycom nuttycom force-pushed the bug/shardtree_pruning branch from 39360f5 to b006e39 Compare March 13, 2025 15:32
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.

2 participants