From 9569a1cf10f26b51afcce41facb356a147c9db10 Mon Sep 17 00:00:00 2001 From: Pablo Deymonnaz Date: Wed, 18 Feb 2026 20:00:22 -0300 Subject: [PATCH] fix: handle pruned justified root in compute_lmd_ghost_head When finalization advances, prune_live_chain removes entries with slot < finalized_slot. If the justified checkpoint root (e.g. genesis at slot 0) has been pruned, the unchecked blocks[&start_root] index panics with "no entry found for key". Replace the panicking index with blocks.get() and return start_root as fallback when it's absent from the live chain. This matches the existing early-return for empty blocks and keeps the head at the justified root until more blocks are available. --- crates/blockchain/fork_choice/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/blockchain/fork_choice/src/lib.rs b/crates/blockchain/fork_choice/src/lib.rs index c36049f..4458122 100644 --- a/crates/blockchain/fork_choice/src/lib.rs +++ b/crates/blockchain/fork_choice/src/lib.rs @@ -23,7 +23,9 @@ pub fn compute_lmd_ghost_head( .map(|(root, _)| root) .expect("we already checked blocks is non-empty"); } - let start_slot = blocks[&start_root].0; + let Some(&(start_slot, _)) = blocks.get(&start_root) else { + return start_root; + }; let mut weights: HashMap = HashMap::new(); for attestation_data in attestations.values() {