Skip to content

Conversation

@tilo-14
Copy link
Contributor

@tilo-14 tilo-14 commented Aug 20, 2025

added description to each part

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// 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
Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
output_tree_index: u8, // Index in the output state tree
output_tree_index: u8, // Index in the output state tree in remaining accounts

Comment on lines +66 to +67
// Set up CPI accounts for calling the Light system program
// This includes the user account and remaining accounts for tree operations
Copy link
Contributor

@ananas-block ananas-block Aug 21, 2025

Choose a reason for hiding this comment

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

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.

Comment on lines +74 to +75
// Derive a deterministic address for the compressed account
// Uses a seed based on the user's public key to ensure uniqueness
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +84 to +86
// 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
Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't say anything useful

Copy link
Contributor

Choose a reason for hiding this comment

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

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).

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.

3 participants