Fix stake split rent-exempt adjustment (#13357)
* Add failing tests * Fix stake split * Calculate split rent-exempt-reserve and use * Add comment in rent.rs * Add tests for edge cases when splitting to larger accounts, and reject overflow splits * Reframe InsufficientFunds checks in terms of lamports var * Test hardening review comments
This commit is contained in:
@ -46,6 +46,10 @@ impl Rent {
|
||||
(burned_portion, rent_collected - burned_portion)
|
||||
}
|
||||
/// minimum balance due for a given size Account::data.len()
|
||||
///
|
||||
/// Note: a stripped-down version of this calculation is used in
|
||||
/// calculate_split_rent_exempt_reserve in the stake program. When this function is updated, --
|
||||
/// eg. when making rent variable -- the stake program will need to be refactored
|
||||
pub fn minimum_balance(&self, data_len: usize) -> u64 {
|
||||
let bytes = data_len as u64;
|
||||
(((ACCOUNT_STORAGE_OVERHEAD + bytes) * self.lamports_per_byte_year) as f64
|
||||
|
Reference in New Issue
Block a user