Skip to content

Commit 137dcf0

Browse files
committed
exit miner thread behavior for late blockfound tenures, add tests to CI
1 parent 65c2eb3 commit 137dcf0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.github/workflows/bitcoin-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ jobs:
143143
- tests::signer::v0::outgoing_signers_ignore_block_proposals
144144
- tests::signer::v0::injected_signatures_are_ignored_across_boundaries
145145
- tests::signer::v0::fast_sortition
146+
- tests::signer::v0::single_miner_empty_sortition
147+
- tests::signer::v0::multiple_miners_empty_sortition
146148
- tests::nakamoto_integrations::burn_ops_integration_test
147149
- tests::nakamoto_integrations::check_block_heights
148150
- tests::nakamoto_integrations::clarity_burn_state

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ pub enum MinerReason {
138138
},
139139
}
140140

141+
impl MinerReason {
142+
pub fn is_late_block(&self) -> bool {
143+
match self {
144+
Self::BlockFound { ref late } => *late,
145+
Self::Extended { .. } => false,
146+
}
147+
}
148+
}
149+
141150
impl std::fmt::Display for MinerReason {
142151
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
143152
match self {
@@ -434,6 +443,11 @@ impl BlockMinerThread {
434443
"Failed to open chainstate DB. Cannot mine! {e:?}"
435444
))
436445
})?;
446+
if self.last_block_mined.is_some() && self.reason.is_late_block() {
447+
info!("Miner: finished mining a late tenure");
448+
return Err(NakamotoNodeError::StacksTipChanged);
449+
}
450+
437451
let new_block = loop {
438452
// If we're mock mining, we may not have processed the block that the
439453
// actual tenure winner committed to yet. So, before attempting to

0 commit comments

Comments
 (0)