Always activate Canopy at Height(1) on Regtest
This commit is contained in:
parent
d84d7356dd
commit
7b009b34c4
|
@ -11,8 +11,6 @@ use crate::{
|
|||
parameters::NetworkUpgrade,
|
||||
};
|
||||
|
||||
use self::testnet::ConfiguredActivationHeights;
|
||||
|
||||
pub mod testnet;
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -167,8 +165,8 @@ 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))
|
||||
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 the default Testnet, or false otherwise.
|
||||
|
|
|
@ -310,7 +310,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()
|
||||
|
@ -323,7 +323,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()
|
||||
}
|
||||
}
|
||||
|
@ -344,7 +348,7 @@ impl Parameters {
|
|||
hrp_sapling_extended_full_viewing_key,
|
||||
hrp_sapling_payment_address,
|
||||
disable_pow,
|
||||
} = Self::new_regtest(ConfiguredActivationHeights::default());
|
||||
} = Self::new_regtest(None);
|
||||
|
||||
self.network_name == network_name
|
||||
&& self.genesis_hash == genesis_hash
|
||||
|
|
|
@ -135,7 +135,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 [
|
||||
|
|
|
@ -230,9 +230,7 @@ impl Config {
|
|||
Network::Testnet(params) if params.is_default_testnet() => {
|
||||
self.initial_testnet_peers.clone()
|
||||
}
|
||||
// TODO: Check if the network is an incompatible custom testnet (_not_ Regtest), then panic if `initial_testnet_peers`
|
||||
// contains any of the default testnet peers, or return `initial_testnet_peers` otherwise. See:
|
||||
// <https://github.com/ZcashFoundation/zebra/pull/7924#discussion_r1385881828>
|
||||
// TODO: Add a `disable_peers` field to `Network` to check instead of `is_default_testnet()` (#8361)
|
||||
Network::Testnet(_params) => IndexSet::new(),
|
||||
}
|
||||
}
|
||||
|
@ -639,7 +637,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 +654,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 +669,7 @@ impl<'de> Deserialize<'de> for Config {
|
|||
listen_addr,
|
||||
network: network_kind,
|
||||
testnet_parameters,
|
||||
regtest_activation_heights,
|
||||
regtest_nu5_activation_height,
|
||||
initial_mainnet_peers,
|
||||
initial_testnet_peers,
|
||||
cache_dir,
|
||||
|
@ -700,7 +698,7 @@ impl<'de> Deserialize<'de> for Config {
|
|||
let network = match (network_kind, testnet_parameters) {
|
||||
(NetworkKind::Mainnet, _) => Network::Mainnet,
|
||||
(NetworkKind::Testnet, None) => Network::new_default_testnet(),
|
||||
(NetworkKind::Regtest, _) => Network::new_regtest(regtest_activation_heights),
|
||||
(NetworkKind::Regtest, _) => Network::new_regtest(regtest_nu5_activation_height),
|
||||
(
|
||||
NetworkKind::Testnet,
|
||||
Some(DTestnetParameters {
|
||||
|
|
|
@ -60,6 +60,8 @@ max_connections_per_ip = 1
|
|||
network = "Regtest"
|
||||
peerset_initial_target_size = 25
|
||||
|
||||
regtest_nu5_activation_height = 1
|
||||
|
||||
[network.testnet_parameters]
|
||||
network_name = "ConfiguredTestnet_1"
|
||||
|
||||
|
|
Loading…
Reference in New Issue