Skip to content

Commit bfa941e

Browse files
author
Aaron Blankstein
authored
Merge pull request #3610 from stacks-network/fix/chain-liveness-poll
Fix: reduce chain-liveness poll frequency
2 parents 1ebd2a0 + 6ccadda commit bfa941e

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1212
- Handle the case where a bitcoin node returns zero headers (#3588)
1313
- The default value for `always_use_affirmation_maps` is now set to `false`,
1414
instead of `true`. This was preventing testnet nodes from reaching the chain
15-
tip with the default configuration.
15+
tip with the default configuration.
16+
- Reduce default poll time of the `chain-liveness` thread which reduces the
17+
possibility that a miner thread will get interrupted (#3610).
1618

1719
## [2.1]
1820

testnet/stacks-node/src/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,9 @@ impl Config {
665665
// chainstate fault_injection activation for hide_blocks.
666666
// you can't set this in the config file.
667667
fault_injection_hide_blocks: false,
668+
chain_liveness_poll_time_secs: node
669+
.chain_liveness_poll_time_secs
670+
.unwrap_or(default_node_config.chain_liveness_poll_time_secs),
668671
};
669672
(node_config, node.bootstrap_node, node.deny_nodes)
670673
}
@@ -1450,6 +1453,9 @@ pub struct NodeConfig {
14501453
// fault injection for hiding blocks.
14511454
// not part of the config file.
14521455
pub fault_injection_hide_blocks: bool,
1456+
/// At most, how often should the chain-liveness thread
1457+
/// wake up the chains-coordinator. Defaults to 300s (5 min).
1458+
pub chain_liveness_poll_time_secs: u64,
14531459
}
14541460

14551461
#[derive(Clone, Debug)]
@@ -1727,6 +1733,7 @@ impl NodeConfig {
17271733
always_use_affirmation_maps: false,
17281734
require_affirmed_anchor_blocks: true,
17291735
fault_injection_hide_blocks: false,
1736+
chain_liveness_poll_time_secs: 300,
17301737
}
17311738
}
17321739

@@ -1928,6 +1935,9 @@ pub struct NodeConfigFile {
19281935
pub use_test_genesis_chainstate: Option<bool>,
19291936
pub always_use_affirmation_maps: Option<bool>,
19301937
pub require_affirmed_anchor_blocks: Option<bool>,
1938+
/// At most, how often should the chain-liveness thread
1939+
/// wake up the chains-coordinator. Defaults to 300s (5 min).
1940+
pub chain_liveness_poll_time_secs: Option<u64>,
19311941
}
19321942

19331943
#[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)