Skip to content

fix: don't expect tokens out queue for mint to ctoken#2077

Closed
ananas-block wants to merge 1 commit intomainfrom
jorrit/fix-ctoken-program-requires-too-many-accounts
Closed

fix: don't expect tokens out queue for mint to ctoken#2077
ananas-block wants to merge 1 commit intomainfrom
jorrit/fix-ctoken-program-requires-too-many-accounts

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Nov 24, 2025

Issue:

  • mint_action instruction expects tokens out queue when minting to ctoken accounts but minting to ctoken accounts don't create compressed accounts thus doesn't use the tokens out queue

Summary by CodeRabbit

  • Bug Fixes
    • Refined token handling logic in the mint action configuration to improve accuracy in processing compressed token transactions.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 24, 2025

Walkthrough

The change modifies the has_mint_to_actions condition in AccountsConfig::new (non-CPI path) to only check for ZAction::MintToCompressed(_) rather than both MintToCompressed and MintToCToken. The corresponding comment is updated to reflect this narrowing of scope for tokens_out_queue handling.

Changes

Cohort / File(s) Summary
Action Processing Logic
programs/compressed-token/program/src/mint_action/accounts.rs
Removed ZAction::MintToCToken(_) from the has_mint_to_actions check in the non-CPI context path; updated comment to reflect MintToCompressed as the sole action type considered for tokens_out_queue handling

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Key concern: Verify that MintToCToken action processing has been relocated or properly handled elsewhere in the codebase, particularly given the related PR #2053 which also modifies MintToCToken paths
  • Secondary concern: Confirm that the tokens_out_queue logic still maintains correct invariants with this narrowed condition
  • Verification point: Cross-reference with related PR #2053 to understand the full refactoring context

Possibly related PRs

Suggested reviewers

  • sergeytimoshin

Poem

🔧 One action pruned, the logic refined,
MintToCompressed stays, MintToCToken resigned,
From tokens_out_queue's watchful eye,
Cleaner pathways help systems fly ✨

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 describes the main fix: removing the expectation of a tokens out queue for MintToCToken operations, which aligns with the code change that removes ZAction::MintToCToken(_) from the conditional check.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jorrit/fix-ctoken-program-requires-too-many-accounts

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5f84a0 and 44cabeb.

📒 Files selected for processing (1)
  • programs/compressed-token/program/src/mint_action/accounts.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: cli-v1
  • GitHub Check: Forester e2e test
  • GitHub Check: stateless-js-v1
  • GitHub Check: stateless-js-v2

Comment on lines +452 to +456
// Used to expect tokens_out_queue for MintToCompressed action.
let has_mint_to_actions = parsed_instruction_data
.actions
.iter()
.any(|action| matches!(action, ZAction::MintToCompressed(_)));
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify that MintToCToken actions don't require tokens_out_queue.

The narrowing of the condition to only check MintToCompressed aligns with the PR objective and the comment at line 121 ("Only needed for minting to compressed token accounts"). This change will cause tokens_out_queue to not be expected when only MintToCToken actions are present.

However, confirm that MintToCToken action processing doesn't rely on tokens_out_queue being present in the ExecutingAccounts struct, and that recipient token accounts from packed_accounts (mentioned in the comment at line 36) are sufficient.

Run the following script to verify the implementation:


🏁 Script executed:

#!/bin/bash
# Description: Verify MintToCToken action implementation doesn't use tokens_out_queue

# Search for MintToCToken action processing to check if it accesses tokens_out_queue
ast-grep --pattern $'match $_ {
  $$$
  ZAction::MintToCToken($_) => {
    $$$
  }
  $$$
}'

# Also search for any direct references to tokens_out_queue in action processing
rg -n -C5 'tokens_out_queue' --type=rust -g '!target/**'

# Search for where MintToCToken actions are handled
rg -n -C5 'MintToCToken' --type=rust -g '!target/**'

Length of output: 94730


Looking at the script output provided, I can now identify a critical inconsistency that the review comment missed:

The script output shows that the test file contradicts the program change. At programs/compressed-token/program/tests/mint_action.rs lines 227-232, the test checks for both MintToCompressed and MintToCToken:

let has_mint_to_actions = data.actions.iter().any(|action| {
    matches!(
        action,
        Action::MintToCompressed(_) | Action::MintToCToken(_)
    )
});

However, the program change in accounts.rs lines 452-456 narrows this to only MintToCompressed. This creates a mismatch: the test expects tokens_out_queue to be required for both actions, but the program code now only requires it for MintToCompressed.


Test file condition still checks both MintToCompressed and MintToCToken actions.

The narrowed condition in the program (lines 452-456) now only checks for MintToCompressed, but the test file (programs/compressed-token/program/tests/mint_action.rs:227-232) still checks for both actions when calculating has_mint_to_actions. This creates a test-to-implementation mismatch.

Verify that the test file was updated to match the narrowed condition. If the test wasn't updated, it will have incorrect expectations about when tokens_out_queue is required, potentially masking bugs where MintToCToken actions incorrectly pass without the required tokens_out_queue account.

🤖 Prompt for AI Agents
In programs/compressed-token/program/src/mint_action/accounts.rs around lines
452-456 the code only treats MintToCompressed as requiring tokens_out_queue, but
the test programs/compressed-token/program/tests/mint_action.rs (lines 227-232)
still checks for both MintToCompressed and MintToCToken; update the test to
match the program change by changing its has_mint_to_actions predicate to only
check for Action::MintToCompressed(_) (or alternatively, if the original
behavior is desired, revert/expand the program check to include MintToCToken),
then run the test suite to confirm the expectation and account requirement are
aligned.

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.

1 participant