Mint-creation error message uses excessive rent
Description
In process_create_mint, the backpointer PDA account is created to associate the newly created wrapped token mint with the original mint. As the account must be created, rent is required to be supplied for the account. Rent requirement is enforced by determining the space required to store the backpointer and then checking the minimum_balance(..) required via the Rent sysvar.
If the rent requirement is not met, an error message is logged with the amount of rent required.
let backpointer_rent_required = rent.minimum_balance(space);
if wrapped_backpointer_account.lamports() < rent.minimum_balance(backpointer_space) {
msg!(
"Error: wrapped_backpointer_account requires pre-funding of {} lamports",
backpointer_rent_required
);
Err(ProgramError::AccountNotRentExempt)?
}In this instance, the backpointer_rent_required is incorrectly computed as it uses the space variable defined earlier via spl_token_2022::state::Mint::get_packed_len() rather than the correct backpointer_space variable. However, the backpointer_rent_required amount is only used in the error log. The check itself uses the correct amount with backpointer_space.
Impact
The required rent amount present in the error log is higher than actually required by the backpointer account.
Recommendations
Compute the rent for backpointer_rent_required with backpointer_space. Also, this can be reused for the check instead of calling rent.minimum_balance() again.
Remediation
This issue has been acknowledged by Anza, and a fix was implemented in commit 84e30ae8↗.