Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[program] Account for the confidential transfer fee extension when re-allocating during configure account #172

Merged
merged 4 commits into from
Feb 8, 2025

Conversation

samkim-crypto
Copy link
Contributor

@samkim-crypto samkim-crypto commented Feb 7, 2025

Problem

When configuring a new confidential transfer account with ConfigureAccountWithRegistry, it does not reallocate space for the confidential transfer with fee even when the mint is extended for transfer fees.

More details in #129.

Summary of Changes

I added logic that checks whether the account is extended for transfer fees. If it does, then the logic accounts for the confidential transfer fee extension when calculating the needed space the account.

A test for configuring accounts with registry when there are fees was missing, so I added it.

Fixes #129.

@samkim-crypto samkim-crypto marked this pull request as ready for review February 7, 2025 13:44
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

It's nice when the change is so simple! Just a couple of comments on the tests

Comment on lines 1252 to 1260
let alice_account_keypair = Keypair::new();
token
.create_auxiliary_token_account_with_extension_space(
&alice_account_keypair,
&alice.pubkey(),
vec![ExtensionType::ConfidentialTransferAccount],
)
.await
.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry if I'm being dense, but what is this for?

Copy link
Contributor Author

@samkim-crypto samkim-crypto Feb 8, 2025

Choose a reason for hiding this comment

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

Sorry, this is a little embarrassing, but I copied the test template from the test function in confidential_transfer.rs and this logic is a relic from there. This logic is actually not needed even in confidential_transfer.rs, so I removed this logic in both test files. Thanks for the catch.

Comment on lines 1321 to 1327
let state = token.get_account_info(&alice_token_account).await.unwrap();
let extension = state
.get_extension::<ConfidentialTransferAccount>()
.unwrap();
assert!(bool::from(&extension.approved));
assert!(bool::from(&extension.allow_confidential_credits));
assert_eq!(extension.elgamal_pubkey, (*elgamal_keypair.pubkey()).into());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also check that the TransferFeeAmount and ConfidentialTransferFeeAmount extensions are present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, done!

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@samkim-crypto samkim-crypto merged commit d14c98b into solana-program:main Feb 8, 2025
19 of 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.

[confidential-transfer] Realloc for registry configs is too small for mints with fees (Neodyme L03)
2 participants