Skip to content

Conversation

@ananas-block
Copy link
Contributor

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

Changes:

  • add compressed only placeholder to CompressibleExtension

Summary by CodeRabbit

  • Refactor

    • Consolidated compressible extension data into a nested info container across the codebase; behavior and control flow preserved.
  • Chores

    • Updated token account size and rent-exemption values to reflect the new layout.
  • Tests

    • Adjusted tests and utilities to match the new nested extension shape without changing observable behavior.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Walkthrough

Introduces a new CompressibleExtension wrapper that nests CompressionInfo under an info field and updates all code paths to access compressible fields and methods via .info (e.g., .info.compress_to_pubkey, .info.get_last_funded_epoch, .info.calculate_top_up_lamports). Constants and zero-copy layouts updated accordingly.

Changes

Cohort / File(s) Summary
Extension type & zero-copy layout
program-libs/ctoken-interface/src/state/extensions/extension_struct.rs
Added CompressibleExtension { compression_only, info }; changed ExtensionStruct::Compressible and zero-copy encode/decode to use CompressibleExtension.
Constants & sizes
program-libs/ctoken-interface/src/constants.rs
Switched constant size to use CompressibleExtension::LEN; updated COMPRESSIBLE_TOKEN_ACCOUNT_SIZE doc and COMPRESSIBLE_TOKEN_RENT_EXEMPTION value (2700480 → 2707440).
Zero-copy config & equality
program-libs/ctoken-interface/src/state/ctoken/zero_copy.rs
Added CompressibleExtensionConfig; CompressedTokenConfig::new_compressible now nests CompressionInfoConfig inside it; PartialEq updated to compare zc_comp.info.* fields.
Tests & spl compatibility
program-libs/ctoken-interface/tests/ctoken/spl_compat.rs, programs/compressed-token/program/tests/compress_and_close.rs
Tests updated to construct and access compressible payloads via CompressibleExtension/CompressibleExtensionConfig and comp.info.* fields.
Compressed-token program: init/claim/transfer
programs/compressed-token/program/src/shared/initialize_ctoken_account.rs, programs/compressed-token/program/src/claim.rs, programs/compressed-token/program/src/ctoken_transfer.rs
Zero-copy creation now uses CompressibleExtension::zero_copy_at_mut, initializes compression_only, and routes calls/fields through .info (e.g., claim_and_update, calculate_top_up_lamports).
Compressed-token program: close account & compression flows
programs/compressed-token/program/src/close_token_account/processor.rs, programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs, programs/compressed-token/program/src/transfer2/compression/ctoken/compress_or_decompress_ctokens.rs
Replaced direct compressible fields/methods with .info.* equivalents across validation, distribution, and compression processing.
Forester & sdk test helpers
forester/src/compressible/compressor.rs, forester/src/compressible/state.rs, sdk-libs/program-test/src/compressible.rs, sdk-libs/program-test/src/forester/compress_and_close_forester.rs
Updated accesses and calls to use compressible_ext.info.* and info.get_last_funded_epoch(...).
SDK & token client
sdk-libs/ctoken-sdk/src/compressed_token/v2/compress_and_close.rs, sdk-libs/token-client/src/instructions/transfer2.rs
Changed packing and instruction metadata collection to read compression_authority, rent_sponsor, compress_to_pubkey via .info.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas to spot-check:
    • COMPRESSIBLE_TOKEN_ACCOUNT_SIZE calculation and the adjusted rent-exemption constant.
    • PartialEq in zero-copy ZCToken to ensure all relevant nested fields are compared.
    • All moved method calls: calculate_top_up_lamports, get_last_funded_epoch, claim_and_update invoked on .info.
    • Zero-copy initialization sites ensuring compression_only is set and info is passed where expected.

Possibly related PRs

Suggested reviewers

  • sergeytimoshin

Poem

🌱 A little wrapper, tidy and new,
Info tucked in, fields in view,
Calls redirected, paths made clear,
Consistent access far and near,
Small change, neat lines — hooray, review! 🎉

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 PR title accurately describes the main change: adding a missing compression_only placeholder field to CompressibleExtension, which is the core structural modification across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.
✨ 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/chore-add-missing-compressible-ext-placeholder

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/chore-add-missing-compressible-ext-placeholder branch from 8c485c0 to 0eae076 Compare December 17, 2025 21:56
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: 2

@ananas-block ananas-block force-pushed the jorrit/chore-add-missing-compressible-ext-placeholder branch from 0eae076 to 402fde6 Compare December 17, 2025 22:41
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: 0

Caution

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

⚠️ Outside diff range comments (1)
program-libs/ctoken-interface/tests/ctoken/spl_compat.rs (1)

577-602: Consider adding test coverage for compression_only field.

The PartialEq tests verify mismatches for compress_to_pubkey and account_version, but the new compression_only field is always set to false. Consider adding a test case that verifies the comparison behavior when compression_only differs between instances:

// Test compression_only mismatch
let ctoken_diff_compression_only = CToken {
    extensions: Some(vec![ExtensionStruct::Compressible(CompressibleExtension {
        compression_only: true,  // Different from buffer which has false
        info: compression_info,
    })]),
    ..ctoken.clone()
};
assert_ne!(zctoken, ctoken_diff_compression_only);
♻️ Duplicate comments (2)
program-libs/ctoken-interface/src/state/extensions/extension_struct.rs (2)

165-168: Stale comment: still references CompressionInfo instead of CompressibleExtension.

The inline comment on line 166 says "CompressionInfo size" but the code correctly uses CompressibleExtension::byte_len. This was flagged in a prior review and should be updated for consistency.

             ExtensionStructConfig::Compressible(config) => {
-                // 1 byte for discriminant + CompressionInfo size
+                // 1 byte for discriminant + CompressibleExtension size
                 1 + CompressibleExtension::byte_len(config)?
             }

257-257: Define CompressibleExtensionConfig struct in extension_struct.rs.

The ExtensionStructConfig::Compressible variant references CompressibleExtensionConfig, but this type is not defined anywhere in the crate. The struct is imported in zero_copy.rs and used in tests with a field info: CompressionInfoConfig, following the same pattern as TokenMetadataConfig. Add the missing struct definition in extension_struct.rs and ensure it's exported from state/extensions/mod.rs.

@ananas-block ananas-block merged commit 2c8f623 into main Dec 18, 2025
32 checks passed
@ananas-block ananas-block deleted the jorrit/chore-add-missing-compressible-ext-placeholder branch December 18, 2025 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants