From 241fd49579af7d747f55896d06b3d938d9e5092e Mon Sep 17 00:00:00 2001 From: nemo Date: Tue, 26 Oct 2021 11:01:01 -0400 Subject: [PATCH] fix: updates required after rebase to master style: clippy updates style: rust fmt --- filecoin-proofs/src/api/update.rs | 10 +-- filecoin-proofs/tests/api.rs | 97 ++------------------------ storage-proofs-core/src/gadgets/por.rs | 4 +- storage-proofs-update/Cargo.toml | 6 +- storage-proofs-update/src/gadgets.rs | 9 ++- storage-proofs-update/src/vanilla.rs | 9 ++- 6 files changed, 22 insertions(+), 113 deletions(-) diff --git a/filecoin-proofs/src/api/update.rs b/filecoin-proofs/src/api/update.rs index 0fc873cc9..f0e40c69b 100644 --- a/filecoin-proofs/src/api/update.rs +++ b/filecoin-proofs/src/api/update.rs @@ -130,11 +130,11 @@ pub fn encode_into>( tree_r_last_new_config, ::Domain::try_from_bytes(&p_aux.comm_c.into_bytes())?, ::Domain::try_from_bytes(&p_aux.comm_r_last.into_bytes())?, - &new_replica_path, - &new_cache_path, - §or_key_path, - §or_key_cache_path, - &staged_data_path, + new_replica_path, + new_cache_path, + sector_key_path, + sector_key_cache_path, + staged_data_path, usize::from(config.h_select), )?; diff --git a/filecoin-proofs/tests/api.rs b/filecoin-proofs/tests/api.rs index 40d24b442..adf629ee9 100644 --- a/filecoin-proofs/tests/api.rs +++ b/filecoin-proofs/tests/api.rs @@ -11,114 +11,25 @@ use blstrs::{Bls12, Scalar as Fr}; use ff::Field; use filecoin_hashers::Hasher; use filecoin_proofs::{ -<<<<<<< HEAD -<<<<<<< HEAD - add_piece, aggregate_seal_commit_proofs, clear_cache, compute_comm_d, fauxrep_aux, - generate_fallback_sector_challenges, generate_piece_commitment, generate_single_vanilla_proof, - generate_single_window_post_with_vanilla, generate_window_post, - generate_window_post_with_vanilla, generate_winning_post, - generate_winning_post_sector_challenge, generate_winning_post_with_vanilla, - get_num_partition_for_fallback_post, get_seal_inputs, merge_window_post_partition_proofs, - seal_commit_phase1, seal_commit_phase2, seal_pre_commit_phase1, seal_pre_commit_phase2, - unseal_range, validate_cache_for_commit, validate_cache_for_precommit_phase2, - verify_aggregate_seal_commit_proofs, verify_seal, verify_window_post, verify_winning_post, - Commitment, DefaultTreeDomain, MerkleTreeTrait, PaddedBytesAmount, PieceInfo, PoRepConfig, - PoRepProofPartitions, PoStConfig, PoStType, PrivateReplicaInfo, ProverId, PublicReplicaInfo, - SealCommitOutput, SealPreCommitOutput, SealPreCommitPhase1Output, SectorShape16KiB, - SectorShape2KiB, SectorShape32KiB, SectorShape4KiB, SectorSize, UnpaddedByteIndex, - UnpaddedBytesAmount, POREP_PARTITIONS, SECTOR_SIZE_16_KIB, SECTOR_SIZE_2_KIB, - SECTOR_SIZE_32_KIB, SECTOR_SIZE_4_KIB, WINDOW_POST_CHALLENGE_COUNT, WINDOW_POST_SECTOR_COUNT, - WINNING_POST_CHALLENGE_COUNT, WINNING_POST_SECTOR_COUNT, -======= - add_piece, aggregate_seal_commit_proofs, clear_cache, compare_elements, compute_comm_d, -<<<<<<< HEAD - decode_from, encode_into, fauxrep_aux, generate_fallback_sector_challenges, -<<<<<<< HEAD - generate_piece_commitment, generate_single_vanilla_proof, generate_update_proof, - generate_window_post, generate_window_post_with_vanilla, generate_winning_post, - generate_winning_post_sector_challenge, generate_winning_post_with_vanilla, get_seal_inputs, - remove_encoded_data, seal_commit_phase1, seal_commit_phase2, seal_pre_commit_phase1, - seal_pre_commit_phase2, unseal_range, validate_cache_for_commit, - validate_cache_for_precommit_phase2, verify_aggregate_seal_commit_proofs, verify_seal, -<<<<<<< HEAD - verify_window_post, verify_winning_post, Commitment, DefaultTreeDomain, MerkleTreeTrait, - PaddedBytesAmount, PieceInfo, PoRepConfig, PoRepProofPartitions, PoStConfig, PoStType, - PrivateReplicaInfo, ProverId, PublicReplicaInfo, SealCommitOutput, SealPreCommitOutput, - SealPreCommitPhase1Output, SectorShape16KiB, SectorShape2KiB, SectorShape32KiB, - SectorShape4KiB, SectorSize, UnpaddedByteIndex, UnpaddedBytesAmount, POREP_PARTITIONS, - SECTOR_SIZE_16_KIB, SECTOR_SIZE_2_KIB, SECTOR_SIZE_32_KIB, SECTOR_SIZE_4_KIB, - WINDOW_POST_CHALLENGE_COUNT, WINDOW_POST_SECTOR_COUNT, WINNING_POST_CHALLENGE_COUNT, -<<<<<<< HEAD - WINNING_POST_SECTOR_COUNT, ->>>>>>> 5c046723 (feat: encode/decode/remove_data API with tests) -======= - WINNING_POST_SECTOR_COUNT, HSelect, UpdateProofPartitions, ->>>>>>> db10f80f (feat: add Jake's latest circuit code) -======= - verify_window_post, verify_winning_post, Commitment, DefaultTreeDomain, HSelect, - MerkleTreeTrait, PaddedBytesAmount, PieceInfo, PoRepConfig, PoRepProofPartitions, PoStConfig, - PoStType, PrivateReplicaInfo, ProverId, PublicReplicaInfo, SealCommitOutput, - SealPreCommitOutput, SealPreCommitPhase1Output, SectorShape16KiB, SectorShape2KiB, - SectorShape32KiB, SectorShape4KiB, SectorSize, UnpaddedByteIndex, UnpaddedBytesAmount, - UpdateProofPartitions, POREP_PARTITIONS, SECTOR_SIZE_16_KIB, SECTOR_SIZE_2_KIB, - SECTOR_SIZE_32_KIB, SECTOR_SIZE_4_KIB, WINDOW_POST_CHALLENGE_COUNT, WINDOW_POST_SECTOR_COUNT, - WINNING_POST_CHALLENGE_COUNT, WINNING_POST_SECTOR_COUNT, ->>>>>>> 9389307f (style: cargo fmt) -======= -======= add_piece, aggregate_seal_commit_proofs, clear_cache, compute_comm_d, decode_from, encode_into, fauxrep_aux, generate_empty_sector_update_proof, generate_fallback_sector_challenges, ->>>>>>> 1f5042b4 (fix: apply some review feedback) generate_partition_proofs, generate_piece_commitment, generate_single_partition_proof, - generate_single_vanilla_proof, generate_window_post, generate_window_post_with_vanilla, - generate_winning_post, generate_winning_post_sector_challenge, - generate_winning_post_with_vanilla, get_seal_inputs, remove_encoded_data, seal_commit_phase1, - seal_commit_phase2, seal_pre_commit_phase1, seal_pre_commit_phase2, unseal_range, - validate_cache_for_commit, validate_cache_for_precommit_phase2, -<<<<<<< HEAD - verify_aggregate_seal_commit_proofs, verify_partition_proofs, verify_seal, -======= - decode_from, encode_into, fauxrep_aux, generate_empty_sector_update_proof, - generate_fallback_sector_challenges, generate_partition_proofs, generate_piece_commitment, - generate_single_partition_proof, generate_single_vanilla_proof, generate_window_post, + generate_single_vanilla_proof, generate_single_window_post_with_vanilla, generate_window_post, generate_window_post_with_vanilla, generate_winning_post, - generate_winning_post_sector_challenge, generate_winning_post_with_vanilla, get_seal_inputs, + generate_winning_post_sector_challenge, generate_winning_post_with_vanilla, + get_num_partition_for_fallback_post, get_seal_inputs, merge_window_post_partition_proofs, remove_encoded_data, seal_commit_phase1, seal_commit_phase2, seal_pre_commit_phase1, seal_pre_commit_phase2, unseal_range, validate_cache_for_commit, validate_cache_for_precommit_phase2, verify_aggregate_seal_commit_proofs, verify_empty_sector_update_proof, verify_partition_proofs, verify_seal, ->>>>>>> 63296dd3 (feat: add prove and verify API interfaces) verify_single_partition_proof, verify_window_post, verify_winning_post, Commitment, - DefaultTreeDomain, HSelect, MerkleTreeTrait, PaddedBytesAmount, PieceInfo, PoRepConfig, - PoRepProofPartitions, PoStConfig, PoStType, PrivateReplicaInfo, ProverId, PublicReplicaInfo, - SealCommitOutput, SealPreCommitOutput, SealPreCommitPhase1Output, SectorShape16KiB, - SectorShape2KiB, SectorShape32KiB, SectorShape4KiB, SectorSize, UnpaddedByteIndex, - UnpaddedBytesAmount, UpdateProofPartitions, POREP_PARTITIONS, SECTOR_SIZE_16_KIB, - SECTOR_SIZE_2_KIB, SECTOR_SIZE_32_KIB, SECTOR_SIZE_4_KIB, WINDOW_POST_CHALLENGE_COUNT, - WINDOW_POST_SECTOR_COUNT, WINNING_POST_CHALLENGE_COUNT, WINNING_POST_SECTOR_COUNT, ->>>>>>> de953475 (feat: complete vanilla proving and verify through tests) -======= - verify_aggregate_seal_commit_proofs, verify_empty_sector_update_proof, verify_partition_proofs, - verify_seal, verify_single_partition_proof, verify_window_post, verify_winning_post, -<<<<<<< HEAD - Commitment, DefaultTreeDomain, HSelect, MerkleTreeTrait, PaddedBytesAmount, PieceInfo, - PoRepConfig, PoRepProofPartitions, PoStConfig, PoStType, PrivateReplicaInfo, ProverId, - PublicReplicaInfo, SealCommitOutput, SealPreCommitOutput, SealPreCommitPhase1Output, - SectorShape16KiB, SectorShape2KiB, SectorShape32KiB, SectorShape4KiB, SectorSize, - UnpaddedByteIndex, UnpaddedBytesAmount, UpdateProofPartitions, POREP_PARTITIONS, - SECTOR_SIZE_16_KIB, SECTOR_SIZE_2_KIB, SECTOR_SIZE_32_KIB, SECTOR_SIZE_4_KIB, - WINDOW_POST_CHALLENGE_COUNT, WINDOW_POST_SECTOR_COUNT, WINNING_POST_CHALLENGE_COUNT, - WINNING_POST_SECTOR_COUNT, ->>>>>>> 1f5042b4 (fix: apply some review feedback) -======= - Commitment, DefaultTreeDomain, MerkleTreeTrait, PaddedBytesAmount, PieceInfo, PoRepConfig, + DefaultTreeDomain, MerkleTreeTrait, PaddedBytesAmount, PieceInfo, PoRepConfig, PoRepProofPartitions, PoStConfig, PoStType, PrivateReplicaInfo, ProverId, PublicReplicaInfo, SealCommitOutput, SealPreCommitOutput, SealPreCommitPhase1Output, SectorShape16KiB, SectorShape2KiB, SectorShape32KiB, SectorShape4KiB, SectorSize, SectorUpdateConfig, UnpaddedByteIndex, UnpaddedBytesAmount, POREP_PARTITIONS, SECTOR_SIZE_16_KIB, SECTOR_SIZE_2_KIB, SECTOR_SIZE_32_KIB, SECTOR_SIZE_4_KIB, WINDOW_POST_CHALLENGE_COUNT, WINDOW_POST_SECTOR_COUNT, WINNING_POST_CHALLENGE_COUNT, WINNING_POST_SECTOR_COUNT, ->>>>>>> cd695d8f (fix: apply more feedback) }; use fr32::bytes_into_fr; use log::info; diff --git a/storage-proofs-core/src/gadgets/por.rs b/storage-proofs-core/src/gadgets/por.rs index 6efed9000..dfa3aa0be 100644 --- a/storage-proofs-core/src/gadgets/por.rs +++ b/storage-proofs-core/src/gadgets/por.rs @@ -567,8 +567,8 @@ where let preimg = insert( &mut cs.namespace(|| format!("merkle proof insert (height={})", height)), &cur, - insert_index, - siblings, + &insert_index, + &siblings, )?; cur = <::Function as HashFunction< ::Domain, diff --git a/storage-proofs-update/Cargo.toml b/storage-proofs-update/Cargo.toml index 1ba523665..576499aa5 100644 --- a/storage-proofs-update/Cargo.toml +++ b/storage-proofs-update/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "storage-proofs-update" -version = "10.0.0" +version = "10.1.0" authors = ["dignifiedquire "] description = "Proof of SDR-PoRep CC-Sector Update" license = "MIT OR Apache-2.0" @@ -24,13 +24,13 @@ rayon = "1.0.0" serde = { version = "1.0", features = ["derive"]} serde_json = "1.0" ff = "0.11.0" -bellperson = "0.17.0" +bellperson = "0.18.0" blstrs = "0.4.0" log = "0.4.7" pretty_assertions = "0.6.1" generic-array = "0.14.4" anyhow = "1.0.23" -neptune = { version = "5.0.0", features = ["arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] } +neptune = { version = "5.1.0", features = ["arity2", "arity4", "arity8", "arity11", "arity16", "arity24", "arity36"] } num_cpus = "1.10.1" hex = "0.4.2" bincode = "1.1.2" diff --git a/storage-proofs-update/src/gadgets.rs b/storage-proofs-update/src/gadgets.rs index b77ecfa6f..16d79c938 100644 --- a/storage-proofs-update/src/gadgets.rs +++ b/storage-proofs-update/src/gadgets.rs @@ -129,7 +129,7 @@ pub fn gen_challenge_bits>( // `digest = H(comm_r_new || digest_index)` let digest = ::Function::hash2_circuit( cs.namespace(|| format!("digest_{}", j)), - &comm_r_new, + comm_r_new, &digest_index, )?; @@ -311,7 +311,7 @@ mod tests { let challenge_count = challenge_count(sector_nodes); for k in 0..partition_count { - let challenges: Vec = Challenges::new(sector_nodes, comm_r_new, k).collect(); + let challenges = Challenges::new(sector_nodes, comm_r_new, k); let mut cs = TestConstraintSystem::::new(); let comm_r_new = @@ -338,8 +338,7 @@ mod tests { let gadget_constraints = constraints_after - constraints_before; assert_eq!(gadget_constraints, constraints_expected); - for (c, c_generated_bits) in challenges.into_iter().zip(generated_bits.into_iter()) - { + for (c, c_generated_bits) in challenges.zip(generated_bits.into_iter()) { assert_eq!(c_generated_bits.len(), rand_challenge_bits); let mut c_circ: u32 = 0; for (i, bit) in c_generated_bits @@ -417,7 +416,7 @@ mod tests { .enumerate() .map(|(i, apex_leaf)| { AllocatedNum::alloc(cs.namespace(|| format!("apex_leaf_{}", i)), || { - Ok(apex_leaf.clone().into()) + Ok((*apex_leaf).into()) }) .unwrap() }) diff --git a/storage-proofs-update/src/vanilla.rs b/storage-proofs-update/src/vanilla.rs index 43f97591d..21c827fdf 100644 --- a/storage-proofs-update/src/vanilla.rs +++ b/storage-proofs-update/src/vanilla.rs @@ -462,7 +462,7 @@ pub fn phi(comm_d_new: &TreeDDomain, comm_r_old: &TreeRDomain) -> TreeRDomain { let comm_d_new: Fr = (*comm_d_new).into(); comm_d_new.into() }; - ::Function::hash2(&comm_d_new, &comm_r_old) + ::Function::hash2(&comm_d_new, comm_r_old) } // Computes all `2^h` rho values for the given `phi`. Each rho corresponds to one of the `2^h` @@ -471,7 +471,7 @@ pub fn rhos(h: usize, phi: &TreeRDomain) -> Vec { (0..1 << h) .map(|high| { let high: TreeRDomain = Fr::from(high as u64).into(); - ::Function::hash2(&phi, &high).into() + ::Function::hash2(phi, &high).into() }) .collect() } @@ -610,9 +610,8 @@ where // Re-instantiate TreeD's store for reading apex leafs. let tree_d_nodes = tree_d_new_config.size.expect("config size failure"); - let tree_d_store = - TreeDStore::new_from_disk(tree_d_nodes, tree_d_arity, &tree_d_new_config) - .context("tree_d_store")?; + let tree_d_store = TreeDStore::new_from_disk(tree_d_nodes, tree_d_arity, tree_d_new_config) + .context("tree_d_store")?; ensure!( tree_d_nodes == Store::len(&tree_d_store), "TreeD store size mismatch"