File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -182,7 +182,11 @@ impl GetSortitionHandler {
182
182
// try to figure out what the last snapshot in this fork was with a successful
183
183
// sortition.
184
184
// optimization heuristic: short-circuit the load if its just `stacks_parent_sn`
185
- let last_sortition_ch = if stacks_parent_sn. sortition {
185
+ // if the sortition count incremented by exactly 1 between us and our **stacks** parent,
186
+ // then the stacks parent's sortition *must* be the last one with a winner.
187
+ let sortitions_incremented_by_1 =
188
+ sortition_sn. num_sortitions == stacks_parent_sn. num_sortitions + 1 ;
189
+ let last_sortition_ch = if sortitions_incremented_by_1 {
186
190
stacks_parent_sn. consensus_hash . clone ( )
187
191
} else {
188
192
// we actually need to perform the marf lookup
Original file line number Diff line number Diff line change @@ -1123,6 +1123,12 @@ impl BlockMinerThread {
1123
1123
tenure_change_tx : None ,
1124
1124
} ) ;
1125
1125
} ;
1126
+ if self . last_block_mined . is_some ( ) {
1127
+ return Ok ( NakamotoTenureInfo {
1128
+ coinbase_tx : None ,
1129
+ tenure_change_tx : None ,
1130
+ } ) ;
1131
+ }
1126
1132
1127
1133
let parent_block_id = parent_block_info. stacks_parent_header . index_block_hash ( ) ;
1128
1134
let mut payload = TenureChangePayload {
@@ -1152,10 +1158,10 @@ impl BlockMinerThread {
1152
1158
& parent_block_id,
1153
1159
)
1154
1160
. map_err ( NakamotoNodeError :: MiningFailure ) ?;
1155
- debug ! ( "Miner: Extending tenure" ;
1156
- "burn_view_consensus_hash" => %burn_view_consensus_hash,
1157
- "parent_block_id" => %parent_block_id,
1158
- "num_blocks_so_far" => num_blocks_so_far,
1161
+ info ! ( "Miner: Extending tenure" ;
1162
+ "burn_view_consensus_hash" => %burn_view_consensus_hash,
1163
+ "parent_block_id" => %parent_block_id,
1164
+ "num_blocks_so_far" => num_blocks_so_far,
1159
1165
) ;
1160
1166
payload = payload. extend (
1161
1167
* burn_view_consensus_hash,
Original file line number Diff line number Diff line change @@ -8460,8 +8460,10 @@ fn mock_mining() {
8460
8460
let mock_mining_blocks_end = follower_naka_mined_blocks. load ( Ordering :: SeqCst ) ;
8461
8461
let blocks_mock_mined = mock_mining_blocks_end - mock_mining_blocks_start;
8462
8462
assert ! (
8463
- blocks_mock_mined > tenure_count,
8464
- "Should have mock mined at least `tenure_count` nakamoto blocks"
8463
+ blocks_mock_mined >= tenure_count,
8464
+ "Should have mock mined at least `tenure_count` nakamoto blocks. Mined = {}. Expected = {}" ,
8465
+ blocks_mock_mined,
8466
+ tenure_count,
8465
8467
) ;
8466
8468
8467
8469
// wait for follower to reach the chain tip
You can’t perform that action at this time.
0 commit comments