From 7996a77ffd58b3b3c0e502e17177ce8f8d542e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Sat, 19 Jun 2021 16:16:40 +0100 Subject: [PATCH] slots: log the actual proposing duration after lenience is applied --- client/consensus/slots/src/lib.rs | 35 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index c802e3527f5f0..1ec89a6f519af 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -725,27 +725,32 @@ pub fn proposing_remaining_duration( }; if let Some(slot_lenience) = slot_lenience { + let lenient_proposing_duration = + proposing_duration + slot_lenience.mul_f32(block_proposal_slot_portion.get()); + + // if we defined a maximum portion of the slot for proposal then we must make sure the + // lenience doesn't go over it + let lenient_proposing_duration = + if let Some(ref max_block_proposal_slot_portion) = max_block_proposal_slot_portion { + std::cmp::min( + lenient_proposing_duration, + slot_info + .duration + .mul_f32(max_block_proposal_slot_portion.get()), + ) + } else { + lenient_proposing_duration + }; + debug!( target: log_target, - "No block for {} slots. Applying {} lenience of {}s", + "No block for {} slots. Applying {} lenience, total proposing duration: {}", slot_info.slot.saturating_sub(parent_slot + 1), slot_lenience_type.as_str(), - slot_lenience.as_secs(), + lenient_proposing_duration.as_secs(), ); - let lenient_proposing_duration = - proposing_duration + (slot_lenience.mul_f32(block_proposal_slot_portion.get())); - - // if we defined a maximum portion of the slot for proposal then we must make sure the - // lenience doesn't go over it - if let Some(ref max_block_proposal_slot_portion) = max_block_proposal_slot_portion { - std::cmp::min( - lenient_proposing_duration, - slot_info.duration.mul_f32(max_block_proposal_slot_portion.get()), - ) - } else { - lenient_proposing_duration - } + lenient_proposing_duration } else { proposing_duration }