Rename `Future -> ZFuture`
Proactively distinguish against future use of the futures crate for source greppability.
This commit is contained in:
parent
a0a36eddfd
commit
99eb5b9336
|
@ -88,7 +88,7 @@ impl<'a> demo::Context for Context<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Identifier for the set of TZEs associated with the FUTURE network upgrade.
|
||||
/// Identifier for the set of TZEs associated with the ZFUTURE network upgrade.
|
||||
/// This epoch is intended only for use on test networks.
|
||||
struct EpochVTest;
|
||||
|
||||
|
@ -116,7 +116,7 @@ impl Epoch for EpochVTest {
|
|||
pub fn epoch_for_branch(network_upgrade: NetworkUpgrade) -> Option<Box<dyn Epoch<Error = String>>> {
|
||||
// Map from consensus branch IDs to epochs.
|
||||
match network_upgrade {
|
||||
NetworkUpgrade::Future => Some(Box::new(EpochVTest)),
|
||||
NetworkUpgrade::ZFuture => Some(Box::new(EpochVTest)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ impl Parameters for MainNetwork {
|
|||
NetworkUpgrade::Blossom => Some(BlockHeight(653_600)),
|
||||
NetworkUpgrade::Heartwood => Some(BlockHeight(903_000)),
|
||||
NetworkUpgrade::Canopy => Some(BlockHeight(1_046_400)),
|
||||
NetworkUpgrade::Future => None,
|
||||
NetworkUpgrade::ZFuture => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ impl Parameters for TestNetwork {
|
|||
NetworkUpgrade::Blossom => Some(BlockHeight(584_000)),
|
||||
NetworkUpgrade::Heartwood => Some(BlockHeight(903_800)),
|
||||
NetworkUpgrade::Canopy => Some(BlockHeight(1_028_500)),
|
||||
NetworkUpgrade::Future => None,
|
||||
NetworkUpgrade::ZFuture => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,12 +289,12 @@ pub enum NetworkUpgrade {
|
|||
///
|
||||
/// [Canopy]: https://z.cash/upgrade/canopy/
|
||||
Canopy,
|
||||
/// The [FUTURE] network upgrade.
|
||||
/// The [ZFUTURE] network upgrade.
|
||||
///
|
||||
/// This upgrade is expected never to activate on mainnet;
|
||||
/// it is intended for use in integration testing of functionality
|
||||
/// that is a candidate for integration in a future network upgrade.
|
||||
Future,
|
||||
ZFuture,
|
||||
}
|
||||
|
||||
impl fmt::Display for NetworkUpgrade {
|
||||
|
@ -305,7 +305,7 @@ impl fmt::Display for NetworkUpgrade {
|
|||
NetworkUpgrade::Blossom => write!(f, "Blossom"),
|
||||
NetworkUpgrade::Heartwood => write!(f, "Heartwood"),
|
||||
NetworkUpgrade::Canopy => write!(f, "Canopy"),
|
||||
NetworkUpgrade::Future => write!(f, "FUTURE"),
|
||||
NetworkUpgrade::ZFuture => write!(f, "ZFUTURE"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ impl NetworkUpgrade {
|
|||
NetworkUpgrade::Blossom => BranchId::Blossom,
|
||||
NetworkUpgrade::Heartwood => BranchId::Heartwood,
|
||||
NetworkUpgrade::Canopy => BranchId::Canopy,
|
||||
NetworkUpgrade::Future => BranchId::Future,
|
||||
NetworkUpgrade::ZFuture => BranchId::ZFuture,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ pub enum BranchId {
|
|||
Canopy,
|
||||
/// Candidates for future consensus rules; this branch will never
|
||||
/// activate on mainnet.
|
||||
Future,
|
||||
ZFuture,
|
||||
}
|
||||
|
||||
impl TryFrom<u32> for BranchId {
|
||||
|
@ -380,7 +380,7 @@ impl TryFrom<u32> for BranchId {
|
|||
0x2bb4_0e60 => Ok(BranchId::Blossom),
|
||||
0xf5b9_230b => Ok(BranchId::Heartwood),
|
||||
0xe9ff_75a6 => Ok(BranchId::Canopy),
|
||||
0xffff_ffff => Ok(BranchId::Future),
|
||||
0xffff_ffff => Ok(BranchId::ZFuture),
|
||||
_ => Err("Unknown consensus branch ID"),
|
||||
}
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ impl From<BranchId> for u32 {
|
|||
BranchId::Blossom => 0x2bb4_0e60,
|
||||
BranchId::Heartwood => 0xf5b9_230b,
|
||||
BranchId::Canopy => 0xe9ff_75a6,
|
||||
BranchId::Future => 0xffff_ffff,
|
||||
BranchId::ZFuture => 0xffff_ffff,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -363,7 +363,7 @@ impl<'a, P: consensus::Parameters> Builder<'a, P, OsRng> {
|
|||
|
||||
/// Creates a new `Builder` targeted for inclusion in the block with the given height,
|
||||
/// using default values for general transaction fields and the default OS random,
|
||||
/// and the `FUTURE_TX_VERSION` and `FUTURE_VERSION_GROUP_ID` version identifiers.
|
||||
/// and the `ZFUTURE_TX_VERSION` and `ZFUTURE_VERSION_GROUP_ID` version identifiers.
|
||||
///
|
||||
/// # Default values
|
||||
///
|
||||
|
@ -372,9 +372,9 @@ impl<'a, P: consensus::Parameters> Builder<'a, P, OsRng> {
|
|||
///
|
||||
/// The fee will be set to the default fee (0.0001 ZEC).
|
||||
///
|
||||
/// The transaction will be constructed and serialized according to the Future
|
||||
/// network upgrade rules. This is intended only for use in integration testing of
|
||||
/// new features.
|
||||
/// The transaction will be constructed and serialized according to the
|
||||
/// NetworkUpgrade::ZFuture rules. This is intended only for use in
|
||||
/// integration testing of new features.
|
||||
pub fn new_future(params: P, height: BlockHeight) -> Self {
|
||||
Builder::new_with_rng_future(params, height, OsRng)
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ impl<'a, P: consensus::Parameters, R: RngCore + CryptoRng> Builder<'a, P, R> {
|
|||
|
||||
/// Creates a new `Builder` targeted for inclusion in the block with the given height,
|
||||
/// and randomness source, using default values for general transaction fields
|
||||
/// and the `FUTURE_TX_VERSION` and `FUTURE_VERSION_GROUP_ID` version identifiers.
|
||||
/// and the `ZFUTURE_TX_VERSION` and `ZFUTURE_VERSION_GROUP_ID` version identifiers.
|
||||
///
|
||||
/// # Default values
|
||||
///
|
||||
|
@ -405,9 +405,9 @@ impl<'a, P: consensus::Parameters, R: RngCore + CryptoRng> Builder<'a, P, R> {
|
|||
///
|
||||
/// The fee will be set to the default fee (0.0001 ZEC).
|
||||
///
|
||||
/// The transaction will be constructed and serialized according to the Future
|
||||
/// network upgrade rules. This is intended only for use in integration testing of
|
||||
/// new features.
|
||||
/// The transaction will be constructed and serialized according to the
|
||||
/// NetworkUpgrade::ZFuture rules. This is intended only for use in
|
||||
/// integration testing of new features.
|
||||
pub fn new_with_rng_future(params: P, height: BlockHeight, rng: R) -> Builder<'a, P, R> {
|
||||
Self::new_with_mtx(params, height, rng, TransactionData::future())
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ const SAPLING_TX_VERSION: u32 = 4;
|
|||
/// using these constants should be inspected, and use of these constants
|
||||
/// should be removed as appropriate in favor of the new consensus
|
||||
/// transaction version and group.
|
||||
const FUTURE_VERSION_GROUP_ID: u32 = 0xFFFFFFFF;
|
||||
const FUTURE_TX_VERSION: u32 = 0x0000FFFF;
|
||||
const ZFUTURE_VERSION_GROUP_ID: u32 = 0xFFFFFFFF;
|
||||
const ZFUTURE_TX_VERSION: u32 = 0x0000FFFF;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
|
||||
pub struct TxId(pub [u8; 32]);
|
||||
|
@ -152,8 +152,8 @@ impl TransactionData {
|
|||
pub fn future() -> Self {
|
||||
TransactionData {
|
||||
overwintered: true,
|
||||
version: FUTURE_TX_VERSION,
|
||||
version_group_id: FUTURE_VERSION_GROUP_ID,
|
||||
version: ZFUTURE_TX_VERSION,
|
||||
version_group_id: ZFUTURE_VERSION_GROUP_ID,
|
||||
vin: vec![],
|
||||
vout: vec![],
|
||||
tze_inputs: vec![],
|
||||
|
@ -219,8 +219,8 @@ impl Transaction {
|
|||
&& version_group_id == SAPLING_VERSION_GROUP_ID
|
||||
&& version == SAPLING_TX_VERSION;
|
||||
let has_tze = overwintered
|
||||
&& version_group_id == FUTURE_VERSION_GROUP_ID
|
||||
&& version == FUTURE_TX_VERSION;
|
||||
&& version_group_id == ZFUTURE_VERSION_GROUP_ID
|
||||
&& version == ZFUTURE_TX_VERSION;
|
||||
|
||||
if overwintered && !(is_overwinter_v3 || is_sapling_v4 || has_tze) {
|
||||
return Err(io::Error::new(
|
||||
|
@ -319,8 +319,8 @@ impl Transaction {
|
|||
&& self.version_group_id == SAPLING_VERSION_GROUP_ID
|
||||
&& self.version == SAPLING_TX_VERSION;
|
||||
let has_tze = self.overwintered
|
||||
&& self.version_group_id == FUTURE_VERSION_GROUP_ID
|
||||
&& self.version == FUTURE_TX_VERSION;
|
||||
&& self.version_group_id == ZFUTURE_VERSION_GROUP_ID
|
||||
&& self.version == ZFUTURE_TX_VERSION;
|
||||
|
||||
if self.overwintered && !(is_overwinter_v3 || is_sapling_v4 || has_tze) {
|
||||
return Err(io::Error::new(
|
||||
|
|
|
@ -5,8 +5,8 @@ use group::GroupEncoding;
|
|||
|
||||
use super::{
|
||||
components::{Amount, TxOut},
|
||||
Transaction, TransactionData, FUTURE_VERSION_GROUP_ID, OVERWINTER_VERSION_GROUP_ID,
|
||||
SAPLING_TX_VERSION, SAPLING_VERSION_GROUP_ID,
|
||||
Transaction, TransactionData, OVERWINTER_VERSION_GROUP_ID, SAPLING_TX_VERSION,
|
||||
SAPLING_VERSION_GROUP_ID, ZFUTURE_VERSION_GROUP_ID,
|
||||
};
|
||||
use crate::{consensus, extensions::transparent::Precondition, legacy::Script};
|
||||
|
||||
|
@ -51,7 +51,7 @@ enum SigHashVersion {
|
|||
Sprout,
|
||||
Overwinter,
|
||||
Sapling,
|
||||
Future,
|
||||
ZFuture,
|
||||
}
|
||||
|
||||
impl SigHashVersion {
|
||||
|
@ -60,7 +60,7 @@ impl SigHashVersion {
|
|||
match tx.version_group_id {
|
||||
OVERWINTER_VERSION_GROUP_ID => SigHashVersion::Overwinter,
|
||||
SAPLING_VERSION_GROUP_ID => SigHashVersion::Sapling,
|
||||
FUTURE_VERSION_GROUP_ID => SigHashVersion::Future,
|
||||
ZFUTURE_VERSION_GROUP_ID => SigHashVersion::ZFuture,
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
} else {
|
||||
|
@ -220,7 +220,7 @@ pub fn signature_hash_data<'a>(
|
|||
) -> Vec<u8> {
|
||||
let sigversion = SigHashVersion::from_tx(tx);
|
||||
match sigversion {
|
||||
SigHashVersion::Overwinter | SigHashVersion::Sapling | SigHashVersion::Future => {
|
||||
SigHashVersion::Overwinter | SigHashVersion::Sapling | SigHashVersion::ZFuture => {
|
||||
let mut personal = [0; 16];
|
||||
(&mut personal[..12]).copy_from_slice(ZCASH_SIGHASH_PERSONALIZATION_PREFIX);
|
||||
(&mut personal[12..])
|
||||
|
@ -258,12 +258,12 @@ pub fn signature_hash_data<'a>(
|
|||
} else {
|
||||
h.update(&[0; 32]);
|
||||
};
|
||||
if sigversion == SigHashVersion::Future {
|
||||
if sigversion == SigHashVersion::ZFuture {
|
||||
update_hash!(h, !tx.tze_inputs.is_empty(), tze_inputs_hash(tx));
|
||||
update_hash!(h, !tx.tze_outputs.is_empty(), tze_outputs_hash(tx));
|
||||
}
|
||||
update_hash!(h, !tx.joinsplits.is_empty(), joinsplits_hash(tx));
|
||||
if sigversion == SigHashVersion::Sapling || sigversion == SigHashVersion::Future {
|
||||
if sigversion == SigHashVersion::Sapling || sigversion == SigHashVersion::ZFuture {
|
||||
update_hash!(h, !tx.shielded_spends.is_empty(), shielded_spends_hash(tx));
|
||||
update_hash!(
|
||||
h,
|
||||
|
@ -273,7 +273,7 @@ pub fn signature_hash_data<'a>(
|
|||
}
|
||||
update_u32!(h, tx.lock_time, tmp);
|
||||
update_u32!(h, tx.expiry_height.into(), tmp);
|
||||
if sigversion == SigHashVersion::Sapling || sigversion == SigHashVersion::Future {
|
||||
if sigversion == SigHashVersion::Sapling || sigversion == SigHashVersion::ZFuture {
|
||||
h.update(&tx.value_balance.to_i64_le_bytes());
|
||||
}
|
||||
update_u32!(h, hash_type, tmp);
|
||||
|
@ -284,7 +284,7 @@ pub fn signature_hash_data<'a>(
|
|||
script_code,
|
||||
value,
|
||||
} => {
|
||||
let mut data = if sigversion == SigHashVersion::Future {
|
||||
let mut data = if sigversion == SigHashVersion::ZFuture {
|
||||
ZCASH_TRANSPARENT_SIGNED_INPUT_DOMAIN_SEPARATOR.to_vec()
|
||||
} else {
|
||||
vec![]
|
||||
|
@ -303,7 +303,7 @@ pub fn signature_hash_data<'a>(
|
|||
index,
|
||||
precondition,
|
||||
value,
|
||||
} if sigversion == SigHashVersion::Future => {
|
||||
} if sigversion == SigHashVersion::ZFuture => {
|
||||
let mut data = ZCASH_TZE_SIGNED_INPUT_DOMAIN_SEPARATOR.to_vec();
|
||||
|
||||
tx.tze_inputs[index].prevout.write(&mut data).unwrap();
|
||||
|
@ -316,7 +316,7 @@ pub fn signature_hash_data<'a>(
|
|||
}
|
||||
|
||||
SignableInput::Tze { .. } => {
|
||||
panic!("A request has been made to sign a TZE input, but the signature hash version is not Future");
|
||||
panic!("A request has been made to sign a TZE input, but the signature hash version is not ZFuture");
|
||||
}
|
||||
|
||||
_ => (),
|
||||
|
|
|
@ -13,9 +13,8 @@ use super::{
|
|||
components::amount::MAX_MONEY,
|
||||
components::{Amount, OutPoint, TxIn, TxOut, TzeIn, TzeOut},
|
||||
sighash::{signature_hash, SignableInput},
|
||||
Transaction, TransactionData, FUTURE_TX_VERSION, FUTURE_VERSION_GROUP_ID,
|
||||
OVERWINTER_TX_VERSION, OVERWINTER_VERSION_GROUP_ID, SAPLING_TX_VERSION,
|
||||
SAPLING_VERSION_GROUP_ID,
|
||||
Transaction, TransactionData, OVERWINTER_TX_VERSION, OVERWINTER_VERSION_GROUP_ID,
|
||||
SAPLING_TX_VERSION, SAPLING_VERSION_GROUP_ID, ZFUTURE_TX_VERSION, ZFUTURE_VERSION_GROUP_ID,
|
||||
};
|
||||
|
||||
prop_compose! {
|
||||
|
@ -77,7 +76,7 @@ fn tx_versions(branch_id: BranchId) -> impl Strategy<Value = (u32, u32)> {
|
|||
match branch_id {
|
||||
BranchId::Sprout => (1..(2 as u32)).prop_map(|i| (i, 0)).boxed(),
|
||||
BranchId::Overwinter => Just((OVERWINTER_TX_VERSION, OVERWINTER_VERSION_GROUP_ID)).boxed(),
|
||||
BranchId::Future => Just((FUTURE_TX_VERSION, FUTURE_VERSION_GROUP_ID)).boxed(),
|
||||
BranchId::ZFuture => Just((ZFUTURE_TX_VERSION, ZFUTURE_VERSION_GROUP_ID)).boxed(),
|
||||
_otherwise => Just((SAPLING_TX_VERSION, SAPLING_VERSION_GROUP_ID)).boxed(),
|
||||
}
|
||||
}
|
||||
|
@ -98,8 +97,8 @@ prop_compose! {
|
|||
version,
|
||||
version_group_id,
|
||||
vin, vout,
|
||||
tze_inputs: if branch_id == BranchId::Future { tze_inputs } else { vec![] },
|
||||
tze_outputs: if branch_id == BranchId::Future { tze_outputs } else { vec![] },
|
||||
tze_inputs: if branch_id == BranchId::ZFuture { tze_inputs } else { vec![] },
|
||||
tze_outputs: if branch_id == BranchId::ZFuture { tze_outputs } else { vec![] },
|
||||
lock_time,
|
||||
expiry_height: expiry_height.into(),
|
||||
value_balance,
|
||||
|
@ -178,7 +177,7 @@ fn tx_write_rejects_unexpected_binding_sig() {
|
|||
|
||||
proptest! {
|
||||
#[test]
|
||||
fn test_tze_roundtrip(tx in arb_tx(BranchId::Future)) {
|
||||
fn test_tze_roundtrip(tx in arb_tx(BranchId::ZFuture)) {
|
||||
let mut txn_bytes = vec![];
|
||||
tx.write(&mut txn_bytes).unwrap();
|
||||
|
||||
|
|
Loading…
Reference in New Issue