Skip to content

Commit 07a57a9

Browse files
authored
Merge pull request #10 from magicblock-labs/bmuddha/fix/revert-cache-replenish-retries
fix: revert cache replenish retries
2 parents 4878759 + 3e9456e commit 07a57a9

File tree

1 file changed

+18
-36
lines changed

1 file changed

+18
-36
lines changed

src/transaction_processor.rs

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -367,45 +367,27 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
367367
// stage, as we already have an access to all of the accounts
368368
let mut balances = AccountsBalances::default();
369369

370-
let mut replenish_retried = false;
371370
let (mut program_cache_for_tx_batch, program_cache_us) = measure_us!({
372-
loop {
373-
let program_cache_for_tx_batch = self.replenish_program_cache(
374-
callbacks,
375-
&program_accounts_map,
376-
&mut execute_timings,
377-
config.check_program_modification_slot,
378-
config.limit_to_load_programs,
379-
);
380-
381-
// This means the cache is corrupted and runtime cannot load required programs
382-
if program_cache_for_tx_batch.hit_max_limit {
383-
// We retry once (will most likely succeed)
384-
// But to guarantee success we clear the cache
385-
if !replenish_retried {
386-
replenish_retried = true;
387-
let mut cache = self.program_cache.write().unwrap();
388-
// We need to reset the slot to avoid debug panics
389-
let slot = cache.latest_root_slot;
390-
cache.latest_root_slot = 0;
391-
cache.prune(0, 0);
392-
// And restore the slot to previous value after prune
393-
cache.latest_root_slot = slot;
394-
continue;
395-
}
396-
397-
return LoadAndExecuteSanitizedTransactionsOutput {
398-
error_metrics,
399-
execute_timings,
400-
processing_results: (0..sanitized_txs.len())
401-
.map(|_| Err(TransactionError::ProgramCacheHitMaxLimit))
402-
.collect(),
403-
balances,
404-
};
405-
}
371+
let program_cache_for_tx_batch = self.replenish_program_cache(
372+
callbacks,
373+
&program_accounts_map,
374+
&mut execute_timings,
375+
config.check_program_modification_slot,
376+
config.limit_to_load_programs,
377+
);
406378

407-
break program_cache_for_tx_batch;
379+
if program_cache_for_tx_batch.hit_max_limit {
380+
return LoadAndExecuteSanitizedTransactionsOutput {
381+
error_metrics,
382+
execute_timings,
383+
processing_results: (0..sanitized_txs.len())
384+
.map(|_| Err(TransactionError::ProgramCacheHitMaxLimit))
385+
.collect(),
386+
balances,
387+
};
408388
}
389+
390+
program_cache_for_tx_batch
409391
});
410392

411393
// Determine a capacity for the internal account cache. This

0 commit comments

Comments
 (0)