Skip to content

Commit

Permalink
feat: update upstream crates (bellperson, paired, ..) and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire authored Nov 14, 2019
1 parent 330cdf9 commit e550eba
Show file tree
Hide file tree
Showing 59 changed files with 367 additions and 362 deletions.
14 changes: 7 additions & 7 deletions fil-proofs-tooling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ human-size = "0.4"
prettytable-rs = "0.8"
regex = "1.1.6"
commandspec = "0.12.2"
bellperson = ">=0.3.4"
chrono = { version = "0.4.7", features = ["serde"] }
fil-sapling-crypto = "0.1.2"
memmap = "0.7.0"
paired = "0.15.0"
rand = "0.4"
bellperson = "0.4.0"
paired = "0.16.0"
fil-sapling-crypto = "0.2.0"
rand = "0.7"
storage-proofs = { path = "../storage-proofs"}
filecoin-proofs = { path = "../filecoin-proofs"}
tempfile = "3.0.8"
cpu-time = "0.1.0"
cpu-time = "1.0.0"
git2 = "0.10.1"
heim = "0.0.7"
heim = "0.0.8"
futures-preview = "0.3.0-alpha.17"
raw-cpuid = "6.1.0"
raw-cpuid = "7.0.3"
blake2s_simd = "0.5.6"
pretty_env_logger = "0.3.1"
log = "0.4.8"
Expand Down
22 changes: 11 additions & 11 deletions fil-proofs-tooling/src/bin/benchy/hash_fns.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
use bellperson::gadgets::boolean::Boolean;
use bellperson::ConstraintSystem;
use fil_proofs_tooling::metadata::Metadata;
use fil_sapling_crypto::circuit as scircuit;
use fil_sapling_crypto::circuit::boolean::Boolean;
use paired::bls12_381::Bls12;
use rand::{Rng, SeedableRng, XorShiftRng};
use rand::RngCore;
use storage_proofs::circuit::pedersen::{pedersen_compression_num, pedersen_md_no_padding};
use storage_proofs::circuit::test::TestConstraintSystem;
use storage_proofs::crypto;
use storage_proofs::crypto::pedersen::JJ_PARAMS;
use storage_proofs::util::{bits_to_bytes, bytes_into_boolean_vec, bytes_into_boolean_vec_be};

fn blake2s_count(bytes: usize) -> Result<Report, failure::Error> {
let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
let rng = &mut rand::thread_rng();

let mut cs = TestConstraintSystem::<Bls12>::new();
let mut data = vec![0u8; bytes];
Expand All @@ -23,10 +22,11 @@ fn blake2s_count(bytes: usize) -> Result<Report, failure::Error> {
};

let personalization = vec![0u8; 8];
let out: Vec<bool> = scircuit::blake2s::blake2s(&mut cs, &data_bits, &personalization)?
.into_iter()
.map(|b| b.get_value().unwrap())
.collect();
let out: Vec<bool> =
bellperson::gadgets::blake2s::blake2s(&mut cs, &data_bits, &personalization)?
.into_iter()
.map(|b| b.get_value().unwrap())
.collect();

assert!(cs.is_satisfied(), "constraints not satisfied");

Expand All @@ -45,7 +45,7 @@ fn blake2s_count(bytes: usize) -> Result<Report, failure::Error> {
}

fn sha256_count(bytes: usize) -> Result<Report, failure::Error> {
let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
let mut rng = rand::thread_rng();

let mut cs = TestConstraintSystem::<Bls12>::new();
let mut data = vec![0u8; bytes];
Expand All @@ -56,7 +56,7 @@ fn sha256_count(bytes: usize) -> Result<Report, failure::Error> {
bytes_into_boolean_vec_be(&mut cs, Some(data.as_slice()), data.len()).unwrap()
};

let _out: Vec<bool> = scircuit::sha256::sha256(&mut cs, &data_bits)?
let _out: Vec<bool> = bellperson::gadgets::sha256::sha256(&mut cs, &data_bits)?
.into_iter()
.map(|b| b.get_value().unwrap())
.collect();
Expand All @@ -71,7 +71,7 @@ fn sha256_count(bytes: usize) -> Result<Report, failure::Error> {
}

fn pedersen_count(bytes: usize) -> Result<Report, failure::Error> {
let mut rng = XorShiftRng::from_seed([0x5dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
let mut rng = rand::thread_rng();

let mut cs = TestConstraintSystem::<Bls12>::new();
let mut data = vec![0u8; bytes];
Expand Down
8 changes: 4 additions & 4 deletions fil-proofs-tooling/src/bin/benchy/stacked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ use log::info;
use memmap::MmapMut;
use memmap::MmapOptions;
use paired::bls12_381::Bls12;
use rand::{Rng, SeedableRng, XorShiftRng};
use rand::Rng;

use fil_proofs_tooling::{measure, FuncMeasurement, Metadata};
use storage_proofs::circuit::metric::MetricCS;
use storage_proofs::circuit::stacked::StackedCompound;
use storage_proofs::compound_proof::{self, CompoundProof};
use storage_proofs::crypto::pedersen::JJ_PARAMS;
use storage_proofs::drgraph::*;
use storage_proofs::hasher::{Blake2sHasher, Hasher, PedersenHasher, Sha256Hasher};
use storage_proofs::hasher::{Blake2sHasher, Domain, Hasher, PedersenHasher, Sha256Hasher};
use storage_proofs::porep::PoRep;
use storage_proofs::proof::ProofScheme;
use storage_proofs::stacked::{
Expand Down Expand Up @@ -120,10 +120,10 @@ where
let mut total_proving_wall_time = Duration::new(0, 0);
let mut total_proving_cpu_time = Duration::new(0, 0);

let rng = &mut XorShiftRng::from_seed([0x3dbe_6259, 0x8d31_3d76, 0x3237_db17, 0xe5bc_0654]);
let rng = &mut rand::thread_rng();
let nodes = data_size / 32;

let replica_id: H::Domain = rng.gen();
let replica_id = H::Domain::random(rng);
let sp = stacked::SetupParams {
nodes,
degree: BASE_DEGREE,
Expand Down
18 changes: 9 additions & 9 deletions filecoin-proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ readme = "README.md"
storage-proofs = { version = "^0.6", path = "../storage-proofs" }
bitvec = "0.5"
chrono = "0.4"
rand = "0.4"
rand = "0.7"
failure = "0.1"
lazy_static = "1.2"
memmap = "0.7"
Expand All @@ -21,16 +21,15 @@ pbr = "1.0"
tempfile = "3"
byteorder = "1"
itertools = "0.8"
serde_cbor = "0.9.0"
serde_cbor = "0.10.2"
serde = { version = "1", features = ["rc", "derive"] }
serde_json = "1.0"
regex = "1"
ff = "0.4.0"
ff = "0.5.0"
blake2b_simd = "0.5"
phase21 = "0.3"
bellperson = ">=0.3.4"
paired = "0.15"
fil-sapling-crypto = "0.1.2"
bellperson = "0.4.0"
paired = "0.16.0"
fil-sapling-crypto = "0.2.0"
clap = "2"
log = "0.4.7"
pretty_env_logger = "0.3.0"
Expand All @@ -51,18 +50,19 @@ features = ["default-tls-vendored"]

[dev-dependencies]
gperftools = "0.2"
criterion = "0.2"
criterion = "0.3"
rexpect = "0.3.0"
pretty_env_logger = "0.3.1"
pretty_assertions = "0.6.1"
rand_xorshift = "0.2.0"

[features]
default = ["gpu"]
cpu-profile = []
heap-profile = ["gperftools/heap"]
simd = ["storage-proofs/simd"]
asm = ["storage-proofs/asm"]
gpu = ["storage-proofs/gpu", "bellperson/gpu", "fil-sapling-crypto/gpu", "phase21/gpu"]
gpu = ["storage-proofs/gpu", "bellperson/gpu", "fil-sapling-crypto/gpu"]

[[bench]]
name = "preprocessing"
Expand Down
4 changes: 2 additions & 2 deletions filecoin-proofs/benches/preprocessing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ fn preprocessing_benchmark(c: &mut Criterion) {
write_padded_unpadded_bench(tmpfile, data.clone());
})
})
.sample_size(2)
.throughput(|s| Throughput::Bytes(*s as u32))
.sample_size(10)
.throughput(|s| Throughput::Bytes(*s as u64))
.warm_up_time(Duration::from_secs(1)),
);
}
Expand Down
17 changes: 10 additions & 7 deletions filecoin-proofs/examples/stacked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ extern crate log;

use chrono::Utc;
use clap::{App, Arg};
use ff::Field;
#[cfg(feature = "heap-profile")]
use gperftools::heap_profiler::HEAP_PROFILER;
#[cfg(feature = "cpu-profile")]
use gperftools::profiler::PROFILER;
use memmap::MmapMut;
use memmap::MmapOptions;
use paired::bls12_381::Bls12;
use rand::{Rng, SeedableRng, XorShiftRng};
use paired::bls12_381::{Bls12, Fr};
use rand::Rng;
use std::fs::{File, OpenOptions};
use std::io::Write;
use std::time::{Duration, Instant};
Expand All @@ -29,7 +30,7 @@ use storage_proofs::crypto::pedersen::JJ_PARAMS;
use storage_proofs::drgraph::*;
use storage_proofs::example_helper::prettyb;
use storage_proofs::fr32::fr_into_bytes;
use storage_proofs::hasher::{Blake2sHasher, Hasher, PedersenHasher, Sha256Hasher};
use storage_proofs::hasher::{Blake2sHasher, Domain, Hasher, PedersenHasher, Sha256Hasher};
use storage_proofs::porep::PoRep;
use storage_proofs::proof::ProofScheme;
use storage_proofs::stacked::{
Expand Down Expand Up @@ -80,7 +81,8 @@ fn stop_profile() {
fn stop_profile() {}

fn _file_backed_mmap_from_random_bytes(n: usize, use_tmp: bool) -> MmapMut {
let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
let rng = &mut rand::thread_rng();

let mut file: File = if use_tmp {
tempfile::tempfile().unwrap()
} else {
Expand All @@ -94,7 +96,8 @@ fn _file_backed_mmap_from_random_bytes(n: usize, use_tmp: bool) -> MmapMut {
info!("generating fake data");

for _ in 0..n {
file.write_all(&fr_into_bytes::<Bls12>(&rng.gen())).unwrap();
file.write_all(&fr_into_bytes::<Bls12>(&Fr::random(rng)))
.unwrap();
}

unsafe { MmapOptions::new().map_mut(&file).unwrap() }
Expand Down Expand Up @@ -152,7 +155,7 @@ fn do_the_work<H: 'static>(
) where
H: Hasher,
{
let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
let rng = &mut rand::thread_rng();

let m = BASE_DEGREE;
let expansion_degree = EXP_DEGREE;
Expand All @@ -169,7 +172,7 @@ fn do_the_work<H: 'static>(

let nodes = data_size / 32;

let replica_id: H::Domain = rng.gen();
let replica_id: H::Domain = H::Domain::random(rng);
let sp = stacked::SetupParams {
nodes,
degree: m,
Expand Down
5 changes: 3 additions & 2 deletions filecoin-proofs/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ mod tests {
use std::io::{Seek, SeekFrom, Write};

use paired::bls12_381::Bls12;
use rand::{Rng, SeedableRng, XorShiftRng};
use rand::{Rng, SeedableRng};
use rand_xorshift::XorShiftRng;
use storage_proofs::fr32::bytes_into_fr;
use tempfile::NamedTempFile;

Expand Down Expand Up @@ -368,7 +369,7 @@ mod tests {
fn test_seal_lifecycle() -> Result<(), failure::Error> {
pretty_env_logger::try_init().ok();

let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
let rng = &mut XorShiftRng::from_seed(crate::TEST_SEED);

let sector_size = SECTOR_SIZE_ONE_KIB;

Expand Down
51 changes: 0 additions & 51 deletions filecoin-proofs/src/bin/paramgen.rs

This file was deleted.

9 changes: 5 additions & 4 deletions filecoin-proofs/src/fr32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,8 @@ mod tests {
use super::*;
use itertools::Itertools;
use paired::bls12_381::Bls12;
use rand::{Rng, SeedableRng, XorShiftRng};
use rand::{Rng, SeedableRng};
use rand_xorshift::XorShiftRng;
use std::io::Cursor;
use storage_proofs::fr32::bytes_into_fr;

Expand All @@ -1025,7 +1026,7 @@ mod tests {
// Length of the data vector we'll be extracting from.
let len = 20;

let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
let rng = &mut XorShiftRng::from_seed(crate::TEST_SEED);
let data: Vec<u8> = (0..len).map(|_| rng.gen()).collect();

// TODO: Evaluate designing a scattered pattered of `pos` and `num_bits`
Expand Down Expand Up @@ -1056,7 +1057,7 @@ mod tests {
#[test]
fn test_bit_shifts() {
let len = 5;
let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
let rng = &mut XorShiftRng::from_seed(crate::TEST_SEED);

for amount in 1..8 {
for left in [true, false].iter() {
Expand Down Expand Up @@ -1323,7 +1324,7 @@ mod tests {
// different lengths of raw data at different offset, check integrity.
#[test]
fn test_read_write_padded_offset() {
let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
let rng = &mut XorShiftRng::from_seed(crate::TEST_SEED);

let len = 1016;
let mut data: Vec<u8> = (0..len).map(|_| rng.gen()).collect();
Expand Down
5 changes: 5 additions & 0 deletions filecoin-proofs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ pub use types::*;
#[cfg(test)]
#[macro_use]
extern crate pretty_assertions;

#[cfg(test)]
pub(crate) const TEST_SEED: [u8; 16] = [
0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, 0xe5,
];
5 changes: 4 additions & 1 deletion filecoin-proofs/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const POST_CHALLENGE_COUNT: usize = 30; // TODO: correct value

const LAYERS: usize = 4; // TODO: 10;

const DRG_SEED: [u32; 7] = [1, 2, 3, 4, 5, 6, 7]; // Arbitrary, need a theory for how to vary this over time.
const DRG_SEED: [u8; 28] = [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27,
]; // Arbitrary, need a theory for how to vary this over time.

type PostSetupParams = rational_post::SetupParams;
pub type PostPublicParams = rational_post::PublicParams;
Expand Down
Loading

0 comments on commit e550eba

Please sign in to comment.