diff --git a/testnet/stacks-node/src/config.rs b/testnet/stacks-node/src/config.rs index 65eea9134..ad0234134 100644 --- a/testnet/stacks-node/src/config.rs +++ b/testnet/stacks-node/src/config.rs @@ -1795,6 +1795,13 @@ pub struct NodeConfig { pub max_microblocks: u64, pub wait_time_for_microblocks: u64, pub wait_time_for_blocks: u64, + /// Controls how frequently, in milliseconds, the nakamoto miner's relay thread acts on its own initiative + /// (as opposed to responding to an event from the networking thread, etc.). This is roughly + /// how frequently the miner checks if a new burnchain block has been processed. + /// + /// Default value of 10 seconds is reasonable in mainnet (where bitcoin blocks are ~10 minutes), + /// but environments where burn blocks are more frequent may want to decrease this value. + pub next_initiative_delay: u64, pub prometheus_bind: Option, pub marf_cache_strategy: Option, pub marf_defer_hashing: bool, @@ -2080,6 +2087,7 @@ impl Default for NodeConfig { max_microblocks: u16::MAX as u64, wait_time_for_microblocks: 30_000, wait_time_for_blocks: 30_000, + next_initiative_delay: 10_000, prometheus_bind: None, marf_cache_strategy: None, marf_defer_hashing: true, @@ -2530,6 +2538,7 @@ pub struct NodeConfigFile { pub max_microblocks: Option, pub wait_time_for_microblocks: Option, pub wait_time_for_blocks: Option, + pub next_initiative_delay: Option, pub prometheus_bind: Option, pub marf_cache_strategy: Option, pub marf_defer_hashing: Option, @@ -2590,6 +2599,9 @@ impl NodeConfigFile { wait_time_for_blocks: self .wait_time_for_blocks .unwrap_or(default_node_config.wait_time_for_blocks), + next_initiative_delay: self + .next_initiative_delay + .unwrap_or(default_node_config.next_initiative_delay), prometheus_bind: self.prometheus_bind, marf_cache_strategy: self.marf_cache_strategy, marf_defer_hashing: self diff --git a/testnet/stacks-node/src/nakamoto_node/relayer.rs b/testnet/stacks-node/src/nakamoto_node/relayer.rs index c337418fa..fc4ca1ae0 100644 --- a/testnet/stacks-node/src/nakamoto_node/relayer.rs +++ b/testnet/stacks-node/src/nakamoto_node/relayer.rs @@ -190,8 +190,10 @@ impl RelayerThread { let bitcoin_controller = BitcoinRegtestController::new_dummy(config.clone()); + let next_initiative_delay = config.node.next_initiative_delay; + RelayerThread { - config: config, + config, sortdb, chainstate, mempool, @@ -215,7 +217,7 @@ impl RelayerThread { miner_thread: None, is_miner, - next_initiative: Instant::now() + Duration::from_secs(10), + next_initiative: Instant::now() + Duration::from_millis(next_initiative_delay), last_committed: None, } } @@ -819,10 +821,12 @@ impl RelayerThread { pub fn main(mut self, relay_rcv: Receiver) { debug!("relayer thread ID is {:?}", std::thread::current().id()); - self.next_initiative = Instant::now() + Duration::from_secs(10); + self.next_initiative = + Instant::now() + Duration::from_millis(self.config.node.next_initiative_delay); while self.globals.keep_running() { let directive = if Instant::now() >= self.next_initiative { - self.next_initiative = Instant::now() + Duration::from_secs(10); + self.next_initiative = + Instant::now() + Duration::from_millis(self.config.node.next_initiative_delay); self.initiative() } else { None