diff --git a/pkgs/params/CHANGELOG.md b/pkgs/params/CHANGELOG.md index 6147e62f0..23f708cb1 100644 --- a/pkgs/params/CHANGELOG.md +++ b/pkgs/params/CHANGELOG.md @@ -12,6 +12,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Added - `BRR_PERIODS_PERMILLE`, the masternode share of the block value in each block reward reallocation period. +- **`BuriedDeployment::Ipv4Optional` and `ConsensusParams::ipv4_optional_height`**, from which masternode primary + addresses need not be IPv4. As in the reference implementation v24.0.0, the height is 0 on testnet and not scheduled + (`ConsensusParams::NOT_SCHEDULED`) on mainnet and regtest. ### Changed diff --git a/pkgs/params/corpus/chainparams.json5 b/pkgs/params/corpus/chainparams.json5 index f3a92479d..b69be36f0 100644 --- a/pkgs/params/corpus/chainparams.json5 +++ b/pkgs/params/corpus/chainparams.json5 @@ -1,6 +1,6 @@ // // Chain parameter vectors. Generated with the reference implementation -// (dashpay/dash v24.0.0-rc.5, 8163290aa0). +// (dashpay/dash v24.0.0, 938fba5028). // // Each entry is the output of the command above it, keyed by chain. The node // of each chain runs with an empty data directory and no connections, so it diff --git a/pkgs/params/src/consensus.rs b/pkgs/params/src/consensus.rs index 36ef5017b..83664b7ae 100644 --- a/pkgs/params/src/consensus.rs +++ b/pkgs/params/src/consensus.rs @@ -61,6 +61,8 @@ pub enum BuriedDeployment { MnRr, /// Credit withdrawal transactions. Withdrawals, + /// Masternode primary addresses need not be IPv4. + Ipv4Optional, } /// Parameters that influence chain consensus. @@ -142,6 +144,8 @@ pub struct ConsensusParams { pub mn_rr_height: BlockHeight, /// Credit withdrawal activation height. pub withdrawals_height: BlockHeight, + /// Height from which masternode primary addresses need not be IPv4. + pub ipv4_optional_height: BlockHeight, /// Minimum height before BIP9 warning triggers. pub min_bip9_warning_height: BlockHeight, /// Threshold of blocks in a window that must @@ -188,6 +192,9 @@ pub struct ConsensusParams { } impl ConsensusParams { + /// Activation height of a buried deployment that is not scheduled. + pub const NOT_SCHEDULED: BlockHeight = BlockHeight::from_u32(i32::MAX.unsigned_abs()); + /// Returns the activation height for a buried deployment. pub const fn deployment_height(&self, dep: BuriedDeployment) -> BlockHeight { match dep { @@ -206,6 +213,7 @@ impl ConsensusParams { BuriedDeployment::V20 => self.v20_height, BuriedDeployment::MnRr => self.mn_rr_height, BuriedDeployment::Withdrawals => self.withdrawals_height, + BuriedDeployment::Ipv4Optional => self.ipv4_optional_height, } } diff --git a/pkgs/params/src/params/mainnet.rs b/pkgs/params/src/params/mainnet.rs index f756c5e32..54f1b505d 100644 --- a/pkgs/params/src/params/mainnet.rs +++ b/pkgs/params/src/params/mainnet.rs @@ -59,6 +59,7 @@ pub static PARAMS: ChainParams = ChainParams { v20_height: BlockHeight::from_u32(1_987_776), mn_rr_height: BlockHeight::from_u32(2_128_896), withdrawals_height: BlockHeight::from_u32(2_201_472), + ipv4_optional_height: ConsensusParams::NOT_SCHEDULED, min_bip9_warning_height: BlockHeight::from_u32(2_201_472 + 2016), rule_change_activation_threshold: 1815, // 90% of 2016 miner_confirmation_window: 2016, diff --git a/pkgs/params/src/params/regtest.rs b/pkgs/params/src/params/regtest.rs index 50dc79e73..a027a9992 100644 --- a/pkgs/params/src/params/regtest.rs +++ b/pkgs/params/src/params/regtest.rs @@ -51,6 +51,7 @@ pub static PARAMS: ChainParams = ChainParams { v20_height: BlockHeight::from_u32(432), // equals dip0003_height mn_rr_height: BlockHeight::from_u32(432), // equals v20_height withdrawals_height: BlockHeight::from_u32(600), + ipv4_optional_height: ConsensusParams::NOT_SCHEDULED, min_bip9_warning_height: BlockHeight::from_u32(0), rule_change_activation_threshold: 108, // 75% of 144 miner_confirmation_window: 144, diff --git a/pkgs/params/src/params/test3.rs b/pkgs/params/src/params/test3.rs index 89afe413e..b9815e4e5 100644 --- a/pkgs/params/src/params/test3.rs +++ b/pkgs/params/src/params/test3.rs @@ -57,6 +57,7 @@ pub static PARAMS: ChainParams = ChainParams { v20_height: BlockHeight::from_u32(905_100), mn_rr_height: BlockHeight::from_u32(1_066_900), withdrawals_height: BlockHeight::from_u32(1_148_500), + ipv4_optional_height: BlockHeight::from_u32(0), min_bip9_warning_height: BlockHeight::from_u32(1_148_500 + 2016), rule_change_activation_threshold: 1512, // 75% for testchains miner_confirmation_window: 2016, diff --git a/pkgs/params/tests/corpus.rs b/pkgs/params/tests/corpus.rs index 928135ec7..301705240 100644 --- a/pkgs/params/tests/corpus.rs +++ b/pkgs/params/tests/corpus.rs @@ -62,7 +62,7 @@ struct Bip9 { } /// The buried deployments under the names `getdeploymentinfo` reports them -/// under. +/// under. It does not report [`BuriedDeployment::Ipv4Optional`]. const BURIED: [(&str, BuriedDeployment); 15] = [ ("bip34", BuriedDeployment::HeightInCoinbase), ("bip66", BuriedDeployment::DerSig), @@ -148,6 +148,21 @@ fn deployments_match_vectors(#[case] network: Network) { assert_eq!(infos.get(chain.network_id), Some(&DeploymentInfo::from(chain))); } +/// The `ipv4_optional` height is 0 on testnet and not scheduled (`i32::MAX`) +/// on mainnet and regtest. +#[rstest] +#[case::mainnet(Network::Main, 2_147_483_647)] +#[case::testnet(Network::Testnet3, 0)] +#[case::regtest(Network::Regtest, 2_147_483_647)] +fn ipv4_optional_heights(#[case] network: Network, #[case] height: u32) { + let consensus = network.consensus(); + assert_eq!(consensus.ipv4_optional_height.to_u32(), height); + assert_eq!( + consensus.deployment_height(BuriedDeployment::Ipv4Optional).to_u32(), + height + ); +} + #[rstest] #[case::mainnet(Network::Main)] #[case::testnet(Network::Testnet3)]