From 9dab75ece760c050838b1b97e375f10ffa9a2942 Mon Sep 17 00:00:00 2001 From: dylan Date: Fri, 21 Nov 2025 10:17:58 -0700 Subject: [PATCH 1/3] fix: make block query cutoff properly configurable --- src/config.rs | 8 ++++++++ src/tasks/block/sim.rs | 2 +- src/test_utils.rs | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 0197568..9251609 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_SECS", + desc = "Number of seconds before the end of the slot to stop querying for new blocks", + default = 2 + )] + pub block_query_cutoff_secs: 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..6669c87 100644 --- a/src/tasks/block/sim.rs +++ b/src/tasks/block/sim.rs @@ -253,7 +253,7 @@ 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_secs); 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..6ae7bf8 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_secs: 2, max_host_gas_coefficient: Some(80), constants: SignetSystemConstants::pecorino(), }; From de9d74e616e4a280ee00db6b5a60157812738665 Mon Sep 17 00:00:00 2001 From: dylan Date: Fri, 21 Nov 2025 10:33:33 -0700 Subject: [PATCH 2/3] fmt --- src/config.rs | 2 +- src/tasks/block/sim.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 9251609..d453ddc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -157,7 +157,7 @@ pub struct BuilderConfig { /// Number of seconds before the end of the slot to stop querying for new blocks #[from_env( - var ="BLOCK_QUERY_CUTOFF_SECS", + var = "BLOCK_QUERY_CUTOFF_SECS", desc = "Number of seconds before the end of the slot to stop querying for new blocks", default = 2 )] diff --git a/src/tasks/block/sim.rs b/src/tasks/block/sim.rs index 6669c87..d28f930 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(self.config.block_query_cutoff_secs); + let remaining = (self.slot_calculator().slot_duration() - timepoint) + .saturating_sub(self.config.block_query_cutoff_secs); let deadline = Instant::now() + Duration::from_secs(remaining); deadline.max(Instant::now()) From aa0fb986fca640dc0974114c91541836f960b48a Mon Sep 17 00:00:00 2001 From: dylan Date: Fri, 21 Nov 2025 10:43:03 -0700 Subject: [PATCH 3/3] refactor: secs -> buffer --- src/config.rs | 4 ++-- src/tasks/block/sim.rs | 2 +- src/test_utils.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index d453ddc..9c40760 100644 --- a/src/config.rs +++ b/src/config.rs @@ -157,11 +157,11 @@ pub struct BuilderConfig { /// Number of seconds before the end of the slot to stop querying for new blocks #[from_env( - var = "BLOCK_QUERY_CUTOFF_SECS", + 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_secs: u64, + 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 d28f930..63b7641 100644 --- a/src/tasks/block/sim.rs +++ b/src/tasks/block/sim.rs @@ -254,7 +254,7 @@ impl Simulator { // 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(self.config.block_query_cutoff_secs); + .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 6ae7bf8..636fe86 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -53,7 +53,7 @@ pub fn setup_test_config() -> Result { 1740681556, // pecorino start timestamp as sane default 0, 1, ), - block_query_cutoff_secs: 2, + block_query_cutoff_buffer: 2, max_host_gas_coefficient: Some(80), constants: SignetSystemConstants::pecorino(), };