Skip to content

refactor: check system program account ownership at resize, check account state is zeroed pre initialization#2276

Merged
ananas-block merged 1 commit intomainfrom
jorrit/fix-add-additional-account-creation-checks
Feb 11, 2026
Merged

refactor: check system program account ownership at resize, check account state is zeroed pre initialization#2276
ananas-block merged 1 commit intomainfrom
jorrit/fix-add-additional-account-creation-checks

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Feb 11, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Strengthened validation to prevent token accounts from being re-initialized, improving account state consistency.
    • Enhanced data integrity checks during token account creation to ensure proper initialization state.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Two account initialization functions have been enhanced with stricter validation: create_pda_account now verifies the account isn't already initialized by checking system program ownership before proceeding, while initialize_ctoken_account replaces zero-initialization logic with a comprehensive data validation check that rejects any non-zero bytes.

Changes

Cohort / File(s) Summary
Account Initialization Validation
programs/compressed-token/program/src/shared/create_pda_account.rs, programs/compressed-token/program/src/shared/initialize_ctoken_account.rs
First file adds an early ownership check against system program in the cold path to prevent re-initialization. Second file replaces explicit zeroing with complete byte-level verification of existing data; now rejects any non-zero bytes and changes error type from InvalidAccountData to AccountAlreadyInitialized.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ai-review

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

🔒 Guard clauses stand tall, with verification strong,
Rejecting the initialized accounts, where they don't belong,
Zero bytes must reign, not a whisper of stray data here,
Your accounts now safer—initialization crystal clear! ✨

🚥 Pre-merge checks | ✅ 3
✅ 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 and specifically describes both main changes: adding system program ownership checks during account resize and verifying zeroed account state before initialization.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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-add-additional-account-creation-checks

No actionable comments were generated in the recent review. 🎉


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 merged commit 0f5e5db into main Feb 11, 2026
31 checks passed
@ananas-block ananas-block deleted the jorrit/fix-add-additional-account-creation-checks branch February 11, 2026 20:32
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