You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a note about assumptions that process_transfer makes about its input code, which should eventually be reported to the authors and Solana stakeholders.
Assumed Non-Overflow based on token supply
The proof for the process_transfer properties exhibits arithmetic overflows caused by the following code:
As the comment above the code states, it is assumed that a token's maximum amount is bound by a u64 field in the mint for the token.
Therefore, if (and only if) the sum of all amount fields in all accounts for a particular token is (at most) this maximum amount, the transfer performed here can safely assume that the addition does not overflow:
The source account must have sufficient funds ( amount <= src.amount())
The total supply limits the amounts as src.amount() + dest.amount() <= mint.supply for the respective mint.
It is checked beforehand that both accounts relate to the same mint.
Therefore the sum is not overflowing.
There is obviously no easy way to guarantee the invariant that \sum_{a \in accounts(mint)} a.amount() <= mint.supply except by tightly controlling the accounts created for the mint.
Assumption that the _.is_native() field is consistent for all native accounts (i.e., relating to a mint which operates the native currency).
Assumption that account_info.lamports is the same as account.amount() for an account when account.is_native()
The code in
This is a note about assumptions that
process_transfermakes about its input code, which should eventually be reported to the authors and Solana stakeholders.Assumed Non-Overflow based on token supply
The proof for the
process_transferproperties exhibits arithmetic overflows caused by the following code:solana-token/p-token/src/processor/shared/transfer.rs
Lines 167 to 169 in d19ea27
As the comment above the code states, it is assumed that a token's maximum amount is bound by a
u64field in themintfor the token.Therefore, if (and only if) the sum of all amount fields in all accounts for a particular token is (at most) this maximum amount, the transfer performed here can safely assume that the addition does not overflow:
amount <= src.amount())src.amount() + dest.amount() <= mint.supplyfor the respectivemint.mint.Therefore the sum is not overflowing.
There is obviously no easy way to guarantee the invariant that
\sum_{a \in accounts(mint)} a.amount() <= mint.supplyexcept by tightly controlling the accounts created for the mint.Assumption that the
_.is_native()field is consistent for all native accounts (i.e., relating to a mint which operates the native currency).Assumption that
account_info.lamportsis the same asaccount.amount()for an account whenaccount.is_native()The code in
solana-token/p-token/src/processor/shared/transfer.rs
Lines 171 to 187 in d19ea27
shows that the
amountand thelamportsfields are maintained in parallel (duplicating the amount) on transfers for all native accounts.