File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -158,8 +158,8 @@ pub struct BuilderConfig {
158158 /// Number of seconds before the end of the slot to stop querying for new blocks
159159 #[ from_env(
160160 var = "BLOCK_QUERY_CUTOFF_BUFFER" ,
161- desc = "Number of seconds before the end of the slot to stop querying for new blocks" ,
162- default = 2
161+ desc = "Number of milliseconds before the end of the slot to stop querying for new blocks" ,
162+ default = 3000
163163 ) ]
164164 pub block_query_cutoff_buffer : u64 ,
165165
Original file line number Diff line number Diff line change @@ -249,14 +249,16 @@ impl Simulator {
249249 // Get the current timepoint within the slot.
250250 let timepoint =
251251 self . slot_calculator ( ) . current_point_within_slot ( ) . expect ( "host chain has started" ) ;
252-
253- // We have the timepoint in seconds into the slot. To find out what's
254- // remaining, we need to subtract it from the slot duration
255- // we also subtract 3 seconds to account for the sequencer stopping signing.
256- let remaining = ( self . slot_calculator ( ) . slot_duration ( ) - timepoint)
257- . saturating_sub ( self . config . block_query_cutoff_buffer ) ;
258-
259- let deadline = Instant :: now ( ) + Duration :: from_secs ( remaining) ;
252+ // To find the remaining slot time, subtract the timepoint from the slot duration.
253+ let slot_duration = Duration :: from_secs ( self . slot_calculator ( ) . slot_duration ( ) ) ;
254+ let elapsed_in_slot = Duration :: from_secs ( timepoint) ;
255+ // Then subtract the block query cutoff buffer from the slot duration to account for
256+ // the sequencer stopping signing.
257+ let query_cutoff_buffer = Duration :: from_millis ( self . config . block_query_cutoff_buffer ) ;
258+ let remaining =
259+ slot_duration. saturating_sub ( elapsed_in_slot) . saturating_sub ( query_cutoff_buffer) ;
260+ // The deadline is then calculated by adding the remaining time from this instant.
261+ let deadline = Instant :: now ( ) + remaining;
260262 deadline. max ( Instant :: now ( ) )
261263 }
262264}
You can’t perform that action at this time.
0 commit comments