Skip to content

fix: compressed and close mint check#2094

Merged
ananas-block merged 5 commits intomainfrom
jorrit/fix-compressed-and-close-mint-check
Dec 5, 2025
Merged

fix: compressed and close mint check#2094
ananas-block merged 5 commits intomainfrom
jorrit/fix-compressed-and-close-mint-check

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Dec 4, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Tightened authorization for compress-and-close: only the compression authority can compress-and-close; stronger validation of compressible state and outputs.
    • Stricter checks to ensure compressed outputs match expected mint/owner/version and full-balance requirements.
    • Clearer, more specific error messages for compression and close failures.
  • Documentation

    • Updated Close Token Account and Transfer2 docs to reflect new compress-and-close semantics, rent distribution, and precondition validations.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • program-tests/compressed-token-test/tests/transfer2/functional.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Reworks validation and return types for close/compress flows: simplifies token-close validators, requires compression authority for COMPRESS_AND_CLOSE paths, adds explicit compressibility and mint-PDA checks, updates imports and signatures, and tightens output validation for compress-and-close processing.

Changes

Cohort / File(s) Summary
Close/account validation signatures & logic
programs/compressed-token/program/src/close_token_account/processor.rs
Changed function signatures to return Result<bool, ProgramError> / Result<(), ProgramError>; removed tuple returns; reworked COMPRESS_AND_CLOSE validation to require compression authority signer, added explicit is_compressible checks, added platform-specific current_slot retrieval, and updated error messages and imports (pubkey_eq).
Compress-and-close output validation & mint PDA
programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
Always validate compressed output unconditionally; added pubkey_eq/Pubkey imports; added Mint PDA derivation check against compressed account mint and return MintActionInvalidMintPda on mismatch; removed prior signer-conditional branch.
Compress/decompress mint equality usage
programs/compressed-token/program/src/transfer2/compression/ctoken/compress_or_decompress_ctokens.rs
Replaced byte-wise mint comparison with pubkey_eq public-key comparison; added import.
Docs: close & transfer2 instructions
programs/compressed-token/program/docs/instructions/CLOSE_TOKEN_ACCOUNT.md, programs/compressed-token/program/docs/instructions/TRANSFER2.md
Updated docs to reflect new CompressAndClose semantics: compression_authority-only control, is_compressible gating, refined error cases, modified lamport/rent distribution wording, and strengthened validation and authority descriptions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to: updated public signatures in processor.rs and all updated call sites.
  • Verify platform-specific current_slot usage and non-Solana behavior.
  • Confirm new mint PDA equality (pubkey_eq) semantics and propagated error handling in compress_and_close.rs.

Possibly related PRs

Suggested labels

ai-review

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

✨ A tighter gate, a firmer key,
PDAs checked for all to see.
Compress or close with clearer rule,
Signers, slots, and checks made cool.
Small changes that keep systems free.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the primary change: refactoring mint validation logic in the compress-and-close path to use pubkey_eq instead of byte comparison.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ananas-block ananas-block force-pushed the jorrit/fix-compressed-and-close-mint-check branch from 674a337 to a349139 Compare December 4, 2025 23:41
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