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

runtime: simplify account saver filter #2992

Merged
merged 2 commits into from
Sep 28, 2024
Merged
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
25 changes: 13 additions & 12 deletions runtime/src/account_saver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (0..transaction.account_keys().len()).zip(transaction_accounts) {
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
Expand Down
Loading