Skip to content

Commit 541d13b

Browse files
committed
fix: bug in the tenure extending logic -- only include tenure change tx in the first block after extension
1 parent b995e27 commit 541d13b

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

stackslib/src/chainstate/stacks/miner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2216,7 +2216,7 @@ impl StacksBlockBuilder {
22162216
// mine an empty block so you can start your tenure quickly!
22172217
if let Some(tx) = initial_txs.first() {
22182218
if matches!(&tx.payload, TransactionPayload::TenureChange(_)) {
2219-
debug!("Nakamoto miner heuristic: during tenure change blocks, produce a fast short block to begin tenure");
2219+
info!("Nakamoto miner heuristic: during tenure change blocks, produce a fast short block to begin tenure");
22202220
return Ok((false, tx_events));
22212221
}
22222222
}

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,12 @@ impl BlockMinerThread {
12601260
tenure_change_tx: None,
12611261
});
12621262
};
1263+
if self.last_block_mined.is_some() {
1264+
return Ok(NakamotoTenureInfo {
1265+
coinbase_tx: None,
1266+
tenure_change_tx: None,
1267+
});
1268+
}
12631269

12641270
let parent_block_id = parent_block_info.stacks_parent_header.index_block_hash();
12651271
let mut payload = TenureChangePayload {
@@ -1289,10 +1295,10 @@ impl BlockMinerThread {
12891295
&parent_block_id,
12901296
)
12911297
.map_err(NakamotoNodeError::MiningFailure)?;
1292-
debug!("Miner: Extending tenure";
1293-
"burn_view_consensus_hash" => %burn_view_consensus_hash,
1294-
"parent_block_id" => %parent_block_id,
1295-
"num_blocks_so_far" => num_blocks_so_far,
1298+
info!("Miner: Extending tenure";
1299+
"burn_view_consensus_hash" => %burn_view_consensus_hash,
1300+
"parent_block_id" => %parent_block_id,
1301+
"num_blocks_so_far" => num_blocks_so_far,
12961302
);
12971303
payload = payload.extend(
12981304
*burn_view_consensus_hash,

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6382,7 +6382,8 @@ fn continue_tenure_extend() {
63826382
let (mut naka_conf, _miner_account) = naka_neon_integration_conf(None);
63836383
let prom_bind = format!("{}:{}", "127.0.0.1", 6000);
63846384
naka_conf.node.prometheus_bind = Some(prom_bind.clone());
6385-
naka_conf.miner.wait_on_interim_blocks = Duration::from_secs(1000);
6385+
naka_conf.miner.wait_on_interim_blocks = Duration::from_secs(1);
6386+
let http_origin = naka_conf.node.data_url.clone();
63866387
let sender_sk = Secp256k1PrivateKey::new();
63876388
// setup sender + recipient for a test stx transfer
63886389
let sender_addr = tests::to_addr(&sender_sk);
@@ -6571,12 +6572,13 @@ fn continue_tenure_extend() {
65716572
&signers,
65726573
);
65736574

6574-
wait_for(5, || {
6575+
wait_for(25, || {
65756576
let blocks_processed = coord_channel
65766577
.lock()
65776578
.expect("Mutex poisoned")
65786579
.get_stacks_blocks_processed();
6579-
Ok(blocks_processed > blocks_processed_before)
6580+
let sender_nonce = get_account(&http_origin, &to_addr(&sender_sk)).nonce;
6581+
Ok(blocks_processed > blocks_processed_before && sender_nonce >= 1)
65806582
})
65816583
.unwrap();
65826584

0 commit comments

Comments
 (0)