Skip to content

fix: robust account creation#2097

Merged
ananas-block merged 4 commits intomainfrom
jorrit/fix-robust-account-creation
Dec 5, 2025
Merged

fix: robust account creation#2097
ananas-block merged 4 commits intomainfrom
jorrit/fix-robust-account-creation

Conversation

@ananas-block
Copy link
Contributor

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

Summary by CodeRabbit

  • Refactor
    • Reworked account-creation flow for compressed tokens: simplified seed/fee-payer handling and unified PDA creation paths.
  • Bug Fixes / Reliability
    • Improved support for pre-funded (already-lamported) accounts and clarified when rent payments are transferred, reducing failure cases during account setup.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR refactors PDA account creation across the compressed-token program by changing create_pda_account to accept explicit optional fee_payer_seeds and new_account_seeds, adds a cold-path for pre-funded accounts, and updates call sites to separate fee-payer vs account seeds and to move conditional lamports transfer after creation.

Changes

Cohort / File(s) Change Summary
Core PDA Creation Refactor
programs/compressed-token/program/src/shared/create_pda_account.rs
Replaced the const-generic seeds_inputs API with explicit fee_payer_seeds: Option<&[Seed]> and new_account_seeds: Option<&[Seed]>. Added a cold-path that handles accounts already funded using Assign → resize → Transfer. Updated imports and signer construction logic; signature and public API changed.
ATA and Token Account Creation
programs/compressed-token/program/src/create_associated_token_account.rs, programs/compressed-token/program/src/create_token_account.rs
Reworked seed construction to build ata_seeds/rent_sponsor_seeds separately and pass them as Some(... )/None to the new create_pda_account parameters. Introduced fee_payer_seeds selection (rent sponsor PDA vs custom payer) and moved conditional lamports transfer to occur after account creation. Consolidated related comments and seed blocks.
Mint and Pool Account Creation
programs/compressed-token/program/src/mint_action/actions/create_spl_mint/create_mint_account.rs, programs/compressed-token/program/src/mint_action/actions/create_spl_mint/create_token_pool.rs
Renamed local seed variables (seedsmint_seeds / pool_seeds), removed prior seeds_inputs usage, and updated create_pda_account calls to pass None for fee-payer seeds and Some(... ) for account PDA seeds. Minor comment and naming clarifications only.
Manifest
Cargo.toml
(Unchanged content noted in diff manifest; no source-code API changes beyond above.)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45–60 minutes

  • Attention areas:
    • create_pda_account.rs: verify cold-path correctness (Assign → resize → Transfer), signer collection from optional seeds, and rent-exemption handling.
    • create_associated_token_account.rs / create_token_account.rs: confirm fee_payer_seeds vs new_account_seeds usage and that post-creation lamports transfer doesn't violate rent rules.
    • Ensure all call sites (including any outside this diff) were updated to the new signature and that no generic-seed callers remain.

Possibly related PRs

Suggested labels

ai-review

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

🌱 Seeds split clean — payer and account aligned,
Cold lamports handled, old arrays resigned.
PDAs signed with clearer, steadier beats,
Creation flows tidy, and fewer conceits. ✨

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 reflects the core change: refactoring account creation logic to be more robust by separating fee_payer and new_account seed handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.

📜 Recent 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 a353e1e and c4f5fdb.

📒 Files selected for processing (1)
  • programs/compressed-token/program/src/shared/create_pda_account.rs (1 hunks)

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 and others added 3 commits December 5, 2025 21:51
…t.rs

Co-authored-by: Swen Schäferjohann <swen@lightprotocol.com>
…t.rs

Co-authored-by: Swen Schäferjohann <swen@lightprotocol.com>
…t.rs

Co-authored-by: Swen Schäferjohann <swen@lightprotocol.com>
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