@@ -473,25 +473,24 @@ fn load_transaction_accounts<CB: TransactionProcessingCallback>(
473473 }
474474
475475 let program_indices = message
476- . instructions_iter ( )
477- . map ( |instruction| {
476+ . program_instructions_iter ( )
477+ . map ( |( program_id , instruction) | {
478478 let mut account_indices = Vec :: with_capacity ( 2 ) ;
479- let program_index = instruction. program_id_index as usize ;
480- // This command may never return error, because the transaction is sanitized
481- let ( program_id, program_account) = accounts
482- . get ( program_index)
483- . ok_or ( TransactionError :: ProgramAccountNotFound ) ?;
484479 if native_loader:: check_id ( program_id) {
485480 return Ok ( account_indices) ;
486481 }
487482
488- let account_found = account_loader
489- . load_account ( program_id, AccountUsagePattern :: ReadOnlyInvisible )
490- . is_some ( ) ;
491- if !account_found {
483+ let program_index = instruction. program_id_index as usize ;
484+ let program_usage_pattern = AccountUsagePattern :: new ( message, program_index) ;
485+
486+ let Some ( LoadedTransactionAccount {
487+ account : program_account,
488+ ..
489+ } ) = account_loader. load_account ( program_id, program_usage_pattern)
490+ else {
492491 error_metrics. account_not_found += 1 ;
493492 return Err ( TransactionError :: ProgramAccountNotFound ) ;
494- }
493+ } ;
495494
496495 if !account_loader
497496 . feature_set
@@ -502,10 +501,12 @@ fn load_transaction_accounts<CB: TransactionProcessingCallback>(
502501 return Err ( TransactionError :: InvalidProgramForExecution ) ;
503502 }
504503 account_indices. insert ( 0 , program_index as IndexOfAccount ) ;
504+
505505 let owner_id = program_account. owner ( ) ;
506506 if native_loader:: check_id ( owner_id) {
507507 return Ok ( account_indices) ;
508508 }
509+
509510 if !validated_loaders. contains ( owner_id) {
510511 // NOTE we load the program owner as `ReadOnlyInstruction` to bypass the program cache
511512 // since the program cache would incorrectly mark a user-created native-owned account as executable
0 commit comments