diff --git a/zebra-chain/src/block/commitment.rs b/zebra-chain/src/block/commitment.rs index 2cb09e75b22..ec4ef7d2616 100644 --- a/zebra-chain/src/block/commitment.rs +++ b/zebra-chain/src/block/commitment.rs @@ -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), )), } diff --git a/zebra-chain/src/history_tree.rs b/zebra-chain/src/history_tree.rs index 91fa3a17628..613bf0616d7 100644 --- a/zebra-chain/src/history_tree.rs +++ b/zebra-chain/src/history_tree.rs @@ -102,7 +102,7 @@ impl NonEmptyHistoryTree { )?; InnerHistoryTree::PreOrchard(tree) } - NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 => { + NetworkUpgrade::Nu5 | NetworkUpgrade::Nu6 | NetworkUpgrade::Nu7 => { let tree = Tree::::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::::new_from_block( network, block, diff --git a/zebra-chain/src/parameters/network.rs b/zebra-chain/src/parameters/network.rs index e8571340b7d..d119c087dd9 100644 --- a/zebra-chain/src/parameters/network.rs +++ b/zebra-chain/src/parameters/network.rs @@ -152,10 +152,12 @@ impl Network { pub fn new_regtest( nu5_activation_height: Option, nu6_activation_height: Option, + nu7_activation_height: Option, ) -> Self { Self::new_configured_testnet(testnet::Parameters::new_regtest( nu5_activation_height, nu6_activation_height, + nu7_activation_height, )) } diff --git a/zebra-chain/src/parameters/network/testnet.rs b/zebra-chain/src/parameters/network/testnet.rs index 78f7a69a302..dc1b4c83e28 100644 --- a/zebra-chain/src/parameters/network/testnet.rs +++ b/zebra-chain/src/parameters/network/testnet.rs @@ -206,6 +206,9 @@ pub struct ConfiguredActivationHeights { /// Activation height for `NU6` network upgrade. #[serde(rename = "NU6")] pub nu6: Option, + /// Activation height for `NU7` network upgrade. + #[serde(rename = "NU7")] + pub nu7: Option, } /// 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, nu6_activation_height: Option, + nu7_activation_height: Option, ) -> 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 diff --git a/zebra-chain/src/parameters/network/tests/vectors.rs b/zebra-chain/src/parameters/network/tests/vectors.rs index 4282c86844f..6c1426e4e0e 100644 --- a/zebra-chain/src/parameters/network/tests/vectors.rs +++ b/zebra-chain/src/parameters/network/tests/vectors.rs @@ -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'" ); diff --git a/zebra-chain/src/parameters/network_upgrade.rs b/zebra-chain/src/parameters/network_upgrade.rs index 3d35f0526d2..52edecb9045 100644 --- a/zebra-chain/src/parameters/network_upgrade.rs +++ b/zebra-chain/src/parameters/network_upgrade.rs @@ -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) diff --git a/zebra-chain/src/primitives/zcash_history.rs b/zebra-chain/src/primitives/zcash_history.rs index e8ca97d63f8..4b52c85d8e8 100644 --- a/zebra-chain/src/primitives/zcash_history.rs +++ b/zebra-chain/src/primitives/zcash_history.rs @@ -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, diff --git a/zebra-chain/src/transaction/arbitrary.rs b/zebra-chain/src/transaction/arbitrary.rs index cf4aa7a9552..0541bd7acd3 100644 --- a/zebra-chain/src/transaction/arbitrary.rs +++ b/zebra-chain/src/transaction/arbitrary.rs @@ -778,7 +778,7 @@ impl Arbitrary for Transaction { NetworkUpgrade::Blossom | NetworkUpgrade::Heartwood | NetworkUpgrade::Canopy => { Self::v4_strategy(ledger_state) } - 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) ] diff --git a/zebra-consensus/src/checkpoint/list/tests.rs b/zebra-consensus/src/checkpoint/list/tests.rs index 5a2fe803f3d..698eaf36082 100644 --- a/zebra-consensus/src/checkpoint/list/tests.rs +++ b/zebra-consensus/src/checkpoint/list/tests.rs @@ -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(()) } diff --git a/zebra-consensus/src/transaction.rs b/zebra-consensus/src/transaction.rs index 1c303003615..192f1413332 100644 --- a/zebra-consensus/src/transaction.rs +++ b/zebra-consensus/src/transaction.rs @@ -678,7 +678,8 @@ where | NetworkUpgrade::Heartwood | NetworkUpgrade::Canopy | NetworkUpgrade::Nu5 - | NetworkUpgrade::Nu6 => Ok(()), + | NetworkUpgrade::Nu6 + | NetworkUpgrade::Nu7 => Ok(()), // Does not support V4 transactions NetworkUpgrade::Genesis @@ -766,7 +767,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 diff --git a/zebra-consensus/src/transaction/tests/prop.rs b/zebra-consensus/src/transaction/tests/prop.rs index f45b4731de0..3f57bbb74bf 100644 --- a/zebra-consensus/src/transaction/tests/prop.rs +++ b/zebra-consensus/src/transaction/tests/prop.rs @@ -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, } }; diff --git a/zebra-network/src/config.rs b/zebra-network/src/config.rs index 8619507fa0d..25e82714ae5 100644 --- a/zebra-network/src/config.rs +++ b/zebra-network/src/config.rs @@ -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(); - - Network::new_regtest(nu5_activation_height, nu6_activation_height) + 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, + nu7_activation_height, + ) } ( NetworkKind::Testnet, diff --git a/zebra-network/src/constants.rs b/zebra-network/src/constants.rs index a116fd63018..a9ecf68537a 100644 --- a/zebra-network/src/constants.rs +++ b/zebra-network/src/constants.rs @@ -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 }; diff --git a/zebra-network/src/protocol/external/types.rs b/zebra-network/src/protocol/external/types.rs index c6241ba4d78..725d8d6d8de 100644 --- a/zebra-network/src/protocol/external/types.rs +++ b/zebra-network/src/protocol/external/types.rs @@ -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, diff --git a/zebra-rpc/src/methods/get_block_template_rpcs/types/get_block_template/proposal.rs b/zebra-rpc/src/methods/get_block_template_rpcs/types/get_block_template/proposal.rs index fc0805b533d..373ba2d7c20 100644 --- a/zebra-rpc/src/methods/get_block_template_rpcs/types/get_block_template/proposal.rs +++ b/zebra-rpc/src/methods/get_block_template_rpcs/types/get_block_template/proposal.rs @@ -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() } }; diff --git a/zebra-rpc/src/methods/tests/snapshots/get_blockchain_info@testnet_10.snap b/zebra-rpc/src/methods/tests/snapshots/get_blockchain_info@testnet_10.snap index 3bea6c01509..9d7ea3f5176 100644 --- a/zebra-rpc/src/methods/tests/snapshots/get_blockchain_info@testnet_10.snap +++ b/zebra-rpc/src/methods/tests/snapshots/get_blockchain_info@testnet_10.snap @@ -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": { diff --git a/zebrad/tests/acceptance.rs b/zebrad/tests/acceptance.rs index cd3572ce3f2..c71cede4c3b 100644 --- a/zebrad/tests/acceptance.rs +++ b/zebrad/tests/acceptance.rs @@ -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(); diff --git a/zebrad/tests/common/configs/v1.9.0.toml b/zebrad/tests/common/configs/v1.9.0.toml index 11bcf62107a..93291298f98 100644 --- a/zebrad/tests/common/configs/v1.9.0.toml +++ b/zebrad/tests/common/configs/v1.9.0.toml @@ -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 diff --git a/zebrad/tests/common/regtest.rs b/zebrad/tests/common/regtest.rs index bf1cba697de..f7b571e5a09 100644 --- a/zebrad/tests/common/regtest.rs +++ b/zebrad/tests/common/regtest.rs @@ -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);