Skip to content

Commit 259a35a

Browse files
author
Aaron Blankstein
committed
fix: reduce chain-liveness poll frequency
1 parent c1a2c2e commit 259a35a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

testnet/stacks-node/src/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,9 @@ impl Config {
670670
// chainstate fault_injection activation for hide_blocks.
671671
// you can't set this in the config file.
672672
fault_injection_hide_blocks: false,
673+
chain_liveness_poll_time_secs: node
674+
.chain_liveness_poll_time_secs
675+
.unwrap_or(default_node_config.chain_liveness_poll_time_secs),
673676
};
674677
(node_config, node.bootstrap_node, node.deny_nodes)
675678
}
@@ -1455,6 +1458,9 @@ pub struct NodeConfig {
14551458
// fault injection for hiding blocks.
14561459
// not part of the config file.
14571460
pub fault_injection_hide_blocks: bool,
1461+
/// At most, how often should the chain-liveness thread
1462+
/// wake up the chains-coordinator. Defaults to 300s (5 min).
1463+
pub chain_liveness_poll_time_secs: u64,
14581464
}
14591465

14601466
#[derive(Clone, Debug)]
@@ -1732,6 +1738,7 @@ impl NodeConfig {
17321738
always_use_affirmation_maps: false,
17331739
require_affirmed_anchor_blocks: true,
17341740
fault_injection_hide_blocks: false,
1741+
chain_liveness_poll_time_secs: 300,
17351742
}
17361743
}
17371744

@@ -1933,6 +1940,9 @@ pub struct NodeConfigFile {
19331940
pub use_test_genesis_chainstate: Option<bool>,
19341941
pub always_use_affirmation_maps: Option<bool>,
19351942
pub require_affirmed_anchor_blocks: Option<bool>,
1943+
/// At most, how often should the chain-liveness thread
1944+
/// wake up the chains-coordinator. Defaults to 300s (5 min).
1945+
pub chain_liveness_poll_time_secs: Option<u64>,
19361946
}
19371947

19381948
#[derive(Clone, Deserialize, Debug)]

testnet/stacks-node/src/run_loop/neon.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl RunLoop {
629629
last_stacks_pox_reorg_recover_time: &mut u128,
630630
) {
631631
let delay = cmp::max(
632-
1,
632+
config.node.chain_liveness_poll_time_secs,
633633
cmp::max(
634634
config.miner.first_attempt_time_ms,
635635
config.miner.subsequent_attempt_time_ms,
@@ -724,7 +724,9 @@ impl RunLoop {
724724
&stacks_tip_affirmation_map, &heaviest_affirmation_map
725725
);
726726

727-
// do it anyway since it's harmless
727+
// announce a new stacks block to force the chains coordinator
728+
// to wake up anyways. this isn't free, so we have to make sure
729+
// the chain-liveness thread doesn't wake up too often
728730
globals.coord().announce_new_stacks_block();
729731
}
730732

@@ -747,7 +749,7 @@ impl RunLoop {
747749
last_announce_time: &mut u128,
748750
) {
749751
let delay = cmp::max(
750-
1,
752+
config.node.chain_liveness_poll_time_secs,
751753
cmp::max(
752754
config.miner.first_attempt_time_ms,
753755
config.miner.subsequent_attempt_time_ms,

0 commit comments

Comments
 (0)