Adds a DNetworkUpgradeActivationHeights struct for better control over how activation heights can be configured
This commit is contained in:
parent
325a6c6154
commit
f724c0188f
|
@ -625,10 +625,23 @@ impl<'de> Deserialize<'de> for Config {
|
|||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
#[derive(Deserialize, Default)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
struct DNetworkUpgradeActivationHeights {
|
||||
before_overwinter: Option<u32>,
|
||||
overwinter: Option<u32>,
|
||||
sapling: Option<u32>,
|
||||
blossom: Option<u32>,
|
||||
heartwood: Option<u32>,
|
||||
canopy: Option<u32>,
|
||||
#[serde(rename = "NU5")]
|
||||
nu5: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct DTestnetParameters {
|
||||
#[serde(default)]
|
||||
pub(super) activation_heights: Vec<(u32, NetworkUpgrade)>,
|
||||
pub(super) activation_heights: DNetworkUpgradeActivationHeights,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -675,7 +688,21 @@ impl<'de> Deserialize<'de> for Config {
|
|||
max_connections_per_ip,
|
||||
} = DConfig::deserialize(deserializer)?;
|
||||
|
||||
let network = if let Some(DTestnetParameters { activation_heights }) = testnet_parameters {
|
||||
let network = if let Some(DTestnetParameters {
|
||||
activation_heights:
|
||||
DNetworkUpgradeActivationHeights {
|
||||
before_overwinter,
|
||||
overwinter,
|
||||
sapling,
|
||||
blossom,
|
||||
heartwood,
|
||||
canopy,
|
||||
nu5,
|
||||
},
|
||||
}) = testnet_parameters
|
||||
{
|
||||
use NetworkUpgrade::*;
|
||||
|
||||
// TODO: Panic here if the initial testnet peers are the default initial testnet peers.
|
||||
assert_eq!(
|
||||
network_kind,
|
||||
|
@ -683,19 +710,16 @@ impl<'de> Deserialize<'de> for Config {
|
|||
"set network to 'Testnet' to use configured testnet parameters"
|
||||
);
|
||||
|
||||
let activation_heights = activation_heights
|
||||
let activation_heights = before_overwinter
|
||||
.into_iter()
|
||||
.map(|(height, network_upgrade)| {
|
||||
assert!(
|
||||
network_upgrade != NetworkUpgrade::Genesis || height == 0,
|
||||
"Genesis network upgrade activation height is not configurable"
|
||||
);
|
||||
|
||||
(
|
||||
height.try_into().expect("activation height must be valid"),
|
||||
network_upgrade,
|
||||
)
|
||||
})
|
||||
.map(|h| (h, BeforeOverwinter))
|
||||
.chain(overwinter.into_iter().map(|h| (h, Overwinter)))
|
||||
.chain(sapling.into_iter().map(|h| (h, Sapling)))
|
||||
.chain(blossom.into_iter().map(|h| (h, Blossom)))
|
||||
.chain(heartwood.into_iter().map(|h| (h, Heartwood)))
|
||||
.chain(canopy.into_iter().map(|h| (h, Canopy)))
|
||||
.chain(nu5.into_iter().map(|h| (h, Nu5)))
|
||||
.map(|(h, nu)| (h.try_into().expect("activation height must be valid"), nu))
|
||||
.collect();
|
||||
|
||||
let testnet_parameters = testnet::Parameters::build()
|
||||
|
|
|
@ -60,16 +60,14 @@ max_connections_per_ip = 1
|
|||
network = "Testnet"
|
||||
peerset_initial_target_size = 25
|
||||
|
||||
[network.testnet_parameters]
|
||||
activation_heights = [
|
||||
[1, "BeforeOverwinter"],
|
||||
[207_500, "Overwinter"],
|
||||
[280_000, "Sapling"],
|
||||
[584_000, "Blossom"],
|
||||
[903_800, "Heartwood"],
|
||||
[1_028_500, "Canopy"],
|
||||
[1_842_420, "NU5"],
|
||||
]
|
||||
[network.testnet_parameters.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
|
||||
|
@ -90,4 +88,4 @@ parallel_cpu_threads = 0
|
|||
buffer_limit = 128000
|
||||
force_use_color = false
|
||||
use_color = true
|
||||
use_journald = false
|
||||
use_journald = false
|
||||
|
|
Loading…
Reference in New Issue