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
3 changes: 0 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[alias]
xtask = "run --package xtask --"

[resolver]
incompatible-rust-versions = "fallback"

# On Windows
# ```
# cargo install -f cargo-binutils
Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ create-address-program-test = { path = "program-tests/create-address-test-progra
groth16-solana = { version = "0.2.0" }
bytemuck = { version = "1.19.0" }
arrayvec = "0.7"
smallvec = "1.15"
tinyvec = "1.10.0"
pinocchio-token-program = { git= "https://github.com/Lightprotocol/token", rev="9ea04560a039d1a44f0411b5eaa7c0b79ed575ab" }
# Math and crypto
Expand Down
12 changes: 6 additions & 6 deletions js/compressed-token/src/v3/layout/layout-mint-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const CompressedMintMetadataLayout = struct([
u8('bump'),
]);

export const CompressedMintInstructionDataLayout = struct([
export const MintInstructionDataLayout = struct([
u64('supply'),
u8('decimals'),
CompressedMintMetadataLayout.replicate('metadata'),
Expand All @@ -164,7 +164,7 @@ export const MintActionCompressedInstructionDataLayout = struct([
vec(ActionLayout, 'actions'),
option(CompressedProofLayout, 'proof'),
option(CpiContextLayout, 'cpiContext'),
option(CompressedMintInstructionDataLayout, 'mint'),
option(MintInstructionDataLayout, 'mint'),
]);

// TODO: Remove V1 layouts after devnet program update
Expand All @@ -184,7 +184,7 @@ const CompressedMintMetadataLayoutV1 = struct([
publicKey('mint'),
]);
// TODO: Remove V1 layouts after devnet program update
const CompressedMintInstructionDataLayoutV1 = struct([
const MintInstructionDataLayoutV1 = struct([
u64('supply'),
u8('decimals'),
CompressedMintMetadataLayoutV1.replicate('metadata'),
Expand All @@ -205,7 +205,7 @@ const MintActionCompressedInstructionDataLayoutV1 = struct([
vec(ActionLayoutV1, 'actions'),
option(CompressedProofLayout, 'proof'),
option(CpiContextLayout, 'cpiContext'),
CompressedMintInstructionDataLayoutV1.replicate('mint'), // V1: not optional
MintInstructionDataLayoutV1.replicate('mint'), // V1: not optional
]);

export interface ValidityProof {
Expand Down Expand Up @@ -314,7 +314,7 @@ export interface CompressedMintMetadata {
bump: number;
}

export interface CompressedMintInstructionData {
export interface MintLayoutData {
supply: bigint;
decimals: number;
metadata: CompressedMintMetadata;
Expand All @@ -332,7 +332,7 @@ export interface MintActionCompressedInstructionData {
actions: Action[];
proof: ValidityProof | null;
cpiContext: CpiContext | null;
mint: CompressedMintInstructionData | null;
mint: MintLayoutData | null;
}

/**
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

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

pls revert changes to this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mhm idk why it shows a diff

image

actually it seems like your most recent commit on main had reverted your own renamings, so now mine is re-applying them? see
image

Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,26 @@ Batch instruction for managing compressed mint accounts (cmints) and performing
This instruction supports 10 total actions - one creation action (controlled by `create_mint` flag) and 9 enum-based actions:

**Compressed mint creation (executed first when `create_mint` is Some):**

1. **Create Compressed Mint** - Create a new compressed mint account with initial authorities and optional TokenMetadata extension

**Core mint operations (Action enum variants):**
2. `MintToCompressed` - Mint new compressed tokens to one or more compressed token accounts
3. `MintToCToken` - Mint new tokens to decompressed ctoken accounts (not SPL tokens)
**Core mint operations (Action enum variants):** 2. `MintToCompressed` - Mint new compressed tokens to one or more compressed token accounts 3. `MintTo` - Mint new tokens to decompressed ctoken accounts (not SPL tokens)

**Authority updates (Action enum variants):**
4. `UpdateMintAuthority` - Update or remove the mint authority
5. `UpdateFreezeAuthority` - Update or remove the freeze authority
**Authority updates (Action enum variants):** 4. `UpdateMintAuthority` - Update or remove the mint authority 5. `UpdateFreezeAuthority` - Update or remove the freeze authority

**TokenMetadata extension operations (Action enum variants):**
6. `UpdateMetadataField` - Update name, symbol, uri, or additional_metadata fields in the TokenMetadata extension
7. `UpdateMetadataAuthority` - Update the metadata update authority in the TokenMetadata extension
8. `RemoveMetadataKey` - Remove a key-value pair from additional_metadata in the TokenMetadata extension
**TokenMetadata extension operations (Action enum variants):** 6. `UpdateMetadataField` - Update name, symbol, uri, or additional_metadata fields in the TokenMetadata extension 7. `UpdateMetadataAuthority` - Update the metadata update authority in the TokenMetadata extension 8. `RemoveMetadataKey` - Remove a key-value pair from additional_metadata in the TokenMetadata extension

**Decompress/Compress operations (Action enum variants):**
9. `DecompressMint` - Decompress a compressed mint to a CMint Solana account. Creates a CMint PDA that becomes the source of truth.
10. `CompressAndCloseCMint` - Compress and close a CMint Solana account. Permissionless - anyone can call if is_compressible() returns true (rent expired).
**Decompress/Compress operations (Action enum variants):** 9. `DecompressMint` - Decompress a compressed mint to a CMint Solana account. Creates a CMint PDA that becomes the source of truth. 10. `CompressAndCloseMint` - Compress and close a CMint Solana account. Permissionless - anyone can call if is_compressible() returns true (rent expired).

Key concepts integrated:

- **Compressed mint (cmint)**: Mint state stored in compressed account with deterministic address derived from a mint signer PDA
- **Decompressed mint (CMint)**: When a compressed mint is decompressed, a CMint Solana account becomes the source of truth
- **Authority validation**: All actions require appropriate authority (mint/freeze/metadata) to be transaction signer
- **Batch processing**: Multiple actions execute sequentially with state updates persisted between actions

**Instruction data:**

1. instruction data is defined in path: program-libs/token-interface/src/instructions/mint_action/instruction_data.rs

**Core fields:**
Expand All @@ -47,24 +41,25 @@ Key concepts integrated:
- `actions`: Vec<Action> - Ordered list of actions to execute
- `proof`: Option<CompressedProof> - ZK proof for compressed account validation (required unless prove_by_index=true)
- `cpi_context`: Option<CpiContext> - For cross-program invocation support
- `mint`: Option<CompressedMintInstructionData> - Full mint state including supply, decimals, metadata, authorities, and extensions (None when reading from decompressed CMint)
- `mint`: Option<MintInstructionData> - Full mint state including supply, decimals, metadata, authorities, and extensions (None when reading from decompressed CMint)

2. Action types (path: program-libs/token-interface/src/instructions/mint_action/):
- `MintToCompressed(MintToCompressedAction)` - Mint tokens to compressed accounts (mint_to_compressed.rs)
- `UpdateMintAuthority(UpdateAuthority)` - Update mint authority (update_mint.rs)
- `UpdateFreezeAuthority(UpdateAuthority)` - Update freeze authority (update_mint.rs)
- `MintToCToken(MintToCTokenAction)` - Mint to ctoken accounts (mint_to_ctoken.rs)
- `MintTo(MintToAction)` - Mint to ctoken accounts (mint_to.rs)
- `UpdateMetadataField(UpdateMetadataFieldAction)` - Update metadata field (update_metadata.rs)
- `UpdateMetadataAuthority(UpdateMetadataAuthorityAction)` - Update metadata authority (update_metadata.rs)
- `RemoveMetadataKey(RemoveMetadataKeyAction)` - Remove metadata key (update_metadata.rs)
- `DecompressMint(DecompressMintAction)` - Decompress compressed mint to CMint Solana account (decompress_mint.rs)
- `CompressAndCloseCMint(CompressAndCloseCMintAction)` - Compress and close CMint Solana account (compress_and_close_cmint.rs)
- `CompressAndCloseMint(CompressAndCloseMintAction)` - Compress and close CMint Solana account (compress_and_close_cmint.rs)

**Accounts:**

The account ordering differs based on whether writing to CPI context or executing.

**Always present:**

1. light_system_program
- non-mutable
- Light Protocol system program for CPI to create or update the compressed mint account.
Expand All @@ -81,54 +76,61 @@ The account ordering differs based on whether writing to CPI context or executin
**For execution (when not writing to CPI context):**

4. compressible_config (optional)
- Required when DecompressMint or CompressAndCloseCMint action is present
- Required when DecompressMint or CompressAndCloseMint action is present
- CompressibleConfig account - parsed and validated for active state

5. cmint (optional)
- (mutable) - CMint Solana account (decompressed compressed mint)
- Required when cmint_decompressed=true OR DecompressMint OR CompressAndCloseCMint action present
- Required when cmint_decompressed=true OR DecompressMint OR CompressAndCloseMint action present

6. rent_sponsor (optional)
- (mutable) - Required when DecompressMint or CompressAndCloseCMint action is present
- (mutable) - Required when DecompressMint or CompressAndCloseMint action is present
- Rent sponsor PDA that pays for CMint account creation

7-12. Light system accounts (standard set):
- fee_payer (signer, mutable)
- cpi_authority_pda
- registered_program_pda
- account_compression_authority
- account_compression_program
- system_program
- sol_pool_pda (optional)
- sol_decompression_recipient (optional)
- cpi_context (optional)

- fee_payer (signer, mutable)
- cpi_authority_pda
- registered_program_pda
- account_compression_authority
- account_compression_program
- system_program
- sol_pool_pda (optional)
- sol_decompression_recipient (optional)
- cpi_context (optional)

13. out_output_queue
- (mutable)
- Output queue for compressed mint account updates

- (mutable)
- Output queue for compressed mint account updates

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 None: in_merkle_tree for existing mint validation

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

15. in_output_queue
- (mutable) - optional, required if create_mint is None
- Input queue for existing compressed mint

- (mutable) - optional, required if create_mint is None
- Input queue for existing compressed mint

16. tokens_out_queue
- (mutable) - optional, required for MintToCompressed actions
- Output queue for newly minted compressed token accounts

- (mutable) - optional, required for MintToCompressed actions
- Output queue for newly minted compressed token accounts

**For CPI context write (when write_to_cpi_context=true):**
4-6. CPI context accounts:
- fee_payer (signer, mutable)
- cpi_authority_pda
- cpi_context

- fee_payer (signer, mutable)
- cpi_authority_pda
- cpi_context

**Packed accounts (remaining accounts):**

- Merkle tree and queue accounts for compressed storage
- Recipient ctoken accounts for MintToCToken action
- Recipient ctoken accounts for MintTo action

**Instruction Logic and Checks:**

Expand All @@ -141,7 +143,7 @@ The account ordering differs based on whether writing to CPI context or executin
- 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
- Parse compressible config when DecompressMint or CompressAndCloseCMint action present
- Parse compressible config when DecompressMint or CompressAndCloseMint action present
- Extract packed accounts for dynamic operations

3. **Process mint creation or input:**
Expand All @@ -167,7 +169,7 @@ The account ordering differs based on whether writing to CPI context or executin
- Validate: current authority matches signer
- Update: set new authority (can be None to disable)

**MintToCToken:**
**MintTo:**
- Validate: mint authority matches signer
- Calculate: sum recipient amount
- Update: mint supply += amount
Expand All @@ -192,7 +194,7 @@ The account ordering differs based on whether writing to CPI context or executin
- Create CMint PDA that becomes the source of truth
- Update cmint_decompressed flag in compressed mint metadata

**CompressAndCloseCMint:**
**CompressAndCloseMint:**
- Compress and close a CMint Solana account
- Permissionless - anyone can call if is_compressible() returns true (rent expired)
- Compressed mint state is preserved
Expand Down Expand Up @@ -230,16 +232,17 @@ The account ordering differs based on whether writing to CPI context or executin
- `ErrorCode::MintActionInvalidCompressionState` (error code: 6072) - New mint must start as compressed
- `ErrorCode::MintActionUnsupportedOperation` (error code: 6073) - Unsupported operation
- `ErrorCode::CpiContextExpected` (error code: 6085) - CPI context required but not provided
- `ErrorCode::TooManyCompressionTransfers` (error code: 6095) - Account index out of bounds for MintToCToken
- `ErrorCode::TooManyCompressionTransfers` (error code: 6095) - Account index out of bounds for MintTo
- `ErrorCode::MintActionInvalidCpiContextForCreateMint` (error code: 6104) - Invalid CPI context for create mint operation
- `ErrorCode::MintActionInvalidCpiContextAddressTreePubkey` (error code: 6105) - Invalid address tree pubkey in CPI context
- `ErrorCode::MintActionInvalidCompressedMintAddress` (error code: 6103) - Invalid compressed mint address derivation
- `ErrorCode::MintDataRequired` (error code: 6125) - Mint data required in instruction when not decompressed
- `ErrorCode::CannotDecompressAndCloseInSameInstruction` (error code: 6123) - Cannot combine DecompressMint and CompressAndCloseCMint in same instruction
- `ErrorCode::CompressAndCloseCMintMustBeOnlyAction` (error code: 6169) - CompressAndCloseCMint must be the only action in the instruction
- `ErrorCode::CannotDecompressAndCloseInSameInstruction` (error code: 6123) - Cannot combine DecompressMint and CompressAndCloseMint in same instruction
- `ErrorCode::CompressAndCloseCMintMustBeOnlyAction` (error code: 6169) - CompressAndCloseMint must be the only action in the instruction
- `ErrorCode::CpiContextSetNotUsable` (error code: 6035) - Mint to ctokens or decompress mint not allowed when writing to CPI context
- `CTokenError::MaxTopUpExceeded` - Max top-up budget exceeded

### Spl mint migration

- cmint to spl mint migration is unimplemented and not planned.
- A way to support it in the future would require a new instruction that creates an spl mint in the mint pda solana account and mints the supply to the spl interface.
3 changes: 3 additions & 0 deletions sdk-libs/compressible-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ light-compressed-account = { workspace = true }
light-compressible = { workspace = true }

anchor-lang = { workspace = true, features = ["idl-build"], optional = true }
async-trait = { workspace = true }
borsh = { workspace = true }
futures = { workspace = true }
smallvec = { workspace = true }

thiserror = { workspace = true }
Loading