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

token-2022: Consider allowing overallocated mints #7358

Open
joncinque opened this issue Oct 16, 2024 · 1 comment
Open

token-2022: Consider allowing overallocated mints #7358

joncinque opened this issue Oct 16, 2024 · 1 comment

Comments

@joncinque
Copy link
Contributor

joncinque commented Oct 16, 2024

Problem

Token-2022 is very strict on the size of mint accounts, prohibiting mints that are overallocated:

if ExtensionType::try_calculate_account_len::<Mint>(&extension_types)? != mint_data_len {
return Err(ProgramError::InvalidAccountData);
}

This made sense when the program was first written, since all mint extensions were meant to be initialized before the mint. With the token metadata and token group extensions, however, the program does initialize extensions after the mint. This makes the current strict behavior tedious for users, and always requires multiple allocations.

Proposed Solution

Look through all the code and make sure that there aren't any problems with overallocated mints. For example, we'll still need to make sure that the account doesn't have a length of Multisig::LEN, or that it isn't underallocated.

After that, write some tests exercising the new behavior, then relax the length check.

cc @lorisleiva

@buffalojoec
Copy link
Contributor

My two cents, the Multisig::LEN bit might be where things get tricky, but otherwise I think this change makes sense. It's a pretty annoying devex to be a few bytes overallocated and get an error.

Additionally, we don't allow overallocation for the Token Metadata extension, because it's a variable-length extension and will realloc itself. I think it would be nice to rope that into the relaxed constraints as well, so I could have enough space allocated for Token Metadata and it would just skip the realloc instead of erroring.

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

No branches or pull requests

2 participants