Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TieredStorage] rent_epoch() returns 0 for zero-lamport accounts #35344

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions accounts-db/src/tiered_storage/readable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use {
TieredStorageResult,
},
},
solana_sdk::{account::ReadableAccount, pubkey::Pubkey, stake_history::Epoch},
solana_sdk::{
account::ReadableAccount, pubkey::Pubkey, rent_collector::RENT_EXEMPT_RENT_EPOCH,
stake_history::Epoch,
},
std::path::Path,
};

Expand Down Expand Up @@ -73,11 +76,16 @@ impl<'accounts_file, M: TieredAccountMeta> ReadableAccount

/// Returns the epoch that this account will next owe rent by parsing
/// the specified account block. Epoch::MAX will be returned if the account
/// is rent-exempt.
/// is rent-exempt, and 0 for any zero-lamport account.
fn rent_epoch(&self) -> Epoch {
self.meta
.rent_epoch(self.account_block)
.unwrap_or(Epoch::MAX)
.unwrap_or(if self.lamports() != 0 {
brooksprumo marked this conversation as resolved.
Show resolved Hide resolved
RENT_EXEMPT_RENT_EPOCH
} else {
// 0 rent-epoch is used for zero-lamport accounts.
0
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writing a 0 lamport account would currently store the rent_epoch as a 0 u64

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writing a 0 lamport account would currently store the rent_epoch as a 0 u64

It shouldn't be the case because zero lamport account will be None:
https://github.com/jeffwashington/solana/blob/ef6c506ab673c570220f39ba2830cd3ce942a40d/accounts-db/src/account_storage/meta.rs#L81

And, for None case, we will write None for the rent_epoch
https://github.com/jeffwashington/solana/blob/ef6c506ab673c570220f39ba2830cd3ce942a40d/accounts-db/src/tiered_storage/hot.rs#L597


/// Returns the data associated to this account.
Expand Down
Loading