Skip to content

[program] Reorder confidential transfer fee harvest logic to terminate early when possible#749

Merged
samkim-crypto merged 2 commits intosolana-program:mainfrom
samkim-crypto:reorder-logic
Sep 30, 2025
Merged

[program] Reorder confidential transfer fee harvest logic to terminate early when possible#749
samkim-crypto merged 2 commits intosolana-program:mainfrom
samkim-crypto:reorder-logic

Conversation

@samkim-crypto
Copy link
Copy Markdown
Contributor

@samkim-crypto samkim-crypto commented Sep 30, 2025

Problem

Currently, in the confidential transfer logic, the summation of fee ciphertexts happens before some of the basic account checks. If some of the basic account checks fail, then the expensive summation of ciphertexts is rendered unnecessary.

Summary of Changes

I reordered the logic so that some of basic account checks happen before the summation of the ciphertexts.

@samkim-crypto samkim-crypto marked this pull request as ready for review September 30, 2025 03:03
joncinque
joncinque previously approved these changes Sep 30, 2025
Copy link
Copy Markdown
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.

Just a nit, looks good otherwise!

// Checks that the withdraw authority ElGamal public key associated with the
// mint is consistent with what was actually used to generate the zkp.
let confidential_transfer_fee_config =
mint.get_extension_mut::<ConfidentialTransferFeeConfig>()?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: can probably just use mint.get_extension since no changing is required

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point. I guess we never really needed to borrow the mint as mut.

@samkim-crypto samkim-crypto merged commit dca3b17 into solana-program:main Sep 30, 2025
32 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.

2 participants