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

Allow sub-rent-exempt-minimum transfers to 1nc1nerator (backport #23382) #23404

Merged
merged 2 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion runtime/src/account_rent_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ pub(crate) fn check_rent_state(
) -> Result<()> {
if let Some((pre_rent_state, post_rent_state)) = pre_rent_state.zip(post_rent_state) {
submit_rent_state_metrics(pre_rent_state, post_rent_state);
if !post_rent_state.transition_allowed_from(pre_rent_state) {
if !solana_sdk::incinerator::check_id(address)
&& !post_rent_state.transition_allowed_from(pre_rent_state)
{
debug!("Account {:?} not rent exempt, state {:?}", address, account);
return Err(TransactionError::InvalidRentPayingAccount);
}
Expand Down
22 changes: 22 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17030,6 +17030,28 @@ pub(crate) mod tests {
));
}

// Ensure System transfers of any size can be made to the incinerator
#[test]
fn test_rent_state_incinerator() {
let GenesisConfigInfo {
mut genesis_config,
mint_keypair,
..
} = create_genesis_config_with_leader(sol_to_lamports(100.), &Pubkey::new_unique(), 42);
genesis_config.rent = Rent::default();
let rent_exempt_minimum = genesis_config.rent.minimum_balance(0);

// Activate features, including require_rent_exempt_accounts
activate_all_features(&mut genesis_config);

let bank = Bank::new_for_tests(&genesis_config);

for amount in [rent_exempt_minimum - 1, rent_exempt_minimum] {
bank.transfer(amount, &mint_keypair, &solana_sdk::incinerator::id())
.unwrap();
}
}

#[test]
fn test_rent_state_list_len() {
let GenesisConfigInfo {
Expand Down