Merge branch 'zsa-integration-nu7' into zsa-integration-block-test
This commit is contained in:
commit
50680a6868
|
@ -125,7 +125,7 @@ impl Commitment {
|
|||
// NetworkUpgrade::current() returns the latest network upgrade that's activated at the provided height, so
|
||||
// on Regtest for heights above height 0, it could return NU6, and it's possible for the current network upgrade
|
||||
// to be NU6 (or Canopy, or any network upgrade above Heartwood) at the Heartwood activation height.
|
||||
(Canopy | Nu5 | Nu6, activation_height)
|
||||
(Canopy | Nu5 | Nu6 | Nu7, activation_height)
|
||||
if height == activation_height
|
||||
&& Some(height) == Heartwood.activation_height(network) =>
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ impl Commitment {
|
|||
}
|
||||
}
|
||||
(Heartwood | Canopy, _) => Ok(ChainHistoryRoot(ChainHistoryMmrRootHash(bytes))),
|
||||
(Nu5 | Nu6, _) => Ok(ChainHistoryBlockTxAuthCommitment(
|
||||
(Nu5 | Nu6 | Nu7, _) => Ok(ChainHistoryBlockTxAuthCommitment(
|
||||
ChainHistoryBlockTxAuthCommitmentHash(bytes),
|
||||
)),
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ impl NonEmptyHistoryTree {
|
|||
)?;
|
||||
InnerHistoryTree::PreOrchard(tree)
|
||||
}
|
||||
NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 => {
|
||||
NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 | NetworkUpgrade::Nu7 => {
|
||||
let tree = Tree::<OrchardOnward>::new_from_cache(
|
||||
network,
|
||||
network_upgrade,
|
||||
|
@ -156,7 +156,7 @@ impl NonEmptyHistoryTree {
|
|||
)?;
|
||||
(InnerHistoryTree::PreOrchard(tree), entry)
|
||||
}
|
||||
NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 => {
|
||||
NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 | NetworkUpgrade::Nu7 => {
|
||||
let (tree, entry) = Tree::<OrchardOnward>::new_from_block(
|
||||
network,
|
||||
block,
|
||||
|
|
|
@ -152,10 +152,12 @@ impl Network {
|
|||
pub fn new_regtest(
|
||||
nu5_activation_height: Option<u32>,
|
||||
nu6_activation_height: Option<u32>,
|
||||
nu7_activation_height: Option<u32>,
|
||||
) -> Self {
|
||||
Self::new_configured_testnet(testnet::Parameters::new_regtest(
|
||||
nu5_activation_height,
|
||||
nu6_activation_height,
|
||||
nu7_activation_height,
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
@ -206,6 +206,9 @@ pub struct ConfiguredActivationHeights {
|
|||
/// Activation height for `NU6` network upgrade.
|
||||
#[serde(rename = "NU6")]
|
||||
pub nu6: Option<u32>,
|
||||
/// Activation height for `NU7` network upgrade.
|
||||
#[serde(rename = "NU7")]
|
||||
pub nu7: Option<u32>,
|
||||
}
|
||||
|
||||
/// Builder for the [`Parameters`] struct.
|
||||
|
@ -336,6 +339,7 @@ impl ParametersBuilder {
|
|||
canopy,
|
||||
nu5,
|
||||
nu6,
|
||||
nu7,
|
||||
}: ConfiguredActivationHeights,
|
||||
) -> Self {
|
||||
use NetworkUpgrade::*;
|
||||
|
@ -358,6 +362,7 @@ impl ParametersBuilder {
|
|||
.chain(canopy.into_iter().map(|h| (h, Canopy)))
|
||||
.chain(nu5.into_iter().map(|h| (h, Nu5)))
|
||||
.chain(nu6.into_iter().map(|h| (h, Nu6)))
|
||||
.chain(nu7.into_iter().map(|h| (h, Nu7)))
|
||||
.map(|(h, nu)| (h.try_into().expect("activation height must be valid"), nu))
|
||||
.collect();
|
||||
|
||||
|
@ -588,6 +593,7 @@ impl Parameters {
|
|||
pub fn new_regtest(
|
||||
nu5_activation_height: Option<u32>,
|
||||
nu6_activation_height: Option<u32>,
|
||||
nu7_activation_height: Option<u32>,
|
||||
) -> Self {
|
||||
#[cfg(any(test, feature = "proptest-impl"))]
|
||||
let nu5_activation_height = nu5_activation_height.or(Some(100));
|
||||
|
@ -604,6 +610,7 @@ impl Parameters {
|
|||
canopy: Some(1),
|
||||
nu5: nu5_activation_height,
|
||||
nu6: nu6_activation_height,
|
||||
nu7: nu7_activation_height,
|
||||
..Default::default()
|
||||
})
|
||||
.with_halving_interval(PRE_BLOSSOM_REGTEST_HALVING_INTERVAL);
|
||||
|
@ -647,7 +654,7 @@ impl Parameters {
|
|||
disable_pow,
|
||||
pre_blossom_halving_interval,
|
||||
post_blossom_halving_interval,
|
||||
} = Self::new_regtest(None, None);
|
||||
} = Self::new_regtest(None, None, None);
|
||||
|
||||
self.network_name == network_name
|
||||
&& self.genesis_hash == genesis_hash
|
||||
|
|
|
@ -109,7 +109,7 @@ fn activates_network_upgrades_correctly() {
|
|||
let expected_activation_height = 1;
|
||||
let network = testnet::Parameters::build()
|
||||
.with_activation_heights(ConfiguredActivationHeights {
|
||||
nu6: Some(expected_activation_height),
|
||||
nu7: Some(expected_activation_height),
|
||||
..Default::default()
|
||||
})
|
||||
.to_network();
|
||||
|
@ -147,7 +147,7 @@ fn activates_network_upgrades_correctly() {
|
|||
(Network::Mainnet, MAINNET_ACTIVATION_HEIGHTS),
|
||||
(Network::new_default_testnet(), TESTNET_ACTIVATION_HEIGHTS),
|
||||
(
|
||||
Network::new_regtest(None, None),
|
||||
Network::new_regtest(None, None, None),
|
||||
expected_default_regtest_activation_heights,
|
||||
),
|
||||
] {
|
||||
|
@ -198,7 +198,7 @@ fn check_configured_network_name() {
|
|||
"Mainnet should be displayed as 'Mainnet'"
|
||||
);
|
||||
assert_eq!(
|
||||
Network::new_regtest(None, None).to_string(),
|
||||
Network::new_regtest(None, None, None).to_string(),
|
||||
"Regtest",
|
||||
"Regtest should be displayed as 'Regtest'"
|
||||
);
|
||||
|
|
|
@ -15,7 +15,7 @@ use hex::{FromHex, ToHex};
|
|||
use proptest_derive::Arbitrary;
|
||||
|
||||
/// A list of network upgrades in the order that they must be activated.
|
||||
pub const NETWORK_UPGRADES_IN_ORDER: [NetworkUpgrade; 9] = [
|
||||
pub const NETWORK_UPGRADES_IN_ORDER: [NetworkUpgrade; 10] = [
|
||||
Genesis,
|
||||
BeforeOverwinter,
|
||||
Overwinter,
|
||||
|
@ -25,6 +25,7 @@ pub const NETWORK_UPGRADES_IN_ORDER: [NetworkUpgrade; 9] = [
|
|||
Canopy,
|
||||
Nu5,
|
||||
Nu6,
|
||||
Nu7,
|
||||
];
|
||||
|
||||
/// A Zcash network upgrade.
|
||||
|
@ -61,6 +62,9 @@ pub enum NetworkUpgrade {
|
|||
/// The Zcash protocol after the NU6 upgrade.
|
||||
#[serde(rename = "NU6")]
|
||||
Nu6,
|
||||
/// The Zcash protocol after the NU7 upgrade.
|
||||
#[serde(rename = "NU7")]
|
||||
Nu7,
|
||||
}
|
||||
|
||||
impl fmt::Display for NetworkUpgrade {
|
||||
|
@ -90,6 +94,8 @@ pub(super) const MAINNET_ACTIVATION_HEIGHTS: &[(block::Height, NetworkUpgrade)]
|
|||
(block::Height(1_046_400), Canopy),
|
||||
(block::Height(1_687_104), Nu5),
|
||||
(block::Height(2_726_400), Nu6),
|
||||
// FIXME: TODO: Add NU7 with a correct value
|
||||
// (block::Height(2_726_401), Nu7),
|
||||
];
|
||||
|
||||
/// Fake mainnet network upgrade activation heights, used in tests.
|
||||
|
@ -104,6 +110,7 @@ const FAKE_MAINNET_ACTIVATION_HEIGHTS: &[(block::Height, NetworkUpgrade)] = &[
|
|||
(block::Height(30), Canopy),
|
||||
(block::Height(35), Nu5),
|
||||
(block::Height(40), Nu6),
|
||||
(block::Height(45), Nu7),
|
||||
];
|
||||
|
||||
/// Testnet network upgrade activation heights.
|
||||
|
@ -126,6 +133,8 @@ pub(super) const TESTNET_ACTIVATION_HEIGHTS: &[(block::Height, NetworkUpgrade)]
|
|||
(block::Height(1_028_500), Canopy),
|
||||
(block::Height(1_842_420), Nu5),
|
||||
(block::Height(2_976_000), Nu6),
|
||||
// FIXME: TODO: Set a correct value for NU7
|
||||
(block::Height(2_942_001), Nu7),
|
||||
];
|
||||
|
||||
/// Fake testnet network upgrade activation heights, used in tests.
|
||||
|
@ -140,6 +149,7 @@ const FAKE_TESTNET_ACTIVATION_HEIGHTS: &[(block::Height, NetworkUpgrade)] = &[
|
|||
(block::Height(30), Canopy),
|
||||
(block::Height(35), Nu5),
|
||||
(block::Height(40), Nu6),
|
||||
(block::Height(45), Nu7),
|
||||
];
|
||||
|
||||
/// The Consensus Branch Id, used to bind transactions and blocks to a
|
||||
|
@ -216,6 +226,8 @@ pub(crate) const CONSENSUS_BRANCH_IDS: &[(NetworkUpgrade, ConsensusBranchId)] =
|
|||
(Canopy, ConsensusBranchId(0xe9ff75a6)),
|
||||
(Nu5, ConsensusBranchId(0xc2d6d0b4)),
|
||||
(Nu6, ConsensusBranchId(0xc8e71055)),
|
||||
// FIXME: use a proper value below
|
||||
(Nu7, ConsensusBranchId(0xc8e71056)),
|
||||
];
|
||||
|
||||
/// The target block spacing before Blossom.
|
||||
|
@ -332,7 +344,8 @@ impl NetworkUpgrade {
|
|||
Heartwood => Some(Canopy),
|
||||
Canopy => Some(Nu5),
|
||||
Nu5 => Some(Nu6),
|
||||
Nu6 => None,
|
||||
Nu6 => Some(Nu7),
|
||||
Nu7 => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,7 +422,9 @@ impl NetworkUpgrade {
|
|||
pub fn target_spacing(&self) -> Duration {
|
||||
let spacing_seconds = match self {
|
||||
Genesis | BeforeOverwinter | Overwinter | Sapling => PRE_BLOSSOM_POW_TARGET_SPACING,
|
||||
Blossom | Heartwood | Canopy | Nu5 | Nu6 => POST_BLOSSOM_POW_TARGET_SPACING.into(),
|
||||
Blossom | Heartwood | Canopy | Nu5 | Nu6 | Nu7 => {
|
||||
POST_BLOSSOM_POW_TARGET_SPACING.into()
|
||||
}
|
||||
};
|
||||
|
||||
Duration::seconds(spacing_seconds)
|
||||
|
|
|
@ -276,7 +276,8 @@ impl Version for zcash_history::V1 {
|
|||
NetworkUpgrade::Heartwood
|
||||
| NetworkUpgrade::Canopy
|
||||
| NetworkUpgrade::Nu5
|
||||
| NetworkUpgrade::Nu6 => zcash_history::NodeData {
|
||||
| NetworkUpgrade::Nu6
|
||||
| NetworkUpgrade::Nu7 => zcash_history::NodeData {
|
||||
consensus_branch_id: branch_id.into(),
|
||||
subtree_commitment: block_hash,
|
||||
start_time: time,
|
||||
|
|
|
@ -881,7 +881,7 @@ impl Arbitrary for Transaction {
|
|||
Self::v4_strategy(ledger_state)
|
||||
}
|
||||
// FIXME: should v6_strategy be included here?
|
||||
NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 => prop_oneof![
|
||||
NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 | NetworkUpgrade::Nu7 => prop_oneof![
|
||||
Self::v4_strategy(ledger_state.clone()),
|
||||
Self::v5_strategy(ledger_state)
|
||||
]
|
||||
|
|
|
@ -237,7 +237,7 @@ fn checkpoint_list_load_hard_coded() -> Result<(), BoxError> {
|
|||
|
||||
let _ = Mainnet.checkpoint_list();
|
||||
let _ = Network::new_default_testnet().checkpoint_list();
|
||||
let _ = Network::new_regtest(None, None).checkpoint_list();
|
||||
let _ = Network::new_regtest(None, None, None).checkpoint_list();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -687,7 +687,8 @@ where
|
|||
| NetworkUpgrade::Heartwood
|
||||
| NetworkUpgrade::Canopy
|
||||
| NetworkUpgrade::Nu5
|
||||
| NetworkUpgrade::Nu6 => Ok(()),
|
||||
| NetworkUpgrade::Nu6
|
||||
| NetworkUpgrade::Nu7 => Ok(()),
|
||||
|
||||
// Does not support V4 transactions
|
||||
NetworkUpgrade::Genesis
|
||||
|
@ -775,7 +776,7 @@ where
|
|||
//
|
||||
// Note: Here we verify the transaction version number of the above rule, the group
|
||||
// id is checked in zebra-chain crate, in the transaction serialize.
|
||||
NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 => Ok(()),
|
||||
NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 | NetworkUpgrade::Nu7 => Ok(()),
|
||||
|
||||
// Does not support V5 transactions
|
||||
NetworkUpgrade::Genesis
|
||||
|
|
|
@ -344,7 +344,8 @@ fn sanitize_transaction_version(
|
|||
BeforeOverwinter => 2,
|
||||
Overwinter => 3,
|
||||
Sapling | Blossom | Heartwood | Canopy => 4,
|
||||
Nu5 | Nu6 => 5,
|
||||
// FIXME: Use 6 for Nu7
|
||||
Nu5 | Nu6 | Nu7 => 5,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -668,12 +668,17 @@ impl<'de> Deserialize<'de> for Config {
|
|||
(NetworkKind::Mainnet, _) => Network::Mainnet,
|
||||
(NetworkKind::Testnet, None) => Network::new_default_testnet(),
|
||||
(NetworkKind::Regtest, testnet_parameters) => {
|
||||
let (nu5_activation_height, nu6_activation_height) = testnet_parameters
|
||||
.and_then(|params| params.activation_heights)
|
||||
.map(|ConfiguredActivationHeights { nu5, nu6, .. }| (nu5, nu6))
|
||||
.unwrap_or_default();
|
||||
let (nu5_activation_height, nu6_activation_height, nu7_activation_height) =
|
||||
testnet_parameters
|
||||
.and_then(|params| params.activation_heights)
|
||||
.map(|ConfiguredActivationHeights { nu5, nu6, nu7, .. }| (nu5, nu6, nu7))
|
||||
.unwrap_or_default();
|
||||
|
||||
Network::new_regtest(nu5_activation_height, nu6_activation_height)
|
||||
Network::new_regtest(
|
||||
nu5_activation_height,
|
||||
nu6_activation_height,
|
||||
nu7_activation_height,
|
||||
)
|
||||
}
|
||||
(
|
||||
NetworkKind::Testnet,
|
||||
|
|
|
@ -403,7 +403,7 @@ lazy_static! {
|
|||
|
||||
hash_map.insert(NetworkKind::Mainnet, Version::min_specified_for_upgrade(&Mainnet, Nu5));
|
||||
hash_map.insert(NetworkKind::Testnet, Version::min_specified_for_upgrade(&Network::new_default_testnet(), Nu5));
|
||||
hash_map.insert(NetworkKind::Regtest, Version::min_specified_for_upgrade(&Network::new_regtest(None, None), Nu5));
|
||||
hash_map.insert(NetworkKind::Regtest, Version::min_specified_for_upgrade(&Network::new_regtest(None, None, None), Nu5));
|
||||
|
||||
hash_map
|
||||
};
|
||||
|
|
|
@ -106,6 +106,9 @@ impl Version {
|
|||
(Mainnet, Nu5) => 170_100,
|
||||
(Testnet(params), Nu6) if params.is_default_testnet() => 170_110,
|
||||
(Mainnet, Nu6) => 170_120,
|
||||
// FIXME: use proper values for Nu7
|
||||
(Testnet(params), Nu7) if params.is_default_testnet() => 170_111,
|
||||
(Mainnet, Nu7) => 170_121,
|
||||
|
||||
// It should be fine to reject peers with earlier network protocol versions on custom testnets for now.
|
||||
(Testnet(_), _) => CURRENT_NETWORK_PROTOCOL_VERSION.0,
|
||||
|
|
|
@ -217,7 +217,7 @@ pub fn proposal_block_from_template(
|
|||
| NetworkUpgrade::Blossom
|
||||
| NetworkUpgrade::Heartwood => panic!("pre-Canopy block templates not supported"),
|
||||
NetworkUpgrade::Canopy => chain_history_root.bytes_in_serialized_order().into(),
|
||||
NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 => {
|
||||
NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 | NetworkUpgrade::Nu7 => {
|
||||
block_commitments_hash.bytes_in_serialized_order().into()
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
source: zebra-rpc/src/methods/tests/snapshot.rs
|
||||
assertion_line: 562
|
||||
expression: info
|
||||
---
|
||||
{
|
||||
|
@ -69,6 +70,11 @@ expression: info
|
|||
"name": "NU6",
|
||||
"activationheight": 2976000,
|
||||
"status": "pending"
|
||||
},
|
||||
"c8e71056": {
|
||||
"name": "NU7",
|
||||
"activationheight": 2942001,
|
||||
"status": "pending"
|
||||
}
|
||||
},
|
||||
"consensus": {
|
||||
|
|
|
@ -2907,7 +2907,7 @@ async fn fully_synced_rpc_z_getsubtreesbyindex_snapshot_test() -> Result<()> {
|
|||
async fn validate_regtest_genesis_block() {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
let network = Network::new_regtest(None, None);
|
||||
let network = Network::new_regtest(None, None, None);
|
||||
let state = zebra_state::init_test(&network);
|
||||
let (
|
||||
block_verifier_router,
|
||||
|
@ -2982,7 +2982,7 @@ async fn trusted_chain_sync_handles_forks_correctly() -> Result<()> {
|
|||
use zebra_state::{ReadResponse, Response};
|
||||
|
||||
let _init_guard = zebra_test::init();
|
||||
let mut config = os_assigned_rpc_port_config(false, &Network::new_regtest(None, None))?;
|
||||
let mut config = os_assigned_rpc_port_config(false, &Network::new_regtest(None, None, None))?;
|
||||
config.state.ephemeral = false;
|
||||
let network = config.network.network.clone();
|
||||
|
||||
|
|
|
@ -73,6 +73,8 @@ Heartwood = 903_800
|
|||
Canopy = 1_028_500
|
||||
NU5 = 1_842_420
|
||||
NU6 = 2_000_000
|
||||
# FIXME: Use a proper value for NU7.
|
||||
NU7 = 2_000_001
|
||||
|
||||
[network.testnet_parameters.pre_nu6_funding_streams.height_range]
|
||||
start = 0
|
||||
|
|
|
@ -43,7 +43,7 @@ pub(crate) async fn submit_blocks_test() -> Result<()> {
|
|||
let _init_guard = zebra_test::init();
|
||||
info!("starting regtest submit_blocks test");
|
||||
|
||||
let network = Network::new_regtest(None, None);
|
||||
let network = Network::new_regtest(None, None, None);
|
||||
let mut config = os_assigned_rpc_port_config(false, &network)?;
|
||||
config.mempool.debug_enable_at_height = Some(0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue