Skip to content

Commit

Permalink
bank forks should track frozen forks too
Browse files Browse the repository at this point in the history
  • Loading branch information
aeyakovenko committed Feb 28, 2019
1 parent a5d8648 commit 007ff57
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
10 changes: 1 addition & 9 deletions src/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,8 @@ impl BankForks {

// TODO: use the bank's own ID instead of receiving a parameter
pub fn insert(&mut self, bank_id: u64, bank: Bank) {
let mut bank = Arc::new(bank);
let bank = Arc::new(bank);
self.banks.insert(bank_id, bank.clone());

// TODO: this really only needs to look at the first
// parent if we're always calling insert()
// when we construct a child bank
while let Some(parent) = bank.parent() {
self.banks.remove(&parent.id());
bank = parent;
}
}

pub fn set_working_bank_id(&mut self, bank_id: u64) {
Expand Down
3 changes: 2 additions & 1 deletion src/poh_recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ impl PohRecorder {
.count();
let e = if cnt > 0 {
debug!(
"flush_cache: {} {} sending: {}",
"flush_cache: bank_id: {} tick_height: {} max: {} sending: {}",
working_bank.bank.id(),
working_bank.bank.tick_height(),
working_bank.max_tick_height,
cnt,
Expand Down
15 changes: 13 additions & 2 deletions src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ impl ReplayStage {
"replicate-stage_failed_process_entries",
entries.len()
);
} else {
trace!("{} verify_and_process_entries passed", my_id);
}
}
} else {
Expand All @@ -163,6 +165,7 @@ impl ReplayStage {
if bank.tick_height() == max_tick_height {
trace!("{} frozen bank: {}", my_id, bank_id);
bank.freeze();
assert!(bank_forks.read().unwrap().frozen_banks().len() > 0);
votable.push(bank_id);
progress.remove(&bank_id);
}
Expand Down Expand Up @@ -198,8 +201,16 @@ impl ReplayStage {
cluster_info.write().unwrap().push_vote(vote);
}
if next_leader == my_id {
let tpu_bank = Bank::new_from_parent_and_id(&bank, my_id, next_slot);
bank_forks.write().unwrap().insert(next_slot, tpu_bank);
trace!("{} I am next_leader", my_id);
let mut wforks = bank_forks.write().unwrap();
let has_bank = wforks.get(next_slot).is_some();
if !has_bank {
let tpu_bank =
Bank::new_from_parent_and_id(&bank, my_id, next_slot);
trace!("{} I am next_leader, new_bank {}", my_id, tpu_bank.id());
wforks.insert(next_slot, tpu_bank);
wforks.set_working_bank_id(next_slot);
}
}
// Always send rotation signal so that other services like
// RPC can be made aware of last slot's bank
Expand Down

0 comments on commit 007ff57

Please sign in to comment.