diff --git a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs index 5c6ba05551..8cf9ac82be 100644 --- a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs +++ b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs @@ -704,7 +704,7 @@ impl BitcoinRegtestController { block_height: u64, ) -> Option { // if mock mining, do not even bother requesting UTXOs - if self.config.get_node_config().mock_mining { + if self.config.get_node_config(false).mock_mining { return None; } diff --git a/testnet/stacks-node/src/config.rs b/testnet/stacks-node/src/config.rs index 0c2e16f8bb..60b60cf9f7 100644 --- a/testnet/stacks-node/src/config.rs +++ b/testnet/stacks-node/src/config.rs @@ -101,7 +101,8 @@ mod tests { seed = "invalid-hex-value" "#, ) - .unwrap() + .unwrap(), + false ) .unwrap_err() ); @@ -115,7 +116,8 @@ mod tests { local_peer_seed = "invalid-hex-value" "#, ) - .unwrap() + .unwrap(), + false ) .unwrap_err() ); @@ -130,6 +132,7 @@ mod tests { "#, ) .unwrap(), + false, ) .unwrap_err(); assert_eq!( @@ -137,7 +140,7 @@ mod tests { &actual_err_msg[..expected_err_prefix.len()] ); - assert!(Config::from_config_file(ConfigFile::from_str("").unwrap()).is_ok()); + assert!(Config::from_config_file(ConfigFile::from_str("").unwrap(), false).is_ok()); } #[test] @@ -195,6 +198,7 @@ mod tests { "#, ) .unwrap(), + false, ) .expect("Expected to be able to parse block proposal token from file"); @@ -218,6 +222,7 @@ mod tests { "# )) .expect("Expected to be able to parse config file from string"), + false, ) .expect("Expected to be able to parse affirmation map from file"); @@ -241,7 +246,7 @@ mod tests { )) .expect("Expected to be able to parse config file from string"); - assert!(Config::from_config_file(file).is_err()); + assert!(Config::from_config_file(file, false).is_err()); } #[test] @@ -249,6 +254,7 @@ mod tests { let config = Config::from_config_file( ConfigFile::from_str(r#""#) .expect("Expected to be able to parse config file from string"), + false, ) .expect("Expected to be able to parse affirmation map from file"); @@ -266,6 +272,7 @@ mod tests { "#, ) .expect("Expected to be able to parse config file from string"), + false, ) .expect("Expected to be able to parse affirmation map from file"); // Should default add xenon affirmation overrides @@ -291,6 +298,7 @@ mod tests { "#, )) .expect("Expected to be able to parse config file from string"), + false, ) .expect("Expected to be able to parse affirmation map from file"); // Should default add xenon affirmation overrides, but overwrite with the configured one above @@ -537,7 +545,7 @@ impl Config { let Ok(config_file) = ConfigFile::from_path(path.as_str()) else { return self.burnchain.clone(); }; - let Ok(config) = Config::from_config_file(config_file) else { + let Ok(config) = Config::from_config_file(config_file, false) else { return self.burnchain.clone(); }; config.burnchain @@ -552,20 +560,20 @@ impl Config { let Ok(config_file) = ConfigFile::from_path(path.as_str()) else { return self.miner.clone(); }; - let Ok(config) = Config::from_config_file(config_file) else { + let Ok(config) = Config::from_config_file(config_file, false) else { return self.miner.clone(); }; return config.miner; } - pub fn get_node_config(&self) -> NodeConfig { + pub fn get_node_config(&self, resolve_bootstrap_nodes: bool) -> NodeConfig { let Some(path) = &self.config_path else { return self.node.clone(); }; let Ok(config_file) = ConfigFile::from_path(path.as_str()) else { return self.node.clone(); }; - let Ok(config) = Config::from_config_file(config_file) else { + let Ok(config) = Config::from_config_file(config_file, resolve_bootstrap_nodes) else { return self.node.clone(); }; return config.node; @@ -941,11 +949,18 @@ impl Config { Ok(out_epochs) } - pub fn from_config_file(config_file: ConfigFile) -> Result { - Self::from_config_default(config_file, Config::default()) + pub fn from_config_file( + config_file: ConfigFile, + resolve_bootstrap_nodes: bool, + ) -> Result { + Self::from_config_default(config_file, Config::default(), resolve_bootstrap_nodes) } - fn from_config_default(config_file: ConfigFile, default: Config) -> Result { + fn from_config_default( + config_file: ConfigFile, + default: Config, + resolve_bootstrap_nodes: bool, + ) -> Result { let Config { node: default_node_config, burnchain: default_burnchain_config, @@ -996,9 +1011,15 @@ impl Config { }; if let Some(bootstrap_node) = bootstrap_node { - node.set_bootstrap_nodes(bootstrap_node, burnchain.chain_id, burnchain.peer_version); + if resolve_bootstrap_nodes { + node.set_bootstrap_nodes( + bootstrap_node, + burnchain.chain_id, + burnchain.peer_version, + ); + } } else { - if is_mainnet { + if is_mainnet && resolve_bootstrap_nodes { let bootstrap_node = ConfigFile::mainnet().node.unwrap().bootstrap_node.unwrap(); node.set_bootstrap_nodes( bootstrap_node, diff --git a/testnet/stacks-node/src/main.rs b/testnet/stacks-node/src/main.rs index cb512969c0..41b7426278 100644 --- a/testnet/stacks-node/src/main.rs +++ b/testnet/stacks-node/src/main.rs @@ -65,7 +65,7 @@ static GLOBAL: Jemalloc = Jemalloc; fn cli_pick_best_tip(config_path: &str, at_stacks_height: Option) -> TipCandidate { info!("Loading config at path {}", config_path); let config = match ConfigFile::from_path(config_path) { - Ok(config_file) => Config::from_config_file(config_file).unwrap(), + Ok(config_file) => Config::from_config_file(config_file, true).unwrap(), Err(e) => { warn!("Invalid config file: {}", e); process::exit(1); @@ -105,7 +105,7 @@ fn cli_get_miner_spend( ) -> u64 { info!("Loading config at path {}", config_path); let config = match ConfigFile::from_path(&config_path) { - Ok(config_file) => Config::from_config_file(config_file).unwrap(), + Ok(config_file) => Config::from_config_file(config_file, true).unwrap(), Err(e) => { warn!("Invalid config file: {}", e); process::exit(1); @@ -334,7 +334,7 @@ fn main() { process::exit(1); } }; - match Config::from_config_file(config_file) { + match Config::from_config_file(config_file, true) { Ok(_) => { info!("Loaded config!"); process::exit(0); @@ -365,9 +365,11 @@ fn main() { let seed = { let config_path: Option = args.opt_value_from_str("--config").unwrap(); if let Some(config_path) = config_path { - let conf = - Config::from_config_file(ConfigFile::from_path(&config_path).unwrap()) - .unwrap(); + let conf = Config::from_config_file( + ConfigFile::from_path(&config_path).unwrap(), + true, + ) + .unwrap(); args.finish(); conf.node.seed } else { @@ -416,7 +418,7 @@ fn main() { } }; - let conf = match Config::from_config_file(config_file) { + let conf = match Config::from_config_file(config_file, true) { Ok(conf) => conf, Err(e) => { warn!("Invalid config: {}", e); diff --git a/testnet/stacks-node/src/nakamoto_node.rs b/testnet/stacks-node/src/nakamoto_node.rs index 0cfc8130a1..439486a34f 100644 --- a/testnet/stacks-node/src/nakamoto_node.rs +++ b/testnet/stacks-node/src/nakamoto_node.rs @@ -167,7 +167,7 @@ impl StacksNode { let local_peer = p2p_net.local_peer.clone(); // setup initial key registration - let leader_key_registration_state = if config.get_node_config().mock_mining { + let leader_key_registration_state = if config.get_node_config(false).mock_mining { // mock mining, pretend to have a registered key let (vrf_public_key, _) = keychain.make_vrf_keypair(VRF_MOCK_MINER_KEY); LeaderKeyRegistrationState::Active(RegisteredKey { diff --git a/testnet/stacks-node/src/nakamoto_node/miner.rs b/testnet/stacks-node/src/nakamoto_node/miner.rs index 7597b3b43a..4b793d0106 100644 --- a/testnet/stacks-node/src/nakamoto_node/miner.rs +++ b/testnet/stacks-node/src/nakamoto_node/miner.rs @@ -656,7 +656,7 @@ impl BlockMinerThread { fn make_vrf_proof(&mut self) -> Option { // if we're a mock miner, then make sure that the keychain has a keypair for the mocked VRF // key - let vrf_proof = if self.config.get_node_config().mock_mining { + let vrf_proof = if self.config.get_node_config(false).mock_mining { self.keychain.generate_proof( VRF_MOCK_MINER_KEY, self.burn_block.sortition_hash.as_bytes(), diff --git a/testnet/stacks-node/src/neon_node.rs b/testnet/stacks-node/src/neon_node.rs index 5695ec81db..28e6552771 100644 --- a/testnet/stacks-node/src/neon_node.rs +++ b/testnet/stacks-node/src/neon_node.rs @@ -1712,7 +1712,7 @@ impl BlockMinerThread { fn make_vrf_proof(&mut self) -> Option { // if we're a mock miner, then make sure that the keychain has a keypair for the mocked VRF // key - let vrf_proof = if self.config.get_node_config().mock_mining { + let vrf_proof = if self.config.get_node_config(false).mock_mining { self.keychain.generate_proof( VRF_MOCK_MINER_KEY, self.burn_block.sortition_hash.as_bytes(), @@ -2535,7 +2535,7 @@ impl BlockMinerThread { let res = bitcoin_controller.submit_operation(target_epoch_id, op, &mut op_signer, attempt); if res.is_none() { self.failed_to_submit_last_attempt = true; - if !self.config.get_node_config().mock_mining { + if !self.config.get_node_config(false).mock_mining { warn!("Relayer: Failed to submit Bitcoin transaction"); return None; } @@ -3518,7 +3518,7 @@ impl RelayerThread { return false; } - if !self.config.get_node_config().mock_mining { + if !self.config.get_node_config(false).mock_mining { // mock miner can't mine microblocks yet, so don't stop it from trying multiple // anchored blocks if self.mined_stacks_block && self.config.node.mine_microblocks { @@ -4777,7 +4777,7 @@ impl StacksNode { let local_peer = p2p_net.local_peer.clone(); // setup initial key registration - let leader_key_registration_state = if config.get_node_config().mock_mining { + let leader_key_registration_state = if config.get_node_config(false).mock_mining { // mock mining, pretend to have a registered key let (vrf_public_key, _) = keychain.make_vrf_keypair(VRF_MOCK_MINER_KEY); LeaderKeyRegistrationState::Active(RegisteredKey { diff --git a/testnet/stacks-node/src/run_loop/nakamoto.rs b/testnet/stacks-node/src/run_loop/nakamoto.rs index fa6045cd66..b7cdb8a053 100644 --- a/testnet/stacks-node/src/run_loop/nakamoto.rs +++ b/testnet/stacks-node/src/run_loop/nakamoto.rs @@ -195,7 +195,7 @@ impl RunLoop { return true; } } - if self.config.get_node_config().mock_mining { + if self.config.get_node_config(false).mock_mining { info!("No UTXOs found, but configured to mock mine"); return true; } else { diff --git a/testnet/stacks-node/src/run_loop/neon.rs b/testnet/stacks-node/src/run_loop/neon.rs index 2c1bc5b70f..c9925ce196 100644 --- a/testnet/stacks-node/src/run_loop/neon.rs +++ b/testnet/stacks-node/src/run_loop/neon.rs @@ -373,7 +373,7 @@ impl RunLoop { return true; } } - if self.config.get_node_config().mock_mining { + if self.config.get_node_config(false).mock_mining { info!("No UTXOs found, but configured to mock mine"); return true; } else { diff --git a/testnet/stacks-node/src/tests/neon_integrations.rs b/testnet/stacks-node/src/tests/neon_integrations.rs index 2dce43b661..20302d251c 100644 --- a/testnet/stacks-node/src/tests/neon_integrations.rs +++ b/testnet/stacks-node/src/tests/neon_integrations.rs @@ -149,7 +149,7 @@ fn inner_neon_integration_test_conf(seed: Option>) -> (Config, StacksAdd burnchain.peer_host = Some("127.0.0.1".to_string()); } - let magic_bytes = Config::from_config_file(cfile) + let magic_bytes = Config::from_config_file(cfile, false) .unwrap() .burnchain .magic_bytes;