Skip to content

Commit ac0d6d8

Browse files
authored
Merge pull request #5979 from obycode/fix/wait_on_interim_blocks
fix: ignore `wait_on_interim_blocks`
2 parents f356db0 + a413ff6 commit ac0d6d8

File tree

7 files changed

+56
-61
lines changed

7 files changed

+56
-61
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
2020
- When a miner times out waiting for signatures, it will re-propose the same block instead of building a new block ([#5877](https://github.com/stacks-network/stacks-core/pull/5877))
2121
- Improve tenure downloader trace verbosity applying proper logging level depending on the tenure state ("debug" if unconfirmed, "info" otherwise) ([#5871](https://github.com/stacks-network/stacks-core/issues/5871))
2222
- Remove warning log about missing UTXOs when a node is configured as `miner` with `mock_mining` mode enabled ([#5841](https://github.com/stacks-network/stacks-core/issues/5841))
23+
- Deprecated the `wait_on_interim_blocks` option in the miner config file. This option is no longer needed, as the miner will always wait for interim blocks to be processed before mining a new block. To wait extra time in between blocks, use the `min_time_between_blocks_ms` option instead.
2324

2425
## [3.1.0.0.7]
2526

stacks-signer/src/signerdb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ impl SignerDb {
12641264
// Plus (ms + 999)/1000 to round up to the nearest second
12651265
let tenure_extend_timestamp = tenure_start_time
12661266
.saturating_add(tenure_idle_timeout_secs)
1267-
.saturating_add(tenure_process_time_ms.saturating_add(999) / 1000);
1267+
.saturating_add(tenure_process_time_ms.div_ceil(1000));
12681268
debug!("Calculated tenure extend timestamp";
12691269
"tenure_extend_timestamp" => tenure_extend_timestamp,
12701270
"tenure_start_time" => tenure_start_time,

stackslib/src/config/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,8 @@ pub struct MinerConfig {
21382138
pub unprocessed_block_deadline_secs: u64,
21392139
pub mining_key: Option<Secp256k1PrivateKey>,
21402140
/// Amount of time while mining in nakamoto to wait in between mining interim blocks
2141-
pub wait_on_interim_blocks: Duration,
2141+
/// DEPRECATED: use `min_time_between_blocks_ms` instead
2142+
pub wait_on_interim_blocks: Option<Duration>,
21422143
/// minimum number of transactions that must be in a block if we're going to replace a pending
21432144
/// block-commit with a new block-commit
21442145
pub min_tx_count: u64,
@@ -2209,7 +2210,7 @@ impl Default for MinerConfig {
22092210
candidate_retry_cache_size: 1024 * 1024,
22102211
unprocessed_block_deadline_secs: 30,
22112212
mining_key: None,
2212-
wait_on_interim_blocks: Duration::from_millis(2_500),
2213+
wait_on_interim_blocks: None,
22132214
min_tx_count: 0,
22142215
only_increase_tx_count: false,
22152216
unconfirmed_commits_helper: None,
@@ -2733,8 +2734,7 @@ impl MinerConfigFile {
27332734
.transpose()?,
27342735
wait_on_interim_blocks: self
27352736
.wait_on_interim_blocks_ms
2736-
.map(Duration::from_millis)
2737-
.unwrap_or(miner_default_config.wait_on_interim_blocks),
2737+
.map(Duration::from_millis),
27382738
min_tx_count: self
27392739
.min_tx_count
27402740
.unwrap_or(miner_default_config.min_tx_count),
@@ -2789,7 +2789,7 @@ impl MinerConfigFile {
27892789
pre_nakamoto_mock_signing: self
27902790
.pre_nakamoto_mock_signing
27912791
.unwrap_or(pre_nakamoto_mock_signing), // Should only default true if mining key is set
2792-
min_time_between_blocks_ms: self.min_time_between_blocks_ms.map(|ms| if ms < DEFAULT_MIN_TIME_BETWEEN_BLOCKS_MS {
2792+
min_time_between_blocks_ms: self.min_time_between_blocks_ms.map(|ms| if ms < DEFAULT_MIN_TIME_BETWEEN_BLOCKS_MS {
27932793
warn!("miner.min_time_between_blocks_ms is less than the minimum allowed value of {DEFAULT_MIN_TIME_BETWEEN_BLOCKS_MS} ms. Using the default value instead.");
27942794
DEFAULT_MIN_TIME_BETWEEN_BLOCKS_MS
27952795
} else {

testnet/stacks-node/src/nakamoto_node/miner.rs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -663,20 +663,35 @@ impl BlockMinerThread {
663663
self.mined_blocks += 1;
664664
}
665665

666-
let Ok(sort_db) = SortitionDB::open(
667-
&self.config.get_burn_db_file_path(),
668-
true,
669-
self.burnchain.pox_constants.clone(),
670-
) else {
671-
error!("Failed to open sortition DB. Will try mining again.");
672-
return Ok(());
673-
};
666+
if let Some(last_block_mined) = &self.last_block_mined {
667+
// Wait until the last block mined has been processed
668+
loop {
669+
let (_, processed, _, _) = chain_state
670+
.nakamoto_blocks_db()
671+
.get_block_processed_and_signed_weight(
672+
&last_block_mined.header.consensus_hash,
673+
&last_block_mined.header.block_hash(),
674+
)?
675+
.ok_or_else(|| NakamotoNodeError::UnexpectedChainState)?;
676+
677+
if processed {
678+
break;
679+
}
680+
681+
thread::sleep(Duration::from_millis(ABORT_TRY_AGAIN_MS));
674682

675-
let wait_start = Instant::now();
676-
while wait_start.elapsed() < self.config.miner.wait_on_interim_blocks {
677-
thread::sleep(Duration::from_millis(ABORT_TRY_AGAIN_MS));
678-
if self.check_burn_tip_changed(&sort_db).is_err() {
679-
return Err(NakamotoNodeError::BurnchainTipChanged);
683+
// Check if the burnchain tip has changed
684+
let Ok(sort_db) = SortitionDB::open(
685+
&self.config.get_burn_db_file_path(),
686+
false,
687+
self.burnchain.pox_constants.clone(),
688+
) else {
689+
error!("Failed to open sortition DB. Will try mining again.");
690+
return Ok(());
691+
};
692+
if self.check_burn_tip_changed(&sort_db).is_err() {
693+
return Err(NakamotoNodeError::BurnchainTipChanged);
694+
}
680695
}
681696
}
682697

0 commit comments

Comments
 (0)