Skip to content

Conversation

@joncinque
Copy link
Contributor

Problem

The token-2022 program has some heavy dependencies that most users of the crate don't care about. This causes dependency issues and long compilation times.

Also, the program uses Agave dependencies, which creates circular dependencies and makes it impossible to upgrade to SDK v3 without some complicated gymnastics.

Summary of changes

Similar to the ATA's interface crate, split out everything need by Agave into a separate crate, which can also be used by on-chain programs as an rlib, and thus allow for LTO in program builds.

#### Problem

The token-2022 program has some heavy dependencies that most users of
the crate don't care about. This causes dependency issues and long
compilation times.

Also, the program uses Agave dependencies, which creates circular
dependencies and makes it impossible to upgrade to SDK v3 without some
complicated gymnastics.

#### Summary of changes

Similar to the ATA's interface crate, split out everything need by Agave
into a separate crate, which can also be used by on-chain programs as an
rlib, and thus allow for LTO in program builds.
@joncinque joncinque requested a review from rustopian July 31, 2025 22:33
@joncinque joncinque marked this pull request as ready for review July 31, 2025 22:34
@joncinque
Copy link
Contributor Author

Sorry for the size of this! The general pattern for the changes goes:

interface crate has:

  • error.rs
  • generic_token_account.rs
  • instruction.rs
  • native_mint.rs
  • pod.rs
  • serialization.rs
  • state.rs
  • extension/mod.rs
  • extension/mint_close_authority.rs
  • extension/permanent_delegate.rs
  • extension/immutable_owner.rs
  • extension/non_transferable.rs

for each extension:

  • mod.rs (struct definitions)
  • instruction.rs

The program has all of the above modules, but they just re-export everything from the interface. On top of that it has:

  • entrypoint.rs
  • pod_instruction.rs
  • offchain.rs (we could eventually move this down into the interface)
  • onchain.rs (same with this)
  • processor.rs
  • extension/reallocate.rs

And for each extension, on top of re-exporting the structs and instructions, it includes:

  • processor.rs
  • account_info.rs (for confidential transfer extensions)

lib.rs is a bit special, so some functions are split between the program and the interface as makes sense.

I also removed a dependency on spl-token for my future sanity.

This might be a bit of a monster to review, but the changes should be straightforward.

@rustopian
Copy link

This might be a bit of a monster to review, but the changes should be straightforward.

Got it, starting to comb through it.

Copy link

@rustopian rustopian left a comment

Choose a reason for hiding this comment

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

Looks good. Large mechanical code relocation. Notable changes along the way:

  • serde_traits -> serde
  • removal of PodTokenInstruction passages in tests
  • import and import path updates
  • visibility + doc comment tweaks
  • removed test_decimals() in native_mint.rs

A few nits, but most are minor errors in the doc comments which were already present.

std::convert::TryInto,
};

/// Interesting-bearing mint extension instructions

Choose a reason for hiding this comment

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

Suggested change
/// Interesting-bearing mint extension instructions
/// Interest-bearing mint extension instructions

/// 0. `[writable]` The mint to initialize.
///
/// Data expected by this instruction:
/// `crate::extension::interest_bearing::instruction::InitializeInstructionData`

Choose a reason for hiding this comment

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

Suggested change
/// `crate::extension::interest_bearing::instruction::InitializeInstructionData`
/// `crate::extension::interest_bearing_mint::instruction::InitializeInstructionData`

pub decryptable_supply: PodAeCiphertext,
}

/// Data expected by `ConfidentialMintBurnInstruction::RotateSupplyElGamal`

Choose a reason for hiding this comment

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

Suggested change
/// Data expected by `ConfidentialMintBurnInstruction::RotateSupplyElGamal`
/// Data expected by `ConfidentialMintBurnInstruction::RotateSupplyElGamalPubkey`

pub new_supply_elgamal_pubkey: PodElGamalPubkey,
/// The location of the
/// `ProofInstruction::VerifyCiphertextCiphertextEquality` instruction
/// relative to the `RotateSupplyElGamal` instruction in the transaction

Choose a reason for hiding this comment

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

Suggested change
/// relative to the `RotateSupplyElGamal` instruction in the transaction
/// relative to the `RotateSupplyElGamalPubkey` instruction in the
/// transaction

))
}

/// Create a `RotateSupplyElGamal` instruction

Choose a reason for hiding this comment

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

Suggested change
/// Create a `RotateSupplyElGamal` instruction
/// Create a `RotateSupplyElGamalPubkey` instruction

Ok(instructions)
}

/// Create a `UpdateMint` instruction

Choose a reason for hiding this comment

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

Suggested change
/// Create a `UpdateMint` instruction
/// Create an `UpdateDecryptableSupply` instruction

Choose a reason for hiding this comment

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

comment nits

@joncinque
Copy link
Contributor Author

joncinque commented Aug 4, 2025

Ok everything should be addressed, thanks again for the review!

@joncinque joncinque merged commit 690985e into solana-program:main Aug 4, 2025
23 checks passed
@joncinque joncinque deleted the interface branch August 4, 2025 12:06
MEGLDON83

This comment was marked as off-topic.

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