diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index 5155b4a678..226fd0c904 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -2528,7 +2528,7 @@ pub(crate) mod tests { let arc_bank0 = Arc::new(bank0); let bank_forks = Arc::new(RwLock::new(BankForks::new_from_banks( &[arc_bank0.clone()], - vec![0], + 0, ))); assert!(block_commitment_cache diff --git a/core/src/storage_stage.rs b/core/src/storage_stage.rs index 865e84ac6f..f02dea7f36 100644 --- a/core/src/storage_stage.rs +++ b/core/src/storage_stage.rs @@ -689,10 +689,7 @@ mod tests { let cluster_info = test_cluster_info(&keypair.pubkey()); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(1000); let bank = Arc::new(Bank::new(&genesis_config)); - let bank_forks = Arc::new(RwLock::new(BankForks::new_from_banks( - &[bank.clone()], - vec![0], - ))); + let bank_forks = Arc::new(RwLock::new(BankForks::new_from_banks(&[bank.clone()], 0))); let ledger_path = get_tmp_ledger_path!(); let blockstore = Arc::new(Blockstore::open(&ledger_path).unwrap()); let block_commitment_cache = Arc::new(RwLock::new( diff --git a/core/tests/storage_stage.rs b/core/tests/storage_stage.rs index 293db146e4..995c84b61d 100644 --- a/core/tests/storage_stage.rs +++ b/core/tests/storage_stage.rs @@ -56,10 +56,7 @@ mod tests { let bank = Bank::new(&genesis_config); let bank = Arc::new(bank); - let bank_forks = Arc::new(RwLock::new(BankForks::new_from_banks( - &[bank.clone()], - vec![0], - ))); + let bank_forks = Arc::new(RwLock::new(BankForks::new_from_banks(&[bank.clone()], 0))); let block_commitment_cache = Arc::new(RwLock::new( BlockCommitmentCache::default_with_blockstore(blockstore.clone()), )); @@ -179,10 +176,7 @@ mod tests { let blockstore = Arc::new(Blockstore::open(&ledger_path).unwrap()); let slot = 1; let bank = Arc::new(Bank::new(&genesis_config)); - let bank_forks = Arc::new(RwLock::new(BankForks::new_from_banks( - &[bank.clone()], - vec![0], - ))); + let bank_forks = Arc::new(RwLock::new(BankForks::new_from_banks(&[bank.clone()], 0))); let block_commitment_cache = Arc::new(RwLock::new( BlockCommitmentCache::default_with_blockstore(blockstore.clone()), )); diff --git a/ledger/src/bank_forks.rs b/ledger/src/bank_forks.rs index 0f2bfd73ca..c3959319ff 100644 --- a/ledger/src/bank_forks.rs +++ b/ledger/src/bank_forks.rs @@ -141,7 +141,7 @@ impl BankForks { self.banks.get(&self.root()).expect("Root bank must exist") } - pub fn new_from_banks(initial_forks: &[Arc], rooted_path: Vec) -> Self { + pub fn new_from_banks(initial_forks: &[Arc], root: Slot) -> Self { let mut banks = HashMap::new(); let working_bank = initial_forks[0].clone(); @@ -157,7 +157,7 @@ impl BankForks { banks.insert(parent.slot(), parent.clone()); } } - let root = *rooted_path.last().unwrap(); + Self { root, banks, diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 0a1e199416..f369736b8e 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -318,7 +318,7 @@ pub fn process_blockstore_from_root( assert!(bank.parent().is_none()); let start_slot = bank.slot(); let now = Instant::now(); - let mut rooted_path = vec![start_slot]; + let mut root = start_slot; bank.set_entered_epoch_callback(solana_genesis_programs::get_entered_epoch_callback( genesis_config.operating_mode, @@ -366,7 +366,7 @@ pub fn process_blockstore_from_root( &meta, blockstore, &mut leader_schedule_cache, - &mut rooted_path, + &mut root, opts, recyclers, )?; @@ -375,7 +375,7 @@ pub fn process_blockstore_from_root( if banks.is_empty() { return Err(BlockstoreProcessorError::NoValidForksFound); } - let bank_forks = BankForks::new_from_banks(&banks, rooted_path); + let bank_forks = BankForks::new_from_banks(&banks, root); (bank_forks, bank_forks_info, leader_schedule_cache) } else { // If there's no meta for the input `start_slot`, then we started from a snapshot @@ -385,7 +385,7 @@ pub fn process_blockstore_from_root( bank_slot: start_slot, }; let leader_schedule_cache = LeaderScheduleCache::new_from_bank(&bank); - let bank_forks = BankForks::new_from_banks(&[bank], rooted_path); + let bank_forks = BankForks::new_from_banks(&[bank], root); (bank_forks, vec![bfi], leader_schedule_cache) } }; @@ -704,7 +704,7 @@ fn process_pending_slots( root_meta: &SlotMeta, blockstore: &Blockstore, leader_schedule_cache: &mut LeaderScheduleCache, - rooted_path: &mut Vec, + root: &mut Slot, opts: &ProcessOptions, recyclers: &VerifyRecyclers, ) -> result::Result, BankForksInfo)>, BlockstoreProcessorError> { @@ -752,10 +752,7 @@ fn process_pending_slots( txs += progress.num_txs; if blockstore.is_root(slot) { - let parents = bank.parents().into_iter().map(|b| b.slot()).rev().skip(1); - let parents: Vec<_> = parents.collect(); - rooted_path.extend(parents); - rooted_path.push(slot); + *root = slot; leader_schedule_cache.set_root(&bank); bank.squash(); pending_slots.clear();