@@ -664,8 +664,8 @@ fn load_transaction_accounts_simd186<CB: TransactionProcessingCallback>(
664
664
665
665
for ( program_id, instruction) in message. program_instructions_iter ( ) {
666
666
if native_loader:: check_id ( program_id) {
667
- loaded_transaction_accounts . program_indices . push ( vec ! [ ] ) ;
668
- continue ;
667
+ error_metrics . invalid_program_for_execution += 1 ;
668
+ return Err ( TransactionError :: InvalidProgramForExecution ) ;
669
669
}
670
670
671
671
let Some ( program_account) = account_loader. load_account ( program_id) else {
@@ -1144,14 +1144,25 @@ mod tests {
1144
1144
1145
1145
assert_eq ! ( error_metrics. account_not_found. 0 , 0 ) ;
1146
1146
match & loaded_accounts {
1147
- TransactionLoadResult :: Loaded ( loaded_transaction) => {
1147
+ TransactionLoadResult :: Loaded ( loaded_transaction)
1148
+ if !formalize_loaded_transaction_data_size =>
1149
+ {
1150
+ assert_eq ! ( error_metrics. invalid_program_for_execution. 0 , 0 ) ;
1148
1151
assert_eq ! ( loaded_transaction. accounts. len( ) , 3 ) ;
1149
1152
assert_eq ! ( loaded_transaction. accounts[ 0 ] . 1 , accounts[ 0 ] . 1 ) ;
1150
1153
assert_eq ! ( loaded_transaction. program_indices. len( ) , 1 ) ;
1151
1154
assert_eq ! ( loaded_transaction. program_indices[ 0 ] . len( ) , 0 ) ;
1152
1155
}
1153
- TransactionLoadResult :: FeesOnly ( fees_only_tx) => panic ! ( "{}" , fees_only_tx. load_error) ,
1154
- TransactionLoadResult :: NotLoaded ( e) => panic ! ( "{e}" ) ,
1156
+ TransactionLoadResult :: FeesOnly ( fees_only_tx)
1157
+ if formalize_loaded_transaction_data_size =>
1158
+ {
1159
+ assert_eq ! ( error_metrics. invalid_program_for_execution. 0 , 1 ) ;
1160
+ assert_eq ! (
1161
+ fees_only_tx. load_error,
1162
+ TransactionError :: InvalidProgramForExecution
1163
+ ) ;
1164
+ }
1165
+ result => panic ! ( "unexpected result: {:?}" , result) ,
1155
1166
}
1156
1167
}
1157
1168
@@ -1391,17 +1402,28 @@ mod tests {
1391
1402
let keypair = Keypair :: new ( ) ;
1392
1403
let account = AccountSharedData :: new ( 1_000_000 , 0 , & Pubkey :: default ( ) ) ;
1393
1404
1405
+ let mut program_account = AccountSharedData :: default ( ) ;
1406
+ program_account. set_lamports ( 1 ) ;
1407
+ program_account. set_executable ( true ) ;
1408
+ program_account. set_owner ( native_loader:: id ( ) ) ;
1409
+
1394
1410
let instructions = vec ! [ CompiledInstruction :: new( 2 , & ( ) , vec![ 0 ] ) ] ;
1395
1411
let tx = Transaction :: new_with_compiled_instructions (
1396
1412
& [ & keypair] ,
1397
1413
& [ slot_history_id] ,
1398
1414
Hash :: default ( ) ,
1399
- vec ! [ native_loader :: id( ) ] ,
1415
+ vec ! [ bpf_loader :: id( ) ] ,
1400
1416
instructions,
1401
1417
) ;
1402
1418
1403
- let loaded_accounts =
1404
- load_accounts_no_store ( & [ ( keypair. pubkey ( ) , account) ] , tx, Some ( & account_overrides) ) ;
1419
+ let loaded_accounts = load_accounts_no_store (
1420
+ & [
1421
+ ( keypair. pubkey ( ) , account) ,
1422
+ ( bpf_loader:: id ( ) , program_account) ,
1423
+ ] ,
1424
+ tx,
1425
+ Some ( & account_overrides) ,
1426
+ ) ;
1405
1427
match & loaded_accounts {
1406
1428
TransactionLoadResult :: Loaded ( loaded_transaction) => {
1407
1429
assert_eq ! ( loaded_transaction. accounts[ 0 ] . 0 , keypair. pubkey( ) ) ;
@@ -1718,24 +1740,30 @@ mod tests {
1718
1740
& RentCollector :: default ( ) ,
1719
1741
) ;
1720
1742
1721
- let loaded_accounts_data_size = base_account_size as u32 * 2 ;
1722
-
1723
- assert_eq ! (
1724
- result. unwrap( ) ,
1725
- LoadedTransactionAccounts {
1726
- accounts: vec![
1727
- ( key1. pubkey( ) , fee_payer_account) ,
1728
- (
1729
- native_loader:: id( ) ,
1730
- mock_bank. accounts_map[ & native_loader:: id( ) ] . clone( )
1731
- )
1732
- ] ,
1733
- program_indices: vec![ vec![ ] ] ,
1734
- rent: 0 ,
1735
- rent_debits: RentDebits :: default ( ) ,
1736
- loaded_accounts_data_size,
1737
- }
1738
- ) ;
1743
+ if formalize_loaded_transaction_data_size {
1744
+ assert_eq ! (
1745
+ result. unwrap_err( ) ,
1746
+ TransactionError :: InvalidProgramForExecution
1747
+ ) ;
1748
+ } else {
1749
+ let loaded_accounts_data_size = base_account_size as u32 * 2 ;
1750
+ assert_eq ! (
1751
+ result. unwrap( ) ,
1752
+ LoadedTransactionAccounts {
1753
+ accounts: vec![
1754
+ ( key1. pubkey( ) , fee_payer_account) ,
1755
+ (
1756
+ native_loader:: id( ) ,
1757
+ mock_bank. accounts_map[ & native_loader:: id( ) ] . clone( )
1758
+ )
1759
+ ] ,
1760
+ program_indices: vec![ vec![ ] ] ,
1761
+ rent: 0 ,
1762
+ rent_debits: RentDebits :: default ( ) ,
1763
+ loaded_accounts_data_size,
1764
+ }
1765
+ ) ;
1766
+ }
1739
1767
}
1740
1768
1741
1769
#[ test]
0 commit comments