Add initial support for NU5 to zebra (#1823)
* Add NU5 variant to NetworkUpgrade * Add consensus branch ID for NU5 * Add network protocol versions for NU5 * Add NU5 to the protocol::version_consistent test * Make unimplemented panic messages more specific * Block target spacing doesn't change in NU5 * add comments for future updates for NU5 Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
parent
3c4cd31ce0
commit
e541746a50
|
|
@ -55,6 +55,7 @@ impl RootHash {
|
||||||
ChainHistoryActivationReserved(bytes)
|
ChainHistoryActivationReserved(bytes)
|
||||||
}
|
}
|
||||||
Heartwood | Canopy => ChainHistoryRoot(ChainHistoryMmrRootHash(bytes)),
|
Heartwood | Canopy => ChainHistoryRoot(ChainHistoryMmrRootHash(bytes)),
|
||||||
|
NU5 => unimplemented!("NU5 uses hashAuthDataRoot as specified in ZIP-244"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,11 @@ pub enum NetworkUpgrade {
|
||||||
Heartwood,
|
Heartwood,
|
||||||
/// The Zcash protocol after the Canopy upgrade.
|
/// The Zcash protocol after the Canopy upgrade.
|
||||||
Canopy,
|
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.
|
/// 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(653_600), Blossom),
|
||||||
(block::Height(903_000), Heartwood),
|
(block::Height(903_000), Heartwood),
|
||||||
(block::Height(1_046_400), Canopy),
|
(block::Height(1_046_400), Canopy),
|
||||||
|
// TODO: Add NU5 mainnet activation height
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Testnet network upgrade activation heights.
|
/// 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(584_000), Blossom),
|
||||||
(block::Height(903_800), Heartwood),
|
(block::Height(903_800), Heartwood),
|
||||||
(block::Height(1_028_500), Canopy),
|
(block::Height(1_028_500), Canopy),
|
||||||
|
// TODO: Add NU5 testnet activation height
|
||||||
];
|
];
|
||||||
|
|
||||||
/// The Consensus Branch Id, used to bind transactions and blocks to a
|
/// 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)),
|
(Blossom, ConsensusBranchId(0x2bb40e60)),
|
||||||
(Heartwood, ConsensusBranchId(0xf5b9230b)),
|
(Heartwood, ConsensusBranchId(0xf5b9230b)),
|
||||||
(Canopy, ConsensusBranchId(0xe9ff75a6)),
|
(Canopy, ConsensusBranchId(0xe9ff75a6)),
|
||||||
|
(NU5, ConsensusBranchId(0xf919a198)),
|
||||||
];
|
];
|
||||||
|
|
||||||
/// The target block spacing before Blossom.
|
/// The target block spacing before Blossom.
|
||||||
|
|
@ -199,7 +207,7 @@ impl NetworkUpgrade {
|
||||||
pub fn target_spacing(&self) -> Duration {
|
pub fn target_spacing(&self) -> Duration {
|
||||||
let spacing_seconds = match self {
|
let spacing_seconds = match self {
|
||||||
Genesis | BeforeOverwinter | Overwinter | Sapling => PRE_BLOSSOM_POW_TARGET_SPACING,
|
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)
|
Duration::seconds(spacing_seconds)
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,9 @@ impl Arbitrary for Transaction {
|
||||||
NetworkUpgrade::Blossom | NetworkUpgrade::Heartwood | NetworkUpgrade::Canopy => {
|
NetworkUpgrade::Blossom | NetworkUpgrade::Heartwood | NetworkUpgrade::Canopy => {
|
||||||
Self::v4_strategy(ledger_state)
|
Self::v4_strategy(ledger_state)
|
||||||
}
|
}
|
||||||
|
NetworkUpgrade::NU5 => {
|
||||||
|
unimplemented!("NU5 upgrade can use v4 or v5 transactions, as specified in ZIP-225")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,9 @@ impl<'a> SigHasher<'a> {
|
||||||
Sapling | Blossom | Heartwood | Canopy => self
|
Sapling | Blossom | Heartwood | Canopy => self
|
||||||
.hash_sighash_zip243(&mut hash)
|
.hash_sighash_zip243(&mut hash)
|
||||||
.expect("serialization into hasher never fails"),
|
.expect("serialization into hasher never fails"),
|
||||||
|
NU5 => unimplemented!(
|
||||||
|
"NU5 upgrade uses a new transaction digest algorithm, as specified in ZIP-244"
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
hash.finalize()
|
hash.finalize()
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ impl Version {
|
||||||
(Mainnet, Heartwood) => 170_011,
|
(Mainnet, Heartwood) => 170_011,
|
||||||
(Testnet, Canopy) => 170_012,
|
(Testnet, Canopy) => 170_012,
|
||||||
(Mainnet, Canopy) => 170_013,
|
(Mainnet, Canopy) => 170_013,
|
||||||
|
(Testnet, NU5) => 170_014,
|
||||||
|
(Mainnet, NU5) => 170_015,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -187,7 +189,7 @@ mod test {
|
||||||
zebra_test::init();
|
zebra_test::init();
|
||||||
|
|
||||||
let highest_network_upgrade = NetworkUpgrade::current(network, block::Height::MAX);
|
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");
|
"expected coverage of all network upgrades: add the new network upgrade to the list in this test");
|
||||||
|
|
||||||
for &network_upgrade in &[
|
for &network_upgrade in &[
|
||||||
|
|
@ -197,6 +199,7 @@ mod test {
|
||||||
Blossom,
|
Blossom,
|
||||||
Heartwood,
|
Heartwood,
|
||||||
Canopy,
|
Canopy,
|
||||||
|
NU5,
|
||||||
] {
|
] {
|
||||||
let height = network_upgrade.activation_height(network);
|
let height = network_upgrade.activation_height(network);
|
||||||
if let Some(height) = height {
|
if let Some(height) = height {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue