Skip to content

fix: cmint instruction data & cleanup#2164

Merged
ananas-block merged 38 commits intomainfrom
jorrit/fix-cmint-instruction-data
Jan 12, 2026
Merged

fix: cmint instruction data & cleanup#2164
ananas-block merged 38 commits intomainfrom
jorrit/fix-cmint-instruction-data

Conversation

@ananas-block
Copy link
Copy Markdown
Contributor

@ananas-block ananas-block commented Jan 7, 2026

Bug Fixes

  1. Compression index bounds check - Added validation preventing array index out-of-bounds in transfer2 token inputs
  2. Decompress amount validation - Added check that ATA/compress_to_pubkey decompress amount matches input token data amount
  3. MAX_COMPRESSIONS boundary fix - Changed >= to > to allow exactly MAX_COMPRESSIONS items in transfer2
  4. Explicit ATA derivation error - Added InvalidAtaDerivation error instead of silent fallback when ATA derivation fails or mismatches
  5. Rent exemption stability - Made rent calculations read CompressionInfo directly from bytes rather than relying on sysvar
  6. CompressedMintMetadata change - Added compressed_address field (32 bytes) directly to mint struct, reduced reserved from 49 to 17 bytes; unifies compressed address source

Error Handling

  1. New error types - Added 6 errors to CTokenError: MissingPayer, BorrowFailed, InvalidCTokenOwner, DecompressAmountMismatch, CompressionIndexOutOfBounds, InvalidAtaDerivation
  2. SPL Token error mapping - Changed from raw SPL Token error codes to Anchor ErrorCode mappings (+6000 offset)

Refactoring

  1. Program folder restructure - Reorganized compressed-token/program/src/ into compressed_token/ (mint_action, transfer2), compressible/ (claim, withdraw), and ctoken/ (approve, burn, close, create, freeze_thaw, mint_to, transfer) subdirectories
  2. File renaming - Removed ctoken_ prefix from files (e.g., ctoken_burn.rs -> ctoken/burn.rs, create_associated_token_account.rs -> ctoken/create_ata.rs)
  3. Added top-up modules - New top_up.rs files for ctoken and mint in ctoken-interface with optimized lamports calculation from account bytes
  4. TypeScript layout alignment - Moved compressedAddress from instruction-level to mint.metadata, removed tokenPoolBump and tokenPoolIndex fields, added rentExemptionPaid and reserved fields to CompressionInfo (88 -> 96 bytes)
  5. Removed CreateSplMint action - Deleted CreateSplMint action type and related code from both Rust and TypeScript

Documentation

  1. Documentation restructure - Moved docs from flat instructions/ to categorized ctoken/, compressed_token/, compressible/ directories; added new INSTRUCTIONS.md with discriminator reference table

Tests

  1. New test coverage - Added ata_decompress.rs (532 lines), check_extensions.rs (744 lines), mint_validation.rs (358 lines), create_ata.rs, create.rs, failing.rs for comprehensive validation testing

Summary by CodeRabbit

  • New Features

    • Added rent exemption tracking in compressed accounts.
    • Introduced ATA (Associated Token Account) support for compressed-only extensions.
    • Added compress-and-close functionality for managing compressed token lifecycles.
  • Bug Fixes

    • Improved error handling with new error codes for better diagnostics.
    • Fixed account validation for compressed account operations.
  • Documentation

    • Reorganized architecture documentation with clearer instruction references and examples.

✏️ Tip: You can customize this high-level summary in your review settings.

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

2 participants