caches descendants in bank forks (#15107)
This commit is contained in:
@ -1386,7 +1386,7 @@ pub mod test {
|
||||
.clone();
|
||||
|
||||
// Try to vote on the given slot
|
||||
let descendants = self.bank_forks.read().unwrap().descendants();
|
||||
let descendants = self.bank_forks.read().unwrap().descendants().clone();
|
||||
let SelectVoteAndResetForkResult {
|
||||
heaviest_fork_failures,
|
||||
..
|
||||
@ -1688,7 +1688,12 @@ pub mod test {
|
||||
fork_progress.fork_stats.computed = true;
|
||||
}
|
||||
let ancestors = vote_simulator.bank_forks.read().unwrap().ancestors();
|
||||
let mut descendants = vote_simulator.bank_forks.read().unwrap().descendants();
|
||||
let mut descendants = vote_simulator
|
||||
.bank_forks
|
||||
.read()
|
||||
.unwrap()
|
||||
.descendants()
|
||||
.clone();
|
||||
let mut tower = Tower::new_with_key(&my_pubkey);
|
||||
|
||||
// Last vote is 47
|
||||
@ -1819,7 +1824,12 @@ pub mod test {
|
||||
tower.lockouts.root_slot = Some(43);
|
||||
// Refresh ancestors and descendants for new root.
|
||||
let ancestors = vote_simulator.bank_forks.read().unwrap().ancestors();
|
||||
let descendants = vote_simulator.bank_forks.read().unwrap().descendants();
|
||||
let descendants = vote_simulator
|
||||
.bank_forks
|
||||
.read()
|
||||
.unwrap()
|
||||
.descendants()
|
||||
.clone();
|
||||
|
||||
assert_eq!(
|
||||
tower.check_switch_threshold(
|
||||
@ -2470,7 +2480,12 @@ pub mod test {
|
||||
}
|
||||
|
||||
let ancestors = vote_simulator.bank_forks.read().unwrap().ancestors();
|
||||
let descendants = vote_simulator.bank_forks.read().unwrap().descendants();
|
||||
let descendants = vote_simulator
|
||||
.bank_forks
|
||||
.read()
|
||||
.unwrap()
|
||||
.descendants()
|
||||
.clone();
|
||||
let mut tower = Tower::new_with_key(&my_pubkey);
|
||||
|
||||
tower.record_vote(43, Hash::default());
|
||||
@ -2562,7 +2577,12 @@ pub mod test {
|
||||
let mut slot_history = SlotHistory::default();
|
||||
vote_simulator.set_root(replayed_root_slot);
|
||||
let ancestors = vote_simulator.bank_forks.read().unwrap().ancestors();
|
||||
let descendants = vote_simulator.bank_forks.read().unwrap().descendants();
|
||||
let descendants = vote_simulator
|
||||
.bank_forks
|
||||
.read()
|
||||
.unwrap()
|
||||
.descendants()
|
||||
.clone();
|
||||
for slot in &[0, 1, 2, 43, replayed_root_slot] {
|
||||
slot_history.add(*slot);
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ impl ReplayStage {
|
||||
|
||||
let mut reset_duplicate_slots_time = Measure::start("reset_duplicate_slots");
|
||||
let mut ancestors = bank_forks.read().unwrap().ancestors();
|
||||
let mut descendants = bank_forks.read().unwrap().descendants();
|
||||
let mut descendants = bank_forks.read().unwrap().descendants().clone();
|
||||
let forks_root = bank_forks.read().unwrap().root();
|
||||
let start = allocated.get();
|
||||
|
||||
@ -3678,7 +3678,7 @@ pub(crate) mod tests {
|
||||
#[test]
|
||||
fn test_purge_unconfirmed_duplicate_slot() {
|
||||
let (bank_forks, mut progress) = setup_forks();
|
||||
let mut descendants = bank_forks.read().unwrap().descendants();
|
||||
let mut descendants = bank_forks.read().unwrap().descendants().clone();
|
||||
let mut ancestors = bank_forks.read().unwrap().ancestors();
|
||||
|
||||
// Purging slot 5 should purge only slots 5 and its descendant 6
|
||||
@ -3699,7 +3699,7 @@ pub(crate) mod tests {
|
||||
}
|
||||
|
||||
// Purging slot 4 should purge only slot 4
|
||||
let mut descendants = bank_forks.read().unwrap().descendants();
|
||||
let mut descendants = bank_forks.read().unwrap().descendants().clone();
|
||||
let mut ancestors = bank_forks.read().unwrap().ancestors();
|
||||
ReplayStage::purge_unconfirmed_duplicate_slot(
|
||||
4,
|
||||
@ -3718,7 +3718,7 @@ pub(crate) mod tests {
|
||||
}
|
||||
|
||||
// Purging slot 1 should purge both forks 2 and 3
|
||||
let mut descendants = bank_forks.read().unwrap().descendants();
|
||||
let mut descendants = bank_forks.read().unwrap().descendants().clone();
|
||||
let mut ancestors = bank_forks.read().unwrap().ancestors();
|
||||
ReplayStage::purge_unconfirmed_duplicate_slot(
|
||||
1,
|
||||
@ -3740,7 +3740,7 @@ pub(crate) mod tests {
|
||||
let (bank_forks, _) = setup_forks();
|
||||
|
||||
// Purge branch rooted at slot 2
|
||||
let mut descendants = bank_forks.read().unwrap().descendants();
|
||||
let mut descendants = bank_forks.read().unwrap().descendants().clone();
|
||||
let mut ancestors = bank_forks.read().unwrap().ancestors();
|
||||
let slot_2_descendants = descendants.get(&2).unwrap().clone();
|
||||
ReplayStage::purge_ancestors_descendants(
|
||||
@ -3770,7 +3770,7 @@ pub(crate) mod tests {
|
||||
.write()
|
||||
.unwrap()
|
||||
.set_root(3, &ABSRequestSender::default(), None);
|
||||
let mut descendants = bank_forks.read().unwrap().descendants();
|
||||
let mut descendants = bank_forks.read().unwrap().descendants().clone();
|
||||
let mut ancestors = bank_forks.read().unwrap().ancestors();
|
||||
let slot_3_descendants = descendants.get(&3).unwrap().clone();
|
||||
ReplayStage::purge_ancestors_descendants(
|
||||
|
@ -1587,7 +1587,7 @@ pub(crate) mod tests {
|
||||
.unwrap();
|
||||
|
||||
let next_bank = Bank::new_from_parent(
|
||||
&bank_forks.banks[&0].clone(),
|
||||
&bank_forks.get(0).unwrap().clone(),
|
||||
&solana_sdk::pubkey::new_rand(),
|
||||
1,
|
||||
);
|
||||
|
@ -217,7 +217,7 @@ impl Tvu {
|
||||
let (pruned_banks_sender, pruned_banks_receiver) = unbounded();
|
||||
|
||||
// Before replay starts, set the callbacks in each of the banks in BankForks
|
||||
for bank in bank_forks.read().unwrap().banks.values() {
|
||||
for bank in bank_forks.read().unwrap().banks().values() {
|
||||
bank.set_callback(Some(Box::new(SendDroppedBankCallback::new(
|
||||
pruned_banks_sender.clone(),
|
||||
))));
|
||||
|
Reference in New Issue
Block a user