Remove const activation heights from consensus.rs
This commit is contained in:
parent
9970a8aefd
commit
4f22077cf6
|
@ -191,7 +191,7 @@ mod tests {
|
||||||
use pairing::bls12_381::{Bls12, Fr};
|
use pairing::bls12_381::{Bls12, Fr};
|
||||||
use rand_core::{OsRng, RngCore};
|
use rand_core::{OsRng, RngCore};
|
||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
consensus::{TestNetwork},
|
consensus::TestNetwork,
|
||||||
jubjub::{fs::Fs, FixedGenerators, JubjubParams, ToUniform},
|
jubjub::{fs::Fs, FixedGenerators, JubjubParams, ToUniform},
|
||||||
merkle_tree::CommitmentTree,
|
merkle_tree::CommitmentTree,
|
||||||
note_encryption::{Memo, SaplingNoteEncryption},
|
note_encryption::{Memo, SaplingNoteEncryption},
|
||||||
|
|
|
@ -13,12 +13,6 @@ pub trait Parameters {
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const OVERWINTER_ACTIVATION_HEIGHT: u32;
|
|
||||||
const SAPLING_ACTIVATION_HEIGHT: u32;
|
|
||||||
const BLOSSOM_ACTIVATION_HEIGHT: u32;
|
|
||||||
const HEARTWOOD_ACTIVATION_HEIGHT: u32;
|
|
||||||
const CANOPY_ACTIVATION_HEIGHT: u32;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Marker struct for the production network.
|
/// Marker struct for the production network.
|
||||||
|
@ -35,12 +29,6 @@ impl Parameters for MainNetwork {
|
||||||
NetworkUpgrade::Canopy => Some(1_046_400),
|
NetworkUpgrade::Canopy => Some(1_046_400),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const OVERWINTER_ACTIVATION_HEIGHT: u32 = 347_500;
|
|
||||||
const SAPLING_ACTIVATION_HEIGHT: u32 = 419_200;
|
|
||||||
const BLOSSOM_ACTIVATION_HEIGHT: u32 = 653_600;
|
|
||||||
const HEARTWOOD_ACTIVATION_HEIGHT: u32 = 903_000;
|
|
||||||
const CANOPY_ACTIVATION_HEIGHT: u32 = 1_046_400;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Marker struct for the test network.
|
/// Marker struct for the test network.
|
||||||
|
@ -57,12 +45,6 @@ impl Parameters for TestNetwork {
|
||||||
NetworkUpgrade::Canopy => Some(1_028_500),
|
NetworkUpgrade::Canopy => Some(1_028_500),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const OVERWINTER_ACTIVATION_HEIGHT: u32 = 207_500;
|
|
||||||
const SAPLING_ACTIVATION_HEIGHT: u32 = 280_200;
|
|
||||||
const BLOSSOM_ACTIVATION_HEIGHT: u32 = 584_000;
|
|
||||||
const HEARTWOOD_ACTIVATION_HEIGHT: u32 = 903_800;
|
|
||||||
const CANOPY_ACTIVATION_HEIGHT: u32 = 1_028_500;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An event that occurs at a specified height on the Zcash chain, at which point the
|
/// An event that occurs at a specified height on the Zcash chain, at which point the
|
||||||
|
@ -208,10 +190,10 @@ impl BranchId {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{BranchId, MainNetwork, NetworkUpgrade, UPGRADES_IN_ORDER};
|
|
||||||
use crate::consensus::Parameters;
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
|
use super::{BranchId, MainNetwork, NetworkUpgrade, Parameters, UPGRADES_IN_ORDER};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn nu_ordering() {
|
fn nu_ordering() {
|
||||||
for i in 1..UPGRADES_IN_ORDER.len() {
|
for i in 1..UPGRADES_IN_ORDER.len() {
|
||||||
|
|
|
@ -586,7 +586,11 @@ pub fn try_sapling_output_recovery<P: consensus::Parameters>(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
consensus::{NetworkUpgrade, Parameters, TestNetwork, ZIP212_GRACE_PERIOD},
|
consensus::{
|
||||||
|
NetworkUpgrade,
|
||||||
|
NetworkUpgrade::{Canopy, Sapling},
|
||||||
|
Parameters, TestNetwork, ZIP212_GRACE_PERIOD,
|
||||||
|
},
|
||||||
jubjub::{
|
jubjub::{
|
||||||
edwards,
|
edwards,
|
||||||
fs::{Fs, FsRepr},
|
fs::{Fs, FsRepr},
|
||||||
|
@ -912,8 +916,8 @@ mod tests {
|
||||||
fn decryption_with_invalid_ivk() {
|
fn decryption_with_invalid_ivk() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -936,8 +940,8 @@ mod tests {
|
||||||
fn decryption_with_invalid_epk() {
|
fn decryption_with_invalid_epk() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -960,8 +964,8 @@ mod tests {
|
||||||
fn decryption_with_invalid_cmu() {
|
fn decryption_with_invalid_cmu() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -984,8 +988,8 @@ mod tests {
|
||||||
fn decryption_with_invalid_tag() {
|
fn decryption_with_invalid_tag() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1009,10 +1013,11 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn decryption_with_invalid_version_byte() {
|
fn decryption_with_invalid_version_byte() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
|
let canopy_activation_height = TestNetwork::activation_height(Canopy).unwrap();
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT - 1,
|
canopy_activation_height - 1,
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
canopy_activation_height,
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT + ZIP212_GRACE_PERIOD,
|
canopy_activation_height + ZIP212_GRACE_PERIOD,
|
||||||
];
|
];
|
||||||
let leadbyte_array = [0x02, 0x03, 0x01];
|
let leadbyte_array = [0x02, 0x03, 0x01];
|
||||||
|
|
||||||
|
@ -1046,8 +1051,8 @@ mod tests {
|
||||||
fn decryption_with_invalid_diversifier() {
|
fn decryption_with_invalid_diversifier() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1080,8 +1085,8 @@ mod tests {
|
||||||
fn decryption_with_incorrect_diversifier() {
|
fn decryption_with_incorrect_diversifier() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1114,8 +1119,8 @@ mod tests {
|
||||||
fn compact_decryption_with_invalid_ivk() {
|
fn compact_decryption_with_invalid_ivk() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1138,8 +1143,8 @@ mod tests {
|
||||||
fn compact_decryption_with_invalid_epk() {
|
fn compact_decryption_with_invalid_epk() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1162,8 +1167,8 @@ mod tests {
|
||||||
fn compact_decryption_with_invalid_cmu() {
|
fn compact_decryption_with_invalid_cmu() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1185,10 +1190,11 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn compact_decryption_with_invalid_version_byte() {
|
fn compact_decryption_with_invalid_version_byte() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
|
let canopy_activation_height = TestNetwork::activation_height(Canopy).unwrap();
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT - 1,
|
canopy_activation_height - 1,
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
canopy_activation_height,
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT + ZIP212_GRACE_PERIOD,
|
canopy_activation_height + ZIP212_GRACE_PERIOD,
|
||||||
];
|
];
|
||||||
let leadbyte_array = [0x02, 0x03, 0x01];
|
let leadbyte_array = [0x02, 0x03, 0x01];
|
||||||
|
|
||||||
|
@ -1222,8 +1228,8 @@ mod tests {
|
||||||
fn compact_decryption_with_invalid_diversifier() {
|
fn compact_decryption_with_invalid_diversifier() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1256,8 +1262,8 @@ mod tests {
|
||||||
fn compact_decryption_with_incorrect_diversifier() {
|
fn compact_decryption_with_incorrect_diversifier() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1290,8 +1296,8 @@ mod tests {
|
||||||
fn recovery_with_invalid_ovk() {
|
fn recovery_with_invalid_ovk() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1318,8 +1324,8 @@ mod tests {
|
||||||
fn recovery_with_invalid_cv() {
|
fn recovery_with_invalid_cv() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1345,8 +1351,8 @@ mod tests {
|
||||||
fn recovery_with_invalid_cmu() {
|
fn recovery_with_invalid_cmu() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1372,8 +1378,8 @@ mod tests {
|
||||||
fn recovery_with_invalid_epk() {
|
fn recovery_with_invalid_epk() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1399,8 +1405,8 @@ mod tests {
|
||||||
fn recovery_with_invalid_enc_tag() {
|
fn recovery_with_invalid_enc_tag() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1427,8 +1433,8 @@ mod tests {
|
||||||
fn recovery_with_invalid_out_tag() {
|
fn recovery_with_invalid_out_tag() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1454,10 +1460,11 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn recovery_with_invalid_version_byte() {
|
fn recovery_with_invalid_version_byte() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
|
let canopy_activation_height = TestNetwork::activation_height(Canopy).unwrap();
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT - 1,
|
canopy_activation_height - 1,
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
canopy_activation_height,
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT + ZIP212_GRACE_PERIOD,
|
canopy_activation_height + ZIP212_GRACE_PERIOD,
|
||||||
];
|
];
|
||||||
let leadbyte_array = [0x02, 0x03, 0x01];
|
let leadbyte_array = [0x02, 0x03, 0x01];
|
||||||
|
|
||||||
|
@ -1493,8 +1500,8 @@ mod tests {
|
||||||
fn recovery_with_invalid_diversifier() {
|
fn recovery_with_invalid_diversifier() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1529,8 +1536,8 @@ mod tests {
|
||||||
fn recovery_with_incorrect_diversifier() {
|
fn recovery_with_incorrect_diversifier() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
@ -1565,8 +1572,8 @@ mod tests {
|
||||||
fn recovery_with_invalid_pk_d() {
|
fn recovery_with_invalid_pk_d() {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let heights = [
|
let heights = [
|
||||||
TestNetwork::SAPLING_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Sapling).unwrap(),
|
||||||
TestNetwork::CANOPY_ACTIVATION_HEIGHT,
|
TestNetwork::activation_height(Canopy).unwrap(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for &height in heights.iter() {
|
for &height in heights.iter() {
|
||||||
|
|
Loading…
Reference in New Issue