Skip to content

Commit

Permalink
Add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
georgwiese committed Jul 12, 2024
1 parent 6bd3996 commit ab487dd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
9 changes: 6 additions & 3 deletions pipeline/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ pub fn verify_pipeline(
verify(pipeline.output_dir().as_ref().unwrap())
}

pub fn make_pipeline<T: FieldElement>(file_name: &str, inputs: Vec<T>) -> Pipeline<T> {
/// Makes a new pipeline for the given file and inputs. All steps until witness generation are
/// already computed, so that the test can branch off from there, without having to re-compute
/// these steps.
pub fn make_prepared_pipeline<T: FieldElement>(file_name: &str, inputs: Vec<T>) -> Pipeline<T> {
let mut pipeline = Pipeline::default()
.with_tmp_output()
.from_file(resolve_test_file(file_name))
Expand All @@ -86,7 +89,7 @@ pub fn make_pipeline<T: FieldElement>(file_name: &str, inputs: Vec<T>) -> Pipeli
}

pub fn gen_estark_proof(file_name: &str, inputs: Vec<GoldilocksField>) {
let pipeline = make_pipeline(file_name, inputs);
let pipeline = make_prepared_pipeline(file_name, inputs);
gen_estark_proof_with_backend_variant(pipeline.clone(), BackendVariant::Monolithic);
gen_estark_proof_with_backend_variant(pipeline, BackendVariant::Composite);
}
Expand Down Expand Up @@ -130,7 +133,7 @@ pub fn gen_estark_proof_with_backend_variant(
}

pub fn test_halo2(file_name: &str, inputs: Vec<Bn254Field>) {
let pipeline = make_pipeline(file_name, inputs);
let pipeline = make_prepared_pipeline(file_name, inputs);
test_halo2_with_backend_variant(pipeline.clone(), BackendVariant::Monolithic);
test_halo2_with_backend_variant(pipeline, BackendVariant::Composite);
}
Expand Down
12 changes: 8 additions & 4 deletions pipeline/tests/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use powdr_backend::BackendType;
use powdr_number::{Bn254Field, FieldElement, GoldilocksField};
use powdr_pipeline::{
test_util::{
gen_estark_proof, gen_estark_proof_with_backend_variant, make_pipeline, resolve_test_file,
test_halo2, test_halo2_with_backend_variant, verify_test_file, BackendVariant,
gen_estark_proof, gen_estark_proof_with_backend_variant, make_prepared_pipeline,
resolve_test_file, test_halo2, test_halo2_with_backend_variant, verify_test_file,
BackendVariant,
},
util::{read_poly_set, FixedPolySet, WitnessPolySet},
Pipeline,
Expand Down Expand Up @@ -227,8 +228,11 @@ fn vm_to_block_different_length() {
let f = "asm/vm_to_block_different_length.asm";
// Because machines have different lengths, this can only be proven
// with a composite proof.
test_halo2_with_backend_variant(make_pipeline(f, vec![]), BackendVariant::Composite);
gen_estark_proof_with_backend_variant(make_pipeline(f, vec![]), BackendVariant::Composite);
test_halo2_with_backend_variant(make_prepared_pipeline(f, vec![]), BackendVariant::Composite);
gen_estark_proof_with_backend_variant(
make_prepared_pipeline(f, vec![]),
BackendVariant::Composite,
);
}

#[test]
Expand Down
9 changes: 6 additions & 3 deletions pipeline/tests/pil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use powdr_pipeline::test_util::{
assert_proofs_fail_for_invalid_witnesses, assert_proofs_fail_for_invalid_witnesses_estark,
assert_proofs_fail_for_invalid_witnesses_halo2,
assert_proofs_fail_for_invalid_witnesses_pilcom, gen_estark_proof,
gen_estark_proof_with_backend_variant, make_pipeline, test_halo2,
gen_estark_proof_with_backend_variant, make_prepared_pipeline, test_halo2,
test_halo2_with_backend_variant, test_plonky3, verify_test_file, BackendVariant,
};

Expand Down Expand Up @@ -313,8 +313,11 @@ fn different_degrees() {
let f = "pil/different_degrees.pil";
// Because machines have different lengths, this can only be proven
// with a composite proof.
test_halo2_with_backend_variant(make_pipeline(f, vec![]), BackendVariant::Composite);
gen_estark_proof_with_backend_variant(make_pipeline(f, vec![]), BackendVariant::Composite);
test_halo2_with_backend_variant(make_prepared_pipeline(f, vec![]), BackendVariant::Composite);
gen_estark_proof_with_backend_variant(
make_prepared_pipeline(f, vec![]),
BackendVariant::Composite,
);
}

#[test]
Expand Down
9 changes: 6 additions & 3 deletions pipeline/tests/powdr_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use powdr_pil_analyzer::evaluator::Value;
use powdr_pipeline::{
test_util::{
evaluate_function, evaluate_integer_function, execute_test_file, gen_estark_proof,
gen_halo2_proof, make_pipeline, resolve_test_file, std_analyzed, test_halo2,
gen_halo2_proof, make_prepared_pipeline, resolve_test_file, std_analyzed, test_halo2,
verify_test_file, BackendVariant,
},
Pipeline,
Expand All @@ -21,8 +21,11 @@ fn poseidon_bn254_test() {
// `test_halo2` only does a mock proof in the PR tests.
// This makes sure we test the whole proof generation for one example
// file even in the PR tests.
gen_halo2_proof(make_pipeline(f, vec![]), BackendVariant::Monolithic);
gen_halo2_proof(make_pipeline(f, vec![]), BackendVariant::Composite);
gen_halo2_proof(
make_prepared_pipeline(f, vec![]),
BackendVariant::Monolithic,
);
gen_halo2_proof(make_prepared_pipeline(f, vec![]), BackendVariant::Composite);
}

#[test]
Expand Down

0 comments on commit ab487dd

Please sign in to comment.