Skip to content

Add rent awareness to spl-token #66

Closed
@mvines

Description

Current spl-token is completed rent unaware, which leads to a couple problems:

  1. If the Token account is not rent-exempt,
    pub struct Token {
    /// The total supply of tokens.
    pub info: TokenInfo,
    /// Optional token owner, used to mint new tokens. The owner may only
    /// be provided during token creation. If no owner is present then the token
    /// has a fixed supply and no further tokens may be minted.
    pub owner: COption<Pubkey>,
    }
    and if it's rent collected then all the basic information about the token is lost, as well as the ability to mint new tokens or burn existing tokens
  2. If the Account account is not rent-exempt,
    pub struct Account {
    /// The type of token this account holds.
    pub token: Pubkey,
    /// Owner of this account.
    pub owner: Pubkey,
    /// Amount of tokens this account holds.
    pub amount: u64,
    /// If `delegate` is None, `amount` belongs to this account.
    /// If `delegate` is Option<_>, `amount` represents the remaining allowance
    /// of tokens this delegate is authorized to transfer from the `source` account.
    pub delegate: COption<AccountDelegate>,
    }
    and if it's rent collected then the supply field in the Token account is now wrong.

(1) is probably not a big issue, but (2) certainly is.

Possible solution:
a) Require the Token account to be rent-exempt
b) Remove the supply field from Token account so that an Account account that is not rent-exempt cannot poison the supply. This increases the burden on Rpc and other clients, as the token supply must now be calculated by enumerating all the Account accounts for a given token

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions