From 1bbb9d25fa79510903e68763aa668e447bb969f9 Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 5 Mar 2026 16:36:43 +0100 Subject: [PATCH] refactor(node): bundle set_with_head and set_backfill_thresholds into configure_notifications The two calls were always paired across 4 call sites in set_exex_head. Bundling them into a single helper eliminates the risk of forgetting to pair them when adding new code paths. ENG-1959 Co-Authored-By: Claude Opus 4.6 --- crates/node/src/node.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/node/src/node.rs b/crates/node/src/node.rs index 4b5ac4f..fa59746 100644 --- a/crates/node/src/node.rs +++ b/crates/node/src/node.rs @@ -242,8 +242,7 @@ where match host_deployment_block { Some(genesis_block) => { let exex_head = ExExHead { block: genesis_block.num_hash_slow() }; - self.host.notifications.set_with_head(exex_head); - self.set_backfill_thresholds(); + self.configure_notifications(exex_head); return Ok(exex_head); } None => { @@ -256,8 +255,7 @@ where match genesis_block { Some(genesis_block) => { let exex_head = ExExHead { block: genesis_block.num_hash_slow() }; - self.host.notifications.set_with_head(exex_head); - self.set_backfill_thresholds(); + self.configure_notifications(exex_head); return Ok(exex_head); } None => panic!("failed to find genesis block"), @@ -275,8 +273,7 @@ where Some(host_block) => { debug!(host_height, "found host block for height"); let exex_head = ExExHead { block: host_block.num_hash_slow() }; - self.host.notifications.set_with_head(exex_head); - self.set_backfill_thresholds(); + self.configure_notifications(exex_head); Ok(exex_head) } None => { @@ -285,8 +282,7 @@ where match genesis_block { Some(genesis_block) => { let exex_head = ExExHead { block: genesis_block.num_hash_slow() }; - self.host.notifications.set_with_head(exex_head); - self.set_backfill_thresholds(); + self.configure_notifications(exex_head); Ok(exex_head) } None => panic!("failed to find genesis block"), @@ -295,10 +291,11 @@ where } } - /// Sets backfill thresholds to limit memory usage during sync. - /// This should be called after `set_with_head` to configure how many - /// blocks can be processed per backfill batch. - fn set_backfill_thresholds(&mut self) { + /// Configures the ExEx notification stream with the given head and + /// backfill thresholds from the node config. + fn configure_notifications(&mut self, exex_head: ExExHead) { + self.host.notifications.set_with_head(exex_head); + let max_blocks = self.config.backfill_max_blocks(); let max_duration = self.config.backfill_max_duration(); self.host.notifications.set_backfill_thresholds(ExecutionStageThresholds {