height (header version) specific output PMMR root rules (#3147)
* height (header version) specific output PMMR root rules * cleanup * cleanup based on PR feedback * address feedback
This commit is contained in:
+18
-2
@@ -133,12 +133,19 @@ pub const FLOONET_FIRST_HARD_FORK: u64 = 185_040;
|
||||
/// Floonet second hard fork height, set to happen around 2019-12-19
|
||||
pub const FLOONET_SECOND_HARD_FORK: u64 = 298_080;
|
||||
|
||||
/// AutomatedTesting and UserTesting first hard fork height.
|
||||
pub const TESTING_FIRST_HARD_FORK: u64 = 3;
|
||||
|
||||
/// AutomatedTesting and UserTesting second hard fork height.
|
||||
pub const TESTING_SECOND_HARD_FORK: u64 = 6;
|
||||
|
||||
/// Compute possible block version at a given height, implements
|
||||
/// 6 months interval scheduled hard forks for the first 2 years.
|
||||
pub fn header_version(height: u64) -> HeaderVersion {
|
||||
let chain_type = global::CHAIN_TYPE.read().clone();
|
||||
let hf_interval = (1 + height / HARD_FORK_INTERVAL) as u16;
|
||||
match chain_type {
|
||||
global::ChainTypes::Mainnet => HeaderVersion(hf_interval),
|
||||
global::ChainTypes::Floonet => {
|
||||
if height < FLOONET_FIRST_HARD_FORK {
|
||||
(HeaderVersion(1))
|
||||
@@ -150,8 +157,17 @@ pub fn header_version(height: u64) -> HeaderVersion {
|
||||
HeaderVersion(hf_interval)
|
||||
}
|
||||
}
|
||||
// everything else just like mainnet
|
||||
_ => HeaderVersion(hf_interval),
|
||||
global::ChainTypes::AutomatedTesting | global::ChainTypes::UserTesting => {
|
||||
if height < TESTING_FIRST_HARD_FORK {
|
||||
(HeaderVersion(1))
|
||||
} else if height < TESTING_SECOND_HARD_FORK {
|
||||
(HeaderVersion(2))
|
||||
} else if height < 3 * HARD_FORK_INTERVAL {
|
||||
(HeaderVersion(3))
|
||||
} else {
|
||||
HeaderVersion(hf_interval)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ impl Hashed for HeaderEntry {
|
||||
}
|
||||
|
||||
/// Some type safety around header versioning.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct HeaderVersion(pub u16);
|
||||
|
||||
impl From<HeaderVersion> for u16 {
|
||||
|
||||
Reference in New Issue
Block a user