Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zcash Sustainability Fund #8807

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ dependencies = [
[[package]]
name = "equihash"
version = "0.2.0"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"blake2b_simd",
"byteorder",
Expand Down Expand Up @@ -1352,7 +1352,7 @@ dependencies = [
[[package]]
name = "f4jumble"
version = "0.1.0"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"blake2b_simd",
]
Expand Down Expand Up @@ -5550,8 +5550,8 @@ checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546"

[[package]]
name = "zcash_address"
version = "0.4.0"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
version = "0.3.2"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"bech32",
"bs58",
Expand All @@ -5562,8 +5562,8 @@ dependencies = [

[[package]]
name = "zcash_client_backend"
version = "0.13.0"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
version = "0.12.1"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"base64 0.21.7",
"bech32",
Expand Down Expand Up @@ -5601,8 +5601,8 @@ dependencies = [

[[package]]
name = "zcash_encoding"
version = "0.2.1"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
version = "0.2.0"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"byteorder",
"nonempty",
Expand All @@ -5611,7 +5611,7 @@ dependencies = [
[[package]]
name = "zcash_history"
version = "0.4.0"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"blake2b_simd",
"byteorder",
Expand All @@ -5620,8 +5620,8 @@ dependencies = [

[[package]]
name = "zcash_keys"
version = "0.3.0"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
version = "0.2.0"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"bech32",
"blake2b_simd",
Expand Down Expand Up @@ -5658,16 +5658,16 @@ dependencies = [

[[package]]
name = "zcash_primitives"
version = "0.16.0"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
version = "0.15.1"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"aes",
"bip32",
"blake2b_simd",
"bs58",
"byteorder",
"document-features",
"equihash 0.2.0 (git+https://github.com/zcash/librustzcash/?branch=main)",
"equihash 0.2.0 (git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main)",
"ff",
"fpe",
"group",
Expand Down Expand Up @@ -5696,8 +5696,8 @@ dependencies = [

[[package]]
name = "zcash_proofs"
version = "0.16.0"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
version = "0.15.0"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"bellman",
"blake2b_simd",
Expand All @@ -5718,8 +5718,8 @@ dependencies = [

[[package]]
name = "zcash_protocol"
version = "0.2.0"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
version = "0.1.1"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"document-features",
"memuse",
Expand Down Expand Up @@ -6252,8 +6252,8 @@ dependencies = [

[[package]]
name = "zip321"
version = "0.1.0"
source = "git+https://github.com/zcash/librustzcash/?branch=main#40ca428c6081c61d5a2bf3f2053eb9e18219ca95"
version = "0.0.0"
source = "git+https://github.com/eigerco/librustzcash/?branch=zsf_on_main#280f4408dd3657ec5a32dcafa079414367445cc6"
dependencies = [
"base64 0.21.7",
"nom",
Expand Down
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ incrementalmerkletree = "0.6.0"
orchard = "0.9.0"
sapling-crypto = "0.2.0"
# TODO: Revert to a release once librustzcash is released (#8749).
zcash_address = { git = "https://github.com/zcash/librustzcash/", branch = "main" }
zcash_client_backend = { git = "https://github.com/zcash/librustzcash/", branch = "main" }
zcash_encoding = { git = "https://github.com/zcash/librustzcash/", branch = "main" }
zcash_history = { git = "https://github.com/zcash/librustzcash/", branch = "main" }
zcash_keys = { git = "https://github.com/zcash/librustzcash/", branch = "main" }
zcash_primitives = { git = "https://github.com/zcash/librustzcash/", branch = "main" }
zcash_proofs = { git = "https://github.com/zcash/librustzcash/", branch = "main" }
zcash_protocol = { git = "https://github.com/zcash/librustzcash/", branch = "main" }
zcash_address = { git = "https://github.com/eigerco/librustzcash/", branch = "zsf_on_main" }
zcash_client_backend = { git = "https://github.com/eigerco/librustzcash/", branch = "zsf_on_main" }
zcash_encoding = { git = "https://github.com/eigerco/librustzcash/", branch = "zsf_on_main" }
zcash_history = { git = "https://github.com/eigerco/librustzcash/", branch = "zsf_on_main" }
zcash_keys = { git = "https://github.com/eigerco/librustzcash/", branch = "zsf_on_main" }
zcash_primitives = { git = "https://github.com/eigerco/librustzcash/", branch = "zsf_on_main" }
zcash_proofs = { git = "https://github.com/eigerco/librustzcash/", branch = "zsf_on_main" }
zcash_protocol = { git = "https://github.com/eigerco/librustzcash/", branch = "zsf_on_main" }

[workspace.metadata.release]

Expand Down
2 changes: 2 additions & 0 deletions zebra-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ categories = ["asynchronous", "cryptography::cryptocurrencies", "encoding"]
[features]
default = []

zsf = []

# Production features that activate extra functionality

# Consensus-critical conversion from JSON to Zcash types
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ impl Constraint for NonNegative {
/// -MAX_MONEY..=0,
/// );
/// ```
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Default)]
pub struct NegativeOrZero;

impl Constraint for NegativeOrZero {
Expand Down
4 changes: 4 additions & 0 deletions zebra-chain/src/block/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ impl Commitment {
(Nu5 | Nu6, _) => Ok(ChainHistoryBlockTxAuthCommitment(
ChainHistoryBlockTxAuthCommitmentHash(bytes),
)),
#[cfg(feature = "zsf")]
(ZFuture, _) => Ok(ChainHistoryBlockTxAuthCommitment(
ChainHistoryBlockTxAuthCommitmentHash(bytes),
)),
}
}

Expand Down
21 changes: 21 additions & 0 deletions zebra-chain/src/history_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ impl NonEmptyHistoryTree {
)?;
InnerHistoryTree::OrchardOnward(tree)
}
#[cfg(feature = "zsf")]
NetworkUpgrade::ZFuture => {
let tree = Tree::<OrchardOnward>::new_from_cache(
network,
network_upgrade,
size,
&peaks,
&Default::default(),
)?;
InnerHistoryTree::OrchardOnward(tree)
}
};
Ok(Self {
network: network.clone(),
Expand Down Expand Up @@ -165,6 +176,16 @@ impl NonEmptyHistoryTree {
)?;
(InnerHistoryTree::OrchardOnward(tree), entry)
}
#[cfg(feature = "zsf")]
NetworkUpgrade::ZFuture => {
let (tree, entry) = Tree::<OrchardOnward>::new_from_block(
network,
block,
sapling_root,
orchard_root,
)?;
(InnerHistoryTree::OrchardOnward(tree), entry)
}
};
let mut peaks = BTreeMap::new();
peaks.insert(0u32, entry);
Expand Down
17 changes: 15 additions & 2 deletions zebra-chain/src/parameters/network/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ pub struct ConfiguredActivationHeights {
/// Activation height for `NU6` network upgrade.
#[serde(rename = "NU6")]
pub nu6: Option<u32>,
#[cfg(feature = "zsf")]
#[serde(rename = "ZFuture")]
pub zfuture: Option<u32>,
}

/// Builder for the [`Parameters`] struct.
Expand Down Expand Up @@ -314,6 +317,8 @@ impl ParametersBuilder {
canopy,
nu5,
nu6,
#[cfg(feature = "zsf")]
zfuture,
}: ConfiguredActivationHeights,
) -> Self {
use NetworkUpgrade::*;
Expand All @@ -322,7 +327,7 @@ impl ParametersBuilder {
//
// These must be in order so that later network upgrades overwrite prior ones
// if multiple network upgrades are configured with the same activation height.
let activation_heights: BTreeMap<_, _> = before_overwinter
let activation_heights = before_overwinter
.into_iter()
.map(|h| (h, BeforeOverwinter))
.chain(overwinter.into_iter().map(|h| (h, Overwinter)))
Expand All @@ -331,7 +336,13 @@ impl ParametersBuilder {
.chain(heartwood.into_iter().map(|h| (h, Heartwood)))
.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(nu6.into_iter().map(|h| (h, Nu6)));

#[cfg(feature = "zsf")]
let activation_heights =
activation_heights.chain(zfuture.into_iter().map(|h| (h, ZFuture)));

let activation_heights: BTreeMap<_, _> = activation_heights
.map(|(h, nu)| (h.try_into().expect("activation height must be valid"), nu))
.collect();

Expand Down Expand Up @@ -538,6 +549,8 @@ impl Parameters {
canopy: Some(1),
nu5: nu5_activation_height,
nu6: nu6_activation_height,
#[cfg(feature = "zsf")]
zfuture: nu5_activation_height.map(|height| height + 1),
..Default::default()
})
.finish()
Expand Down
9 changes: 8 additions & 1 deletion zebra-chain/src/parameters/network/tests/vectors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Fixed test vectors for the network consensus parameters.

use zcash_primitives::consensus::NetworkConstants as _;
use zcash_primitives::consensus::{self as zp_consensus, Parameters};
use zcash_protocol::consensus::NetworkConstants as _;

use crate::{
block::Height,
Expand Down Expand Up @@ -31,6 +31,8 @@ fn check_parameters_impl() {
zp_consensus::NetworkUpgrade::Heartwood,
zp_consensus::NetworkUpgrade::Canopy,
zp_consensus::NetworkUpgrade::Nu5,
#[cfg(feature = "zsf")]
zp_consensus::NetworkUpgrade::ZFuture,
];

for (network, zp_network) in [
Expand Down Expand Up @@ -109,7 +111,10 @@ fn activates_network_upgrades_correctly() {
let expected_activation_height = 1;
let network = testnet::Parameters::build()
.with_activation_heights(ConfiguredActivationHeights {
#[cfg(not(feature = "zsf"))]
nu6: Some(expected_activation_height),
#[cfg(feature = "zsf")]
zfuture: Some(expected_activation_height),
..Default::default()
})
.to_network();
Expand Down Expand Up @@ -141,6 +146,8 @@ fn activates_network_upgrades_correctly() {
(Height(1), NetworkUpgrade::Canopy),
// TODO: Remove this once the testnet parameters are being serialized.
(Height(100), NetworkUpgrade::Nu5),
#[cfg(feature = "zsf")]
(Height(101), NetworkUpgrade::ZFuture),
];

for (network, expected_activation_heights) in [
Expand Down
Loading