Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkgs/params/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pkgs/params/corpus/chainparams.json5
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions pkgs/params/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
}
}

Expand Down
1 change: 1 addition & 0 deletions pkgs/params/src/params/mainnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions pkgs/params/src/params/regtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions pkgs/params/src/params/test3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 16 additions & 1 deletion pkgs/params/tests/corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)]
Expand Down
Loading