From b14f1037bb725a3c9afb3db0f5158d548c6266b4 Mon Sep 17 00:00:00 2001 From: asolana <110843012+ksolana@users.noreply.github.com> Date: Sat, 27 Jul 2024 08:21:31 -0700 Subject: [PATCH] Add removed line from PR1192 (#2249) * Add removed line from PR1192 * Test missing programs were loaded --- svm/src/transaction_processor.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 149e635b083e48..9f6f6e94b26db1 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -526,7 +526,7 @@ impl TransactionBatchProcessor { }) .collect(); - let mut loaded_programs_for_txs = None; + let mut loaded_programs_for_txs: Option = None; loop { let (program_to_store, task_cookie, task_waiter) = { // Lock the global cache. @@ -567,6 +567,7 @@ impl TransactionBatchProcessor { }; if let Some((key, program)) = program_to_store { + loaded_programs_for_txs.as_mut().unwrap().loaded_missing = true; let mut program_cache = self.program_cache.write().unwrap(); // Submit our last completed loading task. if program_cache.finish_cooperative_loading_task(self.slot, key, program) @@ -1277,6 +1278,7 @@ mod tests { let mut account_maps: HashMap = HashMap::new(); account_maps.insert(key, 4); + let mut loaded_missing = 0; for limit_to_load_programs in [false, true] { let result = batch_processor.replenish_program_cache( @@ -1286,12 +1288,17 @@ mod tests { limit_to_load_programs, ); assert!(!result.hit_max_limit); + if result.loaded_missing { + loaded_missing += 1; + } + let program = result.find(&key).unwrap(); assert!(matches!( program.program, ProgramCacheEntryType::FailedVerification(_) )); } + assert!(loaded_missing > 0); } #[test]