light_merkle_tree_program/transaction_merkle_tree/
state.rs

1use aligned_sized::aligned_sized;
2use anchor_lang::prelude::*;
3
4use crate::{
5    impl_indexed_merkle_tree,
6    utils::config::{MERKLE_TREE_HEIGHT, MERKLE_TREE_HISTORY_SIZE},
7};
8
9// NOTE(vadorovsky): This implementation of Merkle tree exists only for
10// transactions and handling Poseidon in multiple rounds. Once Poseidon syscall
11// in Solana is implemented, this implementation will be replaced with
12// light-merkle-tree crate.
13#[account(zero_copy)]
14#[aligned_sized(anchor)]
15#[derive(Eq, PartialEq, Debug)]
16pub struct TransactionMerkleTree {
17    pub filled_subtrees: [[u8; 32]; MERKLE_TREE_HEIGHT],
18    pub current_root_index: u64,
19    pub next_index: u64,
20    pub roots: [[u8; 32]; MERKLE_TREE_HISTORY_SIZE as usize],
21    pub pubkey_locked: Pubkey,
22    pub time_locked: u64,
23    pub height: u64,
24    pub merkle_tree_nr: u64,
25    pub lock_duration: u64,
26    pub next_queued_index: u64,
27    pub newest: u8,
28    _padding: [u8; 7],
29}
30
31impl_indexed_merkle_tree!(TransactionMerkleTree);
32
33#[account]
34#[derive(Eq, PartialEq, Debug)]
35pub struct TwoLeavesBytesPda {
36    pub node_left: [u8; 32],
37    pub node_right: [u8; 32],
38    pub merkle_tree_pubkey: Pubkey,
39    pub encrypted_utxos: [u8; 256],
40    pub left_leaf_index: u64,
41}