Skip to content

Commit

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

* Test missing programs were loaded

(cherry picked from commit b14f103)
  • Loading branch information
ksolana authored and mergify[bot] committed Jul 27, 2024
1 parent 4234b1b commit dc8933e
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 @@ -543,7 +543,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 @@ -584,6 +584,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 @@ -1334,6 +1335,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 @@ -1343,12 +1345,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 dc8933e

Please sign in to comment.