1- use super :: {
2- genesis_data:: GENESIS_DATA , BurnchainController , BurnchainTip , Config , EventDispatcher ,
3- Keychain , Tenure ,
4- } ;
5- use crate :: run_loop:: RegisteredKey ;
1+ use super :: { BurnchainController , BurnchainTip , Config , EventDispatcher , Keychain , Tenure } ;
2+ use crate :: { genesis_data:: USE_TEST_GENESIS_CHAINSTATE , run_loop:: RegisteredKey } ;
63
7- use std:: collections:: HashSet ;
84use std:: convert:: TryFrom ;
95use std:: default:: Default ;
106use std:: net:: SocketAddr ;
7+ use std:: { collections:: HashSet , env} ;
118use std:: { thread, thread:: JoinHandle , time} ;
129
1310use stacks:: chainstate:: burn:: db:: sortdb:: SortitionDB ;
@@ -87,9 +84,11 @@ pub struct Node {
8784 nonce : u64 ,
8885}
8986
90- pub fn get_account_lockups ( ) -> Box < dyn Iterator < Item = ChainstateAccountLockup > > {
87+ pub fn get_account_lockups (
88+ use_test_chainstate_data : bool ,
89+ ) -> Box < dyn Iterator < Item = ChainstateAccountLockup > > {
9190 Box :: new (
92- GENESIS_DATA
91+ stx_genesis :: GenesisData :: new ( use_test_chainstate_data )
9392 . read_lockups ( )
9493 . map ( |item| ChainstateAccountLockup {
9594 address : item. address ,
@@ -99,9 +98,11 @@ pub fn get_account_lockups() -> Box<dyn Iterator<Item = ChainstateAccountLockup>
9998 )
10099}
101100
102- pub fn get_account_balances ( ) -> Box < dyn Iterator < Item = ChainstateAccountBalance > > {
101+ pub fn get_account_balances (
102+ use_test_chainstate_data : bool ,
103+ ) -> Box < dyn Iterator < Item = ChainstateAccountBalance > > {
103104 Box :: new (
104- GENESIS_DATA
105+ stx_genesis :: GenesisData :: new ( use_test_chainstate_data )
105106 . read_balances ( )
106107 . map ( |item| ChainstateAccountBalance {
107108 address : item. address ,
@@ -181,6 +182,22 @@ fn spawn_peer(
181182impl Node {
182183 /// Instantiate and initialize a new node, given a config
183184 pub fn new ( config : Config , boot_block_exec : Box < dyn FnOnce ( & mut ClarityTx ) -> ( ) > ) -> Self {
185+ let use_test_genesis_data = if config. burnchain . mode == "mocknet" {
186+ // When running in mocknet mode allow the small test genesis chainstate data to be enabled.
187+ // First check env var, then config file, then use default.
188+ if env:: var ( "BLOCKSTACK_USE_TEST_GENESIS_CHAINSTATE" ) == Ok ( "1" . to_string ( ) ) {
189+ true
190+ } else if let Some ( use_test_genesis_chainstate) =
191+ config. node . use_test_genesis_chainstate
192+ {
193+ use_test_genesis_chainstate
194+ } else {
195+ USE_TEST_GENESIS_CHAINSTATE
196+ }
197+ } else {
198+ USE_TEST_GENESIS_CHAINSTATE
199+ } ;
200+
184201 let keychain = Keychain :: default ( config. node . seed . clone ( ) ) ;
185202
186203 let initial_balances = config
@@ -195,8 +212,12 @@ impl Node {
195212 first_burnchain_block_height : 0 ,
196213 first_burnchain_block_timestamp : 0 ,
197214 post_flight_callback : Some ( boot_block_exec) ,
198- get_bulk_initial_lockups : Some ( Box :: new ( get_account_lockups) ) ,
199- get_bulk_initial_balances : Some ( Box :: new ( get_account_balances) ) ,
215+ get_bulk_initial_lockups : Some ( Box :: new ( move || {
216+ get_account_lockups ( use_test_genesis_data)
217+ } ) ) ,
218+ get_bulk_initial_balances : Some ( Box :: new ( move || {
219+ get_account_balances ( use_test_genesis_data)
220+ } ) ) ,
200221 } ;
201222
202223 let chain_state_result = StacksChainState :: open_and_exec (
0 commit comments