Skip to content

Commit fa0d9ac

Browse files
committed
chore: address PR feedback
1 parent 48567ed commit fa0d9ac

File tree

2 files changed

+6
-52
lines changed

2 files changed

+6
-52
lines changed

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

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ use stacks::chainstate::coordinator::OnChainRewardSetProvider;
3232
use stacks::chainstate::nakamoto::coordinator::load_nakamoto_reward_set;
3333
use stacks::chainstate::nakamoto::miner::{NakamotoBlockBuilder, NakamotoTenureInfo};
3434
use stacks::chainstate::nakamoto::staging_blocks::NakamotoBlockObtainMethod;
35-
use stacks::chainstate::nakamoto::tenure::NakamotoTenureEventId;
36-
use stacks::chainstate::nakamoto::{NakamotoBlock, NakamotoChainState, StacksDBIndexed};
35+
use stacks::chainstate::nakamoto::{NakamotoBlock, NakamotoChainState};
3736
use stacks::chainstate::stacks::boot::{RewardSet, MINERS_NAME};
3837
use stacks::chainstate::stacks::db::{StacksChainState, StacksHeaderInfo};
3938
use stacks::chainstate::stacks::{
@@ -1326,33 +1325,6 @@ impl BlockMinerThread {
13261325
})
13271326
}
13281327

1329-
/// Get the ongoing burn view in the chain state
1330-
pub fn get_ongoing_tenure_id(
1331-
sortdb: &SortitionDB,
1332-
chain_state: &mut StacksChainState,
1333-
) -> Result<NakamotoTenureEventId, NakamotoNodeError> {
1334-
let cur_stacks_tip_header =
1335-
NakamotoChainState::get_canonical_block_header(chain_state.db(), sortdb)?
1336-
.ok_or_else(|| NakamotoNodeError::UnexpectedChainState)?;
1337-
1338-
let cur_stacks_tip_id = cur_stacks_tip_header.index_block_hash();
1339-
let ongoing_tenure_id = if let Some(tenure_id) = chain_state
1340-
.index_conn()
1341-
.get_ongoing_tenure_id(&cur_stacks_tip_id)?
1342-
{
1343-
// ongoing tenure is a Nakamoto tenure
1344-
tenure_id
1345-
} else {
1346-
// ongoing tenure is an epoch 2.x tenure, so it's the same as the canonical stacks 2.x
1347-
// tip
1348-
NakamotoTenureEventId {
1349-
burn_view_consensus_hash: cur_stacks_tip_header.consensus_hash,
1350-
block_id: cur_stacks_tip_id,
1351-
}
1352-
};
1353-
Ok(ongoing_tenure_id)
1354-
}
1355-
13561328
/// Check if the tenure needs to change -- if so, return a BurnchainTipChanged error
13571329
/// The tenure should change if there is a new burnchain tip with a valid sortition,
13581330
/// or if the stacks chain state's burn view has advanced beyond our burn view.

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -530,30 +530,12 @@ impl RelayerThread {
530530
});
531531
}
532532

533-
let mining_pkh_opt = self.get_mining_key_pkh();
534-
535533
// a sortition happened, but we didn't win.
536-
match Self::can_continue_tenure(
537-
&self.sortdb,
538-
&mut self.chainstate,
539-
sn.consensus_hash,
540-
mining_pkh_opt,
541-
) {
542-
Ok(Some(_)) => {
543-
// we can continue our ongoing tenure, but we should give the new winning miner
544-
// a chance to send their BlockFound first.
545-
debug!("Relayer: Did not win sortition, but am mining the ongoing tenure. Allowing the new miner some time to come online before trying to continue.");
546-
self.tenure_extend_timeout = Some(Instant::now());
547-
return Some(MinerDirective::StopTenure);
548-
}
549-
Ok(None) => {
550-
return Some(MinerDirective::StopTenure);
551-
}
552-
Err(e) => {
553-
warn!("Relayer: failed to check to see if we can continue tenure: {e:?}");
554-
return Some(MinerDirective::StopTenure);
555-
}
556-
}
534+
debug!(
535+
"Relayer: did not win sortition {}, so stopping tenure",
536+
&sn.sortition
537+
);
538+
return Some(MinerDirective::StopTenure);
557539
}
558540

559541
// no sortition happened.

0 commit comments

Comments
 (0)