@@ -537,11 +537,16 @@ impl<Z: SpawnedSignerTrait> SignerTest<Z> {
537
537
}
538
538
539
539
pub fn mine_bitcoin_block ( & self ) {
540
+ let mined_btc_block_time = Instant :: now ( ) ;
540
541
let info = self . get_peer_info ( ) ;
541
542
next_block_and ( & self . running_nodes . btc_regtest_controller , 60 , || {
542
543
Ok ( get_chain_info ( & self . running_nodes . conf ) . burn_block_height > info. burn_block_height )
543
544
} )
544
545
. unwrap ( ) ;
546
+ info ! (
547
+ "Bitcoin block mine time elapsed: {:?}" ,
548
+ mined_btc_block_time. elapsed( )
549
+ ) ;
545
550
}
546
551
547
552
/// Fetch the local signer state machine for all the signers,
@@ -1100,36 +1105,19 @@ impl<Z: SpawnedSignerTrait> SignerTest<Z> {
1100
1105
output
1101
1106
}
1102
1107
1103
- /// Mine a BTC block and wait for a new Stacks block to be mined
1108
+ /// Mine a BTC block and wait for a new Stacks block to be mined, but do not wait for a commit
1104
1109
/// 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 ) {
1110
+ fn mine_nakamoto_block_without_commit (
1111
+ & self ,
1112
+ timeout : Duration ,
1113
+ use_nakamoto_blocks_mined : bool ,
1114
+ ) {
1106
1115
let info_before = get_chain_info ( & self . running_nodes . conf ) ;
1107
1116
info ! ( "Pausing stacks block mining" ) ;
1108
1117
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
- ) ;
1118
+ let mined_blocks = self . running_nodes . counters . naka_mined_blocks . clone ( ) ;
1119
+ let mined_before = mined_blocks. get ( ) ;
1120
+ self . mine_bitcoin_block ( ) ;
1133
1121
wait_for_state_machine_update_by_miner_tenure_id (
1134
1122
timeout. as_secs ( ) ,
1135
1123
& get_chain_info ( & self . running_nodes . conf ) . pox_consensus ,
@@ -1145,22 +1133,35 @@ impl<Z: SpawnedSignerTrait> SignerTest<Z> {
1145
1133
wait_for ( timeout. as_secs ( ) , || {
1146
1134
Ok ( get_chain_info ( & self . running_nodes . conf ) . stacks_tip_height
1147
1135
> info_before. stacks_tip_height
1148
- && ( !use_nakamoto_blocks_mined
1149
- || mined_blocks. load ( Ordering :: SeqCst ) > mined_before) )
1136
+ && ( !use_nakamoto_blocks_mined || mined_blocks. get ( ) > mined_before) )
1150
1137
} )
1151
1138
. expect ( "Failed to mine Tenure Change block" ) ;
1139
+ info ! (
1140
+ "Nakamoto block mine time elapsed: {:?}" ,
1141
+ mined_block_time. elapsed( )
1142
+ ) ;
1143
+ }
1144
+
1145
+ /// Mine a BTC block and wait for a new Stacks block to be mined and commit to be submitted
1146
+ /// Note: do not use nakamoto blocks mined heuristic if running a test with multiple miners
1147
+ fn mine_nakamoto_block ( & self , timeout : Duration , use_nakamoto_blocks_mined : bool ) {
1148
+ let Counters {
1149
+ naka_submitted_commits : commits_submitted,
1150
+ naka_submitted_commit_last_burn_height : commits_last_burn_height,
1151
+ naka_submitted_commit_last_stacks_tip : commits_last_stacks_tip,
1152
+ ..
1153
+ } = self . running_nodes . counters . clone ( ) ;
1154
+ let commits_before = commits_submitted. get ( ) ;
1155
+ let commit_burn_height_before = commits_last_burn_height. get ( ) ;
1156
+ self . mine_nakamoto_block_without_commit ( timeout, use_nakamoto_blocks_mined) ;
1152
1157
// Ensure the subsequent block commit confirms the previous Tenure Change block
1153
1158
let stacks_tip_height = get_chain_info ( & self . running_nodes . conf ) . stacks_tip_height ;
1154
1159
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)
1160
+ Ok ( commits_submitted. get ( ) > commits_before
1161
+ && commits_last_burn_height. get ( ) > commit_burn_height_before
1162
+ && commits_last_stacks_tip. get ( ) >= stacks_tip_height)
1158
1163
} )
1159
1164
. expect ( "Failed to update Block Commit" ) ;
1160
- info ! (
1161
- "Nakamoto block mine time elapsed: {:?}" ,
1162
- mined_block_time. elapsed( )
1163
- ) ;
1164
1165
}
1165
1166
1166
1167
fn mine_block_wait_on_processing (
0 commit comments