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

feat: multiple tokenPoolPda accounts #1407

Merged
merged 3 commits into from
Dec 24, 2024

Conversation

ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Dec 19, 2024

Issue:

  • the compress token program allows only one tokenPoolPda account to be created per token mint
  • this causes a single shared write-lock for all tokens of a mint that get compressed or decompressed

Solution:

  • enable multiple tokenPoolPda accounts per mint
  • don't allow too many accounts so that users can still decompress from all token pool accounts in one instruction if required
  • as of this pr, the maximum of token pool accounts per mint is 5

Changes:

  • add instruction add_token_pool
  • adapt spl_token_pool_derivation with a bump to derive multiple accounts
  • for spl token compression loop over possible derivations until we find the correct one
  • for spl token decompression, if the balance of the first tokenPoolPda is insufficient to support the decompression amount, loop over remaining accounts starting from index 0 and decompress. Loop until the complete decompression amount has been decompressed.

@SwenSchaeferjohann SwenSchaeferjohann changed the title feat: multipl token pool accounts feat: multiple token pool accounts Dec 19, 2024
@SwenSchaeferjohann SwenSchaeferjohann changed the title feat: multiple token pool accounts feat: multiple tokenPoolPda accounts Dec 19, 2024
@ananas-block ananas-block force-pushed the jorrit/feat-multiple-token-pool-accounts branch from 93ebd77 to 4a44eaa Compare December 23, 2024 06:20
@ananas-block ananas-block force-pushed the jorrit/feat-multiple-token-pool-accounts branch 4 times, most recently from 16e0246 to f80ecb9 Compare December 23, 2024 22:51
@ananas-block ananas-block force-pushed the jorrit/feat-multiple-token-pool-accounts branch from f80ecb9 to fe1308a Compare December 24, 2024 14:14
@ananas-block ananas-block force-pushed the jorrit/feat-multiple-token-pool-accounts branch from f0f8785 to c385d63 Compare December 24, 2024 16:52
@ananas-block ananas-block merged commit 39262ba into main Dec 24, 2024
17 checks passed
@ananas-block ananas-block deleted the jorrit/feat-multiple-token-pool-accounts branch December 24, 2024 17:43
@@ -206,14 +221,20 @@ pub mod sdk {
pub burn_amount: u64,
pub signer_is_delegate: bool,
pub is_token_22: bool,
pub token_pool_bump: u8,
pub additonal_pool_accounts: Vec<Pubkey>,
Copy link
Contributor

Choose a reason for hiding this comment

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

typo, should be additional_pool_accounts

) -> (
HashMap<Pubkey, usize>,
CompressedTokenInstructionDataTransfer,
) {
let mut additonal_accounts = Vec::new();
additonal_accounts.extend_from_slice(accounts);
Copy link
Contributor

Choose a reason for hiding this comment

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

same, typo

SwenSchaeferjohann pushed a commit that referenced this pull request Dec 26, 2024
* feat: multiple token pool accounts

* fix: lint

* chore: unify execute token program instruction with multiple token pool accounts

---------

Co-authored-by: ananas-block <[email protected]>

chore: fix additonal typo (#1426)

fix: invoke_token_program_with_multiple_token_pool_accounts (#1427)
SwenSchaeferjohann pushed a commit that referenced this pull request Dec 26, 2024
* feat: multiple token pool accounts

* fix: lint

* chore: unify execute token program instruction with multiple token pool accounts

---------

Co-authored-by: ananas-block <[email protected]>

chore: fix additonal typo (#1426)

fix: invoke_token_program_with_multiple_token_pool_accounts (#1427)

chore: unify is_valid_token_pool_pda in compress spl tokens & mint to, fix comments in invoke_token_program_with_multiple_token_pool_accounts (#1429)
SwenSchaeferjohann pushed a commit that referenced this pull request Dec 26, 2024
* feat: multiple token pool accounts

* fix: lint

* chore: unify execute token program instruction with multiple token pool accounts

---------

Co-authored-by: ananas-block <[email protected]>
SwenSchaeferjohann pushed a commit that referenced this pull request Dec 26, 2024
* feat: multiple token pool accounts

* fix: lint

* chore: unify execute token program instruction with multiple token pool accounts

---------

Co-authored-by: ananas-block <[email protected]>

chore: fix additonal typo (#1426)

fix: invoke_token_program_with_multiple_token_pool_accounts (#1427)

chore: unify is_valid_token_pool_pda in compress spl tokens & mint to, fix comments in invoke_token_program_with_multiple_token_pool_accounts (#1429)

fix cherry-pick
ananas-block added a commit that referenced this pull request Dec 26, 2024
* feat: multiple `tokenPoolPda` accounts (#1407)

* feat: multiple token pool accounts

* fix: lint

* chore: unify execute token program instruction with multiple token pool accounts

---------

Co-authored-by: ananas-block <[email protected]>

chore: fix additonal typo (#1426)

fix: invoke_token_program_with_multiple_token_pool_accounts (#1427)

chore: unify is_valid_token_pool_pda in compress spl tokens & mint to, fix comments in invoke_token_program_with_multiple_token_pool_accounts (#1429)

* rename is_valid_token_pool_pda, check_spl_token_pool_derviation, _with_bump

---------

Co-authored-by: ananas-block <[email protected]>
Co-authored-by: Swenschaeferjohann <[email protected]>
/// CHECK: (seed constraint) is derived from mint account.
#[account(mut, seeds = [POOL_SEED, mint.key().as_ref()], bump)]
pub token_pool_pda: InterfaceAccount<'info, TokenAccount>,
/// CHECK: in burn_spl_from_pool_pda.
Copy link

Choose a reason for hiding this comment

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

a check is not really being done!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

4 participants