diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 78077638a2..016be46149 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -2105,7 +2105,7 @@ fn main() { println!(" - owner: '{}'", account.owner()); println!(" - executable: {}", account.executable()); println!(" - slot: {}", slot); - println!(" - rent_epoch: {}", account.rent_epoch); + println!(" - rent_epoch: {}", account.rent_epoch()); if !exclude_account_data { println!(" - data: '{}'", bs58::encode(account.data()).into_string()); } diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index bf50c38222..fc5ad69582 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -976,7 +976,7 @@ impl Accounts { _ => panic!("unexpected nonce_rollback condition"), } } - if account.rent_epoch == INITIAL_RENT_EPOCH { + if account.rent_epoch() == INITIAL_RENT_EPOCH { loaded_transaction.rent += rent_collector.collect_from_created_account(&key, account); } diff --git a/runtime/src/message_processor.rs b/runtime/src/message_processor.rs index 8d36c3f272..c18bdfe215 100644 --- a/runtime/src/message_processor.rs +++ b/runtime/src/message_processor.rs @@ -183,7 +183,7 @@ impl PreAccount { } // No one modifies rent_epoch (yet). - let rent_epoch_changed = pre.rent_epoch != post.rent_epoch; + let rent_epoch_changed = pre.rent_epoch() != post.rent_epoch(); if rent_epoch_changed { return Err(InstructionError::RentEpochModified); } diff --git a/runtime/src/rent_collector.rs b/runtime/src/rent_collector.rs index 38e9788dc4..641260bfbd 100644 --- a/runtime/src/rent_collector.rs +++ b/runtime/src/rent_collector.rs @@ -1,6 +1,6 @@ //! calculate and collect rent from Accounts use solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, + account::{AccountSharedData, ReadableAccount, WritableAccount}, clock::Epoch, epoch_schedule::EpochSchedule, genesis_config::GenesisConfig, @@ -62,13 +62,13 @@ impl RentCollector { account: &mut AccountSharedData, ) -> u64 { if account.executable() - || account.rent_epoch > self.epoch + || account.rent_epoch() > self.epoch || sysvar::check_id(account.owner()) || *address == incinerator::id() { 0 } else { - let slots_elapsed: u64 = (account.rent_epoch..=self.epoch) + let slots_elapsed: u64 = (account.rent_epoch()..=self.epoch) .map(|epoch| self.epoch_schedule.get_slots_in_epoch(epoch + 1)) .sum(); @@ -85,15 +85,17 @@ impl RentCollector { if exempt || rent_due != 0 { if account.lamports() > rent_due { - account.rent_epoch = self.epoch - + if exempt { - // Rent isn't collected for the next epoch - // Make sure to check exempt status later in current epoch again - 0 - } else { - // Rent is collected for next epoch - 1 - }; + account.set_rent_epoch( + self.epoch + + if exempt { + // Rent isn't collected for the next epoch + // Make sure to check exempt status later in current epoch again + 0 + } else { + // Rent is collected for next epoch + 1 + }, + ); account.lamports -= rent_due; rent_due } else { @@ -115,7 +117,7 @@ impl RentCollector { account: &mut AccountSharedData, ) -> u64 { // initialize rent_epoch as created at this epoch - account.rent_epoch = self.epoch; + account.set_rent_epoch(self.epoch); self.collect_from_existing_account(address, account) } } diff --git a/sdk/src/keyed_account.rs b/sdk/src/keyed_account.rs index 22933eb0af..19cc48eb1a 100644 --- a/sdk/src/keyed_account.rs +++ b/sdk/src/keyed_account.rs @@ -56,7 +56,7 @@ impl<'a> KeyedAccount<'a> { } pub fn rent_epoch(&self) -> Result { - Ok(self.try_borrow()?.rent_epoch) + Ok(self.try_borrow()?.rent_epoch()) } pub fn try_account_ref(&'a self) -> Result, InstructionError> {