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: require all token accounts be rent-exempt and restore total supply field in the mint #328

Closed
mvines opened this issue Aug 26, 2020 · 6 comments · Fixed by #342
Closed
Assignees
Milestone

Comments

@mvines
Copy link
Member

mvines commented Aug 26, 2020

We lost the total supply field in the mint when we realized that if token accounts aren't created rent-exempt, they could just disappear and cause the total supply to be inflated.

However we've failed to discover a compelling reason to permit non-rent-exempt token accounts. Additionally with the new CloseAccount instruction, you can reclaim your SOL from a token account at any time.

Requiring rent exemption also simplifies wallets and other token clients, as they no longer need to be considered about a token account disappearing because it was underfunded, either by accident or maliciously.

@mvines mvines added this to the Token 2 milestone Aug 26, 2020
@CriesofCarrots
Copy link
Contributor

Mints too

@mvines
Copy link
Member Author

mvines commented Aug 27, 2020

and multisigs!

@CriesofCarrots CriesofCarrots self-assigned this Aug 27, 2020
@CriesofCarrots
Copy link
Contributor

One effect of this change is that wrapped SOL accounts cannot hold less wrapped SOL than the account rent-exempt minimum balance. Any concerns about this?

@mvines
Copy link
Member Author

mvines commented Aug 27, 2020

Seems fine to me. Technically not necessary but the consistency is nice. Here's a fun edge case:

  1. Wrap the rent-exempt amount of SOL
  2. Transfer 1 lamport to another token account
  3. Now the source account is no longer rent-exempt.

@mvines
Copy link
Member Author

mvines commented Aug 27, 2020

I think we need a rent_exempt_reserve field, like Stake accounts:
https://github.com/solana-labs/solana/blob/57174cdabed9821b529ed359eab759f7b28f52c4/programs/stake/src/stake_state.rs#L130

@CriesofCarrots
Copy link
Contributor

CriesofCarrots commented Aug 27, 2020

Technically not necessary but the consistency is nice

Allowing non-rent-exempt wrapped SOL accounts requires a bit of special casing, since rent debits will not be reflected in the account's amount field. So yay, glad that seems fine to you.

I think we need a rent_exempt_reserve field, like Stake accounts:

Agreed, we'll need that for wrapped SOL, so Account structs. I think we can leave that out of Mint and Multisig, since there's no way to withdraw lamports from those accounts.

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 a pull request may close this issue.

2 participants