diff --git a/src/config.rs b/src/config.rs index 0197568..9c40760 100644 --- a/src/config.rs +++ b/src/config.rs @@ -155,6 +155,14 @@ pub struct BuilderConfig { )] pub max_host_gas_coefficient: Option, + /// Number of seconds before the end of the slot to stop querying for new blocks + #[from_env( + var = "BLOCK_QUERY_CUTOFF_BUFFER", + desc = "Number of seconds before the end of the slot to stop querying for new blocks", + default = 2 + )] + pub block_query_cutoff_buffer: u64, + /// The slot calculator for the builder. pub slot_calculator: SlotCalculator, diff --git a/src/tasks/block/sim.rs b/src/tasks/block/sim.rs index a294538..63b7641 100644 --- a/src/tasks/block/sim.rs +++ b/src/tasks/block/sim.rs @@ -253,7 +253,8 @@ impl Simulator { // We have the timepoint in seconds into the slot. To find out what's // remaining, we need to subtract it from the slot duration // we also subtract 3 seconds to account for the sequencer stopping signing. - let remaining = (self.slot_calculator().slot_duration() - timepoint).saturating_sub(3); + let remaining = (self.slot_calculator().slot_duration() - timepoint) + .saturating_sub(self.config.block_query_cutoff_buffer); let deadline = Instant::now() + Duration::from_secs(remaining); deadline.max(Instant::now()) diff --git a/src/test_utils.rs b/src/test_utils.rs index c5c5ef4..636fe86 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -53,6 +53,7 @@ pub fn setup_test_config() -> Result { 1740681556, // pecorino start timestamp as sane default 0, 1, ), + block_query_cutoff_buffer: 2, max_host_gas_coefficient: Some(80), constants: SignetSystemConstants::pecorino(), };