mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-01-12 22:43:42 +08:00
Do not use canonical tip as a fork may have happened when getting parent info for a miner
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
This commit is contained in:
committed by
jferrant
parent
d56e256421
commit
64dca26168
@@ -660,8 +660,18 @@ impl BlockMinerThread {
|
||||
burn_db: &mut SortitionDB,
|
||||
chain_state: &mut StacksChainState,
|
||||
) -> Result<ParentStacksBlockInfo, NakamotoNodeError> {
|
||||
let Some(stacks_tip) =
|
||||
NakamotoChainState::get_canonical_block_header(chain_state.db(), burn_db)
|
||||
// The nakamoto miner must always build off of a chain tip that is the highest of:
|
||||
// 1. The highest block in the miner's current tenure
|
||||
// 2. The highest block in the current tenure's parent tenure
|
||||
// Where the current tenure's parent tenure is the tenure start block committed to in the current tenure's associated block commit.
|
||||
let stacks_block_id = if let Some(block) = self.mined_blocks.last() {
|
||||
block.block_id()
|
||||
} else {
|
||||
self.parent_tenure_id
|
||||
};
|
||||
|
||||
let Some(stacks_tip_header) =
|
||||
NakamotoChainState::get_block_header(chain_state.db(), &stacks_block_id)
|
||||
.expect("FATAL: could not query chain tip")
|
||||
else {
|
||||
debug!("No Stacks chain tip known, will return a genesis block");
|
||||
@@ -693,7 +703,7 @@ impl BlockMinerThread {
|
||||
&self.burn_block,
|
||||
miner_address,
|
||||
&self.parent_tenure_id,
|
||||
stacks_tip,
|
||||
stacks_tip_header,
|
||||
) {
|
||||
Ok(parent_info) => Ok(parent_info),
|
||||
Err(NakamotoNodeError::BurnchainTipChanged) => {
|
||||
|
||||
Reference in New Issue
Block a user