Skip to content

Commit b6c2e55

Browse files
committed
Use the ACTUAL burnchain tip in run_sign_v0 instead of the election block snapshot
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent e64de15 commit b6c2e55

File tree

4 files changed

+20
-30
lines changed

4 files changed

+20
-30
lines changed

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

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -531,22 +531,6 @@ impl BlockMinerThread {
531531
))
532532
})?;
533533

534-
let tip = SortitionDB::get_block_snapshot_consensus(
535-
sort_db.conn(),
536-
&new_block.header.consensus_hash,
537-
)
538-
.map_err(|e| {
539-
NakamotoNodeError::SigningCoordinatorFailure(format!(
540-
"Failed to retrieve chain tip: {:?}",
541-
e
542-
))
543-
})
544-
.and_then(|result| {
545-
result.ok_or_else(|| {
546-
NakamotoNodeError::SigningCoordinatorFailure("Failed to retrieve chain tip".into())
547-
})
548-
})?;
549-
550534
let reward_set = self.load_signer_set()?;
551535

552536
if self.config.get_node_config(false).mock_mining {
@@ -574,7 +558,7 @@ impl BlockMinerThread {
574558

575559
let signature = coordinator.run_sign_v0(
576560
new_block,
577-
&tip,
561+
&self.burn_block,
578562
&self.burnchain,
579563
&sort_db,
580564
&mut chain_state,
@@ -1206,9 +1190,7 @@ impl BlockMinerThread {
12061190
let cur_burn_chain_tip = SortitionDB::get_canonical_burn_chain_tip(sortdb.conn())
12071191
.expect("FATAL: failed to query sortition DB for canonical burn chain tip");
12081192

1209-
if cur_burn_chain_tip.consensus_hash != self.burn_block.consensus_hash
1210-
&& cur_burn_chain_tip.sortition_id != self.burn_block.sortition_id
1211-
{
1193+
if cur_burn_chain_tip.consensus_hash != self.burn_block.consensus_hash {
12121194
info!("Miner: Cancel block assembly; burnchain tip has changed");
12131195
self.globals.counters.bump_missed_tenures();
12141196
Err(NakamotoNodeError::BurnchainTipChanged)
@@ -1247,9 +1229,7 @@ impl ParentStacksBlockInfo {
12471229
let burn_chain_tip = SortitionDB::get_canonical_burn_chain_tip(burn_db.conn())
12481230
.expect("FATAL: failed to query sortition DB for canonical burn chain tip");
12491231

1250-
if burn_chain_tip.consensus_hash != check_burn_block.consensus_hash
1251-
&& burn_chain_tip.sortition_id != check_burn_block.sortition_id
1252-
{
1232+
if burn_chain_tip.consensus_hash != check_burn_block.consensus_hash {
12531233
info!(
12541234
"New canonical burn chain tip detected. Will not try to mine.";
12551235
"new_consensus_hash" => %burn_chain_tip.consensus_hash,

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,7 @@ impl SignCoordinator {
255255
let cur_burn_chain_tip = SortitionDB::get_canonical_burn_chain_tip(sortdb.conn())
256256
.expect("FATAL: failed to query sortition DB for canonical burn chain tip");
257257

258-
if cur_burn_chain_tip.consensus_hash != burn_block.consensus_hash
259-
&& cur_burn_chain_tip.sortition_id != burn_block.sortition_id
260-
{
258+
if cur_burn_chain_tip.consensus_hash != burn_block.consensus_hash {
261259
info!("SignCoordinator: Cancel signature aggregation; burnchain tip has changed");
262260
true
263261
} else {

testnet/stacks-node/src/neon_node.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4324,9 +4324,7 @@ impl ParentStacksBlockInfo {
43244324
let burn_chain_tip = SortitionDB::get_canonical_burn_chain_tip(burn_db.conn())
43254325
.expect("FATAL: failed to query sortition DB for canonical burn chain tip");
43264326

4327-
if burn_chain_tip.consensus_hash != check_burn_block.consensus_hash
4328-
&& burn_chain_tip.sortition_id != check_burn_block.sortition_id
4329-
{
4327+
if burn_chain_tip.consensus_hash != check_burn_block.consensus_hash {
43304328
info!(
43314329
"New canonical burn chain tip detected. Will not try to mine.";
43324330
"new_consensus_hash" => %burn_chain_tip.consensus_hash,

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5121,7 +5121,11 @@ fn continue_after_tenure_extend() {
51215121

51225122
// It's possible that we have a pending block commit already.
51235123
// Mine two BTC blocks to "flush" this commit.
5124-
5124+
let burn_height = signer_test
5125+
.stacks_client
5126+
.get_peer_info()
5127+
.expect("Failed to get peer info")
5128+
.burn_block_height;
51255129
for i in 0..2 {
51265130
info!(
51275131
"------------- After pausing commits, triggering 2 BTC blocks: ({} of 2) -----------",
@@ -5147,6 +5151,16 @@ fn continue_after_tenure_extend() {
51475151
.expect("Timed out waiting for tenure extend block");
51485152
}
51495153

5154+
wait_for(30, || {
5155+
let new_burn_height = signer_test
5156+
.stacks_client
5157+
.get_peer_info()
5158+
.expect("Failed to get peer info")
5159+
.burn_block_height;
5160+
Ok(new_burn_height == burn_height + 2)
5161+
})
5162+
.expect("Timed out waiting for burnchain to advance");
5163+
51505164
// The last block should have a single instruction in it, the tenure extend
51515165
let blocks = test_observer::get_blocks();
51525166
let last_block = blocks.last().unwrap();

0 commit comments

Comments
 (0)