Skip to content

Commit

Permalink
Prune programs deployed in duplicate unconfirmed slot
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 committed Aug 25, 2023
1 parent 8c49a0c commit 91ba493
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,13 @@ impl ReplayStage {
// and are looking up the signature for this slot?
root_bank.clear_slot_signatures(slot);

// Remove cached entries of the programs that were deployed in this slot.
root_bank
.loaded_programs_cache
.write()
.unwrap()
.prune_slot(slot);

if let Some(bank_hash) = blockstore.get_bank_hash(slot) {
// If a descendant was successfully replayed and chained from a duplicate it must
// also be a duplicate. In this case we *need* to repair it, so we clear from
Expand Down
12 changes: 12 additions & 0 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,18 @@ impl LoadedPrograms {
self.remove_programs_with_no_entries();
}

pub fn prune_slot(&mut self, slot: Slot) {
self.entries.retain(|_key, second_level| {
*second_level = second_level
.iter()
.filter(|entry| entry.deployment_slot != slot)
.cloned()
.collect();
!second_level.is_empty()
});
self.remove_programs_with_no_entries();
}

/// Before rerooting the blockstore this removes all programs of orphan forks
pub fn prune<F: ForkGraph>(&mut self, fork_graph: &F, new_root: Slot) {
let previous_root = self.latest_root;
Expand Down

0 comments on commit 91ba493

Please sign in to comment.