Require a minimum network protocol version of 170_040 (#3976)

This is the `zcashd` network protocol version:
- after the first NU5 testnet activation, and
- after updating to the second NU5 testnet activation consensus rules,
- but before setting the second NU5 testnet activation height.
This commit is contained in:
teor 2022-04-20 02:14:24 +10:00 committed by GitHub
parent 65b94f7e50
commit 5054e048d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 12 deletions

View File

@ -68,7 +68,7 @@ pub(super) const MAINNET_ACTIVATION_HEIGHTS: &[(block::Height, NetworkUpgrade)]
(block::Height(653_600), Blossom), (block::Height(653_600), Blossom),
(block::Height(903_000), Heartwood), (block::Height(903_000), Heartwood),
(block::Height(1_046_400), Canopy), (block::Height(1_046_400), Canopy),
// TODO: Add Nu5 mainnet activation height // TODO: Add Nu5 mainnet activation height (#4115)
]; ];
/// Fake mainnet network upgrade activation heights, used in tests. /// Fake mainnet network upgrade activation heights, used in tests.

View File

@ -1,4 +1,9 @@
//! Definitions of constants. //! Definitions of Zebra network constants, including:
//! - network protocol versions,
//! - network protocol user agents,
//! - peer address limits,
//! - peer connection limits, and
//! - peer connection timeouts.
use std::{collections::HashMap, time::Duration}; use std::{collections::HashMap, time::Duration};
@ -9,7 +14,10 @@ use regex::Regex;
use crate::protocol::external::types::*; use crate::protocol::external::types::*;
use zebra_chain::{ use zebra_chain::{
parameters::{Network, NetworkUpgrade}, parameters::{
Network::{self, *},
NetworkUpgrade::*,
},
serialization::Duration32, serialization::Duration32,
}; };
@ -241,6 +249,8 @@ pub const USER_AGENT: &str = "/Zebra:1.0.0-beta.8/";
/// ///
/// The current protocol version typically changes before Mainnet and Testnet /// The current protocol version typically changes before Mainnet and Testnet
/// network upgrades. /// network upgrades.
//
// TODO: update to Nu5 mainnet (#4115)
pub const CURRENT_NETWORK_PROTOCOL_VERSION: Version = Version(170_050); pub const CURRENT_NETWORK_PROTOCOL_VERSION: Version = Version(170_050);
/// The default RTT estimate for peer responses. /// The default RTT estimate for peer responses.
@ -275,10 +285,22 @@ lazy_static! {
/// ///
/// The minimum network protocol version typically changes after Mainnet and/or /// The minimum network protocol version typically changes after Mainnet and/or
/// Testnet network upgrades. /// Testnet network upgrades.
pub static ref INITIAL_MIN_NETWORK_PROTOCOL_VERSION: HashMap<Network, NetworkUpgrade> = { pub static ref INITIAL_MIN_NETWORK_PROTOCOL_VERSION: HashMap<Network, Version> = {
let mut hash_map = HashMap::new(); let mut hash_map = HashMap::new();
hash_map.insert(Network::Mainnet, NetworkUpgrade::Canopy);
hash_map.insert(Network::Testnet, NetworkUpgrade::Canopy); // TODO: update to Nu5 when there are enough Nu5 mainnet nodes deployed (#4117)
hash_map.insert(Mainnet, Version::min_specified_for_upgrade(Mainnet, Canopy));
// This is the `zcashd` network protocol version:
// - after the first NU5 testnet activation, and
// - after updating to the second NU5 testnet activation consensus rules,
// - but before setting the second NU5 testnet activation height.
//
// TODO: update to:
// Version::min_specified_for_upgrade(Mainnet, Nu5)
// when there are enough Nu5 testnet nodes deployed (#4116)
hash_map.insert(Testnet, Version(170_040));
hash_map hash_map
}; };

View File

@ -77,12 +77,9 @@ impl Version {
/// - after Zebra restarts, and /// - after Zebra restarts, and
/// - after Zebra's local network is slow or shut down. /// - after Zebra's local network is slow or shut down.
fn initial_min_for_network(network: Network) -> Version { fn initial_min_for_network(network: Network) -> Version {
Version::min_specified_for_upgrade(
network,
*constants::INITIAL_MIN_NETWORK_PROTOCOL_VERSION *constants::INITIAL_MIN_NETWORK_PROTOCOL_VERSION
.get(&network) .get(&network)
.expect("We always have a value for testnet or mainnet"), .expect("We always have a value for testnet or mainnet")
)
} }
/// Returns the minimum specified network protocol version for `network` and /// Returns the minimum specified network protocol version for `network` and