Skip to content

Commit

Permalink
Use current root slot to disambiguate pruning of old programs (#31548)
Browse files Browse the repository at this point in the history
* Use current root slot to unambiguate pruning of old programs

* simplify the change

* address comment
  • Loading branch information
pgarg66 authored May 9, 2023
1 parent 3bb2e3b commit 3fd3e6d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ impl LoadedPrograms {

/// 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;
self.entries.retain(|_key, second_level| {
let mut first_ancestor_found = false;
*second_level = second_level
Expand All @@ -383,7 +384,10 @@ impl LoadedPrograms {
let relation = fork_graph.relationship(entry.deployment_slot, new_root);
if entry.deployment_slot >= new_root {
matches!(relation, BlockRelation::Equal | BlockRelation::Descendant)
} else if !first_ancestor_found && matches!(relation, BlockRelation::Ancestor) {
} else if !first_ancestor_found
&& (matches!(relation, BlockRelation::Ancestor)
|| entry.deployment_slot < previous_root)
{
first_ancestor_found = true;
first_ancestor_found
} else {
Expand Down

0 comments on commit 3fd3e6d

Please sign in to comment.