Skip to content

[#1924] Add Android voting snapshot wallet notes and note witnesses#1951

Merged
nullcopy merged 20 commits into
mainfrom
greg/voting-snapshot-notes
May 13, 2026
Merged

[#1924] Add Android voting snapshot wallet notes and note witnesses#1951
nullcopy merged 20 commits into
mainfrom
greg/voting-snapshot-notes

Conversation

@greg0x

@greg0x greg0x commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Part of zodl-inc/zodl-android#2193.
Slice of #1924 (umbrella draft PR being split into reviewable pieces).
Stacked on #1950 (PR 5 — delegation proof + submission).
Resolves MOB-1109

Why

Sixth slice of the Android shielded-voting integration. PR 5 (#1950) finishes
the delegation half (PIR precompute, proof + progress callback, submission).
This PR introduces the snapshot input-prep path that vote construction will
consume in PR 7: extracting wallet notes at a historical snapshot height,
storing the matching tree state in the voting DB, and generating per-bundle
note witnesses against that snapshot.

No public Synchronizer voting API is added. Wallet DB access from the voting
backend goes through a new internal SdkSynchronizer.getWalletDbPathForVoting()
rather than a public getWalletDbPath() accessor (one of the open decisions in
the split plan).

Not included

  • Vote tree sync / VAN witnesses / vote commitment / cast-vote payloads (PR 7).
  • Recovery records and share tracking (PR 8).
  • Any new submission or proof-generation behavior.

Review focus

Primary review track: core-dev. Secondary: mobile-app-dev.

  • getWalletDbPathForVoting() as internal suspend on SdkSynchronizer
    whether this is the right shape, or whether voting note extraction should go
    through a narrower SDK API instead.
  • Read-only wallet DB access from the voting backend, including account UUID,
    UFVK, and network binding for getWalletNotes.
  • Historical note selection / snapshot anchor correctness in
    voting/notes.rs.
  • TreeState frontier parsing and root consistency in extractNcRoot.
  • Witness generation against a stored snapshot, including bundle-specific note
    filtering and stale cached witness replacement behavior.
  • JNI byte-boundary validation via the shared helpers in voting/helpers.rs
    (Orchard FVK bytes, TreeState bytes, account UUID, witness payload sizes).
  • Typed FFI models (JniNoteInfo, JniWitnessData) and how the typesafe layer
    enforces size/count invariants before handing data back to the SDK.

Validation

  • cargo check --manifest-path backend-lib/Cargo.toml --locked
  • cargo fmt --manifest-path backend-lib/Cargo.toml --check
  • ./gradlew :backend-lib:compileReleaseKotlin :sdk-lib:compileReleaseKotlin
  • ./gradlew ktlint detektAll
  • ./gradlew checkProperties
  • git diff --check

Author

  • Self-review your own code in GitHub web interface
  • Add automated tests as appropriate
  • Update the manual tests as appropriate
  • Check the code coverage report for the automated tests
  • Update documentation as appropriate
  • Run the demo app and try the changes
  • Pull in the latest changes from the main branch and squash your commits before assigning a reviewer

Reviewer

  • Check the code with the Code Review Guidelines checklist
  • Perform an ad hoc review
  • Review the automated tests
  • Review the manual tests
  • Review the documentation as appropriate
  • Run the demo app and try the changes

Base automatically changed from greg/voting-delegation-proof to main May 12, 2026 18:33
greg0x added 3 commits May 12, 2026 21:44
Validate selected bundle note identities, verify generated witnesses before replacing cached rows, and make the delete/store operation atomic.

Also document the direct incrementalmerkletree dependency and reuse the existing note scope constants.
Return witness verification as a boolean, make tree-state storage exception-only, and keep BlockHeight/AccountUuid at the typesafe Kotlin boundary.

Adds test-only JNI fixture hooks used by the follow-up coverage commit.
Add focused Android JNI coverage for FVK/root extraction, witness verification, Rust-built note/witness arrays, and tree-state storage.

Extend typesafe wrapper tests to assert forwarding for tree-state storage and generated witness retrieval.
@greg0x greg0x marked this pull request as ready for review May 12, 2026 20:01
Comment thread backend-lib/src/main/rust/voting/helpers.rs
Comment thread sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/TypesafeVotingBackend.kt Outdated
Comment thread backend-lib/src/main/rust/voting/notes.rs Outdated
Comment thread backend-lib/src/main/rust/voting/notes.rs Outdated
Comment thread backend-lib/src/main/rust/voting/helpers.rs Outdated
@greg0x greg0x force-pushed the greg/voting-snapshot-notes branch from c65067e to 5cc3c41 Compare May 12, 2026 20:46
Comment thread backend-lib/src/main/rust/voting/helpers.rs Outdated
greg0x added 2 commits May 13, 2026 00:04
chore: refresh zcash_voting 0.5.11 lock

chore: use released zcash_voting 0.5.11
@greg0x greg0x force-pushed the greg/voting-snapshot-notes branch from f8c1e31 to cb040af Compare May 12, 2026 22:04
@greg0x greg0x force-pushed the greg/voting-snapshot-notes branch from fd4bc88 to 0f3d3f9 Compare May 12, 2026 22:17
Comment thread backend-lib/src/main/rust/voting/notes.rs Outdated
@greg0x greg0x force-pushed the greg/voting-snapshot-notes branch from 3aa29c5 to 97925a9 Compare May 13, 2026 07:48
noop-sk
noop-sk previously approved these changes May 13, 2026
@noop-sk noop-sk requested review from noop-sk and nullcopy May 13, 2026 08:29
Comment thread backend-lib/src/main/rust/voting/notes.rs Outdated

@nullcopy nullcopy 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.

Reviewed up to 97925a9

@greg0x greg0x force-pushed the greg/voting-snapshot-notes branch 2 times, most recently from 05e3356 to a2c049e Compare May 13, 2026 14:03
nullcopy
nullcopy previously approved these changes May 13, 2026

@nullcopy nullcopy 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.

utACK a2c049e

@nullcopy nullcopy enabled auto-merge May 13, 2026 14:04
@greg0x greg0x force-pushed the greg/voting-snapshot-notes branch from a2c049e to 35e546f Compare May 13, 2026 14:10
@greg0x greg0x force-pushed the greg/voting-snapshot-notes branch from 35e546f to de35143 Compare May 13, 2026 14:28

@nullcopy nullcopy 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.

utACK de35143

@nullcopy nullcopy merged commit 2797994 into main May 13, 2026
15 checks passed
@nullcopy nullcopy deleted the greg/voting-snapshot-notes branch May 13, 2026 15:24
@linear

linear Bot commented Jun 1, 2026

Copy link
Copy Markdown

MOB-1109

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