From b77852fe8a1423cd1863eca6336778fb4d2f04f7 Mon Sep 17 00:00:00 2001 From: hanako mumei <81144685+2501babe@users.noreply.github.com> Date: Thu, 26 Sep 2024 04:20:23 -0700 Subject: [PATCH 1/2] runtime: simplify account saver filter --- runtime/src/account_saver.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/runtime/src/account_saver.rs b/runtime/src/account_saver.rs index 941e4934175af3..fa4df885200d83 100644 --- a/runtime/src/account_saver.rs +++ b/runtime/src/account_saver.rs @@ -110,18 +110,19 @@ fn collect_accounts_for_successful_tx<'a, T: SVMMessage>( transaction_ref: Option<&'a SanitizedTransaction>, transaction_accounts: &'a [TransactionAccount], ) { - for (_, (address, account)) in (0..transaction.account_keys().len()) - .zip(transaction_accounts) - .filter(|(i, _)| { - transaction.is_writable(*i) && { - // Accounts that are invoked and also not passed as an instruction - // account to a program don't need to be stored because it's assumed - // to be impossible for a committable transaction to modify an - // invoked account if said account isn't passed to some program. - !transaction.is_invoked(*i) || transaction.is_instruction_account(*i) - } - }) - { + for (i, (address, account)) in transaction_accounts.iter().enumerate() { + if !transaction.is_writable(i) { + continue; + } + + // Accounts that are invoked and also not passed as an instruction + // account to a program don't need to be stored because it's assumed + // to be impossible for a committable transaction to modify an + // invoked account if said account isn't passed to some program. + if transaction.is_invoked(i) && !transaction.is_instruction_account(i) { + continue; + } + collected_accounts.push((address, account)); if let Some(collected_account_transactions) = collected_account_transactions { collected_account_transactions From d39504957ff2f6ec01dac2c716febd529035f831 Mon Sep 17 00:00:00 2001 From: hanako mumei <81144685+2501babe@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:17:49 -0700 Subject: [PATCH 2/2] correctly skip extra loaders --- runtime/src/account_saver.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/account_saver.rs b/runtime/src/account_saver.rs index fa4df885200d83..4d7be1150b89d1 100644 --- a/runtime/src/account_saver.rs +++ b/runtime/src/account_saver.rs @@ -110,7 +110,7 @@ fn collect_accounts_for_successful_tx<'a, T: SVMMessage>( transaction_ref: Option<&'a SanitizedTransaction>, transaction_accounts: &'a [TransactionAccount], ) { - for (i, (address, account)) in transaction_accounts.iter().enumerate() { + for (i, (address, account)) in (0..transaction.account_keys().len()).zip(transaction_accounts) { if !transaction.is_writable(i) { continue; }