Skip to content

perf(transaction): cache empty ZIP-244 bundle hashes#385

Open
ValarDragon wants to merge 1 commit into
ironwood-mainfrom
perf/zip244-empty-hash-constants
Open

perf(transaction): cache empty ZIP-244 bundle hashes#385
ValarDragon wants to merge 1 commit into
ironwood-mainfrom
perf/zip244-empty-hash-constants

Conversation

@ValarDragon

Copy link
Copy Markdown

Motivation

ZIP-244 txid and authorizing-data digests use bare BLAKE2b personalization hashes when a bundle is absent. The native Zebra implementation recomputed those empty hashes on each v5/v6 transaction even though the values are fixed by the personalization strings.

Solution

  • Add private byte constants for the empty transparent, Sapling, Orchard, and Ironwood ZIP-244 txid/auth digest nodes.
  • Feed those constants directly into the parent txid/auth hash when a bundle is absent.
  • Keep a unit test that recomputes every constant from its personalization string.
  • Add an Orchard-only ZIP-244 digest benchmark with 1000 samples.

Benchmarks

Command:

cargo bench -p zebra-chain --bench transaction auth_digest/orchard_only

Exact origin/ironwood-main baseline with the benchmark added:

Benchmark Baseline This PR Speedup
auth_digest/orchard_only 8.3584 us 8.0284 us ~4.0%
txid_and_auth_digest/orchard_only 11.892 us 11.194 us ~5.9%

Both runs used 1000 Criterion samples.

Validation

  • cargo fmt --all
  • cargo test -p zebra-chain zip244
  • cargo bench -p zebra-chain --bench transaction --no-run
  • cargo bench -p zebra-chain --bench transaction auth_digest/orchard_only

AI Disclosure

Used Codex to implement the constants, benchmark, tests, and PR description.

@v12-auditor

v12-auditor Bot commented Jul 1, 2026

Copy link
Copy Markdown

Note

Complete: Audit complete. V12 did not find any issues that need review.

Open the full results here.

Analyzed two files, diff e3571d1...c8741a8.

@ValarDragon ValarDragon changed the title [codex] perf(transaction): cache empty ZIP-244 bundle hashes perf(transaction): cache empty ZIP-244 bundle hashes Jul 2, 2026
@ValarDragon
ValarDragon marked this pull request as ready for review July 2, 2026 01:39
@ValarDragon
ValarDragon force-pushed the perf/zip244-empty-hash-constants branch from c8741a8 to cdf75e2 Compare July 2, 2026 01:42
@ValarDragon
ValarDragon force-pushed the perf/zip244-empty-hash-constants branch from cdf75e2 to 6d40399 Compare July 2, 2026 22:29
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