zcash_client_sqlite: Use MemoryShardStore for historical witness generation#38
Merged
p0mvn merged 1 commit intoApr 23, 2026
Conversation
…ration Replaces the in-memory SQLite scratch DB used by `generate_orchard_witnesses_at_historical_height` with shardtree's `MemoryShardStore`. The wallet DB shards and cap are loaded directly into the in-memory `ShardStore`, avoiding the round-trip through SQLite DDL and row-by-row blob copying, and removing the local `create_tree_tables` / `copy_tree_data` helpers that existed only for this function. Behavior is preserved: the same `LocatedPrunableTree` values end up in the store (both paths go through `get_shard`/`get_cap`), the ShardTree algorithms are unchanged, and the public API is identical. A side benefit is that corrupt shard blobs are now detected at load time rather than lazily on first access. Mirrors the upstream change applied on PR zcash#2283 after review feedback from @nuttycom. Made-with: Cursor
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.
Summary
Mirrors the latest update on upstream PR zcash/librustzcash#2283 (commit
b3fabf3) ontoshielded-voting-wallet-support.Replaces the in-memory SQLite scratch DB used by
generate_orchard_witnesses_at_historical_heightwith shardtree'sMemoryShardStore. The wallet DB shards and cap are loaded directly into the in-memoryShardStore, avoiding the round-trip through SQLite DDL and row-by-row blob copying, and removing the localcreate_tree_tables/copy_tree_datahelpers that existed only for this function.Behavior
Preserved:
LocatedPrunableTreevalues end up in the store (both paths go throughget_shard/get_cap).ShardTreealgorithms are unchanged.Side benefits:
ShardTreecheckpoint limit lowered from 100 to 1 (only one checkpoint is ever inserted — the historical frontier).Marking,ShardTree,Checkpoint,ORCHARD_SHARD_HEIGHT) moved to the module-level import block.Changes
zcash_client_sqlite/src/wallet/commitment_tree.rs— swap inMemoryShardStore; drop the now-unusedcreate_tree_tables/copy_tree_datahelpers; tidy imports.zcash_client_sqlite/src/lib.rs— update doc comment on the publicWalletDb::generate_orchard_witnesses_at_historical_heightmethod.zcash_client_sqlite/CHANGELOG.md— mentionMemoryShardStorein the[Unreleased]entry.Test plan
cargo check -p zcash_client_sqlite --features orchard --all-targetscargo test -p zcash_client_sqlite --features orchard witnesses_at_historical_height— passesContext
Addresses the same review feedback from @nuttycom on upstream zcash#2283: using the fully in-memory
ShardStoreimpl avoids the SQLite round-trip and the dependency on table-schema plumbing.Made with Cursor