Browse Source

Refactor - Rename `LoadedProgram` to `ProgramCacheEntry` (#880)

LoadedProgramOwner => ProgramCacheEntryOwner.
LoadedProgramType => ProgramCacheEntryType.
LoadedProgram => ProgramCacheEntry.
LoadedProgramStats => ProgramCacheStats.
LoadedProgramMatchCriteria => ProgramCacheMatchCriteria.
LoadedProgramsForTxBatch => ProgramCacheForTxBatch.
Alexander Meißner 1 year ago
parent
commit
e43338f3d6

+ 2 - 2
accounts-db/src/accounts.rs

@@ -816,7 +816,7 @@ mod tests {
     use {
         super::*,
         assert_matches::assert_matches,
-        solana_program_runtime::loaded_programs::LoadedProgramsForTxBatch,
+        solana_program_runtime::loaded_programs::ProgramCacheForTxBatch,
         solana_sdk::{
             account::{AccountSharedData, WritableAccount},
             address_lookup_table::state::LookupTableMeta,
@@ -867,7 +867,7 @@ mod tests {
                 executed_units: 0,
                 accounts_data_len_delta: 0,
             },
-            programs_modified_by_tx: Box::<LoadedProgramsForTxBatch>::default(),
+            programs_modified_by_tx: Box::<ProgramCacheForTxBatch>::default(),
         }
     }
 

+ 4 - 2
ledger-tool/src/program.rs

@@ -12,7 +12,9 @@ use {
     solana_ledger::{blockstore_options::AccessType, use_snapshot_archives_at_startup},
     solana_program_runtime::{
         invoke_context::InvokeContext,
-        loaded_programs::{LoadProgramMetrics, LoadedProgramType, DELAY_VISIBILITY_SLOT_OFFSET},
+        loaded_programs::{
+            LoadProgramMetrics, ProgramCacheEntryType, DELAY_VISIBILITY_SLOT_OFFSET,
+        },
         with_mock_invoke_context,
     },
     solana_rbpf::{
@@ -344,7 +346,7 @@ fn load_program<'a>(
         );
         match result {
             Ok(loaded_program) => match loaded_program.program {
-                LoadedProgramType::Loaded(program) => Ok(program),
+                ProgramCacheEntryType::Loaded(program) => Ok(program),
                 _ => unreachable!(),
             },
             Err(err) => Err(format!("Loading executable failed: {err:?}")),

+ 17 - 16
program-runtime/src/invoke_context.rs

@@ -3,7 +3,8 @@ use {
         compute_budget::ComputeBudget,
         ic_msg,
         loaded_programs::{
-            LoadedProgram, LoadedProgramType, LoadedProgramsForTxBatch, ProgramRuntimeEnvironments,
+            ProgramCacheEntry, ProgramCacheEntryType, ProgramCacheForTxBatch,
+            ProgramRuntimeEnvironments,
         },
         log_collector::LogCollector,
         stable_log,
@@ -165,8 +166,8 @@ pub struct InvokeContext<'a> {
     compute_budget: ComputeBudget,
     current_compute_budget: ComputeBudget,
     compute_meter: RefCell<u64>,
-    pub programs_loaded_for_tx_batch: &'a LoadedProgramsForTxBatch,
-    pub programs_modified_by_tx: &'a mut LoadedProgramsForTxBatch,
+    pub programs_loaded_for_tx_batch: &'a ProgramCacheForTxBatch,
+    pub programs_modified_by_tx: &'a mut ProgramCacheForTxBatch,
     pub feature_set: Arc<FeatureSet>,
     pub timings: ExecuteDetailsTimings,
     pub blockhash: Hash,
@@ -182,8 +183,8 @@ impl<'a> InvokeContext<'a> {
         sysvar_cache: &'a SysvarCache,
         log_collector: Option<Rc<RefCell<LogCollector>>>,
         compute_budget: ComputeBudget,
-        programs_loaded_for_tx_batch: &'a LoadedProgramsForTxBatch,
-        programs_modified_by_tx: &'a mut LoadedProgramsForTxBatch,
+        programs_loaded_for_tx_batch: &'a ProgramCacheForTxBatch,
+        programs_modified_by_tx: &'a mut ProgramCacheForTxBatch,
         feature_set: Arc<FeatureSet>,
         blockhash: Hash,
         lamports_per_signature: u64,
@@ -206,7 +207,7 @@ impl<'a> InvokeContext<'a> {
         }
     }
 
-    pub fn find_program_in_cache(&self, pubkey: &Pubkey) -> Option<Arc<LoadedProgram>> {
+    pub fn find_program_in_cache(&self, pubkey: &Pubkey) -> Option<Arc<ProgramCacheEntry>> {
         // First lookup the cache of the programs modified by the current transaction. If not found, lookup
         // the cache of the cache of the programs that are loaded for the transaction batch.
         self.programs_modified_by_tx
@@ -478,7 +479,7 @@ impl<'a> InvokeContext<'a> {
             .find(&builtin_id)
             .ok_or(InstructionError::UnsupportedProgramId)?;
         let function = match &entry.program {
-            LoadedProgramType::Builtin(program) => program
+            ProgramCacheEntryType::Builtin(program) => program
                 .get_function_registry()
                 .lookup_by_key(ENTRYPOINT_KEY)
                 .map(|(_name, function)| function),
@@ -645,7 +646,7 @@ macro_rules! with_mock_invoke_context {
             std::sync::Arc,
             $crate::{
                 compute_budget::ComputeBudget, invoke_context::InvokeContext,
-                loaded_programs::LoadedProgramsForTxBatch, log_collector::LogCollector,
+                loaded_programs::ProgramCacheForTxBatch, log_collector::LogCollector,
                 sysvar_cache::SysvarCache,
             },
         };
@@ -674,8 +675,8 @@ macro_rules! with_mock_invoke_context {
                 }
             }
         });
-        let programs_loaded_for_tx_batch = LoadedProgramsForTxBatch::default();
-        let mut programs_modified_by_tx = LoadedProgramsForTxBatch::default();
+        let programs_loaded_for_tx_batch = ProgramCacheForTxBatch::default();
+        let mut programs_modified_by_tx = ProgramCacheForTxBatch::default();
         let mut $invoke_context = InvokeContext::new(
             &mut $transaction_context,
             &sysvar_cache,
@@ -741,10 +742,10 @@ pub fn mock_process_instruction<F: FnMut(&mut InvokeContext), G: FnMut(&mut Invo
         false
     };
     with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts);
-    let mut programs_loaded_for_tx_batch = LoadedProgramsForTxBatch::default();
+    let mut programs_loaded_for_tx_batch = ProgramCacheForTxBatch::default();
     programs_loaded_for_tx_batch.replenish(
         *loader_id,
-        Arc::new(LoadedProgram::new_builtin(0, 0, builtin_function)),
+        Arc::new(ProgramCacheEntry::new_builtin(0, 0, builtin_function)),
     );
     invoke_context.programs_loaded_for_tx_batch = &programs_loaded_for_tx_batch;
     pre_adjustments(&mut invoke_context);
@@ -998,10 +999,10 @@ mod tests {
             })
             .collect::<Vec<_>>();
         with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts);
-        let mut programs_loaded_for_tx_batch = LoadedProgramsForTxBatch::default();
+        let mut programs_loaded_for_tx_batch = ProgramCacheForTxBatch::default();
         programs_loaded_for_tx_batch.replenish(
             callee_program_id,
-            Arc::new(LoadedProgram::new_builtin(0, 1, MockBuiltin::vm)),
+            Arc::new(ProgramCacheEntry::new_builtin(0, 1, MockBuiltin::vm)),
         );
         invoke_context.programs_loaded_for_tx_batch = &programs_loaded_for_tx_batch;
 
@@ -1147,10 +1148,10 @@ mod tests {
             },
         ];
         with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts);
-        let mut programs_loaded_for_tx_batch = LoadedProgramsForTxBatch::default();
+        let mut programs_loaded_for_tx_batch = ProgramCacheForTxBatch::default();
         programs_loaded_for_tx_batch.replenish(
             program_key,
-            Arc::new(LoadedProgram::new_builtin(0, 0, MockBuiltin::vm)),
+            Arc::new(ProgramCacheEntry::new_builtin(0, 0, MockBuiltin::vm)),
         );
         invoke_context.programs_loaded_for_tx_batch = &programs_loaded_for_tx_batch;
 

File diff suppressed because it is too large
+ 205 - 204
program-runtime/src/loaded_programs.rs


+ 3 - 3
program-test/src/lib.rs

@@ -17,7 +17,7 @@ use {
     solana_bpf_loader_program::serialization::serialize_parameters,
     solana_program_runtime::{
         compute_budget::ComputeBudget, ic_msg, invoke_context::BuiltinFunctionWithContext,
-        loaded_programs::LoadedProgram, stable_log, timings::ExecuteTimings,
+        loaded_programs::ProgramCacheEntry, stable_log, timings::ExecuteTimings,
     },
     solana_runtime::{
         accounts_background_service::{AbsRequestSender, SnapshotRequestKind},
@@ -463,7 +463,7 @@ pub fn read_file<P: AsRef<Path>>(path: P) -> Vec<u8> {
 
 pub struct ProgramTest {
     accounts: Vec<(Pubkey, AccountSharedData)>,
-    builtin_programs: Vec<(Pubkey, &'static str, LoadedProgram)>,
+    builtin_programs: Vec<(Pubkey, &'static str, ProgramCacheEntry)>,
     compute_max_units: Option<u64>,
     prefer_bpf: bool,
     deactivate_feature_set: HashSet<Pubkey>,
@@ -728,7 +728,7 @@ impl ProgramTest {
         self.builtin_programs.push((
             program_id,
             program_name,
-            LoadedProgram::new_builtin(0, program_name.len(), builtin_function),
+            ProgramCacheEntry::new_builtin(0, program_name.len(), builtin_function),
         ));
     }
 

+ 17 - 17
programs/bpf_loader/src/lib.rs

@@ -10,7 +10,7 @@ use {
         ic_logger_msg, ic_msg,
         invoke_context::{BpfAllocator, InvokeContext, SerializedAccountMetadata, SyscallContext},
         loaded_programs::{
-            LoadProgramMetrics, LoadedProgram, LoadedProgramOwner, LoadedProgramType,
+            LoadProgramMetrics, ProgramCacheEntry, ProgramCacheEntryOwner, ProgramCacheEntryType,
             DELAY_VISIBILITY_SLOT_OFFSET,
         },
         log_collector::LogCollector,
@@ -69,12 +69,12 @@ pub fn load_program_from_bytes(
     deployment_slot: Slot,
     program_runtime_environment: Arc<BuiltinProgram<InvokeContext<'static>>>,
     reloading: bool,
-) -> Result<LoadedProgram, InstructionError> {
+) -> Result<ProgramCacheEntry, InstructionError> {
     let effective_slot = deployment_slot.saturating_add(DELAY_VISIBILITY_SLOT_OFFSET);
     let loaded_program = if reloading {
         // Safety: this is safe because the program is being reloaded in the cache.
         unsafe {
-            LoadedProgram::reload(
+            ProgramCacheEntry::reload(
                 loader_key,
                 program_runtime_environment,
                 deployment_slot,
@@ -85,7 +85,7 @@ pub fn load_program_from_bytes(
             )
         }
     } else {
-        LoadedProgram::new(
+        ProgramCacheEntry::new(
             loader_key,
             program_runtime_environment,
             deployment_slot,
@@ -451,13 +451,13 @@ pub fn process_instruction_inner(
 
     executor.ix_usage_counter.fetch_add(1, Ordering::Relaxed);
     match &executor.program {
-        LoadedProgramType::FailedVerification(_)
-        | LoadedProgramType::Closed
-        | LoadedProgramType::DelayVisibility => {
+        ProgramCacheEntryType::FailedVerification(_)
+        | ProgramCacheEntryType::Closed
+        | ProgramCacheEntryType::DelayVisibility => {
             ic_logger_msg!(log_collector, "Program is not deployed");
             Err(Box::new(InstructionError::InvalidAccountData) as Box<dyn std::error::Error>)
         }
-        LoadedProgramType::Loaded(executable) => execute(executable, invoke_context),
+        ProgramCacheEntryType::Loaded(executable) => execute(executable, invoke_context),
         _ => Err(Box::new(InstructionError::IncorrectProgramId) as Box<dyn std::error::Error>),
     }
     .map(|_| 0)
@@ -1111,10 +1111,10 @@ fn process_loader_upgradeable_instruction(
                             let clock = invoke_context.get_sysvar_cache().get_clock()?;
                             invoke_context.programs_modified_by_tx.replenish(
                                 program_key,
-                                Arc::new(LoadedProgram::new_tombstone(
+                                Arc::new(ProgramCacheEntry::new_tombstone(
                                     clock.slot,
-                                    LoadedProgramOwner::LoaderV3,
-                                    LoadedProgramType::Closed,
+                                    ProgramCacheEntryOwner::LoaderV3,
+                                    ProgramCacheEntryType::Closed,
                                 )),
                             );
                         }
@@ -3760,9 +3760,9 @@ mod tests {
         with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts);
         let program_id = Pubkey::new_unique();
         let env = Arc::new(BuiltinProgram::new_mock());
-        let program = LoadedProgram {
-            program: LoadedProgramType::Unloaded(env),
-            account_owner: LoadedProgramOwner::LoaderV2,
+        let program = ProgramCacheEntry {
+            program: ProgramCacheEntryType::Unloaded(env),
+            account_owner: ProgramCacheEntryOwner::LoaderV2,
             account_size: 0,
             deployment_slot: 0,
             effective_slot: 0,
@@ -3804,9 +3804,9 @@ mod tests {
         with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts);
         let program_id = Pubkey::new_unique();
         let env = Arc::new(BuiltinProgram::new_mock());
-        let program = LoadedProgram {
-            program: LoadedProgramType::Unloaded(env),
-            account_owner: LoadedProgramOwner::LoaderV2,
+        let program = ProgramCacheEntry {
+            program: ProgramCacheEntryType::Unloaded(env),
+            account_owner: ProgramCacheEntryOwner::LoaderV2,
             account_size: 0,
             deployment_slot: 0,
             effective_slot: 0,

+ 8 - 7
programs/loader-v4/src/lib.rs

@@ -5,7 +5,8 @@ use {
         ic_logger_msg,
         invoke_context::InvokeContext,
         loaded_programs::{
-            LoadProgramMetrics, LoadedProgram, LoadedProgramType, DELAY_VISIBILITY_SLOT_OFFSET,
+            LoadProgramMetrics, ProgramCacheEntry, ProgramCacheEntryType,
+            DELAY_VISIBILITY_SLOT_OFFSET,
         },
         log_collector::LogCollector,
         stable_log,
@@ -417,7 +418,7 @@ pub fn process_instruction_deploy(
         program_id: buffer.get_key().to_string(),
         ..LoadProgramMetrics::default()
     };
-    let executor = LoadedProgram::new(
+    let executor = ProgramCacheEntry::new(
         &loader_v4::id(),
         environments.program_runtime_v2.clone(),
         deployment_slot,
@@ -602,13 +603,13 @@ pub fn process_instruction_inner(
             .ix_usage_counter
             .fetch_add(1, Ordering::Relaxed);
         match &loaded_program.program {
-            LoadedProgramType::FailedVerification(_)
-            | LoadedProgramType::Closed
-            | LoadedProgramType::DelayVisibility => {
+            ProgramCacheEntryType::FailedVerification(_)
+            | ProgramCacheEntryType::Closed
+            | ProgramCacheEntryType::DelayVisibility => {
                 ic_logger_msg!(log_collector, "Program is not deployed");
                 Err(Box::new(InstructionError::InvalidAccountData) as Box<dyn std::error::Error>)
             }
-            LoadedProgramType::Loaded(executable) => execute(invoke_context, executable),
+            ProgramCacheEntryType::Loaded(executable) => execute(invoke_context, executable),
             _ => Err(Box::new(InstructionError::IncorrectProgramId) as Box<dyn std::error::Error>),
         }
     }
@@ -653,7 +654,7 @@ mod tests {
                 if let Some(programdata) =
                     account.data().get(LoaderV4State::program_data_offset()..)
                 {
-                    if let Ok(loaded_program) = LoadedProgram::new(
+                    if let Ok(loaded_program) = ProgramCacheEntry::new(
                         &loader_v4::id(),
                         invoke_context
                             .programs_modified_by_tx

+ 2 - 2
programs/sbf/tests/programs.rs

@@ -4281,7 +4281,7 @@ fn test_cpi_deprecated_loader_realloc() {
 #[test]
 #[cfg(feature = "sbf_rust")]
 fn test_cpi_change_account_data_memory_allocation() {
-    use solana_program_runtime::{declare_process_instruction, loaded_programs::LoadedProgram};
+    use solana_program_runtime::{declare_process_instruction, loaded_programs::ProgramCacheEntry};
 
     solana_logger::setup();
 
@@ -4331,7 +4331,7 @@ fn test_cpi_change_account_data_memory_allocation() {
         &bank,
         builtin_program_id,
         "test_cpi_change_account_data_memory_allocation_builtin",
-        LoadedProgram::new_builtin(0, 42, MockBuiltin::vm),
+        ProgramCacheEntry::new_builtin(0, 42, MockBuiltin::vm),
     );
 
     let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests();

+ 16 - 18
runtime/src/bank.rs

@@ -99,8 +99,8 @@ use {
         compute_budget_processor::process_compute_budget_instructions,
         invoke_context::BuiltinFunctionWithContext,
         loaded_programs::{
-            LoadedProgram, LoadedProgramMatchCriteria, LoadedProgramOwner, LoadedProgramType,
-            ProgramCache,
+            ProgramCache, ProgramCacheEntry, ProgramCacheEntryOwner, ProgramCacheEntryType,
+            ProgramCacheMatchCriteria,
         },
         timings::{ExecuteTimingType, ExecuteTimings},
     },
@@ -202,9 +202,7 @@ use {
     solana_accounts_db::accounts_db::{
         ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING,
     },
-    solana_program_runtime::{
-        loaded_programs::LoadedProgramsForTxBatch, sysvar_cache::SysvarCache,
-    },
+    solana_program_runtime::{loaded_programs::ProgramCacheForTxBatch, sysvar_cache::SysvarCache},
 };
 
 /// params to `verify_accounts_hash`
@@ -5212,7 +5210,7 @@ impl Bank {
                         self,
                         builtin.program_id,
                         builtin.name,
-                        LoadedProgram::new_builtin(0, builtin.name.len(), builtin.entrypoint),
+                        ProgramCacheEntry::new_builtin(0, builtin.name.len(), builtin.entrypoint),
                     );
                 }
             }
@@ -6302,7 +6300,7 @@ impl Bank {
             self,
             program_id,
             "mockup",
-            LoadedProgram::new_builtin(self.slot, 0, builtin_function),
+            ProgramCacheEntry::new_builtin(self.slot, 0, builtin_function),
         );
     }
 
@@ -6315,10 +6313,10 @@ impl Bank {
             self,
             program_id,
             name,
-            LoadedProgram::new_tombstone(
+            ProgramCacheEntry::new_tombstone(
                 self.slot,
-                LoadedProgramOwner::NativeLoader,
-                LoadedProgramType::Closed,
+                ProgramCacheEntryOwner::NativeLoader,
+                ProgramCacheEntryType::Closed,
             ),
         );
         debug!("Removed program {}", program_id);
@@ -6579,7 +6577,7 @@ impl Bank {
                         self,
                         builtin.program_id,
                         builtin.name,
-                        LoadedProgram::new_builtin(
+                        ProgramCacheEntry::new_builtin(
                             self.feature_set.activated_slot(&feature_id).unwrap_or(0),
                             builtin.name.len(),
                             builtin.entrypoint,
@@ -6754,7 +6752,7 @@ impl Bank {
         pubkey: &Pubkey,
         reload: bool,
         effective_epoch: Epoch,
-    ) -> Option<Arc<LoadedProgram>> {
+    ) -> Option<Arc<ProgramCacheEntry>> {
         self.transaction_processor
             .load_program_with_pubkey(self, pubkey, reload, effective_epoch)
     }
@@ -6793,15 +6791,15 @@ impl TransactionProcessingCallback for Bank {
         self.feature_set.clone()
     }
 
-    fn get_program_match_criteria(&self, program: &Pubkey) -> LoadedProgramMatchCriteria {
+    fn get_program_match_criteria(&self, program: &Pubkey) -> ProgramCacheMatchCriteria {
         if self.check_program_modification_slot {
             self.transaction_processor
                 .program_modification_slot(self, program)
-                .map_or(LoadedProgramMatchCriteria::Tombstone, |slot| {
-                    LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(slot)
+                .map_or(ProgramCacheMatchCriteria::Tombstone, |slot| {
+                    ProgramCacheMatchCriteria::DeployedOnOrAfterSlot(slot)
                 })
         } else {
-            LoadedProgramMatchCriteria::NoCriteria
+            ProgramCacheMatchCriteria::NoCriteria
         }
     }
 
@@ -7039,8 +7037,8 @@ impl Bank {
         self.update_accounts_hash(CalcAccountsHashDataSource::IndexForTests, false, false)
     }
 
-    pub fn new_program_cache_for_tx_batch_for_slot(&self, slot: Slot) -> LoadedProgramsForTxBatch {
-        LoadedProgramsForTxBatch::new_from_cache(
+    pub fn new_program_cache_for_tx_batch_for_slot(&self, slot: Slot) -> ProgramCacheForTxBatch {
+        ProgramCacheForTxBatch::new_from_cache(
             slot,
             self.epoch_schedule.get_epoch(slot),
             &self.transaction_processor.program_cache.read().unwrap(),

+ 8 - 8
runtime/src/bank/builtins/core_bpf_migration/mod.rs

@@ -7,7 +7,7 @@ use {
     crate::bank::Bank,
     error::CoreBpfMigrationError,
     solana_program_runtime::{
-        invoke_context::InvokeContext, loaded_programs::LoadedProgramsForTxBatch,
+        invoke_context::InvokeContext, loaded_programs::ProgramCacheForTxBatch,
         sysvar_cache::SysvarCache,
     },
     solana_sdk::{
@@ -154,14 +154,14 @@ impl Bank {
             .get(programdata_data_offset..)
             .ok_or(InstructionError::InvalidAccountData)?;
 
-        // Set up the two `LoadedProgramsForTxBatch` instances, as if
+        // Set up the two `ProgramCacheForTxBatch` instances, as if
         // processing a new transaction batch.
-        let programs_loaded = LoadedProgramsForTxBatch::new_from_cache(
+        let programs_loaded = ProgramCacheForTxBatch::new_from_cache(
             self.slot,
             self.epoch,
             &self.transaction_processor.program_cache.read().unwrap(),
         );
-        let mut programs_modified = LoadedProgramsForTxBatch::new(
+        let mut programs_modified = ProgramCacheForTxBatch::new(
             self.slot,
             programs_loaded.environments.clone(),
             programs_loaded.upcoming_environments.clone(),
@@ -169,7 +169,7 @@ impl Bank {
         );
 
         // Configure a dummy `InvokeContext` from the runtime's current
-        // environment, as well as the two `LoadedProgramsForTxBatch`
+        // environment, as well as the two `ProgramCacheForTxBatch`
         // instances configured above, then invoke the loader.
         {
             let compute_budget = self.runtime_config.compute_budget.unwrap_or_default();
@@ -300,7 +300,7 @@ mod tests {
         super::*,
         crate::bank::tests::create_simple_test_bank,
         assert_matches::assert_matches,
-        solana_program_runtime::loaded_programs::{LoadedProgram, LoadedProgramType},
+        solana_program_runtime::loaded_programs::{ProgramCacheEntry, ProgramCacheEntryType},
         solana_sdk::{
             account_utils::StateMut,
             bpf_loader_upgradeable::{self, get_program_data_address},
@@ -454,7 +454,7 @@ mod tests {
             assert_eq!(target_entry.latest_access_slot.load(Relaxed), bank.slot());
 
             // The target program entry should now be a BPF program.
-            assert_matches!(target_entry.program, LoadedProgramType::Loaded(..));
+            assert_matches!(target_entry.program, ProgramCacheEntryType::Loaded(..));
         }
     }
 
@@ -481,7 +481,7 @@ mod tests {
                 &bank,
                 builtin_id,
                 builtin_name.as_str(),
-                LoadedProgram::default(),
+                ProgramCacheEntry::default(),
             );
             account
         };

+ 2 - 2
runtime/src/bank/metrics.rs

@@ -1,6 +1,6 @@
 use {
     crate::bank::Bank,
-    solana_program_runtime::loaded_programs::LoadedProgramStats,
+    solana_program_runtime::loaded_programs::ProgramCacheStats,
     solana_sdk::clock::{Epoch, Slot},
     std::sync::atomic::{
         AtomicU64,
@@ -205,7 +205,7 @@ pub(crate) fn report_partitioned_reward_metrics(bank: &Bank, timings: RewardsSto
 }
 
 /// Logs the measurement values
-pub(crate) fn report_loaded_programs_stats(stats: &LoadedProgramStats, slot: Slot) {
+pub(crate) fn report_loaded_programs_stats(stats: &ProgramCacheStats, slot: Slot) {
     let hits = stats.hits.load(Ordering::Relaxed);
     let misses = stats.misses.load(Ordering::Relaxed);
     let evictions: u64 = stats.evictions.values().sum();

+ 10 - 10
runtime/src/bank/tests.rs

@@ -39,7 +39,7 @@ use {
         compute_budget::ComputeBudget,
         compute_budget_processor::{self, MAX_COMPUTE_UNIT_LIMIT},
         declare_process_instruction,
-        loaded_programs::{LoadedProgram, LoadedProgramType, LoadedProgramsForTxBatch},
+        loaded_programs::{ProgramCacheEntry, ProgramCacheEntryType, ProgramCacheForTxBatch},
         prioritization_fee::{PrioritizationFeeDetails, PrioritizationFeeType},
         timings::ExecuteTimings,
     },
@@ -242,7 +242,7 @@ fn new_execution_result(
             executed_units: 0,
             accounts_data_len_delta: 0,
         },
-        programs_modified_by_tx: Box::<LoadedProgramsForTxBatch>::default(),
+        programs_modified_by_tx: Box::<ProgramCacheForTxBatch>::default(),
     }
 }
 
@@ -4709,13 +4709,13 @@ fn test_add_instruction_processor_for_existing_unrelated_accounts() {
             &bank,
             vote_id,
             "mock_program1",
-            LoadedProgram::new_builtin(0, 0, MockBuiltin::vm),
+            ProgramCacheEntry::new_builtin(0, 0, MockBuiltin::vm),
         );
         bank.transaction_processor.add_builtin(
             &bank,
             stake_id,
             "mock_program2",
-            LoadedProgram::new_builtin(0, 0, MockBuiltin::vm),
+            ProgramCacheEntry::new_builtin(0, 0, MockBuiltin::vm),
         );
         {
             let stakes = bank.stakes_cache.stakes();
@@ -6305,7 +6305,7 @@ fn test_fuzz_instructions() {
                 &bank,
                 key,
                 name.as_str(),
-                LoadedProgram::new_builtin(0, 0, MockBuiltin::vm),
+                ProgramCacheEntry::new_builtin(0, 0, MockBuiltin::vm),
             );
             (key, name.as_bytes().to_vec())
         })
@@ -7106,7 +7106,7 @@ fn test_bank_load_program() {
     bank.store_account_and_update_capitalization(&key1, &program_account);
     bank.store_account_and_update_capitalization(&programdata_key, &programdata_account);
     let program = bank.load_program(&key1, false, bank.epoch()).unwrap();
-    assert_matches!(program.program, LoadedProgramType::Loaded(_));
+    assert_matches!(program.program, ProgramCacheEntryType::Loaded(_));
     assert_eq!(
         program.account_size,
         program_account.data().len() + programdata_account.data().len()
@@ -7220,7 +7220,7 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() {
         assert_eq!(slot_versions[0].effective_slot, 0);
         assert!(matches!(
             slot_versions[0].program,
-            LoadedProgramType::Closed,
+            ProgramCacheEntryType::Closed,
         ));
     }
 
@@ -7244,7 +7244,7 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() {
         assert_eq!(slot_versions[0].effective_slot, 0);
         assert!(matches!(
             slot_versions[0].program,
-            LoadedProgramType::Closed,
+            ProgramCacheEntryType::Closed,
         ));
     }
 
@@ -7346,13 +7346,13 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() {
         assert_eq!(slot_versions[0].effective_slot, 0);
         assert!(matches!(
             slot_versions[0].program,
-            LoadedProgramType::Closed,
+            ProgramCacheEntryType::Closed,
         ));
         assert_eq!(slot_versions[1].deployment_slot, 0);
         assert_eq!(slot_versions[1].effective_slot, 1);
         assert!(matches!(
             slot_versions[1].program,
-            LoadedProgramType::Loaded(_),
+            ProgramCacheEntryType::Loaded(_),
         ));
     }
 

+ 3 - 3
svm/doc/spec.md

@@ -229,12 +229,12 @@ Steps of `load_and_execute_sanitized_transactions`
    5. Make two local variables that will be used as output parameters
       of `MessageProcessor::process_message`. One will contain the
       number of executed units (the number of compute unites consumed
-      in the transaction). Another is a container of `LoadedProgramsForTxBatch`.
+      in the transaction). Another is a container of `ProgramCacheForTxBatch`.
       The latter is initialized with the slot, and
       the clone of environments of `programs_loaded_for_tx_batch`
-         - `programs_loaded_for_tx_batch` contains a reference to all the `LoadedProgram`s
+         - `programs_loaded_for_tx_batch` contains a reference to all the `ProgramCacheEntry`s
             necessary for the transaction. It maintains an `Arc` to the programs in the global
-            `LoadedPrograms` data structure.
+            `ProgramCacheEntrys` data structure.
       6. Call `MessageProcessor::process_message` to execute the
       transaction. `MessageProcessor` is contained in
       solana-program-runtime crate. The result of processing message

+ 23 - 23
svm/src/account_loader.rs

@@ -8,7 +8,7 @@ use {
     log::warn,
     solana_program_runtime::{
         compute_budget_processor::process_compute_budget_instructions,
-        loaded_programs::{LoadedProgram, LoadedProgramsForTxBatch},
+        loaded_programs::{ProgramCacheEntry, ProgramCacheForTxBatch},
     },
     solana_sdk::{
         account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
@@ -114,7 +114,7 @@ pub(crate) fn load_accounts<CB: TransactionProcessingCallback>(
     error_counters: &mut TransactionErrorMetrics,
     fee_structure: &FeeStructure,
     account_overrides: Option<&AccountOverrides>,
-    loaded_programs: &LoadedProgramsForTxBatch,
+    loaded_programs: &ProgramCacheForTxBatch,
 ) -> Vec<TransactionLoadResult> {
     let feature_set = callbacks.get_feature_set();
     txs.iter()
@@ -180,7 +180,7 @@ fn load_transaction_accounts<CB: TransactionProcessingCallback>(
     fee: u64,
     error_counters: &mut TransactionErrorMetrics,
     account_overrides: Option<&AccountOverrides>,
-    loaded_programs: &LoadedProgramsForTxBatch,
+    loaded_programs: &ProgramCacheForTxBatch,
 ) -> Result<LoadedTransaction> {
     let feature_set = callbacks.get_feature_set();
 
@@ -408,7 +408,7 @@ fn get_requested_loaded_accounts_data_size_limit(
     )
 }
 
-fn account_shared_data_from_program(loaded_program: &LoadedProgram) -> AccountSharedData {
+fn account_shared_data_from_program(loaded_program: &ProgramCacheEntry) -> AccountSharedData {
     // It's an executable program account. The program is already loaded in the cache.
     // So the account data is not needed. Return a dummy AccountSharedData with meta
     // information.
@@ -461,7 +461,7 @@ mod tests {
         solana_program_runtime::{
             compute_budget::ComputeBudget,
             compute_budget_processor,
-            loaded_programs::{LoadedProgram, LoadedProgramsForTxBatch},
+            loaded_programs::{ProgramCacheEntry, ProgramCacheForTxBatch},
             prioritization_fee::{PrioritizationFeeDetails, PrioritizationFeeType},
         },
         solana_sdk::{
@@ -550,7 +550,7 @@ mod tests {
             error_counters,
             fee_structure,
             None,
-            &LoadedProgramsForTxBatch::default(),
+            &ProgramCacheForTxBatch::default(),
         )
     }
 
@@ -1038,7 +1038,7 @@ mod tests {
             &mut error_counters,
             &FeeStructure::default(),
             account_overrides,
-            &LoadedProgramsForTxBatch::default(),
+            &ProgramCacheForTxBatch::default(),
         )
     }
 
@@ -1429,7 +1429,7 @@ mod tests {
         let sanitized_message = new_unchecked_sanitized_message(message);
         let mock_bank = TestCallbacks::default();
         let mut error_counter = TransactionErrorMetrics::default();
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -1472,7 +1472,7 @@ mod tests {
         mock_bank.accounts_map.insert(key1.pubkey(), account_data);
 
         let mut error_counter = TransactionErrorMetrics::default();
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -1536,8 +1536,8 @@ mod tests {
         mock_bank.accounts_map.insert(key1.pubkey(), account_data);
 
         let mut error_counter = TransactionErrorMetrics::default();
-        let mut loaded_programs = LoadedProgramsForTxBatch::default();
-        loaded_programs.replenish(key2.pubkey(), Arc::new(LoadedProgram::default()));
+        let mut loaded_programs = ProgramCacheForTxBatch::default();
+        loaded_programs.replenish(key2.pubkey(), Arc::new(ProgramCacheEntry::default()));
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -1579,7 +1579,7 @@ mod tests {
         mock_bank.accounts_map.insert(key1.pubkey(), account_data);
 
         let mut error_counter = TransactionErrorMetrics::default();
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -1621,7 +1621,7 @@ mod tests {
         mock_bank.accounts_map.insert(key1.pubkey(), account_data);
 
         let mut error_counter = TransactionErrorMetrics::default();
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -1670,7 +1670,7 @@ mod tests {
         account_data.set_lamports(200);
         mock_bank.accounts_map.insert(key2.pubkey(), account_data);
         let mut error_counter = TransactionErrorMetrics::default();
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -1737,7 +1737,7 @@ mod tests {
         account_data.set_lamports(200);
         mock_bank.accounts_map.insert(key2.pubkey(), account_data);
         let mut error_counter = TransactionErrorMetrics::default();
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -1793,7 +1793,7 @@ mod tests {
             .accounts_map
             .insert(key3.pubkey(), AccountSharedData::default());
         let mut error_counter = TransactionErrorMetrics::default();
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -1854,7 +1854,7 @@ mod tests {
         mock_bank.accounts_map.insert(key3.pubkey(), account_data);
 
         let mut error_counter = TransactionErrorMetrics::default();
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -1941,7 +1941,7 @@ mod tests {
         mock_bank.accounts_map.insert(key3.pubkey(), account_data);
 
         let mut error_counter = TransactionErrorMetrics::default();
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -2025,7 +2025,7 @@ mod tests {
             &mut error_counters,
             &FeeStructure::default(),
             None,
-            &LoadedProgramsForTxBatch::default(),
+            &ProgramCacheForTxBatch::default(),
         );
 
         let compute_budget = ComputeBudget::new(u64::from(
@@ -2091,7 +2091,7 @@ mod tests {
         mock_bank.accounts_map.insert(key3.pubkey(), account_data);
 
         let mut error_counter = TransactionErrorMetrics::default();
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
 
         let sanitized_transaction = SanitizedTransaction::new_for_tests(
             sanitized_message,
@@ -2181,7 +2181,7 @@ mod tests {
             &mut TransactionErrorMetrics::default(),
             &fee_structure,
             None,
-            &LoadedProgramsForTxBatch::default(),
+            &ProgramCacheForTxBatch::default(),
         );
 
         assert_eq!(
@@ -2199,7 +2199,7 @@ mod tests {
             &mut TransactionErrorMetrics::default(),
             &fee_structure,
             None,
-            &LoadedProgramsForTxBatch::default(),
+            &ProgramCacheForTxBatch::default(),
         );
 
         assert_eq!(result, vec![(Err(TransactionError::AccountNotFound), None)]);
@@ -2217,7 +2217,7 @@ mod tests {
             &mut TransactionErrorMetrics::default(),
             &fee_structure,
             None,
-            &LoadedProgramsForTxBatch::default(),
+            &ProgramCacheForTxBatch::default(),
         );
 
         assert_eq!(

+ 14 - 14
svm/src/message_processor.rs

@@ -148,7 +148,7 @@ mod tests {
         solana_program_runtime::{
             compute_budget::ComputeBudget,
             declare_process_instruction,
-            loaded_programs::{LoadedProgram, LoadedProgramsForTxBatch},
+            loaded_programs::{ProgramCacheEntry, ProgramCacheForTxBatch},
             sysvar_cache::SysvarCache,
         },
         solana_sdk::{
@@ -239,10 +239,10 @@ mod tests {
         ];
         let mut transaction_context = TransactionContext::new(accounts, Rent::default(), 1, 3);
         let program_indices = vec![vec![2]];
-        let mut programs_loaded_for_tx_batch = LoadedProgramsForTxBatch::default();
+        let mut programs_loaded_for_tx_batch = ProgramCacheForTxBatch::default();
         programs_loaded_for_tx_batch.replenish(
             mock_system_program_id,
-            Arc::new(LoadedProgram::new_builtin(0, 0, MockBuiltin::vm)),
+            Arc::new(ProgramCacheEntry::new_builtin(0, 0, MockBuiltin::vm)),
         );
         let account_keys = (0..transaction_context.get_number_of_accounts())
             .map(|index| {
@@ -271,7 +271,7 @@ mod tests {
             ]),
         ));
         let sysvar_cache = SysvarCache::default();
-        let mut programs_modified_by_tx = LoadedProgramsForTxBatch::default();
+        let mut programs_modified_by_tx = ProgramCacheForTxBatch::default();
         let mut invoke_context = InvokeContext::new(
             &mut transaction_context,
             &sysvar_cache,
@@ -322,7 +322,7 @@ mod tests {
                 ),
             ]),
         ));
-        let mut programs_modified_by_tx = LoadedProgramsForTxBatch::default();
+        let mut programs_modified_by_tx = ProgramCacheForTxBatch::default();
         let mut invoke_context = InvokeContext::new(
             &mut transaction_context,
             &sysvar_cache,
@@ -363,7 +363,7 @@ mod tests {
                 ),
             ]),
         ));
-        let mut programs_modified_by_tx = LoadedProgramsForTxBatch::default();
+        let mut programs_modified_by_tx = ProgramCacheForTxBatch::default();
         let mut invoke_context = InvokeContext::new(
             &mut transaction_context,
             &sysvar_cache,
@@ -465,10 +465,10 @@ mod tests {
         ];
         let mut transaction_context = TransactionContext::new(accounts, Rent::default(), 1, 3);
         let program_indices = vec![vec![2]];
-        let mut programs_loaded_for_tx_batch = LoadedProgramsForTxBatch::default();
+        let mut programs_loaded_for_tx_batch = ProgramCacheForTxBatch::default();
         programs_loaded_for_tx_batch.replenish(
             mock_program_id,
-            Arc::new(LoadedProgram::new_builtin(0, 0, MockBuiltin::vm)),
+            Arc::new(ProgramCacheEntry::new_builtin(0, 0, MockBuiltin::vm)),
         );
         let account_metas = vec![
             AccountMeta::new(
@@ -495,7 +495,7 @@ mod tests {
             Some(transaction_context.get_key_of_account_at_index(0).unwrap()),
         ));
         let sysvar_cache = SysvarCache::default();
-        let mut programs_modified_by_tx = LoadedProgramsForTxBatch::default();
+        let mut programs_modified_by_tx = ProgramCacheForTxBatch::default();
         let mut invoke_context = InvokeContext::new(
             &mut transaction_context,
             &sysvar_cache,
@@ -531,7 +531,7 @@ mod tests {
             )],
             Some(transaction_context.get_key_of_account_at_index(0).unwrap()),
         ));
-        let mut programs_modified_by_tx = LoadedProgramsForTxBatch::default();
+        let mut programs_modified_by_tx = ProgramCacheForTxBatch::default();
         let mut invoke_context = InvokeContext::new(
             &mut transaction_context,
             &sysvar_cache,
@@ -564,7 +564,7 @@ mod tests {
             )],
             Some(transaction_context.get_key_of_account_at_index(0).unwrap()),
         ));
-        let mut programs_modified_by_tx = LoadedProgramsForTxBatch::default();
+        let mut programs_modified_by_tx = ProgramCacheForTxBatch::default();
         let mut invoke_context = InvokeContext::new(
             &mut transaction_context,
             &sysvar_cache,
@@ -653,12 +653,12 @@ mod tests {
             Some(transaction_context.get_key_of_account_at_index(0).unwrap()),
         ));
         let sysvar_cache = SysvarCache::default();
-        let mut programs_loaded_for_tx_batch = LoadedProgramsForTxBatch::default();
+        let mut programs_loaded_for_tx_batch = ProgramCacheForTxBatch::default();
         programs_loaded_for_tx_batch.replenish(
             mock_program_id,
-            Arc::new(LoadedProgram::new_builtin(0, 0, MockBuiltin::vm)),
+            Arc::new(ProgramCacheEntry::new_builtin(0, 0, MockBuiltin::vm)),
         );
-        let mut programs_modified_by_tx = LoadedProgramsForTxBatch::default();
+        let mut programs_modified_by_tx = ProgramCacheForTxBatch::default();
         let mut invoke_context = InvokeContext::new(
             &mut transaction_context,
             &sysvar_cache,

+ 49 - 45
svm/src/transaction_processor.rs

@@ -19,8 +19,8 @@ use {
         compute_budget::ComputeBudget,
         invoke_context::InvokeContext,
         loaded_programs::{
-            ForkGraph, LoadProgramMetrics, LoadedProgram, LoadedProgramMatchCriteria,
-            LoadedProgramOwner, LoadedProgramType, LoadedProgramsForTxBatch, ProgramCache,
+            ForkGraph, LoadProgramMetrics, ProgramCache, ProgramCacheEntry, ProgramCacheEntryOwner,
+            ProgramCacheEntryType, ProgramCacheForTxBatch, ProgramCacheMatchCriteria,
             ProgramRuntimeEnvironment, DELAY_VISIBILITY_SLOT_OFFSET,
         },
         log_collector::LogCollector,
@@ -105,8 +105,8 @@ pub trait TransactionProcessingCallback {
         Ok(())
     }
 
-    fn get_program_match_criteria(&self, _program: &Pubkey) -> LoadedProgramMatchCriteria {
-        LoadedProgramMatchCriteria::NoCriteria
+    fn get_program_match_criteria(&self, _program: &Pubkey) -> ProgramCacheMatchCriteria {
+        ProgramCacheMatchCriteria::NoCriteria
     }
 
     fn add_builtin_account(&self, _name: &str, _program_id: &Pubkey) {}
@@ -114,7 +114,7 @@ pub trait TransactionProcessingCallback {
 
 #[derive(Debug)]
 enum ProgramAccountLoadResult {
-    InvalidAccountData(LoadedProgramOwner),
+    InvalidAccountData(ProgramCacheEntryOwner),
     ProgramOfLoaderV1(AccountSharedData),
     ProgramOfLoaderV2(AccountSharedData),
     ProgramOfLoaderV3(AccountSharedData, AccountSharedData, Slot),
@@ -403,7 +403,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
         pubkey: &Pubkey,
         reload: bool,
         effective_epoch: Epoch,
-    ) -> Option<Arc<LoadedProgram>> {
+    ) -> Option<Arc<ProgramCacheEntry>> {
         let program_cache = self.program_cache.read().unwrap();
         let environments = program_cache.get_environments_for_epoch(effective_epoch);
         let mut load_program_metrics = LoadProgramMetrics {
@@ -413,7 +413,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
 
         let mut loaded_program = match self.load_program_accounts(callbacks, pubkey)? {
             ProgramAccountLoadResult::InvalidAccountData(owner) => Ok(
-                LoadedProgram::new_tombstone(self.slot, owner, LoadedProgramType::Closed),
+                ProgramCacheEntry::new_tombstone(self.slot, owner, ProgramCacheEntryType::Closed),
             ),
 
             ProgramAccountLoadResult::ProgramOfLoaderV1(program_account) => {
@@ -426,7 +426,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
                     environments.program_runtime_v1.clone(),
                     reload,
                 )
-                .map_err(|_| (0, LoadedProgramOwner::LoaderV1))
+                .map_err(|_| (0, ProgramCacheEntryOwner::LoaderV1))
             }
 
             ProgramAccountLoadResult::ProgramOfLoaderV2(program_account) => {
@@ -439,7 +439,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
                     environments.program_runtime_v1.clone(),
                     reload,
                 )
-                .map_err(|_| (0, LoadedProgramOwner::LoaderV2))
+                .map_err(|_| (0, ProgramCacheEntryOwner::LoaderV2))
             }
 
             ProgramAccountLoadResult::ProgramOfLoaderV3(
@@ -464,7 +464,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
                         reload,
                     )
                 })
-                .map_err(|_| (slot, LoadedProgramOwner::LoaderV3)),
+                .map_err(|_| (slot, ProgramCacheEntryOwner::LoaderV3)),
 
             ProgramAccountLoadResult::ProgramOfLoaderV4(program_account, slot) => program_account
                 .data()
@@ -481,15 +481,19 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
                         reload,
                     )
                 })
-                .map_err(|_| (slot, LoadedProgramOwner::LoaderV4)),
+                .map_err(|_| (slot, ProgramCacheEntryOwner::LoaderV4)),
         }
         .unwrap_or_else(|(slot, owner)| {
-            let env = if let LoadedProgramOwner::LoaderV4 = &owner {
+            let env = if let ProgramCacheEntryOwner::LoaderV4 = &owner {
                 environments.program_runtime_v2.clone()
             } else {
                 environments.program_runtime_v1.clone()
             };
-            LoadedProgram::new_tombstone(slot, owner, LoadedProgramType::FailedVerification(env))
+            ProgramCacheEntry::new_tombstone(
+                slot,
+                owner,
+                ProgramCacheEntryType::FailedVerification(env),
+            )
         });
 
         let mut timings = ExecuteDetailsTimings::default();
@@ -518,8 +522,8 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
         callback: &CB,
         program_accounts_map: &HashMap<Pubkey, u64>,
         limit_to_load_programs: bool,
-    ) -> LoadedProgramsForTxBatch {
-        let mut missing_programs: Vec<(Pubkey, (LoadedProgramMatchCriteria, u64))> =
+    ) -> ProgramCacheForTxBatch {
+        let mut missing_programs: Vec<(Pubkey, (ProgramCacheMatchCriteria, u64))> =
             program_accounts_map
                 .iter()
                 .map(|(pubkey, count)| {
@@ -539,7 +543,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
                 // Initialize our local cache.
                 let is_first_round = loaded_programs_for_txs.is_none();
                 if is_first_round {
-                    loaded_programs_for_txs = Some(LoadedProgramsForTxBatch::new_from_cache(
+                    loaded_programs_for_txs = Some(ProgramCacheForTxBatch::new_from_cache(
                         self.slot,
                         self.epoch,
                         &program_cache,
@@ -553,7 +557,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
                         // This branch is taken when there is an error in assigning a program to a
                         // cache slot. It is not possible to mock this error for SVM unit
                         // tests purposes.
-                        let mut ret = LoadedProgramsForTxBatch::new_from_cache(
+                        let mut ret = ProgramCacheForTxBatch::new_from_cache(
                             self.slot,
                             self.epoch,
                             &program_cache,
@@ -611,7 +615,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
         timings: &mut ExecuteTimings,
         error_counters: &mut TransactionErrorMetrics,
         log_messages_bytes_limit: Option<usize>,
-        programs_loaded_for_tx_batch: &LoadedProgramsForTxBatch,
+        programs_loaded_for_tx_batch: &ProgramCacheForTxBatch,
     ) -> TransactionExecutionResult {
         let transaction_accounts = std::mem::take(&mut loaded_transaction.accounts);
 
@@ -660,7 +664,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
             callback.get_last_blockhash_and_lamports_per_signature();
 
         let mut executed_units = 0u64;
-        let mut programs_modified_by_tx = LoadedProgramsForTxBatch::new(
+        let mut programs_modified_by_tx = ProgramCacheForTxBatch::new(
             self.slot,
             programs_loaded_for_tx_batch.environments.clone(),
             programs_loaded_for_tx_batch.upcoming_environments.clone(),
@@ -832,11 +836,11 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
         deployment_slot: Slot,
         program_runtime_environment: ProgramRuntimeEnvironment,
         reloading: bool,
-    ) -> std::result::Result<LoadedProgram, Box<dyn std::error::Error>> {
+    ) -> std::result::Result<ProgramCacheEntry, Box<dyn std::error::Error>> {
         if reloading {
             // Safety: this is safe because the program is being reloaded in the cache.
             unsafe {
-                LoadedProgram::reload(
+                ProgramCacheEntry::reload(
                     loader_key,
                     program_runtime_environment.clone(),
                     deployment_slot,
@@ -847,7 +851,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
                 )
             }
         } else {
-            LoadedProgram::new(
+            ProgramCacheEntry::new(
                 loader_key,
                 program_runtime_environment.clone(),
                 deployment_slot,
@@ -875,7 +879,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
                     })
                     .map(|slot| ProgramAccountLoadResult::ProgramOfLoaderV4(program_account, slot))
                     .unwrap_or(ProgramAccountLoadResult::InvalidAccountData(
-                        LoadedProgramOwner::LoaderV4,
+                        ProgramCacheEntryOwner::LoaderV4,
                     )),
             );
         }
@@ -909,7 +913,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
             }
         }
         Some(ProgramAccountLoadResult::InvalidAccountData(
-            LoadedProgramOwner::LoaderV3,
+            ProgramCacheEntryOwner::LoaderV3,
         ))
     }
 
@@ -992,7 +996,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
         callbacks: &CB,
         program_id: Pubkey,
         name: &str,
-        builtin: LoadedProgram,
+        builtin: ProgramCacheEntry,
     ) {
         debug!("Adding program {} under {:?}", name, program_id);
         callbacks.add_builtin_account(name, &program_id);
@@ -1374,10 +1378,10 @@ mod tests {
 
         let result = batch_processor.load_program_with_pubkey(&mock_bank, &key, false, 20);
 
-        let loaded_program = LoadedProgram::new_tombstone(
+        let loaded_program = ProgramCacheEntry::new_tombstone(
             0,
-            LoadedProgramOwner::LoaderV4,
-            LoadedProgramType::FailedVerification(
+            ProgramCacheEntryOwner::LoaderV4,
+            ProgramCacheEntryType::FailedVerification(
                 batch_processor
                     .program_cache
                     .read()
@@ -1404,10 +1408,10 @@ mod tests {
 
         // This should return an error
         let result = batch_processor.load_program_with_pubkey(&mock_bank, &key, false, 20);
-        let loaded_program = LoadedProgram::new_tombstone(
+        let loaded_program = ProgramCacheEntry::new_tombstone(
             0,
-            LoadedProgramOwner::LoaderV2,
-            LoadedProgramType::FailedVerification(
+            ProgramCacheEntryOwner::LoaderV2,
+            ProgramCacheEntryType::FailedVerification(
                 batch_processor
                     .program_cache
                     .read()
@@ -1475,10 +1479,10 @@ mod tests {
 
         // This should return an error
         let result = batch_processor.load_program_with_pubkey(&mock_bank, &key1, false, 0);
-        let loaded_program = LoadedProgram::new_tombstone(
+        let loaded_program = ProgramCacheEntry::new_tombstone(
             0,
-            LoadedProgramOwner::LoaderV3,
-            LoadedProgramType::FailedVerification(
+            ProgramCacheEntryOwner::LoaderV3,
+            ProgramCacheEntryType::FailedVerification(
                 batch_processor
                     .program_cache
                     .read()
@@ -1552,10 +1556,10 @@ mod tests {
             .insert(key, account_data.clone());
 
         let result = batch_processor.load_program_with_pubkey(&mock_bank, &key, false, 0);
-        let loaded_program = LoadedProgram::new_tombstone(
+        let loaded_program = ProgramCacheEntry::new_tombstone(
             0,
-            LoadedProgramOwner::LoaderV4,
-            LoadedProgramType::FailedVerification(
+            ProgramCacheEntryOwner::LoaderV4,
+            ProgramCacheEntryType::FailedVerification(
                 batch_processor
                     .program_cache
                     .read()
@@ -1749,7 +1753,7 @@ mod tests {
         };
 
         let sanitized_message = new_unchecked_sanitized_message(message);
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
         let mock_bank = MockBankCallback::default();
         let batch_processor = TransactionBatchProcessor::<TestForkGraph>::default();
 
@@ -1873,7 +1877,7 @@ mod tests {
         };
 
         let sanitized_message = new_unchecked_sanitized_message(message);
-        let loaded_programs = LoadedProgramsForTxBatch::default();
+        let loaded_programs = ProgramCacheForTxBatch::default();
         let mock_bank = MockBankCallback::default();
         let batch_processor = TransactionBatchProcessor::<TestForkGraph>::default();
 
@@ -1957,7 +1961,7 @@ mod tests {
             let program = result.find(&key).unwrap();
             assert!(matches!(
                 program.program,
-                LoadedProgramType::FailedVerification(_)
+                ProgramCacheEntryType::FailedVerification(_)
             ));
         }
     }
@@ -2408,7 +2412,7 @@ mod tests {
 
         let key = Pubkey::new_unique();
         let name = "a_builtin_name";
-        let program = LoadedProgram::new_builtin(
+        let program = ProgramCacheEntry::new_builtin(
             0,
             name.len(),
             |_invoke_context, _param0, _param1, _param2, _param3, _param4| {},
@@ -2421,20 +2425,20 @@ mod tests {
             name.as_bytes()
         );
 
-        let mut loaded_programs_for_tx_batch = LoadedProgramsForTxBatch::new_from_cache(
+        let mut loaded_programs_for_tx_batch = ProgramCacheForTxBatch::new_from_cache(
             0,
             0,
             &batch_processor.program_cache.read().unwrap(),
         );
         batch_processor.program_cache.write().unwrap().extract(
-            &mut vec![(key, (LoadedProgramMatchCriteria::NoCriteria, 1))],
+            &mut vec![(key, (ProgramCacheMatchCriteria::NoCriteria, 1))],
             &mut loaded_programs_for_tx_batch,
             true,
         );
         let entry = loaded_programs_for_tx_batch.find(&key).unwrap();
 
-        // Repeating code because LoadedProgram does not implement clone.
-        let program = LoadedProgram::new_builtin(
+        // Repeating code because ProgramCacheEntry does not implement clone.
+        let program = ProgramCacheEntry::new_builtin(
             0,
             name.len(),
             |_invoke_context, _param0, _param1, _param2, _param3, _param4| {},

+ 2 - 2
svm/src/transaction_results.rs

@@ -5,7 +5,7 @@
 )]
 pub use solana_sdk::inner_instruction::{InnerInstruction, InnerInstructionsList};
 use {
-    solana_program_runtime::loaded_programs::LoadedProgramsForTxBatch,
+    solana_program_runtime::loaded_programs::ProgramCacheForTxBatch,
     solana_sdk::{
         nonce_info::{NonceFull, NonceInfo},
         rent_debits::RentDebits,
@@ -34,7 +34,7 @@ pub struct TransactionResults {
 pub enum TransactionExecutionResult {
     Executed {
         details: TransactionExecutionDetails,
-        programs_modified_by_tx: Box<LoadedProgramsForTxBatch>,
+        programs_modified_by_tx: Box<ProgramCacheForTxBatch>,
     },
     NotExecuted(TransactionError),
 }

+ 3 - 3
svm/tests/integration_test.rs

@@ -10,7 +10,7 @@ use {
         compute_budget::ComputeBudget,
         invoke_context::InvokeContext,
         loaded_programs::{
-            BlockRelation, ForkGraph, LoadedProgram, ProgramCache, ProgramRuntimeEnvironments,
+            BlockRelation, ForkGraph, ProgramCache, ProgramCacheEntry, ProgramRuntimeEnvironments,
         },
         solana_rbpf::{
             program::{BuiltinFunction, BuiltinProgram, FunctionRegistry},
@@ -236,7 +236,7 @@ fn register_builtins(
         mock_bank,
         bpf_loader_upgradeable::id(),
         BPF_LOADER_NAME,
-        LoadedProgram::new_builtin(
+        ProgramCacheEntry::new_builtin(
             DEPLOYMENT_SLOT,
             BPF_LOADER_NAME.len(),
             solana_bpf_loader_program::Entrypoint::vm,
@@ -249,7 +249,7 @@ fn register_builtins(
         mock_bank,
         solana_system_program::id(),
         SYSTEM_PROGRAM_NAME,
-        LoadedProgram::new_builtin(
+        ProgramCacheEntry::new_builtin(
             DEPLOYMENT_SLOT,
             SYSTEM_PROGRAM_NAME.len(),
             solana_system_program::system_processor::Entrypoint::vm,

Some files were not shown because too many files changed in this diff