From 8bb0c3d674e7a24248048aa9b0e25e6f2739426d Mon Sep 17 00:00:00 2001 From: steviez Date: Mon, 29 Jul 2024 14:12:29 -0500 Subject: [PATCH 1/2] Use combinator to simplify check for slot < halt_at_slot --- ledger/src/blockstore_processor.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 70cdf37b567ff5..d7af22926c8885 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -1733,10 +1733,7 @@ fn process_next_slots( // This is a fork point if there are multiple children, create a new child bank for each fork for next_slot in &meta.next_slots { - let skip_next_slot = halt_at_slot - .map(|halt_at_slot| *next_slot > halt_at_slot) - .unwrap_or(false); - if skip_next_slot { + if halt_at_slot.is_some_and(|halt_at_slot| *next_slot > halt_at_slot) { continue; } From 2dc1b2d23fa20c9f819bee085cb501b37a1897ba Mon Sep 17 00:00:00 2001 From: steviez Date: Mon, 29 Jul 2024 14:16:03 -0500 Subject: [PATCH 2/2] Move more logic in blockstore_processor behind allow_dead_slots flag A flag in ProcessOptions can be set to allow dead slots. If the flag is not set and a block is marked dead, fetching the entries will fail as the entry fetch method internally checks if the slot is dead. Within process_next_slots(), new Banks are created as replay progresses through slots. If allow_dead_slots=false and a dead slot is loaded, replay of the slot will error. That error is handled and results in the Bank being removed from BankForks. Instead of allowing the extra work to proceed, check if new slots to replay are dead (and allow_dead_slots=false) BEFORE the creation of a new Bank. --- ledger/src/blockstore_processor.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index d7af22926c8885..b64cbcddeb6240 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -1725,7 +1725,7 @@ fn process_next_slots( blockstore: &Blockstore, leader_schedule_cache: &LeaderScheduleCache, pending_slots: &mut Vec<(SlotMeta, Bank, Hash)>, - halt_at_slot: Option, + opts: &ProcessOptions, ) -> result::Result<(), BlockstoreProcessorError> { if meta.next_slots.is_empty() { return Ok(()); @@ -1733,7 +1733,13 @@ fn process_next_slots( // This is a fork point if there are multiple children, create a new child bank for each fork for next_slot in &meta.next_slots { - if halt_at_slot.is_some_and(|halt_at_slot| *next_slot > halt_at_slot) { + if opts + .halt_at_slot + .is_some_and(|halt_at_slot| *next_slot > halt_at_slot) + { + continue; + } + if !opts.allow_dead_slots && blockstore.is_dead(*next_slot) { continue; } @@ -1812,7 +1818,7 @@ fn load_frozen_forks( blockstore, leader_schedule_cache, &mut pending_slots, - opts.halt_at_slot, + opts, )?; let on_halt_store_hash_raw_data_for_debug = opts.on_halt_store_hash_raw_data_for_debug; @@ -1991,7 +1997,7 @@ fn load_frozen_forks( blockstore, leader_schedule_cache, &mut pending_slots, - opts.halt_at_slot, + opts, )?; } } else if on_halt_store_hash_raw_data_for_debug {