From 9cde4463d4c295b3861369f4edcc1415b3d20cb9 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Thu, 14 Dec 2023 11:41:57 +1100 Subject: [PATCH] v1.16: Initialize LoadedPrograms::latest_root earlier (#34432) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixes BankForks::new_from_banks() not setting the root of LoadedPrograms. --------- Co-authored-by: Alexander Meißner --- runtime/src/bank_forks.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/runtime/src/bank_forks.rs b/runtime/src/bank_forks.rs index 91f2304fd281a4..1404be63640cf8 100644 --- a/runtime/src/bank_forks.rs +++ b/runtime/src/bank_forks.rs @@ -175,7 +175,7 @@ impl BankForks { descendants.entry(parent).or_default().insert(*slot); } } - Self { + let bank_forks = Self { root: Arc::new(AtomicSlot::new(root)), banks, descendants, @@ -184,7 +184,17 @@ impl BankForks { last_accounts_hash_slot: root, in_vote_only_mode: Arc::new(AtomicBool::new(false)), highest_slot_at_startup: 0, - } + }; + let root_bank = bank_forks + .banks + .get(&root) + .expect("root bank didn't exist in bank_forks"); + root_bank + .loaded_programs_cache + .write() + .unwrap() + .prune(&bank_forks, root); + bank_forks } pub fn insert(&mut self, mut bank: Bank) -> Arc {