Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 70 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ members = [
"sdk-libs/sdk-types",
"sdk-libs/photon-api",
"sdk-libs/program-test",
"sdk-libs/compressible-client",
"xtask",
"program-tests/account-compression-test",
"program-tests/batched-merkle-tree-test",
Expand All @@ -57,6 +56,7 @@ members = [
"sdk-tests/sdk-token-test",
"sdk-tests/sdk-light-token-test",
"sdk-tests/csdk-anchor-full-derived-test",
"sdk-tests/csdk-anchor-full-derived-test-sdk",
"forester-utils",
"forester",
"sparse-merkle-tree",
Expand Down Expand Up @@ -122,6 +122,7 @@ solana-system-interface = { version = "1" }
solana-security-txt = "1.1.1"
spl-token = "7.0.0"
spl-token-2022 = { version = "7.0.0", features = ["no-entrypoint"] }
spl-token-2022-interface = "1.0.0"
spl-pod = "0.5.1"
pinocchio = { version = "0.9" }
pinocchio-pubkey = { version = "0.3.0" }
Expand Down Expand Up @@ -189,7 +190,6 @@ light-sdk-macros = { path = "sdk-libs/macros", version = "0.17.1" }
light-sdk-types = { path = "sdk-libs/sdk-types", version = "0.17.1", default-features = false }
light-compressed-account = { path = "program-libs/compressed-account", version = "0.7.0", default-features = false }
light-compressible = { path = "program-libs/compressible", version = "0.2.0", default-features = false }
light-compressible-client = { path = "sdk-libs/compressible-client", version = "0.17.1" }
light-token-interface = { path = "program-libs/token-interface", version = "0.1.0" }
light-account-checks = { path = "program-libs/account-checks", version = "0.6.0", default-features = false }
light-verifier = { path = "program-libs/verifier", version = "6.0.0" }
Expand Down
2 changes: 1 addition & 1 deletion program-libs/token-interface/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub const MINT_ACCOUNT_SIZE: u64 = 82;
pub const COMPRESSED_MINT_SEED: &[u8] = b"compressed_mint";
pub const NATIVE_MINT: [u8; 32] = pubkey_array!("So11111111111111111111111111111111111111112");

pub const CMINT_ADDRESS_TREE: [u8; 32] =
pub const MINT_ADDRESS_TREE: [u8; 32] =
pubkey_array!("amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx");

/// Size of TransferFeeAccountExtension: 1 discriminant + 8 withheld_amount
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use light_compressed_account::instruction_data::zero_copy_set::CompressedCpiContextTrait;
use light_zero_copy::{ZeroCopy, ZeroCopyMut};

use crate::{AnchorDeserialize, AnchorSerialize, CMINT_ADDRESS_TREE};
use crate::{AnchorDeserialize, AnchorSerialize, MINT_ADDRESS_TREE};

#[repr(C)]
#[derive(Debug, Clone, AnchorSerialize, AnchorDeserialize, ZeroCopy, ZeroCopyMut, PartialEq)]
Expand Down Expand Up @@ -32,7 +32,7 @@ impl Default for CpiContext {
token_out_queue_index: 0,
assigned_account_index: 0,
read_only_address_trees: [0; 4],
address_tree_pubkey: CMINT_ADDRESS_TREE,
address_tree_pubkey: MINT_ADDRESS_TREE,
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions program-libs/token-interface/src/state/mint/compressed_mint.rs
Copy link
Contributor

Choose a reason for hiding this comment

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

program-libs/token-interface/src/state/mint/compressed_mint.rs -> program-libs/token-interface/src/state/mint/light_mint.rs

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use pinocchio::account_info::AccountInfo;
use solana_msg::msg;

use crate::{
state::ExtensionStruct, AnchorDeserialize, AnchorSerialize, TokenError, CMINT_ADDRESS_TREE,
LIGHT_TOKEN_PROGRAM_ID,
state::ExtensionStruct, AnchorDeserialize, AnchorSerialize, TokenError, LIGHT_TOKEN_PROGRAM_ID,
MINT_ADDRESS_TREE,
};

/// AccountType::Mint discriminator value
Expand Down Expand Up @@ -90,22 +90,22 @@ pub struct MintMetadata {
}

impl MintMetadata {
/// Derives the compressed address from mint PDA, CMINT_ADDRESS_TREE and LIGHT_TOKEN_PROGRAM_ID
/// Derives the compressed address from mint PDA, MINT_ADDRESS_TREE and LIGHT_TOKEN_PROGRAM_ID
pub fn compressed_address(&self) -> [u8; 32] {
derive_address(
self.mint.array_ref(),
&CMINT_ADDRESS_TREE,
&MINT_ADDRESS_TREE,
&LIGHT_TOKEN_PROGRAM_ID,
)
}
}

impl ZMintMetadata<'_> {
/// Derives the compressed address from mint PDA, CMINT_ADDRESS_TREE and LIGHT_TOKEN_PROGRAM_ID
/// Derives the compressed address from mint PDA, MINT_ADDRESS_TREE and LIGHT_TOKEN_PROGRAM_ID
pub fn compressed_address(&self) -> [u8; 32] {
derive_address(
self.mint.array_ref(),
&CMINT_ADDRESS_TREE,
&MINT_ADDRESS_TREE,
&LIGHT_TOKEN_PROGRAM_ID,
)
}
Expand Down
6 changes: 3 additions & 3 deletions program-tests/compressed-token-test/tests/mint/cpi_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use light_token_interface::{
MintToAction, MintWithContext,
},
state::MintMetadata,
CMINT_ADDRESS_TREE, LIGHT_TOKEN_PROGRAM_ID,
LIGHT_TOKEN_PROGRAM_ID, MINT_ADDRESS_TREE,
};
use light_token_sdk::compressed_token::{
create_compressed_mint::{derive_mint_compressed_address, find_mint_address},
Expand Down Expand Up @@ -436,7 +436,7 @@ async fn test_execute_cpi_context_invalid_tree_index() {
token_out_queue_index: 0,
assigned_account_index: 0,
read_only_address_trees: [0; 4],
address_tree_pubkey: CMINT_ADDRESS_TREE,
address_tree_pubkey: MINT_ADDRESS_TREE,
};

// Build instruction data for execute mode - must mark as create_mint
Expand All @@ -452,7 +452,7 @@ async fn test_execute_cpi_context_invalid_tree_index() {
payer.pubkey(),
mint_authority.pubkey(),
mint_seed.pubkey(),
Pubkey::new_from_array(CMINT_ADDRESS_TREE),
Pubkey::new_from_array(MINT_ADDRESS_TREE),
output_queue,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The account ordering differs based on whether writing to CPI context or executin
14. address_merkle_tree OR in_merkle_tree

- (mutable)
- If create_mint is Some: address_merkle_tree for new mint (must be CMINT_ADDRESS_TREE)
- If create_mint is Some: address_merkle_tree for new mint (must be MINT_ADDRESS_TREE)
- If create_mint is None: in_merkle_tree for existing mint validation

15. in_output_queue
Expand Down Expand Up @@ -142,7 +142,7 @@ The account ordering differs based on whether writing to CPI context or executin
2. **Validate and parse accounts:**
- Check authority is signer
- Validate CMint account matches expected mint pubkey (when cmint_pubkey provided)
- For create_mint: validate address_merkle_tree is CMINT_ADDRESS_TREE
- For create_mint: validate address_merkle_tree is MINT_ADDRESS_TREE
- Parse compressible config when DecompressMint or CompressAndCloseMint action present
- Extract packed accounts for dynamic operations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use light_compressible::config::CompressibleConfig;
use light_program_profiler::profile;
use light_token_interface::{
instructions::mint_action::{ZAction, ZMintActionCompressedInstructionData},
CMINT_ADDRESS_TREE,
MINT_ADDRESS_TREE,
};
use light_zero_copy::U16;
use pinocchio::{account_info::AccountInfo, pubkey::Pubkey};
Expand Down Expand Up @@ -323,10 +323,10 @@ impl<'info> MintActionAccounts<'info> {

// Validate address merkle tree when creating mint
if let Some(address_tree) = accounts.address_merkle_tree {
if *address_tree.key() != CMINT_ADDRESS_TREE {
if *address_tree.key() != MINT_ADDRESS_TREE {
msg!(
"Create mint action expects address Merkle tree {:?} received: {:?}",
solana_pubkey::Pubkey::from(CMINT_ADDRESS_TREE),
solana_pubkey::Pubkey::from(MINT_ADDRESS_TREE),
solana_pubkey::Pubkey::from(*address_tree.key())
);
return Err(ErrorCode::InvalidAddressTree.into());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use anchor_lang::prelude::ProgramError;
use light_compressed_account::instruction_data::with_readonly::ZInstructionDataInvokeCpiWithReadOnlyMut;
use light_program_profiler::profile;
use light_token_interface::{
instructions::mint_action::ZMintActionCompressedInstructionData, CMINT_ADDRESS_TREE,
COMPRESSED_MINT_SEED,
instructions::mint_action::ZMintActionCompressedInstructionData, COMPRESSED_MINT_SEED,
MINT_ADDRESS_TREE,
};
use pinocchio::pubkey::pubkey_eq;
use spl_pod::solana_msg::msg;
Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn process_create_mint_action(
// the light system program checks correct address derivation and we check
// the address tree in new_address_params.
if let Some(cpi_context) = &parsed_instruction_data.cpi_context {
if !pubkey_eq(&cpi_context.address_tree_pubkey, &CMINT_ADDRESS_TREE) {
if !pubkey_eq(&cpi_context.address_tree_pubkey, &MINT_ADDRESS_TREE) {
msg!("Invalid address tree pubkey in cpi context");
return Err(ErrorCode::MintActionInvalidCpiContextAddressTreePubkey.into());
}
Expand All @@ -73,7 +73,7 @@ pub fn process_create_mint_action(
&crate::LIGHT_CPI_SIGNER.program_id,
);
// Validate derived address matches the compressed_address computed from metadata
// (derived from mint PDA, CMINT_ADDRESS_TREE, and LIGHT_TOKEN_PROGRAM_ID)
// (derived from mint PDA, MINT_ADDRESS_TREE, and LIGHT_TOKEN_PROGRAM_ID)
if address != mint.metadata.compressed_address() {
msg!("Invalid compressed mint address derivation");
return Err(ErrorCode::MintActionInvalidMintAddress.into());
Expand Down
4 changes: 2 additions & 2 deletions programs/compressed-token/program/tests/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use light_token_interface::{
AdditionalMetadata, AdditionalMetadataConfig, BaseMint, CompressionInfo, ExtensionStruct,
Mint, MintMetadata, TokenMetadata, ZExtensionStruct, ZMint, ACCOUNT_TYPE_MINT,
},
CMINT_ADDRESS_TREE, COMPRESSED_MINT_SEED, LIGHT_TOKEN_PROGRAM_ID,
COMPRESSED_MINT_SEED, LIGHT_TOKEN_PROGRAM_ID, MINT_ADDRESS_TREE,
};
use light_zero_copy::{traits::ZeroCopyAt, ZeroCopyNew};
use rand::Rng;
Expand Down Expand Up @@ -72,7 +72,7 @@ fn test_rnd_create_compressed_mint_account() {
// Derive compressed account address using the same constants as compressed_address() method
let compressed_account_address = derive_address(
&mint_pda.to_bytes(),
&CMINT_ADDRESS_TREE,
&MINT_ADDRESS_TREE,
&LIGHT_TOKEN_PROGRAM_ID,
);

Expand Down
Loading
Loading