Only examine explicit tx accounts for rent state (#22441)
* Add failing test * Fix: only examine accounts explicitly included in a tx
This commit is contained in:
parent
c45dde6164
commit
3ca16de851
|
@ -15862,6 +15862,51 @@ pub(crate) mod tests {
|
||||||
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 compute_budget = bank.compute_budget.unwrap_or_else(ComputeBudget::new);
|
||||||
|
let transaction_context = TransactionContext::new(
|
||||||
|
loaded_txs[0].0.as_ref().unwrap().accounts.clone(),
|
||||||
|
compute_budget.max_invoke_depth.saturating_add(1),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
bank.get_transaction_account_state_info(&transaction_context, sanitized_tx.message())
|
||||||
|
.len(),
|
||||||
|
num_accounts,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_update_accounts_data_len() {
|
fn test_update_accounts_data_len() {
|
||||||
let (genesis_config, _mint_keypair) = create_genesis_config(100);
|
let (genesis_config, _mint_keypair) = create_genesis_config(100);
|
||||||
|
|
|
@ -19,7 +19,7 @@ impl Bank {
|
||||||
transaction_context: &TransactionContext,
|
transaction_context: &TransactionContext,
|
||||||
message: &SanitizedMessage,
|
message: &SanitizedMessage,
|
||||||
) -> Vec<TransactionAccountStateInfo> {
|
) -> Vec<TransactionAccountStateInfo> {
|
||||||
(0..transaction_context.get_number_of_accounts())
|
(0..message.account_keys_len())
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
let rent_state = if message.is_writable(i) {
|
let rent_state = if message.is_writable(i) {
|
||||||
let account = transaction_context.get_account_at_index(i).borrow();
|
let account = transaction_context.get_account_at_index(i).borrow();
|
||||||
|
|
Loading…
Reference in New Issue