Always activate Canopy at Height(1) on Regtest

This commit is contained in:
Arya 2024-04-23 22:33:14 -04:00
parent 301900435b
commit 663ad1e629
5 changed files with 16 additions and 21 deletions

View File

@ -11,8 +11,6 @@ use crate::{
parameters::NetworkUpgrade,
};
use self::testnet::ConfiguredActivationHeights;
pub mod testnet;
#[cfg(test)]
@ -167,8 +165,9 @@ impl Network {
}
/// Creates a new [`Network::Testnet`] with `Regtest` parameters and the provided network upgrade activation heights.
pub fn new_regtest(activation_heights: ConfiguredActivationHeights) -> Self {
Self::new_configured_testnet(testnet::Parameters::new_regtest(activation_heights))
// TODO: Support constructing pre-Canopy block templates and accept more activation heights (#8434)
pub fn new_regtest(nu5_activation_height: Option<u32>) -> Self {
Self::new_configured_testnet(testnet::Parameters::new_regtest(nu5_activation_height))
}
/// Returns true if the network is Mainnet or the default Testnet, or false otherwise.

View File

@ -328,7 +328,7 @@ impl Parameters {
/// Accepts a [`ConfiguredActivationHeights`].
///
/// Creates an instance of [`Parameters`] with `Regtest` values.
pub fn new_regtest(activation_heights: ConfiguredActivationHeights) -> Self {
pub fn new_regtest(nu5_activation_height: Option<u32>) -> Self {
Self {
network_name: "Regtest".to_string(),
..Self::build()
@ -342,7 +342,11 @@ impl Parameters {
)
// Removes default Testnet activation heights if not configured,
// most network upgrades are disabled by default for Regtest in zcashd
.with_activation_heights(activation_heights)
.with_activation_heights(ConfiguredActivationHeights {
canopy: Some(1),
nu5: nu5_activation_height,
..Default::default()
})
.finish()
}
}
@ -364,7 +368,7 @@ impl Parameters {
hrp_sapling_payment_address,
disable_pow,
debug_validate_without_checkpoints,
} = Self::new_regtest(ConfiguredActivationHeights::default());
} = Self::new_regtest(None);
self.network_name == network_name
&& self.genesis_hash == genesis_hash

View File

@ -134,7 +134,7 @@ fn activates_network_upgrades_correctly() {
let expected_default_regtest_activation_heights = &[
(Height(0), NetworkUpgrade::Genesis),
(Height(1), NetworkUpgrade::BeforeOverwinter),
(Height(1), NetworkUpgrade::Canopy),
];
for (network, expected_activation_heights) in [

View File

@ -639,7 +639,7 @@ impl<'de> Deserialize<'de> for Config {
listen_addr: String,
network: NetworkKind,
testnet_parameters: Option<DTestnetParameters>,
regtest_activation_heights: ConfiguredActivationHeights,
regtest_nu5_activation_height: Option<u32>,
initial_mainnet_peers: IndexSet<String>,
initial_testnet_peers: IndexSet<String>,
cache_dir: CacheDir,
@ -656,7 +656,7 @@ impl<'de> Deserialize<'de> for Config {
listen_addr: "0.0.0.0".to_string(),
network: Default::default(),
testnet_parameters: None,
regtest_activation_heights: ConfiguredActivationHeights::default(),
regtest_nu5_activation_height: None,
initial_mainnet_peers: config.initial_mainnet_peers,
initial_testnet_peers: config.initial_testnet_peers,
cache_dir: config.cache_dir,
@ -671,7 +671,7 @@ impl<'de> Deserialize<'de> for Config {
listen_addr,
network: network_kind,
testnet_parameters,
regtest_activation_heights,
regtest_nu5_activation_height,
mut initial_mainnet_peers,
mut initial_testnet_peers,
cache_dir,
@ -703,7 +703,7 @@ impl<'de> Deserialize<'de> for Config {
(NetworkKind::Regtest, _) => {
initial_mainnet_peers = Default::default();
initial_testnet_peers = Default::default();
Network::new_regtest(regtest_activation_heights)
Network::new_regtest(regtest_nu5_activation_height)
}
(
NetworkKind::Testnet,

View File

@ -59,6 +59,7 @@ listen_addr = "0.0.0.0:8233"
max_connections_per_ip = 1
network = "Regtest"
peerset_initial_target_size = 25
regtest_nu5_activation_height = 1
[network.testnet_parameters]
network_name = "ConfiguredTestnet_1"
@ -72,15 +73,6 @@ Heartwood = 903_800
Canopy = 1_028_500
NU5 = 1_842_420
[network.regtest_activation_heights]
BeforeOverwinter = 1
Overwinter = 207_500
Sapling = 280_000
Blossom = 584_000
Heartwood = 903_800
Canopy = 1_028_500
NU5 = 1_842_420
[rpc]
debug_force_finished_sync = false
parallel_cpu_threads = 0