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

Make fil-blst usage in Window PoSt possible #1272

Merged
merged 3 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,33 @@ jobs:
RUST_TEST_THREADS: 1
no_output_timeout: 30m

# Running with `use_fil_blst=true` should be integrated directly into the test code. For now we
# just re-run the tests that exercise the fil-blst code path with that setting set.
test_fil_blst:
docker:
- image: filecoin/rust:latest
working_directory: /mnt/crate
resource_class: 2xlarge+
steps:
- configure_environment_variables
- checkout
- attach_workspace:
at: "."
- restore_cache:
keys:
- cargo-v28-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
- restore_parameter_cache
- run:
name: Test with fil-blst enabled
command: |
ulimit -n 20000
ulimit -u 20000
ulimit -n 20000
cargo +$(cat rust-toolchain) test --verbose --release --test api -- --ignored
environment:
RUST_TEST_THREADS: 1
FIL_PROOFS_USE_FIL_BLST: true

bench:
docker:
- image: filecoin/rust:latest
Expand Down Expand Up @@ -351,6 +378,10 @@ workflows:
requires:
- cargo_fetch
- ensure_groth_parameters_and_keys_linux
- test_fil_blst:
requires:
- cargo_fetch
- ensure_groth_parameters_and_keys_linux
- test:
requires:
- cargo_fetch
Expand Down
43 changes: 31 additions & 12 deletions filecoin-proofs/src/api/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ pub fn verify_winning_post<Tree: 'static + MerkleTreeTrait>(
.use_fil_blst;

let is_valid = if use_fil_blst {
info!("verify_winning_post: use_fil_blst=true");
let verifying_key_path = post_config.get_cache_verifying_key_path::<Tree>()?;
fallback::FallbackPoStCompound::verify_blst(
&pub_params,
Expand Down Expand Up @@ -566,10 +567,6 @@ pub fn verify_window_post<Tree: 'static + MerkleTreeTrait>(
let pub_params: compound_proof::PublicParams<fallback::FallbackPoSt<Tree>> =
fallback::FallbackPoStCompound::setup(&setup_params)?;

let verifying_key = get_post_verifying_key::<Tree>(&post_config)?;

let proof = MultiProof::new_from_reader(partitions, &proof[..], &verifying_key)?;

let pub_sectors: Vec<_> = replicas
.iter()
.map(|(sector_id, replica)| {
Expand All @@ -588,15 +585,37 @@ pub fn verify_window_post<Tree: 'static + MerkleTreeTrait>(
k: None,
};

let is_valid = fallback::FallbackPoStCompound::verify(
&pub_params,
&pub_inputs,
&proof,
&fallback::ChallengeRequirements {
minimum_challenge_count: post_config.challenge_count * post_config.sector_count,
},
)?;
let use_fil_blst = settings::SETTINGS
.lock()
.expect("use_fil_blst settings lock failure")
.use_fil_blst;

let is_valid = if use_fil_blst {
info!("verify_window_post: use_fil_blst=true");
let verifying_key_path = post_config.get_cache_verifying_key_path::<Tree>()?;
fallback::FallbackPoStCompound::verify_blst(
&pub_params,
&pub_inputs,
&proof,
proof.len() / 192,
&fallback::ChallengeRequirements {
minimum_challenge_count: post_config.challenge_count * post_config.sector_count,
},
&verifying_key_path,
)?
} else {
let verifying_key = get_post_verifying_key::<Tree>(&post_config)?;
let multi_proof = MultiProof::new_from_reader(partitions, &proof[..], &verifying_key)?;

fallback::FallbackPoStCompound::verify(
&pub_params,
&pub_inputs,
&multi_proof,
&fallback::ChallengeRequirements {
minimum_challenge_count: post_config.challenge_count * post_config.sector_count,
},
)?
};
if !is_valid {
return Ok(false);
}
Expand Down
1 change: 1 addition & 0 deletions filecoin-proofs/src/api/seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ pub fn verify_seal<Tree: 'static + MerkleTreeTrait>(
.use_fil_blst;

let result = if use_fil_blst {
info!("verify_seal: use_fil_blst=true");
let verifying_key_path = porep_config.get_cache_verifying_key_path::<Tree>()?;

StackedCompound::verify_blst(
Expand Down