Overview
TheMerkleTreeAccount is a zero-copy account that stores the sparse Merkle tree state used to track all private commitments in the Privacy Cash protocol. Each tree can handle either native SOL or a specific SPL token.
Account Structure
The public key of the authority that can update this tree’s configuration
The index where the next leaf will be inserted in the Merkle tree
Array of intermediate node hashes representing the state of each level in the Merkle tree (height 26)
The current root hash of the Merkle tree
Circular buffer storing the last 100 root hashes to allow proofs against recent tree states
The current position in the root_history circular buffer
Maximum amount (in lamports for SOL, or token units for SPL tokens) that can be deposited in a single transaction
The height of the Merkle tree (fixed at 26)
The size of the root history buffer (fixed at 100)
The PDA bump seed used for account derivation
Padding bytes required for zero-copy account alignment
PDA Seeds
For SOL (Native)
For SPL Tokens
Notes
- This account uses the
#[account(zero_copy)]attribute for efficient memory access without deserialization - The tree height of 26 allows for 2^26 (67,108,864) unique commitments
- The root history enables users to create proofs using recent tree states even while new deposits are being processed
- Each SPL token has its own separate Merkle tree account