Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Fix blocktree processor tick check
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Oct 25, 2019
1 parent e1fa7dd commit fad6bda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions ledger/src/blocktree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,11 +774,12 @@ impl Blocktree {
keypair: &Arc<Keypair>,
entries: Vec<Entry>,
) -> Result<usize> {
assert!(num_ticks_in_start_slot < ticks_per_slot);
let mut remaining_ticks_in_slot = ticks_per_slot - num_ticks_in_start_slot;
let mut parent_slot = parent.map_or(start_slot.saturating_sub(1), |v| v);
let num_slots = (start_slot - parent_slot).max(1); // Note: slot 0 has parent slot 0
assert!(num_ticks_in_start_slot < num_slots * ticks_per_slot);
let mut remaining_ticks_in_slot = num_slots * ticks_per_slot - num_ticks_in_start_slot;

let mut current_slot = start_slot;
let mut parent_slot = parent.map_or(current_slot.saturating_sub(1), |v| v);
let mut shredder = Shredder::new(current_slot, parent_slot, 0.0, keypair.clone())
.expect("Failed to create entry shredder");
let mut all_shreds = vec![];
Expand Down
7 changes: 5 additions & 2 deletions ledger/src/blocktree_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ fn verify_and_process_slot_entries(
assert!(!entries.is_empty());

if opts.verify_ledger {
if bank.ticks_per_slot() != entries.tick_count() {
let next_bank_tick_height = bank.tick_height() + entries.tick_count();
let max_bank_tick_height = bank.max_tick_height();
if next_bank_tick_height != max_bank_tick_height {
warn!(
"Invalid number of entry ticks found in slot: {}",
bank.slot()
Expand Down Expand Up @@ -491,7 +493,8 @@ pub fn fill_blocktree_slot_with_ticks(
parent_slot: u64,
last_entry_hash: Hash,
) -> Hash {
let entries = create_ticks(ticks_per_slot, 0, last_entry_hash);
let num_slots = (slot - parent_slot).max(1); // Note: slot 0 has parent slot 0
let entries = create_ticks(num_slots * ticks_per_slot, 0, last_entry_hash);
let last_entry_hash = entries.last().unwrap().hash;

blocktree
Expand Down

0 comments on commit fad6bda

Please sign in to comment.