@@ -536,12 +536,29 @@ impl<Z: SpawnedSignerTrait> SignerTest<Z> {
536
536
} ) . unwrap ( ) ;
537
537
}
538
538
539
+ /// Mine a bitcoin block and wait for the signers to send an update with the new burn block and pox consensus hash
539
540
pub fn mine_bitcoin_block ( & self ) {
541
+ self . mine_bitcoin_block_without_updates ( ) ;
542
+ wait_for_state_machine_update_by_miner_tenure_id (
543
+ 30 ,
544
+ & get_chain_info ( & self . running_nodes . conf ) . pox_consensus ,
545
+ & self . signer_addresses_versions_majority ( ) ,
546
+ )
547
+ . expect ( "Failed to update signer state machine" ) ;
548
+ }
549
+
550
+ // Mine a bitcoin block but don't wait for signers to send any updates
551
+ pub fn mine_bitcoin_block_without_updates ( & self ) {
552
+ let mined_btc_block_time = Instant :: now ( ) ;
540
553
let info = self . get_peer_info ( ) ;
541
554
next_block_and ( & self . running_nodes . btc_regtest_controller , 60 , || {
542
555
Ok ( get_chain_info ( & self . running_nodes . conf ) . burn_block_height > info. burn_block_height )
543
556
} )
544
557
. unwrap ( ) ;
558
+ info ! (
559
+ "Bitcoin block mine time elapsed: {:?}" ,
560
+ mined_btc_block_time. elapsed( )
561
+ ) ;
545
562
}
546
563
547
564
/// Fetch the local signer state machine for all the signers,
@@ -1100,43 +1117,19 @@ impl<Z: SpawnedSignerTrait> SignerTest<Z> {
1100
1117
output
1101
1118
}
1102
1119
1103
- /// Mine a BTC block and wait for a new Stacks block to be mined
1120
+ /// Mine a BTC block and wait for a new Stacks block to be mined, but do not wait for a commit
1104
1121
/// Note: do not use nakamoto blocks mined heuristic if running a test with multiple miners
1105
- fn mine_nakamoto_block ( & self , timeout : Duration , use_nakamoto_blocks_mined : bool ) {
1122
+ fn mine_nakamoto_block_without_commit (
1123
+ & self ,
1124
+ timeout : Duration ,
1125
+ use_nakamoto_blocks_mined : bool ,
1126
+ ) {
1106
1127
let info_before = get_chain_info ( & self . running_nodes . conf ) ;
1107
1128
info ! ( "Pausing stacks block mining" ) ;
1108
1129
TEST_MINE_SKIP . set ( true ) ;
1109
-
1110
- let Counters {
1111
- naka_submitted_commits : commits_submitted,
1112
- naka_submitted_commit_last_burn_height : commits_last_burn_height,
1113
- naka_submitted_commit_last_stacks_tip : commits_last_stacks_tip,
1114
- naka_mined_blocks : mined_blocks,
1115
- ..
1116
- } = self . running_nodes . counters . clone ( ) ;
1117
-
1118
- let commits_before = commits_submitted. load ( Ordering :: SeqCst ) ;
1119
- let commit_burn_height_before = commits_last_burn_height. load ( Ordering :: SeqCst ) ;
1120
- let mined_before = mined_blocks. load ( Ordering :: SeqCst ) ;
1121
-
1122
- let mined_btc_block_time = Instant :: now ( ) ;
1123
- next_block_and (
1124
- & self . running_nodes . btc_regtest_controller ,
1125
- timeout. as_secs ( ) ,
1126
- || Ok ( self . get_peer_info ( ) . burn_block_height > info_before. burn_block_height ) ,
1127
- )
1128
- . unwrap ( ) ;
1129
- info ! (
1130
- "Bitcoin block mine time elapsed: {:?}" ,
1131
- mined_btc_block_time. elapsed( )
1132
- ) ;
1133
- wait_for_state_machine_update_by_miner_tenure_id (
1134
- timeout. as_secs ( ) ,
1135
- & get_chain_info ( & self . running_nodes . conf ) . pox_consensus ,
1136
- & self . signer_addresses_versions_majority ( ) ,
1137
- )
1138
- . expect ( "Failed to update signer state machine" ) ;
1139
-
1130
+ let mined_blocks = self . running_nodes . counters . naka_mined_blocks . clone ( ) ;
1131
+ let mined_before = mined_blocks. get ( ) ;
1132
+ self . mine_bitcoin_block ( ) ;
1140
1133
info ! ( "Unpausing stacks block mining" ) ;
1141
1134
let mined_block_time = Instant :: now ( ) ;
1142
1135
TEST_MINE_SKIP . set ( false ) ;
@@ -1145,22 +1138,35 @@ impl<Z: SpawnedSignerTrait> SignerTest<Z> {
1145
1138
wait_for ( timeout. as_secs ( ) , || {
1146
1139
Ok ( get_chain_info ( & self . running_nodes . conf ) . stacks_tip_height
1147
1140
> info_before. stacks_tip_height
1148
- && ( !use_nakamoto_blocks_mined
1149
- || mined_blocks. load ( Ordering :: SeqCst ) > mined_before) )
1141
+ && ( !use_nakamoto_blocks_mined || mined_blocks. get ( ) > mined_before) )
1150
1142
} )
1151
1143
. expect ( "Failed to mine Tenure Change block" ) ;
1144
+ info ! (
1145
+ "Nakamoto block mine time elapsed: {:?}" ,
1146
+ mined_block_time. elapsed( )
1147
+ ) ;
1148
+ }
1149
+
1150
+ /// Mine a BTC block and wait for a new Stacks block to be mined and commit to be submitted
1151
+ /// Note: do not use nakamoto blocks mined heuristic if running a test with multiple miners
1152
+ fn mine_nakamoto_block ( & self , timeout : Duration , use_nakamoto_blocks_mined : bool ) {
1153
+ let Counters {
1154
+ naka_submitted_commits : commits_submitted,
1155
+ naka_submitted_commit_last_burn_height : commits_last_burn_height,
1156
+ naka_submitted_commit_last_stacks_tip : commits_last_stacks_tip,
1157
+ ..
1158
+ } = self . running_nodes . counters . clone ( ) ;
1159
+ let commits_before = commits_submitted. get ( ) ;
1160
+ let commit_burn_height_before = commits_last_burn_height. get ( ) ;
1161
+ self . mine_nakamoto_block_without_commit ( timeout, use_nakamoto_blocks_mined) ;
1152
1162
// Ensure the subsequent block commit confirms the previous Tenure Change block
1153
1163
let stacks_tip_height = get_chain_info ( & self . running_nodes . conf ) . stacks_tip_height ;
1154
1164
wait_for ( timeout. as_secs ( ) , || {
1155
- Ok ( commits_submitted. load ( Ordering :: SeqCst ) > commits_before
1156
- && commits_last_burn_height. load ( Ordering :: SeqCst ) > commit_burn_height_before
1157
- && commits_last_stacks_tip. load ( Ordering :: SeqCst ) >= stacks_tip_height)
1165
+ Ok ( commits_submitted. get ( ) > commits_before
1166
+ && commits_last_burn_height. get ( ) > commit_burn_height_before
1167
+ && commits_last_stacks_tip. get ( ) >= stacks_tip_height)
1158
1168
} )
1159
1169
. expect ( "Failed to update Block Commit" ) ;
1160
- info ! (
1161
- "Nakamoto block mine time elapsed: {:?}" ,
1162
- mined_block_time. elapsed( )
1163
- ) ;
1164
1170
}
1165
1171
1166
1172
fn mine_block_wait_on_processing (
0 commit comments