Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: reduce chain-liveness poll frequency #3610

Merged
merged 2 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
- Handle the case where a bitcoin node returns zero headers (#3588)
- The default value for `always_use_affirmation_maps` is now set to `false`,
instead of `true`. This was preventing testnet nodes from reaching the chain
tip with the default configuration.
tip with the default configuration.
- Reduce default poll time of the `chain-liveness` thread which reduces the
possibility that a miner thread will get interrupted (#3610).

## [2.1]

Expand Down
10 changes: 10 additions & 0 deletions testnet/stacks-node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,9 @@ impl Config {
// chainstate fault_injection activation for hide_blocks.
// you can't set this in the config file.
fault_injection_hide_blocks: false,
chain_liveness_poll_time_secs: node
.chain_liveness_poll_time_secs
.unwrap_or(default_node_config.chain_liveness_poll_time_secs),
};
(node_config, node.bootstrap_node, node.deny_nodes)
}
Expand Down Expand Up @@ -1450,6 +1453,9 @@ pub struct NodeConfig {
// fault injection for hiding blocks.
// not part of the config file.
pub fault_injection_hide_blocks: bool,
/// At most, how often should the chain-liveness thread
/// wake up the chains-coordinator. Defaults to 300s (5 min).
pub chain_liveness_poll_time_secs: u64,
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -1727,6 +1733,7 @@ impl NodeConfig {
always_use_affirmation_maps: false,
require_affirmed_anchor_blocks: true,
fault_injection_hide_blocks: false,
chain_liveness_poll_time_secs: 300,
}
}

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

#[derive(Clone, Deserialize, Debug)]
Expand Down
8 changes: 5 additions & 3 deletions testnet/stacks-node/src/run_loop/neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ impl RunLoop {
last_stacks_pox_reorg_recover_time: &mut u128,
) {
let delay = cmp::max(
1,
config.node.chain_liveness_poll_time_secs,
cmp::max(
config.miner.first_attempt_time_ms,
config.miner.subsequent_attempt_time_ms,
Expand Down Expand Up @@ -724,7 +724,9 @@ impl RunLoop {
&stacks_tip_affirmation_map, &heaviest_affirmation_map
);

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

Expand All @@ -747,7 +749,7 @@ impl RunLoop {
last_announce_time: &mut u128,
) {
let delay = cmp::max(
1,
config.node.chain_liveness_poll_time_secs,
cmp::max(
config.miner.first_attempt_time_ms,
config.miner.subsequent_attempt_time_ms,
Expand Down