Remove duplicate and redundant consensus parameter code (#4760)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
teor 2022-07-23 02:33:26 +10:00 committed by GitHub
parent f9d7451fa2
commit 2978cae54c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 0 additions and 102 deletions

View File

@ -37,7 +37,6 @@
mod block;
mod checkpoint;
mod config;
#[allow(dead_code)]
mod parameters;
mod primitives;
mod script;

View File

@ -12,11 +12,6 @@
//! Typically, consensus parameters are accessed via a function that takes a
//! `Network` and `block::Height`.
pub mod minimum_difficulty;
pub mod subsidy;
pub use minimum_difficulty::*;
pub use subsidy::*;
#[cfg(test)]
mod tests;

View File

@ -1,39 +0,0 @@
//! The minimum difficulty block rule for Zcash.
use zebra_chain::{block, parameters::Network};
/// The testnet block height when minimum difficulty blocks start being
/// accepted.
pub(crate) const TESTNET_MINIMUM_DIFFICULTY_HEIGHT: block::Height = block::Height(299_188);
/// The Zcash Testnet consensus rules were changed to allow
/// minimum-difficulty blocks, shortly after Testnet Sapling activation.
/// See ZIP-205 and ZIP-208 for details.
///
/// This change represents a hard-fork on Testnet, but it doesn't appear on
/// Mainnet, so we handle it as an independent consensus rule change.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum MinimumDifficulty {
/// Minimum difficulty blocks are rejected.
///
/// Always returned for Mainnet blocks.
Rejected,
/// Minimum difficulty blocks are allowed.
///
/// Only allowed for Testnet blocks.
AllowedOnTestnet,
}
impl MinimumDifficulty {
/// Returns the current minimum difficulty rule for `network` and `height`.
pub fn current(network: Network, height: block::Height) -> MinimumDifficulty {
use MinimumDifficulty::*;
use Network::*;
match network {
Mainnet => Rejected,
Testnet if (height >= TESTNET_MINIMUM_DIFFICULTY_HEIGHT) => AllowedOnTestnet,
Testnet => Rejected,
}
}
}

View File

@ -52,15 +52,6 @@ pub enum FundingStreamReceiver {
MajorGrants,
}
impl FundingStreamReceiver {
/// Get a list of receiver types
pub const fn receivers() -> [Self; 3] {
[Self::Ecc, Self::ZcashFoundation, Self::MajorGrants]
}
}
/// The number of funding stream receiver categories.
pub const FUNDING_STREAM_RECEIVERS_NUMBER: usize = FundingStreamReceiver::receivers().len();
/// Denominator as described in [protocol specification §7.10.1][7.10.1].
///
/// [7.10.1]: https://zips.z.cash/protocol/protocol.pdf#zip214fundingstreams

View File

@ -1,48 +0,0 @@
//! Consensus parameter tests for Zebra.
use super::*;
use zebra_chain::{
block,
parameters::Network::{self, *},
};
#[test]
fn minimum_difficulty_mainnet() {
minimum_difficulty(Mainnet)
}
#[test]
fn minimum_difficulty_testnet() {
minimum_difficulty(Testnet)
}
/// Test MinimumDifficulty
fn minimum_difficulty(network: Network) {
zebra_test::init();
use block::Height;
use MinimumDifficulty::*;
let allowed_if_testnet = match network {
Mainnet => Rejected,
Testnet => AllowedOnTestnet,
};
assert_eq!(MinimumDifficulty::current(network, Height(0)), Rejected);
assert_eq!(
MinimumDifficulty::current(network, Height(299_187)),
Rejected
);
assert_eq!(
MinimumDifficulty::current(network, Height(299_188)),
allowed_if_testnet
);
assert_eq!(
MinimumDifficulty::current(network, Height(299_189)),
allowed_if_testnet
);
assert_eq!(
MinimumDifficulty::current(network, Height::MAX),
allowed_if_testnet
);
}