v1.9: Only examine explicit tx accounts for rent state (#22442)
* Add failing test * Fix: only examine accounts explicitly included in a tx
This commit is contained in:
@ -15910,4 +15910,46 @@ pub(crate) mod tests {
|
|||||||
let result = bank.process_transaction(&tx);
|
let result = bank.process_transaction(&tx);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rent_state_list_len() {
|
||||||
|
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();
|
||||||
|
// Activate features, including require_rent_exempt_accounts
|
||||||
|
activate_all_features(&mut genesis_config);
|
||||||
|
|
||||||
|
let bank = Bank::new_for_tests(&genesis_config);
|
||||||
|
let recipient = Pubkey::new_unique();
|
||||||
|
let tx = system_transaction::transfer(
|
||||||
|
&mint_keypair,
|
||||||
|
&recipient,
|
||||||
|
sol_to_lamports(1.),
|
||||||
|
bank.last_blockhash(),
|
||||||
|
);
|
||||||
|
let num_accounts = tx.message().account_keys.len();
|
||||||
|
let sanitized_tx = SanitizedTransaction::try_from_legacy_transaction(tx).unwrap();
|
||||||
|
let mut error_counters = ErrorCounters::default();
|
||||||
|
let loaded_txs = bank.rc.accounts.load_accounts(
|
||||||
|
&bank.ancestors,
|
||||||
|
&[sanitized_tx.clone()],
|
||||||
|
vec![(Ok(()), None)],
|
||||||
|
&bank.blockhash_queue.read().unwrap(),
|
||||||
|
&mut error_counters,
|
||||||
|
&bank.rent_collector,
|
||||||
|
&bank.feature_set,
|
||||||
|
);
|
||||||
|
|
||||||
|
let account_refcells =
|
||||||
|
Bank::accounts_to_refcells(&mut loaded_txs[0].0.as_ref().unwrap().accounts.clone());
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
bank.get_transaction_account_state_info(&account_refcells, sanitized_tx.message())
|
||||||
|
.len(),
|
||||||
|
num_accounts,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ impl Bank {
|
|||||||
) -> Vec<TransactionAccountStateInfo> {
|
) -> Vec<TransactionAccountStateInfo> {
|
||||||
transaction_account_refcells
|
transaction_account_refcells
|
||||||
.iter()
|
.iter()
|
||||||
|
.take(message.account_keys_len())
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, (_pubkey, account_refcell))| {
|
.map(|(i, (_pubkey, account_refcell))| {
|
||||||
let account = account_refcell.borrow();
|
let account = account_refcell.borrow();
|
||||||
|
Reference in New Issue
Block a user