Skip to content

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Jan 19, 2026

Changes

  1. Core Macro Renaming: #[derive(RentFree)] → #[derive(LightAccounts)] throughout macros crate
  2. Token Attribute Updates: New #[light_account(token)] attribute for compressed token support
  3. CPI Authority Field: ctoken_cpi_authority → light_token_cpi_authority in SDK integration layer
  4. Documentation: Updated CLAUDE.md, rentfree.md, and inline comments to reflect new naming
  5. Integration: Updated compressible-client and test fixtures to use new field names

Impact

  • Breaking: Users will need to update macro imports and attribute usage in their programs
  • Scope: Affects sdk-libs/macros, sdk-libs/compressible-client, and integration tests
  • Benefits: Clearer API semantics and unified Light Protocol branding

Macros & Attributes

  1. #[derive(RentFree)] -> #[derive(LightAccounts)]
  2. #[rentfree] -> #[light_account(init)]
  3. #[rentfree_token] -> #[light_account(token)]
  4. #[light_mint(...)] -> #[light_account(init, mint, ...)]
  5. #[rentfree_program] -> #[light_program]
  6. #[derive(RentFreeAccount)] -> #[derive(LightAccount)]

Functions

  1. rentfree_program() -> light_program()
  2. rent_free_account() -> light_account_derive()
  3. derive_rentfree_account() -> derive_light_account()
  4. derive_rentfree() -> derive_light_accounts()
  5. rentfree_program_impl() -> light_program_impl()
  6. d5_rentfree_token() -> d5_light_token()
  7. d7_ctoken_config() -> d7_light_token_config()
  8. parse_rentfree_token_list() -> parse_light_token_list()
  9. extract_rentfree_token_attr() -> extract_light_token_attr()

Structs & Types

  1. RentFreeTokenAttr -> LightTokenAttr
  2. D5RentfreeToken -> D5LightToken
  3. D5RentfreeTokenParams -> D5LightTokenParams
  4. D7CtokenConfig -> D7LightTokenConfig
  5. D7CtokenConfigParams -> D7LightTokenConfigParams
  6. RentFreeAccountVariant -> LightAccountVariant
  7. RentFreeAccountData -> LightAccountData

Modules/Directories

  1. rentfree/ -> light_pdas/
  2. rentfree_program/ -> light_program/
  3. rentfree-features.md -> light-features.md
  4. rentfree_program/architecture.md -> light_program/architecture.md
  5. rentfree_program/codegen.md -> light_program/codegen.md

Field/Account Names

  1. ctoken_compressible_config -> light_token_compressible_config
  2. ctoken_cpi_authority -> light_token_cpi_authority
  3. ctoken_rent_sponsor -> light_token_rent_sponsor
  4. d7_ctoken_vault -> d7_light_token_vault
  5. d7_ctoken_authority -> d7_light_token_authority
  6. D7_CTOKEN_AUTH_SEED -> D7_LIGHT_TOKEN_AUTH_SEED
  7. D7_CTOKEN_VAULT_SEED -> D7_LIGHT_TOKEN_VAULT_SEED

Module Imports

  1. crate::rentfree:: -> crate::light_pdas::
  2. mod rentfree; -> mod light_pdas;
  3. use light_sdk_macros::RentFree; -> use light_sdk_macros::LightAccounts;
  4. use light_sdk_macros::RentFreeAccount; -> use light_sdk_macros::LightAccount;

Summary by CodeRabbit

  • New Features

    • Added CompressiblePack derive macro for enhanced account handling.
  • Refactor

    • Renamed account compression derive from RentFree → LightAccounts.
    • Reworked field attribute syntax: #[rentfree] → #[light_account(init)] and token attrs → #[light_account(token)].
    • Standardized infrastructure names to light_token_*.
  • Documentation

    • Updated docs, examples, and guides to reflect the new LightAccounts/light_account terminology.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

This PR renames and restructures the macros from RentFree → LightAccounts, introduces a unified #[light_account(...)] attribute surface, moves code from src/rentfree/src/light_pdas/, renames infra identifiers from ctoken_*light_token_*, adds new parsing/validation for accounts, and updates docs/examples accordingly.

Changes

Cohort / File(s) Summary
Core macro entrypoints & module layout
sdk-libs/macros/src/lib.rs, sdk-libs/macros/src/light_pdas/mod.rs, sdk-libs/macros/src/rentfree/*
Added light_pdas module, removed rentfree module, and re-exported/renamed macro entrypoints (e.g., rentfree_programlight_program, derive_rentfreederive_light_accounts)
Unified attribute parsing
sdk-libs/macros/src/light_pdas/accounts/light_account.rs
NEW: unified parser for #[light_account(...)] handling both PDA and mint variants; introduces LightAccountType/Field, PdaField, parsing helpers, validation, and tests
Accounts-level parsing & builder
sdk-libs/macros/src/light_pdas/accounts/parse.rs, .../builder.rs, .../derive.rs, .../mod.rs
NEW/refactor: parse_light_accounts_struct and ParsedLightAccountsStruct added; RentFreeBuilder → LightAccountsBuilder with validate_infra_fields() enforcing required infra fields; derive orchestration renamed
Mint handling refactor
sdk-libs/macros/src/light_pdas/accounts/mint.rs
Parsing moved into light_account.rs; removed old parse helpers; infra refs renamed (ctoken_*light_token_*) and codegen updated to use new names
PDA & seed extraction
sdk-libs/macros/src/light_pdas/accounts/pda.rs, sdk-libs/macros/src/light_pdas/account/seed_extraction.rs, .../light_compressible.rs
Replaced RentFreeField with ParsedPdaField/Parsed types; seed extraction updated to expect #[light_account(...)]; imports and error messages adjusted to new paths
Program-level macros & generated types
sdk-libs/macros/src/light_pdas/program/* (instructions.rs, variant_enum.rs, parsing.rs, compress.rs, decompress.rs, seed_codegen.rs, seed_utils.rs, expr_traversal.rs, visitors.rs, crate_context.rs)
Renamed entrypoints and generated types (RentFreeAccountVariantLightAccountVariant, RentFreeAccountDataLightAccountData); wrapper/processor renames (wrap_function_with_rentfreewrap_function_with_light); import paths updated to light_pdas; error enum renamed to LightInstructionError
Removed legacy rentfree parse module
sdk-libs/macros/src/rentfree/accounts/parse.rs, sdk-libs/macros/src/rentfree/accounts/mod.rs
Deleted legacy rentfree accounts parsing/entrypoint and associated types
Documentation & examples
sdk-libs/macros/docs/**/*, sdk-libs/macros/CLAUDE.md, sdk-libs/macros/docs/*/light_*, sdk-libs/macros/docs/features/*
Updated docs and examples: #[derive(RentFree)]#[derive(LightAccounts)], #[rentfree]#[light_account(init)], #[light_mint(...)]#[light_account(init, mint, ...)], and infra field name changes
Token SDK / compressible client light naming
sdk-libs/token-sdk/src/token/decompress_mint.rs, sdk-libs/compressible-client/src/lib.rs
Renamed field and doc references: ctoken_cpi_authoritylight_token_cpi_authority (struct field and usage; compressible-client doc comment update only)

Sequence Diagram(s)

(omitted — changes are primarily internal macro refactors and renames, not a multi-component runtime flow requiring sequence visualization)

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Suggested labels

ai-review

Suggested reviewers

  • SwenSchaeferjohann
  • sergeytimoshin

Poem

✨ From RentFree roots to LightAccounts' rise,
One attribute to rule both mints and PDAs,
Names reborn — ctoken_ to light_token_ bright,
Docs and macros step into the light,
A tidy refactor, dancing into night.

🚥 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 'chore: rename macros' directly and accurately reflects the primary change: a comprehensive macro renaming effort throughout the codebase.
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/refactor-macros-5

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/refactor-macros-5 branch from 65d643f to dd12267 Compare January 19, 2026 06:43
@ananas-block ananas-block changed the title chore: rename macros wip chore: rename macros Jan 19, 2026
@ananas-block ananas-block marked this pull request as ready for review January 19, 2026 07:40
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: 13

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (21)
sdk-libs/macros/src/light_pdas/shared_utils.rs (1)

1-6: Module documentation is inconsistent with the rename.

The module doc still references "rentfree macro implementation" but this file is now in light_pdas/. Consider updating it to reflect the new naming convention for consistency across the codebase.

📝 Suggested fix
-//! Shared utilities for rentfree macro implementation.
+//! Shared utilities for light_pdas macro implementation.
sdk-libs/macros/src/light_pdas/README.md (1)

1-29: README has inconsistent naming throughout.

The README is partially updated but retains several stale references:

  1. Title (line 1): Still says "Rent-Free Macros"
  2. Directory structure (lines 7-29): Shows rentfree/ but this file is in light_pdas/
  3. Section headers (lines 33, 40): Still reference "RentFree"
  4. Line 46: Still mentions RentFreeAccountVariant (should be LightAccountVariant per AI summary)

Consider updating these for consistency with the overall rename strategy. The README is often the first thing developers read, so alignment with the new naming convention improves discoverability.

📝 Suggested structural updates
-# Rent-Free Macros
+# Light PDAs Macros

-Procedural macros for generating rent-free account types and their hooks for Solana programs.
+Procedural macros for generating light account types and their hooks for Solana programs.

 ## Directory Structure

-rentfree/
+light_pdas/
├── mod.rs # Module declaration
├── README.md # This file
├── accounts/ # #[derive(LightAccounts)] implementation


And similar updates for section headers and `RentFreeAccountVariant` references.
</details>

</blockquote></details>
<details>
<summary>sdk-libs/macros/src/light_pdas/mod.rs (1)</summary><blockquote>

`1-6`: **Rename remaining “rentfree” terms in module docs.**  
Line 1-4 still say “Rent-free” and `#[rentfree_program]`, which conflicts with the LightAccounts/Light program rename and can mislead readers.

<details>
<summary>✏️ Suggested doc update</summary>

```diff
-//! Rent-free account compression macros.
-//!
-//! This module organizes all rent-free related macros:
-//! - `program/` - `#[rentfree_program]` attribute macro for program-level auto-discovery
+//! Light account compression macros.
+//!
+//! This module organizes all light account related macros:
+//! - `program/` - `#[light_program]` attribute macro for program-level auto-discovery
 //! - `accounts/` - `#[derive(LightAccounts)]` derive macro for Accounts structs

As per coding guidelines, ensure docs match the current API surface.

sdk-libs/macros/docs/account/light_compressible.md (1)

259-275: Rename remaining RentFree references in examples and related macros

The example comment and the related-macros table still mention RentFree; these should align with the LightAccounts rename and the current doc location. As per coding guidelines, ensure docs match the implementation.

✏️ Suggested tweak (example comment)
-// Accounts struct - apply RentFree
+// Accounts struct - apply LightAccounts

Also applies to: 309-315

sdk-libs/macros/docs/light_program/architecture.md (2)

1-17: Docs still describe #[rentfree_program] and “rent-free” field discovery

Title, location, and discovery flow still point at rentfree_program/rentfree semantics even though the table already shows LightAccounts and #[light_account]. Please align these sections with the new macro name and discovery syntax. As per coding guidelines, ensure docs match the implementation.

Also applies to: 29-33, 59-61


90-100: Update diagram and summary table to use actual generated type names

The generated artifacts use LightAccountVariant and LightInstructionError, not the RentFree* names shown in the diagram (lines 90-100) and summary table (lines 197-209). Update both locations to match the actual codegen output.

sdk-libs/macros/src/light_pdas/program/parsing.rs (1)

401-429: Remove unused LightFinalize import in generated wrapper

LightFinalize is currently unused because finalize is commented out. Macro-expanded unused imports generate warnings and can fail in deny(warnings) crates.

🧹 Proposed fix
-            use light_sdk::compressible::{LightPreInit, LightFinalize};
+            use light_sdk::compressible::LightPreInit;
sdk-libs/macros/src/light_pdas/program/decompress.rs (1)

147-159: Align field naming in generated DecompressAccountsIdempotent struct for consistency

The struct does mix light_token_program and light_token_cpi_authority with ctoken_rent_sponsor and ctoken_config. However, this is generated code with hardcoded field name mappings in the DecompressContext trait implementation (decompress_context.rs lines 126, 138). Renaming requires coordinated updates in both decompress.rs and decompress_context.rs.

Since ctoken_* naming appears intentional (hardcoded trait impl references), clarify whether the rename should proceed before making changes. If pursuing consistency with the light_token_* pattern used for other token-related fields, update both:

  • decompress.rs: Rename struct fields
  • decompress_context.rs: Update trait method bodies to reference renamed fields
sdk-libs/macros/CLAUDE.md (2)

14-47: Update macro names and source tree path to Light terminology.*
The macro table, usage import, and source tree still reference rentfree_program and src/rentfree/, but the public macro is now light_program and the module moved to light_pdas/. This will mislead consumers following the docs.

Proposed doc updates
-| `#[rentfree_program]` | Attribute | Program-level auto-discovery and instruction generation |
+| `#[light_program]` | Attribute | Program-level auto-discovery and instruction generation |

-├── rentfree/              # LightAccounts macro system
+├── light_pdas/            # LightAccounts macro system

-use light_sdk_macros::{rentfree_program, LightAccounts, LightCompressible};
+use light_sdk_macros::{light_program, LightAccounts, LightCompressible};

-#[rentfree_program]
+#[light_program]

32-41: Specify a language for the fenced code block.
markdownlint MD040 flags this block because it lacks a language identifier.

Suggested fix
-```
+```text
 src/
 ├── lib.rs                 # Macro entry points
 ├── rentfree/              # LightAccounts macro system
 │   ├── account/           # Trait derive macros for account data structs
 │   ├── accounts/          # #[derive(LightAccounts)] for Accounts structs
 │   ├── program/           # #[rentfree_program] attribute macro
 │   └── shared_utils.rs    # Common utilities
 └── hasher/                # LightHasherSha derive macro
-```
+```
sdk-libs/macros/docs/features/light-features.md (2)

9-19: Overview snippet uses old derives and misplaces #[light_account(init)].
Line 9-19 still imports RentFree and applies #[light_account(init)] to the data struct. #[light_account(init)] is a field attribute inside #[derive(Accounts, LightAccounts)] structs; the data struct should use LightAccount or LightCompressible.

Suggested shape
use light_sdk_macros::{LightAccount, LightAccounts};

#[derive(LightAccount)]
pub struct MyAccount {
    pub data: u64,
    #[compression_info]
    pub compression_info: CompressionInfo,
}

#[derive(Accounts, LightAccounts)]
pub struct Create<'info> {
    #[light_account(init)]
    pub my_account: Account<'info, MyAccount>,
}

130-153: Replace rentfree_program/RentFree references with the new API.
Sections 5 and the complete example still use #[rentfree_program] and RentFree. These should be #[light_program] and LightAccounts/LightAccount to match the renamed macros.

Also applies to: 455-479

sdk-libs/macros/docs/features/comparison.md (2)

7-13: Rename “Light RentFree” headings to LightAccounts for consistency.

The column header and surrounding text still use “Light RentFree” while the examples now use LightAccounts/#[light_account(...)]. Please update the headings and labels to the new name to avoid documenting a deprecated API surface. As per coding guidelines, documentation should match the current API.


153-162: Pack/Unpack traits are not generated by #[derive(LightAccounts)].

LightAccounts derives LightPreInit/LightFinalize for Accounts structs, but Pack/Unpack come from data-struct derives like CompressiblePack or LightCompressible. Update this row to reflect the correct derive(s). Based on learnings, the Pack/Unpack traits are provided by the data-struct derives, not the Accounts derive.

sdk-libs/macros/docs/accounts/light_mint.md (2)

7-16: Update the example import to match the new derive name.

The example still imports RentFree but derives LightAccounts. That will not compile and is confusing for readers. Please update the import to the LightAccounts derive. As per coding guidelines, documentation should reflect the current API.

Proposed fix
-use light_sdk_macros::RentFree;
+use light_sdk_macros::LightAccounts;

292-296: Replace #[light_mint] wording with #[light_account(init, mint)].

The text still refers to #[light_mint], but the examples and new syntax use #[light_account(init, mint, ...)]. Please update this section to the new attribute name. As per coding guidelines, documentation should match the current API.

sdk-libs/macros/docs/accounts/architecture.md (3)

14-25: Module path still references rentfree/ after the rename.

The module structure points to sdk-libs/macros/src/rentfree/, but the code has moved to light_pdas/. Please update the tree to match the new layout. As per coding guidelines, documentation should reflect the current source layout.


69-79: Update the optional-arguments snippet to #[light_account(init, ...)].

The snippet still shows #[rentfree(...)], which no longer matches the new attribute syntax. Please update it to #[light_account(init, ...)] to avoid documenting a deprecated attribute. As per coding guidelines, documentation should match the current API.


124-133: Codegen flow still names #[light_mint] fields.

The parsing/flow description says #[light_mint] and maps to LightMintField. With the unified attribute, this should describe #[light_account(init, mint, ...)]. Please update the flow labels to match the new syntax. As per coding guidelines, documentation should match the current API.

sdk-libs/macros/src/light_pdas/program/variant_enum.rs (1)

46-62: Error message still references #[rentfree_program].

Please update the validation error to #[light_program] and the LightAccounts terminology so users see the correct macro name.

sdk-libs/macros/src/light_pdas/accounts/mint.rs (1)

308-311: Align defaults with documentation—16u8/766u32 do not match documented 2/0.

Three issues need addressing:

  1. Default value mismatch: Code uses 16u8 and 766u32, but the struct doc comments and light_mint.md document defaults as 2u8 and 0u32. Update code defaults to match docs, or revise documentation to reflect the actual defaults.

  2. Multi-mint limitation: Taking rent_payment and write_top_up only from the first mint without validating other mints have compatible values is a known limitation (TODO comment at line 344). Either enforce identical values at parse-time, support per-mint values, or document this constraint explicitly for users.

  3. Empty slice safety: The mints[0] access assumes the slice is non-empty. While the builder pattern's has_mints() check protects this in practice, add an explicit guard or assert for clarity and robustness.

🤖 Fix all issues with AI agents
In `@sdk-libs/macros/docs/accounts/architecture.md`:
- Around line 577-579: Add a single blank line immediately before the "### Type
Restrictions" heading so the heading is separated from the preceding
paragraph/list (fixing MD022); update the section around the "### Type
Restrictions" heading to ensure there is an empty line above it and leave the
existing lines under that heading unchanged.
- Around line 99-106: Update the documentation to stop referencing the old
attribute `#[light_mint]` and instead use the unified macro form
`#[light_account(init, mint)]`; specifically change the example and surrounding
text that mentions `#[light_mint]` to show `#[light_account(init, mint)]` (keep
the `#[derive(Accounts, LightAccounts)]`, `#[instruction(params:
CreateParams)]`, and the `CreateAccounts<'info>` struct name intact) and adjust
any explanatory text so it reflects the new `#[light_account(init, mint, ...)]`
syntax.

In `@sdk-libs/macros/docs/features/comparison.md`:
- Around line 224-227: The markdown has no blank line between the "After
(LightAccounts)" paragraph and the fenced code block, triggering MD031; edit the
section containing the "After (LightAccounts)" heading and the following code
fence (the ```rust block shown) and insert a single blank line between the
paragraph/heading and the opening ```rust fence so the fenced code block is
separated by an empty line.

In `@sdk-libs/macros/src/light_pdas/account/seed_extraction.rs`:
- Around line 204-238: The function check_light_account_type currently iterates
the parsed tokens twice to set has_mint and has_init; change it to a single pass
over the tokens (after extracting list.tokens from attr.meta in
check_light_account_type) and set both boolean flags in that loop, then return
(!has_mint, has_mint) when has_init is true; keep the existing
attr.path().is_ident("light_account") and meta parsing logic and ensure you
still handle non-List metas by continuing the outer loop.

In `@sdk-libs/macros/src/light_pdas/accounts/light_account.rs`:
- Around line 3-6: The doc comment in the light_pdas accounts module incorrectly
states that the PDA form "replaces `#[light_account(init)]`" which is circular;
change the second reference to the legacy PDA attribute (for example
`#[rentfree]`) so the sentence reads that `#[light_account(init)]` replaces the
legacy PDA attribute `#[rentfree]` (or the correct legacy attribute name used
previously), and ensure the surrounding bullet still correctly lists
`#[light_account(init)]` as the new PDA syntax; update the doc string near the
top of the module where the three bullets are defined.
- Around line 88-104: The token branch in the parser (where it checks if first
== "token" and currently consumes remaining tokens then returns Self { has_init:
false, is_token: true, account_type: LightAccountType::Pda, ... }) should not
silently accept arbitrary/malformed arguments; instead, parse and validate the
remaining token arguments using the shared parser (e.g., the seed_extraction.rs
parser) or explicitly validate allowed key/value pairs (like "authority") and
emit a diagnostic on unexpected tokens; update the logic in that branch to call
the common parser or return Err with a clear message when extra tokens are
invalid, and keep setting has_init/is_token appropriately while not hiding
format errors.

In `@sdk-libs/macros/src/light_pdas/accounts/mint.rs`:
- Around line 24-27: Update the doc comment for the field_ident member on struct
LightMintField to reflect the new public attribute syntax: replace the old
reference to #[light_mint] with #[light_account(init, mint, ...)] so the comment
correctly describes where the attribute is applied (the CMint account) and
avoids confusion.

In `@sdk-libs/macros/src/light_pdas/accounts/parse.rs`:
- Around line 90-101: The set method currently overwrites existing infra fields;
change InfraFields::set to detect duplicates and return a failure rather than
silently overwrite: have set take (or return) a Result<(), syn::Error> (or
otherwise produce a compile error via syn::Error::new_spanned on the incoming
Ident) and for each InfraFieldType arm (e.g., InfraFieldType::FeePayer,
CompressionConfig, LightTokenConfig, LightTokenRentSponsor, LightTokenProgram,
LightTokenCpiAuthority) check if the corresponding Option (self.fee_payer,
self.compression_config, etc.) is already Some and, if so, return
Err(syn::Error::new_spanned(ident, "duplicate infrastructure field: <name>"));
otherwise set the field to Some(ident) and return Ok(()); apply the same
duplicate-check logic to the other affected location mentioned (lines around
188-192) and update call sites to handle the Result.
- Around line 205-218: The error messages for the deprecated attributes are
misleading: when attr.path().is_ident("rentfree") and when
attr.path().is_ident("light_mint") the Err::new_spanned messages incorrectly
reference #[light_account(init)] instead of the actual deprecated attribute
names; update the message strings in these branches (the blocks that return
Err::new_spanned for rentfree and light_mint) to mention #[rentfree] and
#[light_mint] respectively and provide the corrected replacement usage text
(e.g., for rentfree explain the new attribute(s) to use, and for light_mint show
the full #[light_account(init, mint, mint_signer = ..., authority = ...,
decimals = ..., mint_seeds = ...)] usage).

In `@sdk-libs/macros/src/light_pdas/program/instructions.rs`:
- Around line 108-110: The current call to
LightVariantBuilder::new(&pda_ctx_seeds).build()? triggers validation that fails
when pda_ctx_seeds is empty, breaking TokenOnly variants; modify the logic to
skip invoking LightVariantBuilder (or skip its validate step) when
pda_ctx_seeds.is_empty() and the instruction_variant is
InstructionVariant::TokenOnly—mirroring the DecompressBuilder approach—so that
TokenOnly programs which legitimately have no PDA seeds do not error; locate
usages around LightVariantBuilder::new, pda_ctx_seeds, and
InstructionVariant::TokenOnly and conditionally bypass or relax validation
accordingly.

In `@sdk-libs/macros/src/light_pdas/program/variant_enum.rs`:
- Around line 490-497: Rename the helper function
generate_rentfree_account_data_struct to a clearer name that matches the emitted
type (e.g., generate_light_account_data_struct); update the function signature,
its doc comment, and all call sites that reference
generate_rentfree_account_data_struct to the new name, and ensure any references
in comments or tests are updated so the helper clearly reflects that it emits
the LightAccountData struct and not a rent-free-specific type.

In `@sdk-libs/macros/src/light_pdas/shared_utils.rs`:
- Line 88: Update the doc comment example for the light_account attribute to add
the missing space after the comma between mint and mint_signer; locate the
comment containing the attribute example `#[light_account(init, mint,mint_signer
= self.authority)]` and change it to use a consistent spacing `mint,
mint_signer` so the attribute reads `#[light_account(init, mint, mint_signer =
self.authority)]`.

In `@sdk-libs/token-sdk/src/token/decompress_mint.rs`:
- Around line 341-343: The doc comment above the struct field
light_token_cpi_authority is outdated (mentions "CToken program's CPI
authority"); update it to match the new name and intent—e.g., replace "CToken
program's CPI authority" with "Light token program's CPI authority" or similar
wording consistent with the renaming so the comment and the field
light_token_cpi_authority are aligned.

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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (16)
sdk-libs/macros/src/light_pdas/README.md (2)

1-20: Doc still references RentFree paths/macros; update to Light naming.

This README lives under light_pdas/ but still documents rentfree/, #[rentfree_program], rentfree_program_impl(), and RentFreeAccountVariant. That conflicts with the PR’s rename and will mislead users. Please align all directory/module/macro names to the Light equivalents (e.g., light_pdas/, #[light_program], light_program_impl(), LightAccountVariant).


33-47: Module header still says RentFree; align section titles.

The accounts/ and program/ section headings still say “RentFree” and describe #[rentfree_program]. Update the headings and macro names to Light nomenclature to avoid mixed terminology.

sdk-libs/macros/docs/accounts/light_mint.md (3)

11-12: Import statement uses outdated macro name.

The example still imports RentFree but per the PR objectives, this should be LightAccounts:

-use light_sdk_macros::RentFree;
+use light_sdk_macros::LightAccounts;

316-320: Related documentation paths reference old naming.

The related documentation section still references the old rentfree paths. These should be updated to reflect the new naming:

-## Related Documentation
-
-- **`../rentfree.md`** - Full RentFree derive macro documentation
-- **`../rentfree_program/`** - Program-level `#[rentfree_program]` macro
-- **`../account/`** - Trait derives for data structs
+## Related Documentation
+
+- **`../light_accounts.md`** - Full LightAccounts derive macro documentation
+- **`../light_program/`** - Program-level `#[light_program]` macro
+- **`../account/`** - Trait derives for data structs

103-112: Add blank lines around fenced code blocks.

Per markdownlint MD031, fenced code blocks should be surrounded by blank lines. The code blocks after "ERROR" comments need spacing:

 // ERROR: name without symbol and uri
 #[light_account(init, mint,
     ...,
     name = params.name.clone()
 )]
+
 // ERROR: additional_metadata without name, symbol, uri
sdk-libs/macros/docs/features/light-features.md (3)

1-3: Title and overview still reference "RentFree" naming.

The document title and opening paragraph still use the old "RentFree" terminology. For consistency with the PR's unified "Light" naming:

-# Light Protocol RentFree Features
+# Light Protocol LightAccounts Features

-This document covers the 17 features available in Light Protocol's rentfree macro system for creating compressed (rent-free) accounts and tokens.
+This document covers the 17 features available in Light Protocol's LightAccounts macro system for creating compressed (rent-free) accounts and tokens.

9-20: Overview example mixes old and new naming conventions.

The overview code block imports RentFree and derives RentFree, but uses the new #[light_account(init)] attribute. This creates confusion. The imports and derives should be updated:

 use light_sdk::compressible::CompressionInfo;
-use light_sdk_macros::{RentFree, Compressible, HasCompressionInfo};
+use light_sdk_macros::LightAccounts;

-#[derive(RentFree, Compressible, HasCompressionInfo)]
+#[derive(LightAccounts)]
 #[light_account(init)]
 pub struct MyAccount {

Note: Based on the coding guidelines, #[derive(LightAccounts)] should replace the combination of RentFree, Compressible, and HasCompressionInfo for account-level macros.


450-464: Complete example still uses old derive naming.

The "Complete Example" section at the end still shows the old derive pattern. This should demonstrate the new unified approach:

-#[derive(RentFree, Compressible, HasCompressionInfo)]
+#[derive(LightAccounts)]
 #[light_account(init)]
 pub struct UserProfile {
sdk-libs/macros/docs/accounts/architecture.md (3)

1-1: Document title inconsistent with content.

The title says "RentFree Derive Macro" but the content describes #[derive(LightAccounts)]. Update for consistency:

-# RentFree Derive Macro and Trait Derives
+# LightAccounts Derive Macro and Trait Derives

14-35: Module structure paths reference old directory.

The module structure diagram still shows sdk-libs/macros/src/rentfree/ but this should be updated to sdk-libs/macros/src/light_pdas/ to match the actual directory structure after the rename:

-sdk-libs/macros/src/rentfree/
+sdk-libs/macros/src/light_pdas/

Similarly, lines 45, 122, 152, 357, 375, 415, 476, and 511-564 reference rentfree/ paths that should be light_pdas/.


587-591: Related documentation paths reference old naming.

The related documentation section references outdated paths:

-## 6. Related Documentation
-
-- **`sdk-libs/macros/docs/rentfree_program/`** - Program-level `#[rentfree_program]` attribute macro (architecture.md + codegen.md)
+## 6. Related Documentation
+
+- **`sdk-libs/macros/docs/light_program/`** - Program-level `#[light_program]` attribute macro (architecture.md + codegen.md)
sdk-libs/macros/src/light_pdas/accounts/mint.rs (2)

330-333: Avoid panics on missing proof.

Using expect will abort the program. Prefer a recoverable error so failures surface cleanly to callers.

🐛 Suggested fix
-            let __proof: light_token_sdk::CompressedProof = `#params_ident.create_accounts_proof.proof.0.clone`()
-                .expect("proof is required for mint creation");
+            let __proof: light_token_sdk::CompressedProof = `#params_ident`
+                .create_accounts_proof
+                .proof
+                .0
+                .clone()
+                .ok_or(anchor_lang::solana_program::program_error::ProgramError::InvalidArgument)?;

42-45: Update field documentation to match actual code defaults.

Lines 42 and 44 document rent_payment as defaulting to 2 and write_top_up as defaulting to 0, but the code at lines 309–310 uses 16u8 and 766u32 as fallback values when these fields are not provided. Update the documentation to reflect the actual defaults:

Doc fix
-    /// Rent payment epochs for decompression (default: 2)
+    /// Rent payment epochs for decompression (default: 16)
    pub rent_payment: Option<Expr>,
-    /// Write top-up lamports for decompression (default: 0)
+    /// Write top-up lamports for decompression (default: 766)
    pub write_top_up: Option<Expr>,
sdk-libs/macros/src/light_pdas/accounts/builder.rs (2)

1-20: Update the header to LightAccounts naming.

The file-level docs still reference RentFree.

✏️ Suggested fix
-//! Builder for RentFree derive macro code generation.
+//! Builder for LightAccounts derive macro code generation.
@@
-/// Builder for RentFree derive macro code generation.
+/// Builder for LightAccounts derive macro code generation.

265-271: Align both CPI accounts paths to the canonical source.

This file uses light_sdk_types::cpi_accounts::CpiAccountsConfig at line 210 but light_sdk::cpi::CpiAccountsConfig at line 270. While both resolve to the same type (the latter re-exports the former), keeping them consistent within the same file improves readability. Use the direct source path throughout.

🛠️ Suggested fix
-                light_sdk::cpi::CpiAccountsConfig::new_with_cpi_context(crate::LIGHT_CPI_SIGNER),
+                light_sdk_types::cpi_accounts::CpiAccountsConfig::new_with_cpi_context(crate::LIGHT_CPI_SIGNER),
sdk-libs/macros/src/light_pdas/program/variant_enum.rs (1)

10-63: Rename remaining RentFree references in docs/errors.

The section header and validation error still mention RentFree/#[rentfree_program], which is inconsistent with the new Light naming.

✏️ Suggested fix
-// RENTFREE VARIANT BUILDER
+// LIGHT VARIANT BUILDER
@@
-                "#[rentfree_program] requires at least one Accounts struct with \
+                "#[light_program] requires at least one Accounts struct with \
🤖 Fix all issues with AI agents
In `@sdk-libs/macros/docs/accounts/light_mint.md`:
- Line 7: The docs reference an outdated module location (old "rentfree" layout)
for light_mint; update the "Source" line in
sdk-libs/macros/docs/accounts/light_mint.md to point to the new module (e.g.,
macros::accounts::light_mint or crate::accounts::light_mint corresponding to the
moved light_mint.rs) so the doc link matches the refactor, then run the
docs/build check to ensure the reference resolves.

In `@sdk-libs/macros/docs/features/comparison.md`:
- Around line 226-227: Replace the old RentFree derive in the "After" example
with the new LightAccounts pattern: change #[derive(RentFree, Compressible,
HasCompressionInfo)] to #[derive(LightAccounts, Compressible,
HasCompressionInfo)] and update the attribute #[light_account(init)] to
#[light_accounts(init)] so the example shows the new derive/attribute names
(referencing the RentFree derive, LightAccounts derive, light_account and
light_accounts attribute identifiers).

In `@sdk-libs/macros/src/light_pdas/accounts/light_account.rs`:
- Around line 290-295: The loop that assigns mint_signer and authority currently
accepts arbitrary values (kv.value) which later get expanded as
self.#mint_signer / self.#authority and can produce invalid code; change the
logic in the key_values match for "mint_signer" and "authority" to validate that
kv.value is a simple identifier (e.g., attempt to parse kv.value as a syn::Ident
or otherwise ensure it matches identifier rules) and return a clear compile-time
error if parsing/validation fails, storing the validated Ident (or its string)
instead of an arbitrary expression; keep the existing handling for other keys
like "decimals" and "mint_seeds".

In `@sdk-libs/macros/src/light_pdas/README.md`:
- Around line 11-14: The README currently repeats the attribute
`#[light_account(init)]` and omits token/mint variants; update the attribute
list that documents the accounts module to remove the duplicate
`#[light_account(init)]` and add the token/mint forms you support (e.g.
`#[light_account(token)]` and `#[light_account(mint)]` or your exact mint
variant name), and make the same correction in the other occurrence of the
duplicated attribute list elsewhere in the file so both places consistently show
init, token, and mint variants.

In `@sdk-libs/token-sdk/src/token/decompress_mint.rs`:
- Around line 398-399: Comment mentions "ctoken's CPI authority" but the field
is now named light_token_cpi_authority; update the inline comment to match the
new identifier and terminology. Locate the line referencing
self.light_token_cpi_authority in decompress_mint (around the CPI call) and
change the comment to something like "Use light_token's CPI authority for the
CPI, not the calling program's authority" so the comment consistently reflects
the renamed field and intent.
♻️ Duplicate comments (3)
sdk-libs/macros/docs/features/comparison.md (1)

224-227: Missing blank line before fenced code block (MD031).

There should be a blank line before the code fence to satisfy markdownlint:

 **After (LightAccounts)**:
+
 ```rust
 #[derive(RentFree, Compressible, HasCompressionInfo)]
sdk-libs/macros/docs/accounts/architecture.md (2)

99-106: Replace #[light_mint] with #[light_account(init, mint)].

This section still mentions #[instruction(...)] being required for #[light_mint], but the macro surface is now unified under #[light_account(init, mint, ...)]:

-Must be present on the struct when using `#[light_account(init)]` or `#[light_account(init)]`.
+Must be present on the struct when using `#[light_account(init)]` or `#[light_account(init, mint)]`.

Note: Line 101 currently shows #[light_account(init)] twice, which appears to be a copy-paste error.


574-580: Add blank line before "Type Restrictions" heading.

Per MD022, headings should be surrounded by blank lines:

 - **Maximum 255 fields**: Total `#[light_account(init)]` + `#[light_account(init)]` fields must be <= 255 (u8 index limit)
 - **Single mint field**: Currently only the first `#[light_account(init)]` field is processed
+
 ### Type Restrictions

Also, line 574 shows #[light_account(init)] twice — should be #[light_account(init)] + #[light_account(init, mint)].

The `#[light_mint(...)]` attribute marks a field in an Anchor Accounts struct for compressed mint creation. When applied to a `CMint` account field, it generates code to create a compressed mint with automatic decompression support.
The `#[light_account(init, mint,...)]` attribute marks a field in an Anchor Accounts struct for compressed mint creation. When applied to a `CMint` account field, it generates code to create a compressed mint with automatic decompression support.

**Source**: `sdk-libs/macros/src/rentfree/accounts/light_mint.rs`
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 | 🟡 Minor

Source path references outdated module location.

The source path still points to the old rentfree directory. Based on the PR's module restructuring:

-**Source**: `sdk-libs/macros/src/rentfree/accounts/light_mint.rs`
+**Source**: `sdk-libs/macros/src/light_pdas/accounts/light_mint.rs`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
**Source**: `sdk-libs/macros/src/rentfree/accounts/light_mint.rs`
**Source**: `sdk-libs/macros/src/light_pdas/accounts/light_mint.rs`
🤖 Prompt for AI Agents
In `@sdk-libs/macros/docs/accounts/light_mint.md` at line 7, The docs reference an
outdated module location (old "rentfree" layout) for light_mint; update the
"Source" line in sdk-libs/macros/docs/accounts/light_mint.md to point to the new
module (e.g., macros::accounts::light_mint or crate::accounts::light_mint
corresponding to the moved light_mint.rs) so the doc link matches the refactor,
then run the docs/build check to ensure the reference resolves.

Comment on lines 226 to +227
#[derive(RentFree, Compressible, HasCompressionInfo)]
#[rentfree]
#[light_account(init)]
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 | 🟡 Minor

"After" example still uses old derive naming.

The "After (LightAccounts)" example ironically still shows the old RentFree derive. This should demonstrate the new pattern:

-#[derive(RentFree, Compressible, HasCompressionInfo)]
+#[derive(LightAccounts)]
 #[light_account(init)]
 pub struct Counter {
🤖 Prompt for AI Agents
In `@sdk-libs/macros/docs/features/comparison.md` around lines 226 - 227, Replace
the old RentFree derive in the "After" example with the new LightAccounts
pattern: change #[derive(RentFree, Compressible, HasCompressionInfo)] to
#[derive(LightAccounts, Compressible, HasCompressionInfo)] and update the
attribute #[light_account(init)] to #[light_accounts(init)] so the example shows
the new derive/attribute names (referencing the RentFree derive, LightAccounts
derive, light_account and light_accounts attribute identifiers).

Comment on lines +290 to +295
for kv in key_values {
match kv.key.to_string().as_str() {
"mint_signer" => mint_signer = Some(kv.value.clone()),
"authority" => authority = Some(kv.value.clone()),
"decimals" => decimals = Some(kv.value.clone()),
"mint_seeds" => mint_seeds = Some(kv.value.clone()),
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 | 🟡 Minor

Validate mint_signer/authority as identifiers.

These values are later expanded as self.#mint_signer / self.#authority. Allowing arbitrary expressions will generate invalid code with confusing errors. Validate them as simple identifiers for clearer diagnostics.

🛠️ Suggested fix
-            "mint_signer" => mint_signer = Some(kv.value.clone()),
-            "authority" => authority = Some(kv.value.clone()),
+            "mint_signer" => {
+                let ident = expr_to_ident(&kv.value, "mint_signer")?;
+                mint_signer = Some(syn::parse_quote!(`#ident`));
+            }
+            "authority" => {
+                let ident = expr_to_ident(&kv.value, "authority")?;
+                authority = Some(syn::parse_quote!(`#ident`));
+            }
🤖 Prompt for AI Agents
In `@sdk-libs/macros/src/light_pdas/accounts/light_account.rs` around lines 290 -
295, The loop that assigns mint_signer and authority currently accepts arbitrary
values (kv.value) which later get expanded as self.#mint_signer /
self.#authority and can produce invalid code; change the logic in the key_values
match for "mint_signer" and "authority" to validate that kv.value is a simple
identifier (e.g., attempt to parse kv.value as a syn::Ident or otherwise ensure
it matches identifier rules) and return a clear compile-time error if
parsing/validation fails, storing the validated Ident (or its string) instead of
an arbitrary expression; keep the existing handling for other keys like
"decimals" and "mint_seeds".

Comment on lines +11 to 14
├── accounts/ # #[derive(LightAccounts)] implementation
│ ├── mod.rs # Entry point: derive_rentfree()
│ ├── parse.rs # Parsing #[rentfree], #[light_mint] attributes
│ ├── parse.rs # Parsing #[light_account(init)], #[light_account(init)] attributes
│ └── codegen.rs # LightPreInit/LightFinalize trait generation
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 | 🟡 Minor

Fix duplicated attribute list; include token/mint variants.

The attribute list repeats #[light_account(init)] twice and omits the token/mint forms mentioned in the PR summary. Please correct the list to include #[light_account(token)] and any mint variant you support.

Also applies to: 37-38

🤖 Prompt for AI Agents
In `@sdk-libs/macros/src/light_pdas/README.md` around lines 11 - 14, The README
currently repeats the attribute `#[light_account(init)]` and omits token/mint
variants; update the attribute list that documents the accounts module to remove
the duplicate `#[light_account(init)]` and add the token/mint forms you support
(e.g. `#[light_account(token)]` and `#[light_account(mint)]` or your exact mint
variant name), and make the same correction in the other occurrence of the
duplicated attribute list elsewhere in the file so both places consistently show
init, token, and mint variants.

Comment on lines 398 to +399
// Use ctoken's CPI authority for the CPI, not the calling program's authority
self.ctoken_cpi_authority.clone(),
self.light_token_cpi_authority.clone(),
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 | 🟡 Minor

Minor inconsistency in inline comment.

The comment on line 398 still references "ctoken's CPI authority" while the field itself has been renamed to light_token_cpi_authority. For consistency with the broader rename:

-            // Use ctoken's CPI authority for the CPI, not the calling program's authority
+            // Use light token program's CPI authority for the CPI, not the calling program's authority
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Use ctoken's CPI authority for the CPI, not the calling program's authority
self.ctoken_cpi_authority.clone(),
self.light_token_cpi_authority.clone(),
// Use light token program's CPI authority for the CPI, not the calling program's authority
self.light_token_cpi_authority.clone(),
🤖 Prompt for AI Agents
In `@sdk-libs/token-sdk/src/token/decompress_mint.rs` around lines 398 - 399,
Comment mentions "ctoken's CPI authority" but the field is now named
light_token_cpi_authority; update the inline comment to match the new identifier
and terminology. Locate the line referencing self.light_token_cpi_authority in
decompress_mint (around the CPI call) and change the comment to something like
"Use light_token's CPI authority for the CPI, not the calling program's
authority" so the comment consistently reflects the renamed field and intent.

@SwenSchaeferjohann SwenSchaeferjohann merged commit 969b6ac into main Jan 19, 2026
20 checks passed
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.

3 participants