diff --git a/zebra-chain/src/block/root_hash.rs b/zebra-chain/src/block/root_hash.rs index 3d2a1501..f40c9a9f 100644 --- a/zebra-chain/src/block/root_hash.rs +++ b/zebra-chain/src/block/root_hash.rs @@ -55,6 +55,7 @@ impl RootHash { ChainHistoryActivationReserved(bytes) } Heartwood | Canopy => ChainHistoryRoot(ChainHistoryMmrRootHash(bytes)), + NU5 => unimplemented!("NU5 uses hashAuthDataRoot as specified in ZIP-244"), } } diff --git a/zebra-chain/src/parameters/network_upgrade.rs b/zebra-chain/src/parameters/network_upgrade.rs index 132368a1..a4348c9a 100644 --- a/zebra-chain/src/parameters/network_upgrade.rs +++ b/zebra-chain/src/parameters/network_upgrade.rs @@ -37,6 +37,11 @@ pub enum NetworkUpgrade { Heartwood, /// The Zcash protocol after the Canopy upgrade. Canopy, + /// The Zcash protocol after the NU5 upgrade. + /// + /// Note: Network Upgrade 5 includes the Orchard Shielded Protocol, and + /// other changes. The NU5 code name has not been chosen yet. + NU5, } /// Mainnet network upgrade activation heights. @@ -51,6 +56,7 @@ pub(crate) const MAINNET_ACTIVATION_HEIGHTS: &[(block::Height, NetworkUpgrade)] (block::Height(653_600), Blossom), (block::Height(903_000), Heartwood), (block::Height(1_046_400), Canopy), + // TODO: Add NU5 mainnet activation height ]; /// Testnet network upgrade activation heights. @@ -65,6 +71,7 @@ pub(crate) const TESTNET_ACTIVATION_HEIGHTS: &[(block::Height, NetworkUpgrade)] (block::Height(584_000), Blossom), (block::Height(903_800), Heartwood), (block::Height(1_028_500), Canopy), + // TODO: Add NU5 testnet activation height ]; /// The Consensus Branch Id, used to bind transactions and blocks to a @@ -94,6 +101,7 @@ pub(crate) const CONSENSUS_BRANCH_IDS: &[(NetworkUpgrade, ConsensusBranchId)] = (Blossom, ConsensusBranchId(0x2bb40e60)), (Heartwood, ConsensusBranchId(0xf5b9230b)), (Canopy, ConsensusBranchId(0xe9ff75a6)), + (NU5, ConsensusBranchId(0xf919a198)), ]; /// The target block spacing before Blossom. @@ -199,7 +207,7 @@ 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 => POST_BLOSSOM_POW_TARGET_SPACING, + Blossom | Heartwood | Canopy | NU5 => POST_BLOSSOM_POW_TARGET_SPACING, }; Duration::seconds(spacing_seconds) diff --git a/zebra-chain/src/transaction/arbitrary.rs b/zebra-chain/src/transaction/arbitrary.rs index c21b3cfa..c34da137 100644 --- a/zebra-chain/src/transaction/arbitrary.rs +++ b/zebra-chain/src/transaction/arbitrary.rs @@ -236,6 +236,9 @@ impl Arbitrary for Transaction { NetworkUpgrade::Blossom | NetworkUpgrade::Heartwood | NetworkUpgrade::Canopy => { Self::v4_strategy(ledger_state) } + NetworkUpgrade::NU5 => { + unimplemented!("NU5 upgrade can use v4 or v5 transactions, as specified in ZIP-225") + } } } diff --git a/zebra-chain/src/transaction/sighash.rs b/zebra-chain/src/transaction/sighash.rs index d4775e11..525b5035 100644 --- a/zebra-chain/src/transaction/sighash.rs +++ b/zebra-chain/src/transaction/sighash.rs @@ -85,6 +85,9 @@ impl<'a> SigHasher<'a> { Sapling | Blossom | Heartwood | Canopy => self .hash_sighash_zip243(&mut hash) .expect("serialization into hasher never fails"), + NU5 => unimplemented!( + "NU5 upgrade uses a new transaction digest algorithm, as specified in ZIP-244" + ), } hash.finalize() diff --git a/zebra-network/src/protocol/external/types.rs b/zebra-network/src/protocol/external/types.rs index a277343d..c4be90f4 100644 --- a/zebra-network/src/protocol/external/types.rs +++ b/zebra-network/src/protocol/external/types.rs @@ -57,6 +57,8 @@ impl Version { (Mainnet, Heartwood) => 170_011, (Testnet, Canopy) => 170_012, (Mainnet, Canopy) => 170_013, + (Testnet, NU5) => 170_014, + (Mainnet, NU5) => 170_015, }) } @@ -187,7 +189,7 @@ mod test { zebra_test::init(); let highest_network_upgrade = NetworkUpgrade::current(network, block::Height::MAX); - assert!(highest_network_upgrade == Canopy || highest_network_upgrade == Heartwood, + assert!(highest_network_upgrade == NU5 || highest_network_upgrade == Canopy, "expected coverage of all network upgrades: add the new network upgrade to the list in this test"); for &network_upgrade in &[ @@ -197,6 +199,7 @@ mod test { Blossom, Heartwood, Canopy, + NU5, ] { let height = network_upgrade.activation_height(network); if let Some(height) = height {