Skip to content

zcash_client_sqlite: Use MemoryShardStore for historical witness generation#38

Merged
p0mvn merged 1 commit into
shielded-voting-wallet-supportfrom
roman/shielded-voting/memory-shard-store
Apr 23, 2026
Merged

zcash_client_sqlite: Use MemoryShardStore for historical witness generation#38
p0mvn merged 1 commit into
shielded-voting-wallet-supportfrom
roman/shielded-voting/memory-shard-store

Conversation

@p0mvn
Copy link
Copy Markdown

@p0mvn p0mvn commented Apr 23, 2026

Summary

Mirrors the latest update on upstream PR zcash/librustzcash#2283 (commit b3fabf3) onto shielded-voting-wallet-support.

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

Preserved:

  • The same LocatedPrunableTree values end up in the store (both paths go through get_shard/get_cap).
  • The ShardTree algorithms are unchanged.
  • The public API is identical.

Side benefits:

  • Corrupt shard blobs are now detected at load time rather than lazily on first access.
  • ShardTree checkpoint limit lowered from 100 to 1 (only one checkpoint is ever inserted — the historical frontier).
  • Formerly function-scoped imports (Marking, ShardTree, Checkpoint, ORCHARD_SHARD_HEIGHT) moved to the module-level import block.

Changes

  • zcash_client_sqlite/src/wallet/commitment_tree.rs — swap in MemoryShardStore; drop the now-unused create_tree_tables / copy_tree_data helpers; tidy imports.
  • zcash_client_sqlite/src/lib.rs — update doc comment on the public WalletDb::generate_orchard_witnesses_at_historical_height method.
  • zcash_client_sqlite/CHANGELOG.md — mention MemoryShardStore in the [Unreleased] entry.

Test plan

  • cargo check -p zcash_client_sqlite --features orchard --all-targets
  • cargo test -p zcash_client_sqlite --features orchard witnesses_at_historical_height — passes
  • CI green

Context

Addresses the same review feedback from @nuttycom on upstream zcash#2283: using the fully in-memory ShardStore impl avoids the SQLite round-trip and the dependency on table-schema plumbing.

Made with Cursor

…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
@p0mvn p0mvn merged commit 7466449 into shielded-voting-wallet-support Apr 23, 2026
22 of 44 checks passed
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.

1 participant