Skip to content

Commit

Permalink
Merge pull request #1061 from powdr-labs/compute-first-row
Browse files Browse the repository at this point in the history
On (N-1, 0) row pair, only execute identities with next reference
  • Loading branch information
chriseth authored Feb 19, 2024
2 parents 1485f50 + 668d881 commit c41f9f6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
14 changes: 12 additions & 2 deletions executor/src/witgen/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,26 @@ impl<'a, T: FieldElement> Generator<'a, T> {
]
.into_iter(),
);

// We're only interested in the first row anyway, so identities without a next reference
// are irrelevant.
// Also, they can lead to problems in the case where some witness columns are provided
// externally, e.g. if the last row happens to call into a stateful machine like memory.
let identities_with_next_reference = self
.identities
.iter()
.filter_map(|identity| identity.contains_next_ref().then_some(*identity))
.collect::<Vec<_>>();
let mut processor = BlockProcessor::new(
self.fixed_data.degree - 1,
data,
mutable_state,
&self.identities,
&identities_with_next_reference,
self.fixed_data,
&self.witnesses,
);
let mut sequence_iterator = ProcessingSequenceIterator::Default(
DefaultSequenceIterator::new(0, self.identities.len(), None),
DefaultSequenceIterator::new(0, identities_with_next_reference.len(), None),
);
processor.solve(&mut sequence_iterator).unwrap();
let first_row = processor.finish().remove(1);
Expand Down
2 changes: 1 addition & 1 deletion pipeline/tests/pil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn test_external_witgen_both_provided() {
}

#[test]
#[should_panic = "called `Result::unwrap()` on an `Err` value: Generic(\"main.b = (main.a + 1);:\\n Linear constraint is not satisfiable: 18446744069414584320 != 0\")"]
#[should_panic = "Witness generation failed."]
fn test_external_witgen_fails_on_conflicting_external_witness() {
let f = "pil/external_witgen.pil";
let external_witness = vec![
Expand Down
8 changes: 7 additions & 1 deletion test_data/pil/sum_via_witness_query.pil
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ namespace Sum(%N);
pol fixed ISALMOSTLAST(i) { if i == %last_row - 1 { 1 } else { 0 } };
pol fixed ISFIRST = [ 1, 0 ] + [0]*;

col witness input(i) query ("input", i);
col witness input(i) query match i {
// A non-exhaustive match statement is the only way to return "None"
0 => ("input", 0),
1 => ("input", 1),
2 => ("input", 2),
// No response in the case of i == 3
};
col witness sum;

ISLAST * sum' = 0;
Expand Down

0 comments on commit c41f9f6

Please sign in to comment.