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

Nu7 implementation #65

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
d58ac5b
minor update
PaulLaux Jan 10, 2023
f34dd02
updated version
PaulLaux Jan 12, 2023
b890183
commented out test code
PaulLaux Jan 12, 2023
f62a230
updated test and cleanup
PaulLaux Jan 23, 2023
a56c5da
New orchard version
alexeykoren Dec 18, 2022
d670033
Add TODO for burn reading/writing
alexeykoren Dec 18, 2022
c6175b8
fixed zcash_client_backend and simplified cargo.toml
PaulLaux Jan 24, 2023
af4d4bb
updated Cargo.toml
PaulLaux Jan 31, 2023
fbbd655
Fix post-rebase problems
alexeykoren May 13, 2024
424bf1a
Make BlockHeader from_data public
alexeykoren Jan 10, 2024
b0b0f65
Make txid bytes public
alexeykoren Jan 10, 2024
dac8d1f
Note serialization
alexeykoren Jan 10, 2024
cd8524b
Update zcash_primitives to use the generalised version of orchard cra…
dmidem Feb 29, 2024
3c83b72
Fix tests accordingly to modifications in orchard
dmidem Mar 4, 2024
aac4840
Minor fix or Rust code format (because of cargo fmt error)
dmidem Mar 5, 2024
6da0474
Fix post-rebase problems
alexeykoren May 13, 2024
0049a3b
Note serialization
alexeykoren Jan 10, 2024
98f4747
Update zcash_primitives to use the generalised version of orchard cra…
dmidem Feb 29, 2024
2365c2b
Introduce issue bundle
alexeykoren Mar 6, 2024
7e87fa5
Orchard domain interface update
alexeykoren Mar 29, 2024
2bd5e45
Work in progress
alexeykoren Apr 1, 2024
2704c8a
Add ZSA
alexeykoren Apr 15, 2024
5eec964
Add issuance
alexeykoren Apr 15, 2024
3a18a4d
Fix fmt
alexeykoren Apr 15, 2024
35f02fb
Fix clippy
alexeykoren Apr 15, 2024
2ab8e16
Fix transparent-inputs
alexeykoren Apr 15, 2024
c841df1
Remove unproven enum
alexeykoren Apr 22, 2024
fb2b73a
Change methods visibility
alexeykoren Apr 22, 2024
cdd8afa
Fix post-rebase compilation errors
alexeykoren May 19, 2024
5733e8d
Revert test vector changes for Nu5
alexeykoren May 19, 2024
008f35e
Change Nu6 activation heights
alexeykoren May 19, 2024
cbd3b38
Use updated sapling-crypto
alexeykoren May 20, 2024
307d025
Add into_transaction method
alexeykoren May 27, 2024
ce0a391
Use nu7 zcash_unstable flag
alexeykoren Jun 10, 2024
b7d4833
Fix transparent builder
alexeykoren Jun 11, 2024
aad64db
Exclude zcash_client crates
alexeykoren Jun 18, 2024
c0d551d
Fix formatting
alexeykoren Jun 18, 2024
944377d
Fix clippy
alexeykoren Jun 18, 2024
5856713
Fix merge issues
alexeykoren Jun 26, 2024
9ddc1a7
Adjust versions
alexeykoren Jun 26, 2024
c0fbc44
Add cargo vet exemption for half
alexeykoren Jun 26, 2024
1ffcf4e
Fix CI
alexeykoren Jun 26, 2024
beb1d8d
Fix tze build
alexeykoren Jun 26, 2024
fee70aa
Fix tze fmt
alexeykoren Jun 26, 2024
2c11d9a
Fix note_encryption version
alexeykoren Jun 26, 2024
918beb9
Disable wasm target
alexeykoren Jun 26, 2024
46ac12c
Replace nu7 with nu6 temporarily
alexeykoren Jun 27, 2024
6b743b8
Fix fmt
alexeykoren Jun 27, 2024
9b9e525
Update librustzcash to align with orchard crate (#67)
dmidem Jul 16, 2024
cac470f
Corrections to V7 transaction format and using updated test vectors (…
vivek-arte Jul 24, 2024
f160f25
Remove duplicate import
alexeykoren Jul 24, 2024
4dbee84
Reformat feature flag
alexeykoren Jul 25, 2024
8b9672d
Address PR comments
alexeykoren Jul 25, 2024
1860f1d
Address PR comments
alexeykoren Jul 25, 2024
f4cf872
Fmt
alexeykoren Jul 26, 2024
aec1879
Clippy
alexeykoren Jul 26, 2024
830260f
Use ZSA BundleType
alexeykoren Jul 26, 2024
acb8f97
Use bundle check instead of has_orchard_zsa
alexeykoren Jul 26, 2024
4f6ec46
Fix upper bound calculation
alexeykoren Jul 26, 2024
3d20879
Fmt
alexeykoren Jul 26, 2024
7f045e7
Add finalization
alexeykoren Jul 29, 2024
f411948
Add issuance builder tests
alexeykoren Jul 30, 2024
3ac2618
Fmt
alexeykoren Jul 30, 2024
ea1770e
Fix double import
alexeykoren Jul 30, 2024
fe88163
Use updated zsa1
alexeykoren Jul 31, 2024
fc38730
Fmt
alexeykoren Jul 31, 2024
6652222
Update zcash_primitives to sync with latest sapling-crypto changes (#70)
dmidem Aug 20, 2024
dc0a815
Minor changes
alexeykoren Aug 14, 2024
a434849
Change V7 to v6
alexeykoren Aug 19, 2024
9f52b1b
Make ciphertext reading generic
alexeykoren Aug 19, 2024
10ff1e0
Updated test vectors (#71)
vivek-arte Sep 3, 2024
f79962b
PR fixes
alexeykoren Sep 4, 2024
738ed17
PR fixes
alexeykoren Sep 4, 2024
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
72 changes: 36 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,42 +168,42 @@ jobs:
- name: Verify working directory is clean (excluding lockfile)
run: git diff --exit-code ':!Cargo.lock'

build-nodefault:
name: Build target ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
matrix:
target:
- wasm32-wasi

steps:
- uses: actions/checkout@v4
with:
path: crates
# We use a synthetic crate to ensure no dev-dependencies are enabled, which can
# be incompatible with some of these targets.
- name: Create synthetic crate for testing
run: cargo init --lib ci-build
- name: Copy Rust version into synthetic crate
run: cp crates/rust-toolchain.toml ci-build/
- name: Copy patch directives into synthetic crate
run: |
echo "[patch.crates-io]" >> ./ci-build/Cargo.toml
cat ./crates/Cargo.toml | sed "0,/.\+\(patch.crates.\+\)/d" >> ./ci-build/Cargo.toml
- name: Add zcash_proofs as a dependency of the synthetic crate
working-directory: ./ci-build
run: cargo add --no-default-features --path ../crates/zcash_proofs
- name: Add zcash_client_backend as a dependency of the synthetic crate
working-directory: ./ci-build
run: cargo add --features lightwalletd-tonic --path ../crates/zcash_client_backend
- name: Copy pinned dependencies into synthetic crate
run: cp crates/Cargo.lock ci-build/
- name: Add target
working-directory: ./ci-build
run: rustup target add ${{ matrix.target }}
- name: Build for target
working-directory: ./ci-build
run: cargo build --verbose --target ${{ matrix.target }}
# build-nodefault:
# name: Build target ${{ matrix.target }}
# runs-on: ubuntu-latest
# strategy:
# matrix:
# target:
# - wasm32-wasi
#
# steps:
# - uses: actions/checkout@v4
# with:
# path: crates
# # We use a synthetic crate to ensure no dev-dependencies are enabled, which can
# # be incompatible with some of these targets.
# - name: Create synthetic crate for testing
# run: cargo init --lib ci-build
# - name: Copy Rust version into synthetic crate
# run: cp crates/rust-toolchain.toml ci-build/
# - name: Copy patch directives into synthetic crate
# run: |
# echo "[patch.crates-io]" >> ./ci-build/Cargo.toml
# cat ./crates/Cargo.toml | sed "0,/.\+\(patch.crates.\+\)/d" >> ./ci-build/Cargo.toml
# - name: Add zcash_proofs as a dependency of the synthetic crate
# working-directory: ./ci-build
# run: cargo add --no-default-features --path ../crates/zcash_proofs
# - name: Add zcash_client_backend as a dependency of the synthetic crate
# working-directory: ./ci-build
# run: cargo add --features lightwalletd-tonic --path ../crates/zcash_client_backend
# - name: Copy pinned dependencies into synthetic crate
# run: cp crates/Cargo.lock ci-build/
# - name: Add target
# working-directory: ./ci-build
# run: rustup target add ${{ matrix.target }}
# - name: Build for target
# working-directory: ./ci-build
# run: cargo build --verbose --target ${{ matrix.target }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why comment out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided not to touch zcah_client_xxx crates for now and this target requires them

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so let's remove just the relevant lines:

name: Add zcash_client_backend as a dependency of the synthetic crate
working-directory: ./ci-build
run: cargo add --features lightwalletd-tonic --path ../crates/zcash_client_backend

Seems that it can work


bitrot:
name: Bitrot check
Expand Down
42 changes: 19 additions & 23 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ sapling = { package = "sapling-crypto", version = "0.1.3" }

# - Orchard
nonempty = "0.7"
orchard = { version = "0.8.0", default-features = false }
orchard = { version = "0.8.0", default-features = false, git = "https://github.com/QED-it/orchard", branch = "zsa1" }
pasta_curves = "0.5"

# - Transparent
Expand Down Expand Up @@ -124,4 +124,5 @@ panic = 'abort'
codegen-units = 1

[patch.crates-io]
orchard = { version = "0.8.0", git = "https://github.com/QED-it/orchard", branch = "zsa1" }
zcash_note_encryption = { version = "0.4", git = "https://github.com/QED-it/zcash_note_encryption", branch = "zsa1" }
sapling = { package = "sapling-crypto", version = "0.1.3", git = "https://github.com/QED-it/sapling-crypto", branch = "zsa1" }
87 changes: 76 additions & 11 deletions components/zcash_protocol/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ impl Parameters for MainNetwork {
NetworkUpgrade::Canopy => Some(BlockHeight(1_046_400)),
NetworkUpgrade::Nu5 => Some(BlockHeight(1_687_104)),
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6 => None,
NetworkUpgrade::Nu6 => Some(BlockHeight(1_687_106)),
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7 => Some(BlockHeight(1_687_107)),
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => None,
}
Expand Down Expand Up @@ -386,6 +388,8 @@ impl Parameters for TestNetwork {
NetworkUpgrade::Nu5 => Some(BlockHeight(1_842_420)),
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6 => None,
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7 => Some(BlockHeight(1_842_421)),
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => None,
}
Expand Down Expand Up @@ -454,6 +458,11 @@ pub enum NetworkUpgrade {
/// [Nu6]: https://z.cash/upgrade/nu6/
#[cfg(zcash_unstable = "nu6")]
Nu6,
/// The [Nu7] network upgrade.
///
/// [Nu7]: https://z.cash/upgrade/nu7/
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
Nu7,
/// The ZFUTURE network upgrade.
///
/// This upgrade is expected never to activate on mainnet;
Expand All @@ -476,6 +485,8 @@ impl fmt::Display for NetworkUpgrade {
NetworkUpgrade::Nu5 => write!(f, "Nu5"),
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6 => write!(f, "Nu6"),
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7 => write!(f, "Nu7"),
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => write!(f, "ZFUTURE"),
}
Expand All @@ -493,6 +504,8 @@ impl NetworkUpgrade {
NetworkUpgrade::Nu5 => BranchId::Nu5,
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6 => BranchId::Nu6,
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7 => BranchId::Nu7,
#[cfg(zcash_unstable = "zfuture")]
NetworkUpgrade::ZFuture => BranchId::ZFuture,
}
Expand All @@ -512,6 +525,8 @@ const UPGRADES_IN_ORDER: &[NetworkUpgrade] = &[
NetworkUpgrade::Nu5,
#[cfg(zcash_unstable = "nu6")]
NetworkUpgrade::Nu6,
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
NetworkUpgrade::Nu7,
];

/// The "grace period" defined in [ZIP 212].
Expand Down Expand Up @@ -551,6 +566,9 @@ pub enum BranchId {
/// The consensus rules deployed by [`NetworkUpgrade::Nu6`].
#[cfg(zcash_unstable = "nu6")]
Nu6,
/// The consensus rules deployed by [`NetworkUpgrade::Nu7`].
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
Nu7,
/// Candidates for future consensus rules; this branch will never
/// activate on mainnet.
#[cfg(zcash_unstable = "zfuture")]
Expand All @@ -573,6 +591,8 @@ impl TryFrom<u32> for BranchId {
0xc2d6_d0b4 => Ok(BranchId::Nu5),
#[cfg(zcash_unstable = "nu6")]
0xc8e7_1055 => Ok(BranchId::Nu6),
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
0x7777_7777 => Ok(BranchId::Nu7),
#[cfg(zcash_unstable = "zfuture")]
0xffff_ffff => Ok(BranchId::ZFuture),
_ => Err("Unknown consensus branch ID"),
Expand All @@ -592,6 +612,8 @@ impl From<BranchId> for u32 {
BranchId::Nu5 => 0xc2d6_d0b4,
#[cfg(zcash_unstable = "nu6")]
BranchId::Nu6 => 0xc8e7_1055,
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
BranchId::Nu7 => 0x7777_7777,
#[cfg(zcash_unstable = "zfuture")]
BranchId::ZFuture => 0xffff_ffff,
}
Expand Down Expand Up @@ -657,15 +679,17 @@ impl BranchId {
BranchId::Canopy => params
.activation_height(NetworkUpgrade::Canopy)
.map(|lower| (lower, params.activation_height(NetworkUpgrade::Nu5))),
BranchId::Nu5 => params.activation_height(NetworkUpgrade::Nu5).map(|lower| {
#[cfg(zcash_unstable = "zfuture")]
let upper = params.activation_height(NetworkUpgrade::ZFuture);
#[cfg(not(zcash_unstable = "zfuture"))]
let upper = None;
(lower, upper)
}),
BranchId::Nu5 => params
.activation_height(NetworkUpgrade::Nu5)
.map(|lower| (lower, upper_bound(lower, params))),
#[cfg(zcash_unstable = "nu6")]
BranchId::Nu6 => None,
BranchId::Nu6 => params
.activation_height(NetworkUpgrade::Nu6)
.map(|lower| (lower, upper_bound(lower, params))),
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
BranchId::Nu7 => params
.activation_height(NetworkUpgrade::Nu7)
.map(|lower| (lower, upper_bound(lower, params))),
#[cfg(zcash_unstable = "zfuture")]
BranchId::ZFuture => params
.activation_height(NetworkUpgrade::ZFuture)
Expand All @@ -677,6 +701,39 @@ impl BranchId {
!matches!(self, BranchId::Sprout | BranchId::Overwinter)
}
}
#[allow(unused_variables)]
fn upper_bound<P: Parameters>(target_height: BlockHeight, params: &P) -> Option<BlockHeight> {
#[allow(dead_code)]
fn check_bound<P: Parameters>(
target_height: BlockHeight,
current_upper: Option<BlockHeight>,
nu: NetworkUpgrade,
params: &P,
) -> Option<BlockHeight> {
let nu_height = params.activation_height(nu);
if nu_height.is_some() && nu_height.unwrap() > target_height {
nu_height
} else {
current_upper
}
}

#[allow(unused_mut)]
let mut upper = None;
#[cfg(zcash_unstable = "nu6")]
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure we need the scope? (x3)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, looks ugly af, but I'm not sure how to do it better. Open to ideas...

upper = check_bound(target_height, upper, NetworkUpgrade::Nu6, params);
}
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
{
upper = check_bound(target_height, upper, NetworkUpgrade::Nu7, params);
}
#[cfg(zcash_unstable = "zfuture")]
{
upper = check_bound(target_height, upper, NetworkUpgrade::ZFuture, params);
}
upper
}

#[cfg(any(test, feature = "test-dependencies"))]
pub mod testing {
Expand All @@ -696,6 +753,8 @@ pub mod testing {
BranchId::Nu5,
#[cfg(zcash_unstable = "nu6")]
BranchId::Nu6,
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
BranchId::Nu7,
#[cfg(zcash_unstable = "zfuture")]
BranchId::ZFuture,
])
Expand Down Expand Up @@ -789,9 +848,15 @@ mod tests {
BranchId::for_height(&MAIN_NETWORK, BlockHeight(1_687_104)),
BranchId::Nu5,
);
#[cfg(zcash_unstable = "nu6")]
assert_eq!(
BranchId::for_height(&MAIN_NETWORK, BlockHeight(5_000_000)),
BranchId::Nu5,
BranchId::for_height(&MAIN_NETWORK, BlockHeight(1_687_106)),
BranchId::Nu6,
);
#[cfg(zcash_unstable = "nu6" /* TODO nu7 */ )]
assert_eq!(
BranchId::for_height(&MAIN_NETWORK, BlockHeight(1_842_421)),
BranchId::Nu7,
);
}
}
Loading
Loading