Skip to content

Commit

Permalink
Merge pull request #152 from zcash/expose_prover_progress
Browse files Browse the repository at this point in the history
Expose prover progress
  • Loading branch information
nuttycom authored Jan 29, 2025
2 parents 87e5ddf + a3cb90a commit e607c52
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and this library adheres to Rust's notion of
avoid the need to depend upon the `bellman` crate.

### Changed
- MSRV is now 1.66
- MSRV is now 1.70

## [0.4.0] - 2024-12-16

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
"Kris Nuttycombe <[email protected]>",
]
edition = "2021"
rust-version = "1.66"
rust-version = "1.70"
description = "Cryptographic library for Zcash Sapling"
homepage = "https://github.com/zcash/sapling-crypto"
repository = "https://github.com/zcash/sapling-crypto"
Expand Down Expand Up @@ -91,7 +91,7 @@ std = [
"core2/std",
"dep:document-features",
"group/wnaf-memuse",
"redjubjub/std",
"redjubjub/std"
]

## Enables creation of Sapling proofs
Expand Down Expand Up @@ -126,4 +126,4 @@ name = "pedersen_hash"
harness = false

[patch.crates-io]
redjubjub = { git = "https://github.com/nuttycom/redjubjub", rev = "e413019904400f4caa3550df7c4040befadfbb14" }
redjubjub = { git = "https://github.com/ZcashFoundation/redjubjub", rev = "eae848c5c14d9c795d000dd9f4c4762d1aee7ee1" }
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.66.0"
channel = "1.70.0"
components = ["clippy", "rustfmt"]
11 changes: 4 additions & 7 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ impl Builder {
Zip212Enforcement::Off | Zip212Enforcement::GracePeriod => {
Err(Error::PcztRequiresZip212)
}
Zip212Enforcement::On => build_bundle::<_, (), (), _>(
Zip212Enforcement::On => build_bundle(
rng,
self.bundle_type,
Zip212Enforcement::On,
Expand Down Expand Up @@ -743,7 +743,7 @@ pub fn bundle<SP: SpendProver, OP: OutputProver, R: RngCore, V: TryFrom<i64>>(
outputs: Vec<OutputInfo>,
extsks: &[ExtendedSpendingKey],
) -> Result<Option<(UnauthorizedBundle<V>, SaplingMetadata)>, Error> {
build_bundle::<_, SP, OP, _>(
build_bundle(
rng,
bundle_type,
zip212_enforcement,
Expand Down Expand Up @@ -813,7 +813,7 @@ pub fn bundle<SP: SpendProver, OP: OutputProver, R: RngCore, V: TryFrom<i64>>(
)
}

fn build_bundle<B, SP, OP, R: RngCore>(
fn build_bundle<B, R: RngCore>(
mut rng: R,
bundle_type: BundleType,
zip212_enforcement: Zip212Enforcement,
Expand Down Expand Up @@ -980,27 +980,24 @@ impl InProgressProofs for Proven {
}

/// Reports on the progress made towards creating proofs for a bundle.
#[cfg(feature = "circuit")]
pub trait ProverProgress {
/// Updates the progress instance with the number of steps completed and the total
/// number of steps.
fn update(&mut self, cur: u32, end: u32);
}

#[cfg(feature = "circuit")]
impl ProverProgress for () {
fn update(&mut self, _: u32, _: u32) {}
}

#[cfg(all(feature = "circuit", feature = "std"))]
#[cfg(feature = "std")]
impl<U: From<(u32, u32)>> ProverProgress for std::sync::mpsc::Sender<U> {
fn update(&mut self, cur: u32, end: u32) {
// If the send fails, we should ignore the error, not crash.
self.send(U::from((cur, end))).unwrap_or(());
}
}

#[cfg(feature = "circuit")]
impl<U: ProverProgress> ProverProgress for &mut U {
fn update(&mut self, cur: u32, end: u32) {
(*self).update(cur, end);
Expand Down

0 comments on commit e607c52

Please sign in to comment.