Skip to content

Commit

Permalink
Add removed line from PR1192 (anza-xyz#2249)
Browse files Browse the repository at this point in the history
* Add removed line from PR1192

* Test missing programs were loaded
  • Loading branch information
ksolana authored Jul 27, 2024
1 parent a76d358 commit b14f103
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
})
.collect();

let mut loaded_programs_for_txs = None;
let mut loaded_programs_for_txs: Option<ProgramCacheForTxBatch> = None;
loop {
let (program_to_store, task_cookie, task_waiter) = {
// Lock the global cache.
Expand Down Expand Up @@ -567,6 +567,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
};

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)
Expand Down Expand Up @@ -1277,6 +1278,7 @@ mod tests {

let mut account_maps: HashMap<Pubkey, u64> = 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(
Expand All @@ -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]
Expand Down

0 comments on commit b14f103

Please sign in to comment.