solana-program-library icon indicating copy to clipboard operation
solana-program-library copied to clipboard

[token-2022] zero amount processing - HAL-07

Open samkim-crypto opened this issue 2 years ago • 1 comments

A number of token-2022 program functions allow for zero amount processing:

  • process_transfer
  • process_approve
  • process_mint_to
  • process_burn
  • process_deposit
  • process_withdraw

Unnecessary computations can be avoided if these functions check the parameter before the main logic.

samkim-crypto avatar Sep 01 '22 02:09 samkim-crypto

Be careful, a lot of these are actually by design -- we used to no-op for zero amounts, but that creates false positives for incorrect instructions. For example, if we return earlier, I can successfully "transfer" 0 tokens from your account to mine without a signature. So be sure that all of the ownership checks and all that are still performed.

joncinque avatar Sep 01 '22 10:09 joncinque