Skip to content

Commit

Permalink
fix: update ec-gpu-gen (#1638)
Browse files Browse the repository at this point in the history
`ec-gpu-gen` needs to be updated to v0.5 as v0.4 has dependencies that
depend on yanked version. It's an indirect dependency of `bellperson` and
`neptune`, which are upgraded here.

Moving from `memmap` (which is deprecated) to `memmap2` was also needed
als dependencies also switched.

`chrono` updated their API, so there was also a small change needed.
  • Loading branch information
vmx committed Nov 23, 2022
1 parent ff886c6 commit e35d322
Show file tree
Hide file tree
Showing 25 changed files with 391 additions and 423 deletions.
710 changes: 336 additions & 374 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ members = [
]

[patch.crates-io]
halo2_proofs = { git = "https://github.com/filecoin-project/halo2", branch = "serialize-vk-pk" }
halo2_proofs = { git = "https://github.com/filecoin-project/halo2", branch = "halo2" }
neptune = { git = "https://github.com/filecoin-project/neptune", branch = "halo2-gpu" }
pasta_curves = { git = "https://github.com/filecoin-project/pasta_curves", branch = "gpu" }
2 changes: 1 addition & 1 deletion fil-halo2-gadgets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository = "https://github.com/filecoin-project/rust-fil-proofs"
ff = "0.12.0"
halo2_proofs = "0.2.0"
halo2_gadgets = "0.2.0"
neptune = { git = "https://github.com/filecoin-project/neptune", branch = "halo2" }
neptune = "~8.1.0"
sha2 = "0.9.2"

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions fil-halo2-gadgets/src/bin/sha256_compute_k.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn sha256_chip_compute_k() {
Ok(_) => {
// Proof size does not change with circuit size.
if num_blocks == PREIMAGE_BLOCK_SIZES.start {
let cost = CircuitCost::<Eq, MyCircuit>::measure(k as usize, &circ);
let cost = CircuitCost::<Eq, MyCircuit>::measure(k, &circ);
let proof_size: usize = cost.marginal_proof_size().into();
println!("\tproof_size = {} bytes", proof_size);
}
Expand Down Expand Up @@ -219,7 +219,7 @@ fn compress_chip_compute_k() {
Ok(_) => {
// Proof size does not change with circuit size.
if num_blocks == PREIMAGE_BLOCK_SIZES.start {
let cost = CircuitCost::<Eq, MyCircuit>::measure(k as usize, &circ);
let cost = CircuitCost::<Eq, MyCircuit>::measure(k, &circ);
let proof_size: usize = cost.marginal_proof_size().into();
println!("\tproof_size = {} bytes", proof_size);
}
Expand Down
2 changes: 1 addition & 1 deletion fil-proofs-param/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ structopt = "0.3.12"
humansize = "1.1.0"
indicatif = "0.16.2"
dialoguer = "0.10.0"
blstrs = "0.5.0"
blstrs = "0.6.1"
typenum = "1.11.2"
generic-array = "0.14.4"
halo2_proofs = "0.2.0"
Expand Down
6 changes: 3 additions & 3 deletions fil-proofs-tooling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ serde_json = "1.0"
regex = "1.3.7"
commandspec = "0.12.2"
chrono = { version = "0.4.7", features = ["serde"] }
memmap = "0.7.0"
bellperson = "0.22.0"
memmap2 = "0.5.6"
bellperson = "0.24.0"
rand = "0.8"
tempfile = "3.0.8"
cpu-time = "1.0.0"
Expand All @@ -47,7 +47,7 @@ fdlimit = "0.2.0"
dialoguer = "0.10.0"
structopt = "0.3.12"
humansize = "1.1.0"
blstrs = "0.5.0"
blstrs = "0.6.1"
time = "0.3.9"
pasta_curves = "0.4.0"

Expand Down
2 changes: 1 addition & 1 deletion fil-proofs-tooling/src/bin/update_tree_r_cache/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use filecoin_proofs::{
SectorShapeSub2, SectorShapeSub8, SectorShapeTop2, OCT_ARITY,
};
use generic_array::typenum::Unsigned;
use memmap::MmapOptions;
use memmap2::MmapOptions;
use merkletree::{
merkle::get_merkle_tree_len,
store::{ExternalReader, ReplicaConfig, Store, StoreConfig},
Expand Down
3 changes: 2 additions & 1 deletion fil-proofs-tooling/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ impl GitMetadata {
let repo = Repository::discover(&repo_path)?;
let head = repo.head()?;
let commit = head.peel_to_commit()?;
let date = Utc.timestamp(commit.time().seconds(), 0);
// Unwrap is OK as the given seconds won't be out of range.
let date = Utc.timestamp_opt(commit.time().seconds(), 0).unwrap();

Ok(GitMetadata {
hash: commit.id().to_string(),
Expand Down
13 changes: 6 additions & 7 deletions filecoin-hashers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ repository = "https://github.com/filecoin-project/rust-fil-proofs"
readme = "README.md"

[dependencies]
bellperson = "0.22.0"
blstrs = "0.5.0"
bellperson = "0.24.0"
blstrs = "0.6.1"
generic-array = "0.14.4"
merkletree = "0.22.0"
ec-gpu = "0.1.0"
ec-gpu = "0.2.0"
ff = "0.12.0"
anyhow = "1.0.34"
serde = "1.0.117"
rand = "0.8.0"
# neptune = { version = "~7.0.0", optional = true, features = ["bls", "arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] }
neptune = { git = "https://github.com/filecoin-project/neptune", branch = "halo2", optional = true, features = ["bls", "pasta", "arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] }
neptune = { version = "~8.1.0", optional = true, features = ["bls", "pasta", "arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] }
lazy_static = { version = "1.4.0", optional = true }
blake2s_simd = { version = "1.0.0", optional = true }
sha2 = { version = "0.10.2", optional = true }
Expand All @@ -31,8 +30,8 @@ fil-halo2-gadgets = { path = "../fil-halo2-gadgets" }
[features]
default = ["opencl", "blake2s", "poseidon", "sha256"]

cuda = ["bellperson/cuda", "neptune/cuda"]
opencl = ["bellperson/opencl", "neptune/opencl"]
cuda = ["bellperson/cuda", "halo2_proofs/cuda", "neptune/cuda"]
opencl = ["bellperson/opencl", "halo2_proofs/opencl", "neptune/opencl"]

# available hashers
blake2s = ["blake2s_simd"]
Expand Down
9 changes: 6 additions & 3 deletions filecoin-hashers/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use bellperson::{
ConstraintSystem, SynthesisError,
};
use blstrs::Scalar as Fr;
use ec_gpu::GpuField;
use ff::{Field, PrimeField};
use fil_halo2_gadgets::ColumnCount;
use halo2_proofs::{
Expand Down Expand Up @@ -44,7 +43,7 @@ pub trait Domain:
+ Element
+ StdHash
{
type Field: PrimeField + GpuField;
type Field: PrimeField;

#[allow(clippy::wrong_self_convention)]
fn into_bytes(&self) -> Vec<u8> {
Expand Down Expand Up @@ -99,7 +98,11 @@ pub trait HashFunction<T: Domain>: Clone + Debug + Send + Sync + LightAlgorithm<
}

pub trait Hasher: Clone + Debug + Eq + Default + Send + Sync {
type Field: PrimeField + GpuField;
#[cfg(not(any(feature = "cuda", feature = "opencl")))]
type Field: PrimeField;
#[cfg(any(feature = "cuda", feature = "opencl"))]
type Field: PrimeField + ec_gpu::GpuName;

type Domain: Domain<Field = Self::Field> + LightHashable<Self::Function> + AsRef<Self::Domain>;
type Function: HashFunction<Self::Domain>;

Expand Down
6 changes: 3 additions & 3 deletions filecoin-proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ storage-proofs-update = { path = "../storage-proofs-update", version = "~12.0.0"
filecoin-hashers = { version = "~7.0.0", path = "../filecoin-hashers", default-features = false, features = ["poseidon", "sha256"] }
rand = "0.8"
lazy_static = "1.2"
memmap = "0.7"
memmap2 = "0.5.6"
serde = { version = "1.0", features = ["rc", "derive"] }
serde_json = "1.0"
ff = "0.12.0"
blake2b_simd = "1.0.0"
bellperson = "0.22.0"
bellperson = "0.24.0"
log = "0.4.7"
rayon = "1.1.0"
hex = "0.4.0"
Expand All @@ -34,7 +34,7 @@ gperftools = { version = "0.2", optional = true }
generic-array = "0.14.4"
fr32 = { path = "../fr32", version = "~5.0.0", default-features = false }
once_cell = "1.8.0"
blstrs = "0.5.0"
blstrs = "0.6.1"
halo2_proofs = "0.2.0"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion filecoin-proofs/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use filecoin_hashers::Hasher;
use fr32::{write_unpadded, Fr32Reader};
use generic_array::typenum::{U2, U8};
use log::{info, trace};
use memmap::MmapOptions;
use memmap2::MmapOptions;
use merkletree::store::{DiskStore, LevelCacheStore, StoreConfig};
use storage_proofs_core::{
cache_key::CacheKey,
Expand Down
2 changes: 1 addition & 1 deletion filecoin-proofs/src/api/seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use ff::PrimeField;
use filecoin_hashers::{Domain, Groth16Hasher, Hasher, PoseidonArity};
use halo2_proofs::pasta::{Fp, Fq};
use log::{info, trace};
use memmap::MmapOptions;
use memmap2::MmapOptions;
use merkletree::store::{DiskStore, Store, StoreConfig};
use rayon::prelude::*;
use sha2::{Digest, Sha256};
Expand Down
2 changes: 1 addition & 1 deletion fr32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ byte-slice-cast = "1.0.0"
byteorder = "1"
ff = "0.12.0"
thiserror = "1.0.6"
blstrs = "0.5.0"
blstrs = "0.6.1"

[dev-dependencies]
bitvec = "0.17"
Expand Down
8 changes: 4 additions & 4 deletions storage-proofs-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ byteorder = "1"
config = { version = "0.12.0", default-features = false, features = ["toml"] }
itertools = "0.10.3"
lazy_static = "1.2"
memmap = "0.7"
memmap2 = "0.5.6"
aes = "0.8.1"
sha2 = "0.10.2"
fs2 = "0.4"
rayon = "1.0.0"
serde = { version = "1.0", features = ["derive"]}
blake2b_simd = "1.0.0"
ff = "0.12.0"
bellperson = "0.22.0"
bellperson = "0.24.0"
serde_json = "1.0"
log = "0.4.7"
rand_chacha = "0.3"
Expand All @@ -40,10 +40,10 @@ num_cpus = "1.10.1"
semver = "1.0.6"
fr32 = { path = "../fr32", version = "~5.0.0"}
cbc = { version = "0.1.2", features = ["std"] }
blstrs = "0.5.0"
blstrs = "0.6.1"
halo2_proofs = "0.2.0"
fil-halo2-gadgets = { path = "../fil-halo2-gadgets" }
ec-gpu = "0.1.0"
ec-gpu = "0.2.0"

[dev-dependencies]
proptest = "1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs-core/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::PathBuf;

use anyhow::{ensure, Context, Result};
use log::info;
use memmap::{MmapMut, MmapOptions};
use memmap2::{MmapMut, MmapOptions};

/// A wrapper around data either on disk or a slice in memory, that can be dropped and read back into memory,
/// to allow for better control of memory consumption.
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs-core/src/drgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ mod tests {
};
use generic_array::typenum::{U0, U2, U4, U8};
use halo2_proofs::pasta::{Fp, Fq};
use memmap::{MmapMut, MmapOptions};
use memmap2::{MmapMut, MmapOptions};
use merkletree::store::StoreConfig;

use crate::merkle::{
Expand Down
6 changes: 4 additions & 2 deletions storage-proofs-core/src/merkle/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};

use anyhow::Result;
use ec_gpu::GpuField;
use ff::PrimeField;
use filecoin_hashers::{Hasher, PoseidonArity};
use generic_array::typenum::U0;
Expand All @@ -23,7 +22,10 @@ pub trait MerkleTreeTrait: Send + Sync + Debug {
type Arity: PoseidonArity<Self::Field>;
type SubTreeArity: PoseidonArity<Self::Field>;
type TopTreeArity: PoseidonArity<Self::Field>;
type Field: PrimeField + GpuField;
#[cfg(not(any(feature = "cuda", feature = "opencl")))]
type Field: PrimeField;
#[cfg(any(feature = "cuda", feature = "opencl"))]
type Field: PrimeField + ec_gpu::GpuName;
type Hasher: 'static + Hasher<Field = Self::Field>;
type Store: Store<<Self::Hasher as Hasher>::Domain>;
type Proof: MerkleProofTrait<
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs-core/src/parameter_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use fs2::FileExt;
use itertools::Itertools;
use lazy_static::lazy_static;
use log::info;
use memmap::MmapOptions;
use memmap2::MmapOptions;
use rand::RngCore;
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs-core/src/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs::OpenOptions;
use std::io::Write;
use std::path::Path;

use memmap::{MmapMut, MmapOptions};
use memmap2::{MmapMut, MmapOptions};

pub fn setup_replica(data: &[u8], replica_path: &Path) -> MmapMut {
let mut f = OpenOptions::new()
Expand Down
7 changes: 3 additions & 4 deletions storage-proofs-porep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ rayon = "1.0.0"
serde = { version = "1.0", features = ["derive"]}
serde_json = "1.0"
ff = "0.12.0"
bellperson = "0.22.0"
bellperson = "0.24.0"
log = "0.4.7"
pretty_assertions = "1.2.0"
generic-array = "0.14.4"
anyhow = "1.0.23"
# neptune = { version = "~7.0.0", features = ["bls", "arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] }
neptune = { git = "https://github.com/filecoin-project/neptune", branch = "halo2", features = ["bls", "pasta", "arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] }
neptune = { version = "~8.1.0", features = ["bls", "pasta", "arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] }
num_cpus = "1.10.1"
hex = "0.4.2"
bincode = "1.1.2"
Expand All @@ -40,7 +39,7 @@ libc = "0.2"
fdlimit = "0.2.0"
fr32 = { path = "../fr32", version = "~5.0.0", default-features = false }
yastl = "0.1.2"
blstrs = "0.5.0"
blstrs = "0.6.1"
typemap = "0.3.3"
halo2_proofs = "0.2.0"
fil-halo2-gadgets = { path = "../fil-halo2-gadgets" }
Expand Down
3 changes: 2 additions & 1 deletion storage-proofs-porep/src/stacked/halo2/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,8 @@ where
{
pub fn proof_size(&self, batch_size: Option<usize>) -> usize {
let k = self.k() as usize;
let cost = halo2_proofs::dev::CircuitCost::<F::Curve, Self>::measure(k, self);
let cost =
halo2_proofs::dev::CircuitCost::<F::Curve, Self>::measure(k.try_into().unwrap(), self);
match batch_size {
Some(batch_size) => cost.proof_size(batch_size).into(),
None => cost.marginal_proof_size().into(),
Expand Down
4 changes: 2 additions & 2 deletions storage-proofs-post/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ rayon = "1.0.0"
serde = { version = "1.0", features = ["derive"]}
blake2b_simd = "1.0.0"
ff = "0.12.0"
bellperson = "0.22.0"
bellperson = "0.24.0"
log = "0.4.7"
hex = "0.4.0"
generic-array = "0.14.4"
anyhow = "1.0.23"
fr32 = { path = "../fr32", version = "~5.0.0", default-features = false }
blstrs = "0.5.0"
blstrs = "0.6.1"
halo2_proofs = "0.2.0"
fil-halo2-gadgets = { path = "../fil-halo2-gadgets" }

Expand Down
9 changes: 4 additions & 5 deletions storage-proofs-update/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ merkletree = "0.22.0"
rayon = "1.0.0"
serde = { version = "1.0", features = ["derive"]}
ff = "0.12.0"
bellperson = "0.22.0"
blstrs = "0.5.0"
bellperson = "0.24.0"
blstrs = "0.6.1"
log = "0.4.7"
generic-array = "0.14.4"
anyhow = "1.0.23"
# neptune = { version = "~7.0.0", features = ["bls", "arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] }
neptune = { git = "https://github.com/filecoin-project/neptune", branch = "halo2", features = ["bls", "pasta", "arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] }
neptune = { version = "~8.1.0", features = ["bls", "pasta", "arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] }
lazy_static = "1.2"
fr32 = { path = "../fr32", version = "~5.0.0", default-features = false }
fil_logger = "0.1.6"
memmap = "0.7"
memmap2 = "0.5.6"
halo2_proofs = "0.2.0"
typemap = "0.3.3"
fil-halo2-gadgets = { path = "../fil-halo2-gadgets" }
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs-update/src/vanilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ff::PrimeField;
use filecoin_hashers::{Domain, HashFunction, Hasher, PoseidonArity, PoseidonLookup};
use generic_array::typenum::{Unsigned, U2};
use log::{info, trace};
use memmap::{Mmap, MmapMut, MmapOptions};
use memmap2::{Mmap, MmapMut, MmapOptions};
use merkletree::{
merkle::{get_merkle_tree_leafs, get_merkle_tree_len},
store::{DiskStore, Store, StoreConfig},
Expand Down

0 comments on commit e35d322

Please sign in to comment.