Skip to content

Commit

Permalink
log leader (#10316)
Browse files Browse the repository at this point in the history
automerge
  • Loading branch information
carllin authored May 29, 2020
1 parent 8db3447 commit bc37dfc
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,8 @@ impl Blockstore {
&mut index_meta_time,
is_trusted,
handle_duplicate,
leader_schedule,
false,
) {
num_inserted += 1;
}
Expand Down Expand Up @@ -901,6 +903,8 @@ impl Blockstore {
&mut index_meta_time,
is_trusted,
&handle_duplicate,
leader_schedule,
true,
);
}
}
Expand Down Expand Up @@ -1113,6 +1117,8 @@ impl Blockstore {
index_meta_time: &mut u64,
is_trusted: bool,
handle_duplicate: &F,
leader_schedule: Option<&Arc<LeaderScheduleCache>>,
is_recovered: bool,
) -> bool
where
F: Fn(Shred) -> (),
Expand All @@ -1133,7 +1139,13 @@ impl Blockstore {
if Self::is_data_shred_present(&shred, slot_meta, &index_meta.data()) {
handle_duplicate(shred);
return false;
} else if !Blockstore::should_insert_data_shred(&shred, slot_meta, &self.last_root) {
} else if !Blockstore::should_insert_data_shred(
&shred,
slot_meta,
&self.last_root,
leader_schedule,
is_recovered,
) {
return false;
}
}
Expand Down Expand Up @@ -1211,6 +1223,8 @@ impl Blockstore {
shred: &Shred,
slot_meta: &SlotMeta,
last_root: &RwLock<u64>,
leader_schedule: Option<&Arc<LeaderScheduleCache>>,
is_recovered: bool,
) -> bool {
let shred_index = u64::from(shred.index());
let slot = shred.slot();
Expand All @@ -1225,13 +1239,16 @@ impl Blockstore {
// for the slot
let last_index = slot_meta.last_index;
if shred_index >= last_index {
let leader_pubkey = leader_schedule
.map(|leader_schedule| leader_schedule.slot_leader_at(slot, None))
.unwrap_or(None);
datapoint_error!(
"blockstore_error",
(
"error",
format!(
"Slot {}: received index {} >= slot.last_index {}",
slot, shred_index, last_index
"Leader {:?}, slot {}: received index {} >= slot.last_index {}, is_recovered: {}",
leader_pubkey, slot, shred_index, last_index, is_recovered
),
String
)
Expand All @@ -1241,13 +1258,16 @@ impl Blockstore {
// Check that we do not receive a shred with "last_index" true, but shred_index
// less than our current received
if last_in_slot && shred_index < slot_meta.received {
let leader_pubkey = leader_schedule
.map(|leader_schedule| leader_schedule.slot_leader_at(slot, None))
.unwrap_or(None);
datapoint_error!(
"blockstore_error",
(
"error",
format!(
"Slot {}: received shred_index {} < slot.received {}",
slot, shred_index, slot_meta.received
"Leader {:?}, slot {}: received shred_index {} < slot.received {}, is_recovered: {}",
leader_pubkey, slot, shred_index, slot_meta.received, is_recovered
),
String
)
Expand Down Expand Up @@ -4720,7 +4740,7 @@ pub mod tests {
}
};
assert_eq!(
Blockstore::should_insert_data_shred(&shred7, &slot_meta, &last_root),
Blockstore::should_insert_data_shred(&shred7, &slot_meta, &last_root, None, false),
false
);

Expand All @@ -4736,7 +4756,7 @@ pub mod tests {
panic!("Shred in unexpected format")
}
assert_eq!(
Blockstore::should_insert_data_shred(&shred7, &slot_meta, &last_root),
Blockstore::should_insert_data_shred(&shred7, &slot_meta, &last_root, None, false),
false
);
}
Expand Down

0 comments on commit bc37dfc

Please sign in to comment.