diff --git a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs index 8b23d48c1f6..04f49b5dbf9 100644 --- a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs +++ b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs @@ -802,8 +802,12 @@ impl BitcoinRegtestController { ) -> Option { let public_key = signer.get_public_key(); - let btc_miner_fee = self.config.burnchain.leader_key_tx_estimated_size - * self.config.burnchain.satoshis_per_byte; + // reload the config to find satoshis_per_byte changes + let satoshis_per_byte = match self.config.get_burnchain_config() { + Ok(s) => s.satoshis_per_byte, + Err(_) => self.config.burnchain.satoshis_per_byte, + }; + let btc_miner_fee = self.config.burnchain.leader_key_tx_estimated_size * satoshis_per_byte; let budget_for_outputs = DUST_UTXO_LIMIT; let total_required = btc_miner_fee + budget_for_outputs; @@ -831,7 +835,7 @@ impl BitcoinRegtestController { tx.output = vec![consensus_output]; - let fee_rate = self.config.burnchain.satoshis_per_byte; + let fee_rate = satoshis_per_byte; self.finalize_tx( epoch_id, diff --git a/testnet/stacks-node/src/config.rs b/testnet/stacks-node/src/config.rs index c7b47f2aadf..987f0cf27d4 100644 --- a/testnet/stacks-node/src/config.rs +++ b/testnet/stacks-node/src/config.rs @@ -48,6 +48,7 @@ const INV_REWARD_CYCLES_TESTNET: u64 = 6; #[derive(Clone, Deserialize, Default, Debug)] pub struct ConfigFile { + pub path: Option, pub burnchain: Option, pub node: Option, pub ustx_balance: Option>, @@ -178,7 +179,9 @@ mod tests { impl ConfigFile { pub fn from_path(path: &str) -> Result { let content = fs::read_to_string(path).map_err(|e| format!("Invalid path: {}", &e))?; - Self::from_str(&content) + let mut f = Self::from_str(&content)?; + f.path = Some(path.to_string()); + Ok(f) } pub fn from_str(content: &str) -> Result { @@ -353,6 +356,7 @@ impl ConfigFile { #[derive(Clone, Debug)] pub struct Config { + pub config_path: Option, pub burnchain: BurnchainConfig, pub node: NodeConfig, pub initial_balances: Vec, @@ -394,6 +398,16 @@ lazy_static! { } impl Config { + /// get the up-to-date burnchain from the config + pub fn get_burnchain_config(&self) -> Result { + if let Some(path) = &self.config_path { + let config_file = ConfigFile::from_path(path.as_str())?; + let config = Config::from_config_file(config_file)?; + Ok(config.burnchain) + } else { + Ok(self.burnchain.clone()) + } + } /// Apply any test settings to this burnchain config struct fn apply_test_settings(&self, burnchain: &mut Burnchain) { if self.burnchain.get_bitcoin_network().1 == BitcoinNetworkType::Mainnet { @@ -1148,6 +1162,7 @@ impl Config { }; Ok(Config { + config_path: config_file.path, node, burnchain, initial_balances, @@ -1308,6 +1323,7 @@ impl std::default::Default for Config { let estimation = FeeEstimationConfig::default(); Config { + config_path: None, burnchain, node, initial_balances: vec![], @@ -1386,7 +1402,6 @@ impl BurnchainConfig { ast_precheck_size_height: None, } } - pub fn get_rpc_url(&self, wallet: Option) -> String { let scheme = match self.rpc_ssl { true => "https://",