Skip to content

Commit 77c0125

Browse files
lexnvgithub-actions[bot]eduardspaskunertsandreim
authored
aura/slot_based: Reduce authoring duration of the last produced block (#10154)
This PR adjusts the block authoring to stop producing blocks 1 second before the scheduled slot change. This introduces a safety buffer to prevent blocks from being authored too late for inclusion. - 2s blocks / 3 cores: The authoring duration of the last block is reduced from 2s to 1s. - 500ms blocks / 12 cores: The authoring duration cannot be reduced past 500ms, therefore the last two blocks are no longer authored ### Testing Done Tested on top of: - #9880 ### 3 cores 2s blocks ``` aura::cumulus: [Parachain] Adjusting authoring duration for slot. authoring_duration=2s duration=1.987s last_reported_slot=Some(Slot(293723040)) next_slot=Slot(293723040) next_duration_change=5.987s next_slot_change=Slot(293723041) aura::cumulus: [Parachain] Adjusted proposal duration. duration=Some(1.987s) aura::cumulus: [Parachain] Adjusting authoring duration for slot. authoring_duration=2s duration=1.991s last_reported_slot=Some(Slot(293723040)) next_slot=Slot(293723040) next_duration_change=3.991s next_slot_change=Slot(293723041) aura::cumulus: [Parachain] Adjusted proposal duration. duration=Some(1.991s) aura::cumulus: [Parachain] Adjusting authoring duration for slot. authoring_duration=2s duration=1.99s last_reported_slot=Some(Slot(293723040)) next_slot=Slot(293723041) next_duration_change=1.99s next_slot_change=Slot(293723041) aura::cumulus: [Parachain] Adjusted proposal duration. duration=Some(990ms) ``` ### 12 cores 500ms blocks ``` aura::cumulus: [Parachain] Adjusting authoring duration for slot. authoring_duration=2s duration=494ms last_reported_slot=Some(Slot(293724134)) next_slot=Slot(293724134) next_duration_change=1.494s next_slot_change=Slot(293724135) deadline=494ms aura::cumulus: [Parachain] Adjusted proposal duration. duration=Some(494ms) aura::cumulus: [Parachain] Adjusting authoring duration for slot. authoring_duration=2s duration=493ms last_reported_slot=Some(Slot(293724134)) next_slot=Slot(293724134) next_duration_change=993ms next_slot_change=Slot(293724135) deadline=0ns aura::cumulus: [Parachain] Not enough time left in the slot to adjust authoring duration. Skipping block production for the slot. next_duration_change=993ms next_slot_change=Slot(293724135) aura::cumulus: [Parachain] Adjusted proposal duration. duration=None aura::cumulus: [Parachain] Not building block due to insufficient authoring duration aura::cumulus: [Parachain] Adjusting authoring duration for slot. authoring_duration=2s duration=494ms last_reported_slot=Some(Slot(293724136)) next_slot=Slot(293724137) next_duration_change=494ms next_slot_change=Slot(293724137) deadline=0ns aura::cumulus: [Parachain] Not enough time left in the slot to adjust authoring duration. Skipping block production for the slot. next_duration_change=494ms next_slot_change=Slot(293724137) aura::cumulus: [Parachain] Adjusted proposal duration. duration=None aura::cumulus: [Parachain] Not building block due to insufficient authoring duration ``` Part of: #9848 --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: eduardspa <eduard@parity.io> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
1 parent d38ac65 commit 77c0125

File tree

3 files changed

+401
-18
lines changed

3 files changed

+401
-18
lines changed

cumulus/client/consensus/aura/src/collators/slot_based/block_builder_task.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,26 @@ where
404404
validation_data.max_pov_size * 85 / 100
405405
} as usize;
406406

407-
let adjusted_authoring_duration = match slot_timer.time_until_next_slot() {
408-
Ok((duration, _slot)) => std::cmp::min(authoring_duration, duration),
409-
Err(_) => authoring_duration,
410-
};
411-
407+
let adjusted_authoring_duration =
408+
slot_timer.adjust_authoring_duration(authoring_duration);
412409
tracing::debug!(target: crate::LOG_TARGET, duration = ?adjusted_authoring_duration, "Adjusted proposal duration.");
413410

411+
let Some(adjusted_authoring_duration) = adjusted_authoring_duration else {
412+
tracing::debug!(
413+
target: crate::LOG_TARGET,
414+
unincluded_segment_len = parent.depth,
415+
relay_parent = ?relay_parent,
416+
relay_parent_num = %relay_parent_header.number(),
417+
included_hash = ?included_header_hash,
418+
included_num = %included_header.number(),
419+
parent = ?parent_hash,
420+
slot = ?para_slot.slot,
421+
"Not building block due to insufficient authoring duration."
422+
);
423+
424+
continue;
425+
};
426+
414427
let Ok(Some(candidate)) = collator
415428
.build_block_and_import(
416429
&parent_header,

0 commit comments

Comments
 (0)