Add description account comparison lib.rs#6
Add description account comparison lib.rs#6tilo-14 wants to merge 1 commit intotilo/add-description/program-examples/account-comparisonfrom
Conversation
added description to each part
| declare_id!("FYX4GmKJYzSiycc7XZKf12NGXNE9siSx1cJubYJniHcv"); | ||
|
|
||
| // Derive a CPI signer for Light system program interactions | ||
| // This is used to sign transactions when calling the Light system program |
There was a problem hiding this comment.
| // This is used to sign transactions when calling the Light system program | |
| // CPI_SIGNER.cpi_signer is a pda used to sign transactions when calling the Light system program |
| address_tree_info: PackedAddressTreeInfo, | ||
| output_tree_index: u8, | ||
| proof: ValidityProof, // Zero-knowledge proof for state transitions | ||
| address_tree_info: PackedAddressTreeInfo, // Information about the address tree |
There was a problem hiding this comment.
contains indices that point to the address Merkle tree in remaining accounts, and other metadata to create the address.
#[derive(Debug, Clone, Copy, AnchorDeserialize, AnchorSerialize, PartialEq, Default)]
pub struct PackedAddressTreeInfo {
pub address_merkle_tree_pubkey_index: u8,
pub address_queue_pubkey_index: u8,
pub root_index: u16,
}
root index is used to get the root for proof verification from the address Merkle tree account but that is not directly exposed here so can be omitted.
| output_tree_index: u8, | ||
| proof: ValidityProof, // Zero-knowledge proof for state transitions | ||
| address_tree_info: PackedAddressTreeInfo, // Information about the address tree | ||
| output_tree_index: u8, // Index in the output state tree |
There was a problem hiding this comment.
| output_tree_index: u8, // Index in the output state tree | |
| output_tree_index: u8, // Index in the output state tree in remaining accounts |
| // Set up CPI accounts for calling the Light system program | ||
| // This includes the user account and remaining accounts for tree operations |
There was a problem hiding this comment.
The user account is the fee payer, the remaining accounts need to contain program Ids, config accounts, and tree accounts.
Note don't use this literally.
| // Derive a deterministic address for the compressed account | ||
| // Uses a seed based on the user's public key to ensure uniqueness |
There was a problem hiding this comment.
this is not descriptive enough, we should assume that the reader knows what a pda is, we should highlight that it is similar but different with some level of detail.
| // Create a new compressed account with empty input state | ||
| // LightAccount::new_init initializes an account for creation | ||
| // The account data will be hashed using Poseidon hashes and stored off-chain |
There was a problem hiding this comment.
input state is too much detail
offchain storage feels not relevant
no need to mention poseidon
no need to mention hashing at this point hashing happens when this struct is converted to_account_info.
| output_tree_index, | ||
| &crate::ID, // Program ID that owns this account | ||
| Some(address), // Derived address for the account | ||
| output_tree_index, // Position in the state tree |
There was a problem hiding this comment.
| output_tree_index, // Position in the state tree | |
| output_tree_index, // Index of the state tree in packed accounts |
The actual position in the tree, the leaf index, is set in the light system program.
| let new_address_params = address_tree_info.into_new_address_params_packed(address_seed); | ||
|
|
||
| // Create CPI inputs with the validity proof and account information | ||
| // This includes the compressed account converted to account info format |
There was a problem hiding this comment.
this doesn't say anything useful
There was a problem hiding this comment.
the comment should describe what this piece of code actually does such as creating the data hash for the compressed account (double check where that actually happens).
added description to each part