From b27333e52d85647b20ba09fc2fde4b3032fcabb4 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 12 Jan 2022 12:32:19 -0700 Subject: [PATCH] Update docs vis-a-vis prohibition of RentPaying accounts (#22438) * Rent-exempt docs for exchange integrations * Remove discussion of rent-paying accounts from developing docs * Improve verbiage --- .../developing/programming-model/accounts.md | 67 ++----------------- docs/src/integrations/exchange.md | 23 +++++-- 2 files changed, 22 insertions(+), 68 deletions(-) diff --git a/docs/src/developing/programming-model/accounts.md b/docs/src/developing/programming-model/accounts.md index bc05d32f8d..06151ddaf9 100644 --- a/docs/src/developing/programming-model/accounts.md +++ b/docs/src/developing/programming-model/accounts.md @@ -135,72 +135,13 @@ blockchain cluster must actively maintain the data to process any future transac This is different from Bitcoin and Ethereum, where storing accounts doesn't incur any costs. -The rent is debited from an account's balance by the runtime upon the first -access (including the initial account creation) in the current epoch by -transactions or once per an epoch if there are no transactions. The fee is -currently a fixed rate, measured in bytes-times-epochs. The fee may change in -the future. - -For the sake of simple rent calculation, rent is always collected for a single, -full epoch. Rent is not pro-rated, meaning there are neither fees nor refunds -for partial epochs. This means that, on account creation, the first rent -collected isn't for the current partial epoch, but collected up front for the -next full epoch. Subsequent rent collections are for further future epochs. On -the other end, if the balance of an already-rent-collected account drops below -another rent fee mid-epoch, the account will continue to exist through the -current epoch and be purged immediately at the start of the upcoming epoch. - -Accounts can be exempt from paying rent if they maintain a minimum balance. This -rent-exemption is described below. - -### Calculation of rent - -Note: The rent rate can change in the future. - -As of writing, the fixed rent fee is 19.055441478439427 lamports per byte-epoch -on the testnet and mainnet-beta clusters. An [epoch](terminology.md#epoch) is -targeted to be 2 days (For devnet, the rent fee is 0.3608183131797095 lamports -per byte-epoch with its 54m36s-long epoch). - -This value is calculated to target 0.01 SOL per mebibyte-day (exactly matching -to 3.56 SOL per mebibyte-year): - -```text -Rent fee: 19.055441478439427 = 10_000_000 (0.01 SOL) * 365(approx. day in a year) / (1024 * 1024)(1 MiB) / (365.25/2)(epochs in 1 year) -``` - -And rent calculation is done with the `f64` precision and the final result is -truncated to `u64` in lamports. - -The rent calculation includes account metadata (address, owner, lamports, etc) -in the size of an account. Therefore the smallest an account can be for rent -calculations is 128 bytes. - -For example, an account is created with the initial transfer of 10,000 lamports -and no additional data. Rent is immediately debited from it on creation, -resulting in a balance of 7,561 lamports: - -```text -Rent: 2,439 = 19.055441478439427 (rent rate) * 128 bytes (minimum account size) * 1 (epoch) -Account Balance: 7,561 = 10,000 (transfered lamports) - 2,439 (this account's rent fee for an epoch) -``` - -The account balance will be reduced to 5,122 lamports at the next epoch even if -there is no activity: - -```text -Account Balance: 5,122 = 7,561 (current balance) - 2,439 (this account's rent fee for an epoch) -``` - -Accordingly, a minimum-size account will be immediately removed after creation -if the transferred lamports are less than or equal to 2,439. +Currently, all new accounts are required to be rent-exempt. ### Rent exemption -Alternatively, an account can be made entirely exempt from rent collection by -depositing at least 2 years worth of rent. This is checked every time an -account's balance is reduced, and rent is immediately debited once the balance -goes below the minimum amount. +An account is considered rent-exempt if it holds at least 2 years worth of rent. +This is checked every time an account's balance is reduced, and transactions +that would reduce the balance to below the minimum amount will fail. Program executable accounts are required by the runtime to be rent-exempt to avoid being purged. diff --git a/docs/src/integrations/exchange.md b/docs/src/integrations/exchange.md index 1cd7615c00..c7ce9f3bda 100644 --- a/docs/src/integrations/exchange.md +++ b/docs/src/integrations/exchange.md @@ -153,10 +153,9 @@ generate a Solana keypair using any of our [wallet tools](../wallet-guide/cli.md We recommend using a unique deposit account for each of your users. -Solana accounts are charged [rent](developing/programming-model/accounts.md#rent) on creation and once per -epoch, but they can be made rent-exempt if they contain 2-years worth of rent in -SOL. In order to find the minimum rent-exempt balance for your deposit accounts, -query the +Solana accounts must be made rent-exempt by containing 2-years worth of +[rent](developing/programming-model/accounts.md#rent) in SOL. In order to find +the minimum rent-exempt balance for your deposit accounts, query the [`getMinimumBalanceForRentExemption` endpoint](developing/clients/jsonrpc-api.md#getminimumbalanceforrentexemption): ```bash @@ -567,6 +566,20 @@ public class PubkeyValidator } ``` +## Minimum Deposit & Withdrawal Amounts + +Every deposit and withdrawal of SOL must be greater or equal to the minimum +rent-exempt balance for the account at the wallet address (a basic SOL account +holding no data), currently: 0.000890880 SOL + +Similarly, every deposit account must contain at least this balance. + +```bash +curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"getMinimumBalanceForRentExemption","params":[0]}' localhost:8899 + +{"jsonrpc":"2.0","result":890880,"id":1} +``` + ## Supporting the SPL Token Standard [SPL Token](https://spl.solana.com/token) is the standard for wrapped/synthetic @@ -750,4 +763,4 @@ Be sure to test your complete workflow on Solana devnet and testnet [clusters](../clusters.md) before moving to production on mainnet-beta. Devnet is the most open and flexible, and ideal for initial development, while testnet offers more realistic cluster configuration. Both devnet and testnet support a faucet, -run `solana airdrop 1` to obtain some devnet or testnet SOL for developement and testing. +run `solana airdrop 1` to obtain some devnet or testnet SOL for development and testing.