@@ -539,17 +539,32 @@ where
539539 let mut mev_timing: Option < author:: TimeParams > = None ;
540540
541541 if role. is_authority ( ) {
542- let slot_duration_ms: u64 = consensus_mechanism. slot_duration ( & client) ?. as_millis ( ) as u64 ;
542+ let slot_duration = consensus_mechanism. slot_duration ( & client) ?;
543+ let slot_duration_ms: u64 =
544+ u64:: try_from ( slot_duration. as_millis ( ) ) . unwrap_or ( u64:: MAX ) ;
545+
546+ // For 12s blocks: announce ≈ 7s, decrypt window ≈ 3s.
547+ // For 250ms blocks: announce ≈ 145ms, decrypt window ≈ 62ms, etc.
548+ let announce_at_ms_raw = slot_duration_ms
549+ . saturating_mul ( 7 )
550+ . saturating_div ( 12 ) ;
551+
552+ let decrypt_window_ms = slot_duration_ms
553+ . saturating_mul ( 3 )
554+ . saturating_div ( 12 ) ;
555+
556+ // Ensure announce_at_ms + decrypt_window_ms never exceeds slot_ms.
557+ let max_announce = slot_duration_ms. saturating_sub ( decrypt_window_ms) ;
558+ let announce_at_ms = announce_at_ms_raw. min ( max_announce) ;
543559
544- // Time windows (7s announce / last 3s decrypt).
545560 let timing = author:: TimeParams {
546561 slot_ms : slot_duration_ms,
547- announce_at_ms : 7_000 ,
548- decrypt_window_ms : 3_000 ,
562+ announce_at_ms,
563+ decrypt_window_ms,
549564 } ;
550565 mev_timing = Some ( timing. clone ( ) ) ;
551566
552- // Start author-side tasks with the epoch .
567+ // Start author-side tasks with dynamic timing .
553568 let mev_ctx = author:: spawn_author_tasks :: < Block , _ , _ > (
554569 & task_manager. spawn_handle ( ) ,
555570 client. clone ( ) ,
@@ -558,7 +573,7 @@ where
558573 timing. clone ( ) ,
559574 ) ;
560575
561- // Start last-3s revealer (decrypt -> execute_revealed).
576+ // Start last-portion-of-slot revealer (decrypt -> execute_revealed).
562577 proposer:: spawn_revealer :: < Block , _ , _ > (
563578 & task_manager. spawn_handle ( ) ,
564579 client. clone ( ) ,
0 commit comments