Skip to content

Defer trial decryption of large compact transactions - #83

Merged
tzarebczan merged 19 commits into
mainfrom
fix/deferred-trial-decrypt
Dec 5, 2026
Merged

tzarebczan merged 19 commits into
mainfrom
fix/deferred-trial-decrypt

Conversation

@tzarebczan

Copy link
Copy Markdown
Owner

Closes #62.

Items 1 and 2 were already on main. Item 3, incremental snapshot chunks, is already on main and is unchanged here. This finishes item 4.

A transaction waits for trial decryption only when one shielded pool has more than eight compact outputs. The switch is off unless the caller opts in. Sync turns it on and finishes the queue before either success return, including when the wallet is already at the tip. Commitments and nullifiers are applied immediately. Notes from that transaction stay unspendable until every output of that transaction has been decrypted. The balance reports verificationPending while the queue is non-empty. The queue is part of the snapshot and is dropped on rewind. A corrupt ciphertext does not advance the scan or drop the row.

Checks: cargo test -p z-engine --lib (498 passed), cargo check -p z-wasm --target wasm32-unknown-unknown, the confirmation-policy tests, and the core typecheck.

A transaction with more than eight outputs in one shielded pool still
records commitments and nullifiers, and stores the ciphertext in the
snapshot. Notes from that transaction stay unspendable, and the balance
reports verificationPending, until every output has been decrypted.
Sync opts in and drains the queue before it returns.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T08:43:49.808764Z 9f2d086 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f2d086497

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/z-engine/src/web/store.rs Resolved
A spend scanned before trial decryption was inserting the note as unspent.
Reset drops the queue. A worker that omits a deferred count has an empty
queue, and reading that count does not force another snapshot write.
A nonempty queue is snapshot version 5 so an older reader rejects it instead of dropping those outputs. Trial decryption releases temporary witness marks, keeps the mined time, and retains memo candidates until ownership is known. Sync drains the queue before memo discovery and refreshes pool totals.
…ume.

A deferred block now rejects a malformed spend in every transaction, holds memo work until that transaction is decrypted, and counts notes revealed before a later spend. A cold at-tip drain refreshes pool history, temporary marks leave the open offload shard, and the queue is checkpointed every 256 outputs.
A deferred block must start at the wallet's note cursors, including the first block after birthday. A version 5 snapshot with an empty queue is rejected. Replay decrypts a transaction's outputs together, and draining the queue no longer rescans the open shard or the remaining backlog.
…ail-closed.

A wallet without a birthday frontier keeps large transactions on the immediate path. Manual memo retrieval decrypts the queue first and does not advance coverage through it. A later nullifier in the same batch keeps the previous block on the parallel path. The queued backlog stays bounded.
…e saving.

A freshness check no longer rewrites an unchanged snapshot. A drain that only rejects outputs still repeats the configured memo lookup and refreshes history. Cancellation during a chunk does not start a save. A known receipt stays pending while its outputs are queued, and tip overlap rebuilds trees after that queue is drained.
A Sapling or Ironwood note that was not already in a pool total is not counted again as Orchard. Restoring a checkpoint keeps a recorded receipt until that transaction leaves the queue. A drain that consumes a queue adopted during the check still repeats the configured memo lookup, including when every output is a miss.
…synced.

One transaction may cross the queue limit. A later large transaction in that block is decrypted immediately. A memo lookup that adopts another checkpoint is repeated after that drain. Sync does not report completion when the final save is still unverified.
…finish verification when a save or memo transport changes.
@tzarebczan
tzarebczan merged commit 248d2fb into main Dec 5, 2026
9 checks passed
@tzarebczan
tzarebczan deleted the fix/deferred-trial-decrypt branch December 5, 2026 16:51
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.

[perf] Next-wave WASM/SDK sync optimizations (persistent indexes, binary snapshots, incremental PIR)

1 participant