fix: validate mint for all token accounts, not just compressible#2251
fix: validate mint for all token accounts, not just compressible#2251ananas-block merged 7 commits intomainfrom
Conversation
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (22)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughCaches mint decimals during ctoken initialization and threads that value into compression setup; tests now create real on-chain decompressed mints before creating token accounts; client account-load ordering is changed so mint loads occur before dependent PDA/ATA loads. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@programs/compressed-token/program/src/shared/initialize_ctoken_account.rs`:
- Around line 164-178: The code currently skips validation when mint data is
empty; change the mint validation block (around mint_decimals, where
AccountInfoTrait::try_borrow_data(mint_account) is used) to treat empty mint
data as an error instead of returning None: if mint_data.is_empty() then log a
descriptive msg! and return Err(ProgramError::InvalidAccountData); otherwise
continue to call is_valid_mint(mint_account.owner(), &mint_data)? and extract
decimals from byte 44 as before. Ensure the same error path and message are used
as other invalid-mint branches so tests like mint_validation.rs fail
appropriately for empty data.
programs/compressed-token/program/src/shared/initialize_ctoken_account.rs
Show resolved
Hide resolved
SwenSchaeferjohann
left a comment
There was a problem hiding this comment.
consensus - we want to force mints to be decompressed when creating token accounts for Light Mints cc @ananas-block
Audit issue #7 (MEDIUM): is_valid_mint was only called inside configure_compression_info, so non-compressible token accounts could be initialized with an invalid mint. Move validation to initialize_ctoken_account so it runs for all account types.
6885468 to
27ae6fa
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
forester/tests/e2e_test.rs (1)
444-459:⚠️ Potential issue | 🔴 CriticalThis is the pipeline failure: subscriber account still uses
Pubkey::new_unique()as mint.Line 450 passes
mint: Pubkey::new_unique()— a nonexistent account. Since this PR enforces mint validation for all token account init paths (not just compressible), the on-chain program now rejects this with "Invalid mint account: account data is empty," which is exactly what the CI failure reports.You need to use
compressible_minthere (or create a second real mint), just as you did for the bootstrap account on line 400.🐛 Proposed fix — reuse the existing on-chain mint
// Create 2nd compressible token account with 0 epochs rent (instantly compressible) // This account is picked up by the subscriber let compressible_account_subscriber = create_compressible_token_account( &mut rpc, CreateCompressibleTokenAccountInputs { owner: Keypair::new().pubkey(), - mint: Pubkey::new_unique(), + mint: compressible_mint, num_prepaid_epochs: 0, payer: &payer, token_account_keypair: None, lamports_per_write: Some(100), token_account_version: TokenDataVersion::ShaFlat, }, ) .await .expect("Failed to create compressible token account");
Summary
initialize_ctoken_account, extract decimals during validation and pass down toconfigure_compression_info.Summary by CodeRabbit