15
15
mod v0;
16
16
17
17
use std:: collections:: HashSet ;
18
- use std:: sync:: atomic:: { AtomicBool , AtomicU64 , Ordering } ;
18
+ use std:: sync:: atomic:: { AtomicBool , Ordering } ;
19
19
use std:: sync:: { Arc , Mutex } ;
20
20
use std:: thread;
21
21
use std:: time:: { Duration , Instant } ;
@@ -44,14 +44,13 @@ use stacks_common::codec::StacksMessageCodec;
44
44
use stacks_common:: consts:: SIGNER_SLOTS_PER_USER ;
45
45
use stacks_common:: types:: StacksEpochId ;
46
46
use stacks_common:: util:: hash:: Sha512Trunc256Sum ;
47
- use stacks_common:: util:: tests:: TestFlag ;
48
47
use stacks_signer:: client:: { ClientError , SignerSlotID , StackerDB , StacksClient } ;
49
48
use stacks_signer:: config:: { build_signer_config_tomls, GlobalConfig as SignerConfig , Network } ;
50
49
use stacks_signer:: runloop:: { SignerResult , State , StateInfo } ;
51
50
use stacks_signer:: { Signer , SpawnedSigner } ;
52
51
53
52
use super :: nakamoto_integrations:: { check_nakamoto_empty_block_heuristics, wait_for} ;
54
- use crate :: neon:: { Counters , RunLoopCounter } ;
53
+ use crate :: neon:: Counters ;
55
54
use crate :: run_loop:: boot_nakamoto;
56
55
use crate :: tests:: bitcoin_regtest:: BitcoinCoreController ;
57
56
use crate :: tests:: nakamoto_integrations:: {
@@ -72,17 +71,6 @@ pub struct RunningNodes {
72
71
pub btcd_controller : BitcoinCoreController ,
73
72
pub run_loop_thread : thread:: JoinHandle < ( ) > ,
74
73
pub run_loop_stopper : Arc < AtomicBool > ,
75
- pub vrfs_submitted : RunLoopCounter ,
76
- pub commits_submitted : RunLoopCounter ,
77
- pub last_commit_burn_height : RunLoopCounter ,
78
- pub blocks_processed : RunLoopCounter ,
79
- pub sortitions_processed : RunLoopCounter ,
80
- pub nakamoto_blocks_proposed : RunLoopCounter ,
81
- pub nakamoto_blocks_mined : RunLoopCounter ,
82
- pub nakamoto_blocks_rejected : RunLoopCounter ,
83
- pub nakamoto_blocks_signer_pushed : RunLoopCounter ,
84
- pub nakamoto_miner_directives : Arc < AtomicU64 > ,
85
- pub nakamoto_test_skip_commit_op : TestFlag < bool > ,
86
74
pub counters : Counters ,
87
75
pub coord_channel : Arc < Mutex < CoordinatorChannels > > ,
88
76
pub conf : NeonConfig ,
@@ -337,7 +325,7 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
337
325
/// Note: do not use nakamoto blocks mined heuristic if running a test with multiple miners
338
326
fn mine_nakamoto_block ( & mut self , timeout : Duration , use_nakamoto_blocks_mined : bool ) {
339
327
let mined_block_time = Instant :: now ( ) ;
340
- let mined_before = self . running_nodes . nakamoto_blocks_mined . get ( ) ;
328
+ let mined_before = self . running_nodes . counters . naka_mined_blocks . get ( ) ;
341
329
let info_before = self . get_peer_info ( ) ;
342
330
next_block_and_mine_commit (
343
331
& mut self . running_nodes . btc_regtest_controller ,
@@ -349,7 +337,7 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
349
337
350
338
wait_for ( timeout. as_secs ( ) , || {
351
339
let info_after = self . get_peer_info ( ) ;
352
- let blocks_mined = self . running_nodes . nakamoto_blocks_mined . get ( ) ;
340
+ let blocks_mined = self . running_nodes . counters . naka_mined_blocks . get ( ) ;
353
341
Ok ( info_after. stacks_tip_height > info_before. stacks_tip_height
354
342
&& ( !use_nakamoto_blocks_mined || blocks_mined > mined_before) )
355
343
} )
@@ -391,14 +379,14 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
391
379
/// to ensure that the block was mined.
392
380
/// Note: this function does _not_ mine a BTC block.
393
381
fn wait_for_nakamoto_block ( & mut self , timeout_secs : u64 , f : impl FnOnce ( ) -> ( ) ) {
394
- let blocks_before = self . running_nodes . nakamoto_blocks_mined . get ( ) ;
382
+ let blocks_before = self . running_nodes . counters . naka_mined_blocks . get ( ) ;
395
383
let info_before = self . get_peer_info ( ) ;
396
384
397
385
f ( ) ;
398
386
399
387
// Verify that the block was mined
400
388
wait_for ( timeout_secs, || {
401
- let blocks_mined = self . running_nodes . nakamoto_blocks_mined . get ( ) ;
389
+ let blocks_mined = self . running_nodes . counters . naka_mined_blocks . get ( ) ;
402
390
let info = self . get_peer_info ( ) ;
403
391
Ok ( blocks_mined > blocks_before
404
392
&& info. stacks_tip_height > info_before. stacks_tip_height )
@@ -509,7 +497,7 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
509
497
// advance to epoch 3.0 and trigger a sign round (cannot vote on blocks in pre epoch 3.0)
510
498
run_until_burnchain_height (
511
499
& mut self . running_nodes . btc_regtest_controller ,
512
- & self . running_nodes . blocks_processed ,
500
+ & self . running_nodes . counters . blocks_processed ,
513
501
epoch_30_boundary,
514
502
& self . running_nodes . conf ,
515
503
) ;
@@ -919,21 +907,8 @@ fn setup_stx_btc_node<G: FnMut(&mut NeonConfig)>(
919
907
920
908
let mut run_loop = boot_nakamoto:: BootRunLoop :: new ( naka_conf. clone ( ) ) . unwrap ( ) ;
921
909
let run_loop_stopper = run_loop. get_termination_switch ( ) ;
922
- let Counters {
923
- blocks_processed,
924
- sortitions_processed,
925
- naka_submitted_vrfs : vrfs_submitted,
926
- naka_submitted_commits : commits_submitted,
927
- naka_submitted_commit_last_burn_height : last_commit_burn_height,
928
- naka_proposed_blocks : naka_blocks_proposed,
929
- naka_mined_blocks : naka_blocks_mined,
930
- naka_rejected_blocks : naka_blocks_rejected,
931
- naka_miner_directives,
932
- naka_skip_commit_op : nakamoto_test_skip_commit_op,
933
- naka_signer_pushed_blocks,
934
- ..
935
- } = run_loop. counters ( ) ;
936
910
let counters = run_loop. counters ( ) ;
911
+ let blocks_processed = counters. blocks_processed . clone ( ) ;
937
912
938
913
let coord_channel = run_loop. coordinator_channels ( ) ;
939
914
let run_loop_thread = thread:: spawn ( move || run_loop. start ( None , 0 ) ) ;
@@ -944,32 +919,21 @@ fn setup_stx_btc_node<G: FnMut(&mut NeonConfig)>(
944
919
945
920
// First block wakes up the run loop.
946
921
info ! ( "Mine first block..." ) ;
947
- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
922
+ next_block_and_wait ( & mut btc_regtest_controller, & counters . blocks_processed ) ;
948
923
949
924
// Second block will hold our VRF registration.
950
925
info ! ( "Mine second block..." ) ;
951
- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
926
+ next_block_and_wait ( & mut btc_regtest_controller, & counters . blocks_processed ) ;
952
927
953
928
// Third block will be the first mined Stacks block.
954
929
info ! ( "Mine third block..." ) ;
955
- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
930
+ next_block_and_wait ( & mut btc_regtest_controller, & counters . blocks_processed ) ;
956
931
957
932
RunningNodes {
958
933
btcd_controller,
959
934
btc_regtest_controller,
960
935
run_loop_thread,
961
936
run_loop_stopper,
962
- vrfs_submitted,
963
- commits_submitted,
964
- last_commit_burn_height,
965
- blocks_processed,
966
- sortitions_processed,
967
- nakamoto_blocks_proposed : naka_blocks_proposed,
968
- nakamoto_blocks_mined : naka_blocks_mined,
969
- nakamoto_blocks_rejected : naka_blocks_rejected,
970
- nakamoto_blocks_signer_pushed : naka_signer_pushed_blocks,
971
- nakamoto_test_skip_commit_op,
972
- nakamoto_miner_directives : naka_miner_directives. 0 ,
973
937
coord_channel,
974
938
counters,
975
939
conf : naka_conf,
0 commit comments