From 390c5667f770363309c0c4ea99df9b0ecf5e04b2 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 15 Mar 2022 19:54:08 -0700 Subject: [PATCH] Setup bank hard_forks in load_bank_forks() --- ledger/src/bank_forks_utils.rs | 18 ++++++++++++++++++ ledger/src/blockstore_processor.rs | 15 --------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ledger/src/bank_forks_utils.rs b/ledger/src/bank_forks_utils.rs index 4459178ef4..1ee8b11069 100644 --- a/ledger/src/bank_forks_utils.rs +++ b/ledger/src/bank_forks_utils.rs @@ -148,6 +148,24 @@ pub fn load_bank_forks( if process_options.full_leader_cache { leader_schedule_cache.set_max_schedules(std::usize::MAX); } + + assert_eq!(bank_forks.banks().len(), 1); + if let Some(ref new_hard_forks) = process_options.new_hard_forks { + let root_bank = bank_forks.root_bank(); + let hard_forks = root_bank.hard_forks(); + + for hard_fork_slot in new_hard_forks.iter() { + if *hard_fork_slot > root_bank.slot() { + hard_forks.write().unwrap().register(*hard_fork_slot); + } else { + warn!( + "Hard fork at {} ignored, --hard-fork option can be removed.", + hard_fork_slot + ); + } + } + } + (bank_forks, leader_schedule_cache, starting_snapshot_hashes) } diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 2426ef0e41..dde1ce562c 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -655,21 +655,6 @@ pub fn process_blockstore_from_root( info!("processing ledger from slot {}...", start_slot); let now = Instant::now(); - if let Some(ref new_hard_forks) = opts.new_hard_forks { - let hard_forks = bank.hard_forks(); - - for hard_fork_slot in new_hard_forks.iter() { - if *hard_fork_slot > start_slot { - hard_forks.write().unwrap().register(*hard_fork_slot); - } else { - warn!( - "Hard fork at {} ignored, --hard-fork option can be removed.", - hard_fork_slot - ); - } - } - } - // ensure start_slot is rooted for correct replay if blockstore.is_primary_access() { blockstore