Skip to content

Commit 2dced24

Browse files
committed
CRC: when reissuing a tenure change payload use the winning stacks block hash to form the parent_tenure_start
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 8c9d129 commit 2dced24

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -922,25 +922,22 @@ impl BlockMinerThread {
922922
fn make_vrf_proof(&mut self) -> Option<VRFProof> {
923923
// if we're a mock miner, then make sure that the keychain has a keypair for the mocked VRF
924924
// key
925-
let sortition_hash = if matches!(self.reason, MinerReason::EmptyTenure) {
926-
self.burn_election_block.sortition_hash
927-
} else {
928-
self.burn_block.sortition_hash
929-
};
930925
let vrf_proof = if self.config.get_node_config(false).mock_mining {
931-
self.keychain
932-
.generate_proof(VRF_MOCK_MINER_KEY, sortition_hash.as_bytes())
926+
self.keychain.generate_proof(
927+
VRF_MOCK_MINER_KEY,
928+
self.burn_election_block.sortition_hash.as_bytes(),
929+
)
933930
} else {
934931
self.keychain.generate_proof(
935932
self.registered_key.target_block_height,
936-
sortition_hash.as_bytes(),
933+
self.burn_election_block.sortition_hash.as_bytes(),
937934
)
938935
};
939936

940937
debug!(
941938
"Generated VRF Proof: {} over {} ({},{}) with key {}",
942939
vrf_proof.to_hex(),
943-
&sortition_hash,
940+
&self.burn_election_block.sortition_hash,
944941
&self.burn_block.block_height,
945942
&self.burn_block.burn_header_hash,
946943
&self.registered_key.vrf_public_key.to_hex()

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ impl RelayerThread {
912912
return Ok(());
913913
}
914914

915-
let last_non_empty_sortition_snapshot =
915+
let canonical_block_snapshot =
916916
SortitionDB::get_block_snapshot_consensus(self.sortdb.conn(), &canonical_stacks_tip_ch)
917917
.map_err(|e| {
918918
error!("Relayer: failed to get block snapshot for canonical tip: {e:?}");
@@ -923,22 +923,22 @@ impl RelayerThread {
923923
NakamotoNodeError::SnapshotNotFoundForChainTip
924924
})?;
925925

926-
let won_last_non_empty_sortition_snapshot =
927-
last_non_empty_sortition_snapshot.miner_pk_hash == Some(mining_pkh);
926+
let won_canonical_block_snapshot =
927+
canonical_block_snapshot.miner_pk_hash == Some(mining_pkh);
928928

929929
let (parent_tenure_start, block_election_snapshot, reason) =
930-
if !won_last_non_empty_sortition_snapshot {
930+
if !won_canonical_block_snapshot {
931931
debug!("Relayer: Failed to issue a tenure change payload in our last tenure. Issue a new tenure change payload.");
932932
(
933-
canonical_stacks_tip,
933+
StacksBlockId(last_block_election_snapshot.winning_stacks_block_hash.0),
934934
last_block_election_snapshot,
935935
MinerReason::EmptyTenure,
936936
)
937937
} else {
938938
debug!("Relayer: Successfully issued a tenure change payload in its tenure. Issue a continue extend from the chain tip.");
939939
(
940-
canonical_stacks_tip, //For tenure extend, we sould be extending off the canonical tip
941-
last_non_empty_sortition_snapshot,
940+
canonical_stacks_tip, //For tenure extend, we should be extending off the canonical tip
941+
canonical_block_snapshot,
942942
MinerReason::Extended {
943943
burn_view_consensus_hash: new_burn_view,
944944
},

0 commit comments

Comments
 (0)