Skip to content

Commit

Permalink
Replace unstable-nu6 and zfuture feature flags with cfg flags
Browse files Browse the repository at this point in the history
Neither of these should have been feature flags, as they gate breaking
changes to the Zcash consensus rules (and in some ways are incompatible
with each other), while feature flags should be additive.
  • Loading branch information
str4d committed Mar 10, 2024
1 parent 98c82eb commit 6898dbf
Show file tree
Hide file tree
Showing 27 changed files with 187 additions and 190 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
extra_flags: orchard
rustflags: '--cfg zcash_unstable="orchard"'
- state: NU6
extra_flags: unstable-nu6
rustflags: '--cfg zcash_unstable="nu6"'

exclude:
- target: macOS
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
os: windows-latest

- state: ZFuture
extra_flags: zfuture
rustflags: '--cfg zcash_unstable="zfuture"'

env:
RUSTFLAGS: ${{ matrix.rustflags }}
Expand Down
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ members = [
"components/zcash_protocol",
"zcash_client_backend",
"zcash_client_sqlite",
# Disabled until we replace the `zfutures` feature flag with a compiler flag.
# "zcash_extensions",
"zcash_extensions",
"zcash_history",
"zcash_keys",
"zcash_primitives",
Expand Down
5 changes: 5 additions & 0 deletions components/zcash_protocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this library adheres to Rust's notion of
- `zcash_protocol::memo`:
- `impl TryFrom<&MemoBytes> for Memo`

### Removed
- `unstable-nu6` and `zfuture` feature flags (use `--cfg zcash_unstable=\"nu6\"`
or `--cfg zcash_unstable=\"zfuture\"` in `RUSTFLAGS` and `RUSTDOCFLAGS`
instead).

## [0.1.0] - 2024-03-06
The entries below are relative to the `zcash_primitives` crate as of the tag
`zcash_primitives-0.14.0`.
Expand Down
11 changes: 0 additions & 11 deletions components/zcash_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,3 @@ test-dependencies = [

## Exposes support for working with a local consensus (e.g. regtest).
local-consensus = []

#! ### Experimental features
#!
#! ⚠️ Enabling these features will likely make your code incompatible with current Zcash
#! consensus rules!

## Exposes the in-development NU6 features.
unstable-nu6 = []

## Exposes early in-development features that are not yet planned for any network upgrade.
zfuture = []
46 changes: 23 additions & 23 deletions components/zcash_protocol/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ impl Parameters for MainNetwork {
NetworkUpgrade::Heartwood => Some(BlockHeight(903_000)),
NetworkUpgrade::Canopy => Some(BlockHeight(1_046_400)),
NetworkUpgrade::Nu5 => Some(BlockHeight(1_687_104)),
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6 => None,
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => None,
}
}
Expand Down Expand Up @@ -384,9 +384,9 @@ impl Parameters for TestNetwork {
NetworkUpgrade::Heartwood => Some(BlockHeight(903_800)),
NetworkUpgrade::Canopy => Some(BlockHeight(1_028_500)),
NetworkUpgrade::Nu5 => Some(BlockHeight(1_842_420)),
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6 => None,
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => None,
}
}
Expand Down Expand Up @@ -452,14 +452,14 @@ pub enum NetworkUpgrade {
/// The [Nu6] network upgrade.
///
/// [Nu6]: https://z.cash/upgrade/nu6/
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
Nu6,
/// 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.
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
ZFuture,
}

Expand All @@ -474,9 +474,9 @@ impl fmt::Display for NetworkUpgrade {
NetworkUpgrade::Heartwood => write!(f, "Heartwood"),
NetworkUpgrade::Canopy => write!(f, "Canopy"),
NetworkUpgrade::Nu5 => write!(f, "Nu5"),
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6 => write!(f, "Nu6"),
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => write!(f, "ZFUTURE"),
}
}
Expand All @@ -491,9 +491,9 @@ impl NetworkUpgrade {
NetworkUpgrade::Heartwood => BranchId::Heartwood,
NetworkUpgrade::Canopy => BranchId::Canopy,
NetworkUpgrade::Nu5 => BranchId::Nu5,
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6 => BranchId::Nu6,
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => BranchId::ZFuture,
}
}
Expand All @@ -510,7 +510,7 @@ const UPGRADES_IN_ORDER: &[NetworkUpgrade] = &[
NetworkUpgrade::Heartwood,
NetworkUpgrade::Canopy,
NetworkUpgrade::Nu5,
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6,
];

Expand Down Expand Up @@ -549,11 +549,11 @@ pub enum BranchId {
/// The consensus rules deployed by [`NetworkUpgrade::Nu5`].
Nu5,
/// The consensus rules deployed by [`NetworkUpgrade::Nu6`].
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
Nu6,
/// Candidates for future consensus rules; this branch will never
/// activate on mainnet.
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
ZFuture,
}

Expand All @@ -571,9 +571,9 @@ impl TryFrom<u32> for BranchId {
0xf5b9_230b => Ok(BranchId::Heartwood),
0xe9ff_75a6 => Ok(BranchId::Canopy),
0xc2d6_d0b4 => Ok(BranchId::Nu5),
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
0xc8e7_1055 => Ok(BranchId::Nu6),
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
0xffff_ffff => Ok(BranchId::ZFuture),
_ => Err("Unknown consensus branch ID"),
}
Expand All @@ -590,9 +590,9 @@ impl From<BranchId> for u32 {
BranchId::Heartwood => 0xf5b9_230b,
BranchId::Canopy => 0xe9ff_75a6,
BranchId::Nu5 => 0xc2d6_d0b4,
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
BranchId::Nu6 => 0xc8e7_1055,
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
BranchId::ZFuture => 0xffff_ffff,
}
}
Expand Down Expand Up @@ -658,15 +658,15 @@ impl BranchId {
.activation_height(NetworkUpgrade::Canopy)
.map(|lower| (lower, params.activation_height(NetworkUpgrade::Nu5))),
BranchId::Nu5 => params.activation_height(NetworkUpgrade::Nu5).map(|lower| {
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]

Check warning on line 661 in components/zcash_protocol/src/consensus.rs

View check run for this annotation

Codecov / codecov/patch

components/zcash_protocol/src/consensus.rs#L661

Added line #L661 was not covered by tests
let upper = params.activation_height(NetworkUpgrade::ZFuture);
#[cfg(not(feature = "zfuture"))]
#[cfg(not(zcash_unstable = "zfuture"))]

Check warning on line 663 in components/zcash_protocol/src/consensus.rs

View check run for this annotation

Codecov / codecov/patch

components/zcash_protocol/src/consensus.rs#L663

Added line #L663 was not covered by tests
let upper = None;
(lower, upper)
}),
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
BranchId::Nu6 => None,
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
BranchId::ZFuture => params
.activation_height(NetworkUpgrade::ZFuture)
.map(|lower| (lower, None)),
Expand Down Expand Up @@ -694,9 +694,9 @@ pub mod testing {
BranchId::Heartwood,
BranchId::Canopy,
BranchId::Nu5,
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]

Check warning on line 697 in components/zcash_protocol/src/consensus.rs

View check run for this annotation

Codecov / codecov/patch

components/zcash_protocol/src/consensus.rs#L697

Added line #L697 was not covered by tests
BranchId::Nu6,
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]

Check warning on line 699 in components/zcash_protocol/src/consensus.rs

View check run for this annotation

Codecov / codecov/patch

components/zcash_protocol/src/consensus.rs#L699

Added line #L699 was not covered by tests
BranchId::ZFuture,
])
}
Expand Down
42 changes: 19 additions & 23 deletions components/zcash_protocol/src/local_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ use crate::consensus::{BlockHeight, NetworkType, NetworkUpgrade, Parameters};
/// heartwood: Some(BlockHeight::from_u32(1)),
/// canopy: Some(BlockHeight::from_u32(1)),
/// nu5: Some(BlockHeight::from_u32(1)),
/// #[cfg(feature = "unstable-nu6")]
/// nu6: Some(BlockHeight::from_u32(1)),
/// #[cfg(feature = "zfuture")]
/// z_future: Some(BlockHeight::from_u32(1)),
/// };
/// ```
///
Expand All @@ -41,9 +37,9 @@ pub struct LocalNetwork {
pub heartwood: Option<BlockHeight>,
pub canopy: Option<BlockHeight>,
pub nu5: Option<BlockHeight>,
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
pub nu6: Option<BlockHeight>,
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
pub z_future: Option<BlockHeight>,
}

Expand All @@ -61,9 +57,9 @@ impl Parameters for LocalNetwork {
NetworkUpgrade::Heartwood => self.heartwood,
NetworkUpgrade::Canopy => self.canopy,
NetworkUpgrade::Nu5 => self.nu5,
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6 => self.nu6,
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => self.z_future,
}
}
Expand All @@ -85,9 +81,9 @@ mod tests {
let expected_heartwood = BlockHeight::from_u32(4);
let expected_canopy = BlockHeight::from_u32(5);
let expected_nu5 = BlockHeight::from_u32(6);
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
let expected_nu6 = BlockHeight::from_u32(7);
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
let expected_z_future = BlockHeight::from_u32(7);

let regtest = LocalNetwork {
Expand All @@ -97,9 +93,9 @@ mod tests {
heartwood: Some(expected_heartwood),
canopy: Some(expected_canopy),
nu5: Some(expected_nu5),
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
nu6: Some(expected_nu6),
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
z_future: Some(expected_z_future),
};

Expand All @@ -109,9 +105,9 @@ mod tests {
assert!(regtest.is_nu_active(NetworkUpgrade::Heartwood, expected_heartwood));
assert!(regtest.is_nu_active(NetworkUpgrade::Canopy, expected_canopy));
assert!(regtest.is_nu_active(NetworkUpgrade::Nu5, expected_nu5));
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
assert!(regtest.is_nu_active(NetworkUpgrade::Nu6, expected_nu6));
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
assert!(!regtest.is_nu_active(NetworkUpgrade::ZFuture, expected_nu5));
}

Expand All @@ -123,9 +119,9 @@ mod tests {
let expected_heartwood = BlockHeight::from_u32(4);
let expected_canopy = BlockHeight::from_u32(5);
let expected_nu5 = BlockHeight::from_u32(6);
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
let expected_nu6 = BlockHeight::from_u32(7);
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
let expected_z_future = BlockHeight::from_u32(7);

let regtest = LocalNetwork {
Expand All @@ -135,9 +131,9 @@ mod tests {
heartwood: Some(expected_heartwood),
canopy: Some(expected_canopy),
nu5: Some(expected_nu5),
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
nu6: Some(expected_nu6),
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
z_future: Some(expected_z_future),
};

Expand Down Expand Up @@ -165,7 +161,7 @@ mod tests {
regtest.activation_height(NetworkUpgrade::Nu5),
Some(expected_nu5)
);
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
assert_eq!(
regtest.activation_height(NetworkUpgrade::ZFuture),
Some(expected_z_future)
Expand All @@ -180,9 +176,9 @@ mod tests {
let expected_heartwood = BlockHeight::from_u32(4);
let expected_canopy = BlockHeight::from_u32(5);
let expected_nu5 = BlockHeight::from_u32(6);
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
let expected_nu6 = BlockHeight::from_u32(7);
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
let expected_z_future = BlockHeight::from_u32(7);

let regtest = LocalNetwork {
Expand All @@ -192,9 +188,9 @@ mod tests {
heartwood: Some(expected_heartwood),
canopy: Some(expected_canopy),
nu5: Some(expected_nu5),
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
nu6: Some(expected_nu6),
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
z_future: Some(expected_z_future),
};

Expand Down
2 changes: 0 additions & 2 deletions zcash_client_sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ zcash_address = { workspace = true, features = ["test-dependencies"] }

[features]
default = ["multicore"]
unstable-nu6 = ["zcash_primitives/unstable-nu6"]
zfuture = ["zcash_primitives/zfuture"]

## Enables multithreading support for creating proofs and building subtrees.
multicore = ["maybe-rayon/threads", "zcash_primitives/multicore"]
Expand Down
4 changes: 2 additions & 2 deletions zcash_client_sqlite/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ impl TestBuilder<()> {
heartwood: Some(BlockHeight::from_u32(100_000)),
canopy: Some(BlockHeight::from_u32(100_000)),
nu5: Some(BlockHeight::from_u32(100_000)),
#[cfg(feature = "unstable-nu6")]
#[cfg(zcash_unstable = "nu6")]
nu6: None,
#[cfg(feature = "zfuture")]
#[cfg(zcash_unstable = "zfuture")]
z_future: None,
},
cache: (),
Expand Down
3 changes: 1 addition & 2 deletions zcash_extensions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
blake2b_simd.workspace = true
zcash_primitives = { workspace = true, features = ["zfuture" ] }
zcash_primitives.workspace = true

[dev-dependencies]
ff.workspace = true
Expand All @@ -29,7 +29,6 @@ zcash_proofs.workspace = true

[features]
transparent-inputs = []
unstable-nu6 = ["zcash_primitives/unstable-nu6"]

[lib]
bench = false
5 changes: 5 additions & 0 deletions zcash_extensions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
// Catch documentation errors caused by code changes.
#![deny(rustdoc::broken_intra_doc_links)]

// For workspace compilation reasons, we have this crate in the workspace and just leave
// it empty if `zfuture` is not enabled.

#[cfg(zcash_unstable = "zfuture")]
pub mod consensus;
#[cfg(zcash_unstable = "zfuture")]
pub mod transparent;
Loading

0 comments on commit 6898dbf

Please sign in to comment.