Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow replacing tombstone with a non-tombstone #31494

Merged
merged 1 commit into from
May 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ impl LoadedPrograms {
Ordering::Relaxed,
);
second_level.swap_remove(entry_index);
} else if existing.is_tombstone() && !entry.is_tombstone() {
// The old entry is tombstone and the new one is not. Let's give the new entry
// a chance.
second_level.swap_remove(entry_index);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the record: this newly-added instance of .swap_remove() is fixed at #32973

} else {
return (true, existing.clone());
}
Expand Down Expand Up @@ -809,6 +813,23 @@ mod tests {
});
}

#[test]
fn test_replace_tombstones() {
let mut cache = LoadedPrograms::default();
let program1 = Pubkey::new_unique();
set_tombstone(
&mut cache,
program1,
10,
LoadedProgramType::FailedVerification,
);

let loaded_program = new_test_loaded_program(10, 10);
let (existing, program) = cache.replenish(program1, loaded_program.clone());
assert!(!existing);
assert_eq!(program, loaded_program);
}

#[test]
fn test_tombstone() {
let tombstone = LoadedProgram::new_tombstone(0, LoadedProgramType::FailedVerification);
Expand Down