Start replay stage from the slot-relative blob index, not the global entry height

This commit is contained in:
Carl 2019-02-24 04:37:11 -08:00 committed by Grimes
parent c13ae10d31
commit 0b37f530ae
4 changed files with 15 additions and 2 deletions

View File

@ -123,6 +123,7 @@ pub struct BankForksInfo {
pub bank_id: u64,
pub entry_height: u64,
pub last_entry_id: Hash,
pub next_blob_index: u64,
}
pub fn process_blocktree(
@ -166,7 +167,6 @@ pub fn process_blocktree(
BankError::LedgerVerificationFailed
})?
.unwrap();
trace!("processing slot {:?}, meta={:?}", slot, meta);
// Fetch all entries for this slot
let mut entries = blocktree.get_slot_entries(slot, 0, None).map_err(|err| {
@ -210,11 +210,19 @@ pub fn process_blocktree(
match meta.next_slots.len() {
0 => {
let next_blob_index = {
if meta.is_full() {
0
} else {
meta.consumed
}
};
// Reached the end of this fork. Record the final entry height and last entry id
bank_forks_info.push(BankForksInfo {
bank_id,
entry_height,
last_entry_id,
next_blob_index,
})
}
1 => pending_slots.push((meta.next_slots[0], bank_id, entry_height, last_entry_id)),
@ -328,6 +336,7 @@ mod tests {
bank_id: 2, // Fork 1 diverged with slot 2
entry_height: ticks_per_slot * 4,
last_entry_id: last_fork1_entry_id,
next_blob_index: 0,
}
);
assert_eq!(
@ -336,6 +345,7 @@ mod tests {
bank_id: 4, // Fork 2 diverged with slot 4
entry_height: ticks_per_slot * 3,
last_entry_id: last_fork2_entry_id,
next_blob_index: 0,
}
);
@ -454,6 +464,7 @@ mod tests {
bank_id: 0,
entry_height,
last_entry_id,
next_blob_index: entry_height,
}
);

View File

@ -201,7 +201,7 @@ impl ReplayStage {
bank,
tick_height,
bank_forks_info[0].last_entry_id,
bank_forks_info[0].entry_height,
bank_forks_info[0].next_blob_index,
)
};

View File

@ -226,6 +226,7 @@ pub mod tests {
bank_id: 0,
entry_height: 0,
last_entry_id: Hash::default(),
next_blob_index: 0,
}];
let leader_scheduler = LeaderScheduler::new_with_bank(&bank_forks.working_bank());
let leader_scheduler = Arc::new(RwLock::new(leader_scheduler));

View File

@ -90,6 +90,7 @@ fn test_replay() {
bank_id: 0,
entry_height: 0,
last_entry_id: cur_hash,
next_blob_index: 0,
}];
let bank = bank_forks.working_bank();