Skip to content

Commit

Permalink
test: update tests for boundary constraint changes
Browse files Browse the repository at this point in the history
  • Loading branch information
grjte committed Jan 27, 2023
1 parent 7be02b9 commit cd08bd7
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 38 deletions.
11 changes: 6 additions & 5 deletions air-script/tests/aux_trace/aux_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,28 @@ impl Air for AuxiliaryAir {

fn get_assertions(&self) -> Vec<Assertion<Felt>> {
let mut result = Vec::new();
let last_step = self.last_step();
result.push(Assertion::single(0, 0, Felt::new(1)));
result.push(Assertion::single(1, 0, Felt::new(1)));
result
}

fn get_aux_assertions<E: FieldElement<BaseField = Felt>>(&self, aux_rand_elements: &AuxTraceRandElements<E>) -> Vec<Assertion<E>> {
let mut result = Vec::new();
result.push(Assertion::single(0, 0, E::from(1_u64)));
result.push(Assertion::single(1, 0, aux_rand_elements.get_segment_elements(0)[0]));
let last_step = self.last_step();
result.push(Assertion::single(0, 0, E::from(1_u64)));
result.push(Assertion::single(0, last_step, E::from(1_u64)));
result.push(Assertion::single(1, 0, aux_rand_elements.get_segment_elements(0)[0]));
result.push(Assertion::single(1, last_step, E::from(1_u64)));
result
}

fn evaluate_transition<E: FieldElement<BaseField = Felt>>(&self, frame: &EvaluationFrame<E>, periodic_values: &[E], result: &mut [E]) {
let current = frame.current();
let next = frame.next();
result[0] = next[0] - (current[1] + current[2]);
result[1] = next[1] - (current[2] + next[0]);
result[2] = current[2] - (current[0] + current[1]);
result[0] = current[2] - (current[0] + current[1]);
result[1] = next[0] - (current[1] + current[2]);
result[2] = next[1] - (current[2] + next[0]);
}

fn evaluate_aux_transition<F, E>(&self, main_frame: &EvaluationFrame<F>, aux_frame: &EvaluationFrame<E>, _periodic_values: &[F], aux_rand_elements: &AuxTraceRandElements<E>, result: &mut [E])
Expand Down
2 changes: 2 additions & 0 deletions air-script/tests/binary/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ impl Air for BinaryAir {

fn get_assertions(&self) -> Vec<Assertion<Felt>> {
let mut result = Vec::new();
let last_step = self.last_step();
result.push(Assertion::single(0, 0, Felt::new(0)));
result
}

fn get_aux_assertions<E: FieldElement<BaseField = Felt>>(&self, aux_rand_elements: &AuxTraceRandElements<E>) -> Vec<Assertion<E>> {
let mut result = Vec::new();
let last_step = self.last_step();
result
}

Expand Down
36 changes: 19 additions & 17 deletions air-script/tests/bitwise/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Air for BitwiseAir {
}

fn new(trace_info: TraceInfo, public_inputs: PublicInputs, options: WinterProofOptions) -> Self {
let main_degrees = vec![TransitionConstraintDegree::new(2), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::new(3)];
let main_degrees = vec![TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::new(3), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::with_cycles(1, vec![8]), TransitionConstraintDegree::with_cycles(1, vec![8])];
let aux_degrees = vec![];
let num_main_assertions = 1;
let num_aux_assertions = 0;
Expand All @@ -63,35 +63,37 @@ impl Air for BitwiseAir {

fn get_assertions(&self) -> Vec<Assertion<Felt>> {
let mut result = Vec::new();
let last_step = self.last_step();
result.push(Assertion::single(13, 0, Felt::new(0)));
result
}

fn get_aux_assertions<E: FieldElement<BaseField = Felt>>(&self, aux_rand_elements: &AuxTraceRandElements<E>) -> Vec<Assertion<E>> {
let mut result = Vec::new();
let last_step = self.last_step();
result
}

fn evaluate_transition<E: FieldElement<BaseField = Felt>>(&self, frame: &EvaluationFrame<E>, periodic_values: &[E], result: &mut [E]) {
let current = frame.current();
let next = frame.next();
result[0] = (current[0]).exp(E::PositiveInteger::from(2_u64)) - (current[0]) - (E::from(0_u64));
result[1] = (periodic_values[1]) * (next[0] - (current[0])) - (E::from(0_u64));
result[2] = (current[3]).exp(E::PositiveInteger::from(2_u64)) - (current[3]) - (E::from(0_u64));
result[3] = (current[4]).exp(E::PositiveInteger::from(2_u64)) - (current[4]) - (E::from(0_u64));
result[4] = (current[5]).exp(E::PositiveInteger::from(2_u64)) - (current[5]) - (E::from(0_u64));
result[5] = (current[6]).exp(E::PositiveInteger::from(2_u64)) - (current[6]) - (E::from(0_u64));
result[6] = (current[7]).exp(E::PositiveInteger::from(2_u64)) - (current[7]) - (E::from(0_u64));
result[7] = (current[8]).exp(E::PositiveInteger::from(2_u64)) - (current[8]) - (E::from(0_u64));
result[8] = (current[9]).exp(E::PositiveInteger::from(2_u64)) - (current[9]) - (E::from(0_u64));
result[9] = (current[10]).exp(E::PositiveInteger::from(2_u64)) - (current[10]) - (E::from(0_u64));
result[10] = (periodic_values[0]) * (current[1] - (((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[3]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[4]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[5]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[6]))) - (E::from(0_u64));
result[11] = (periodic_values[0]) * (current[2] - (((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[7]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[8]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[9]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[10]))) - (E::from(0_u64));
result[12] = (periodic_values[1]) * (next[1] - ((current[1]) * (E::from(16_u64)) + ((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[3]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[4]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[5]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[6]))) - (E::from(0_u64));
result[13] = (periodic_values[1]) * (next[2] - ((current[2]) * (E::from(16_u64)) + ((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[7]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[8]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[9]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[10]))) - (E::from(0_u64));
result[14] = (periodic_values[0]) * (current[11]) - (E::from(0_u64));
result[15] = (periodic_values[1]) * (current[12] - (next[11])) - (E::from(0_u64));
result[16] = (E::from(1_u64) - (current[0])) * (current[12] - ((current[11]) * (E::from(16_u64)) + (((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[3])) * (current[7]) + (((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[4])) * (current[8]) + (((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[5])) * (current[9]) + (((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[6])) * (current[10]))) + (current[0]) * (current[12] - ((current[11]) * (E::from(16_u64)) + ((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[3] + current[7] - (((E::from(2_u64)) * (current[3])) * (current[7]))) + ((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[4] + current[8] - (((E::from(2_u64)) * (current[4])) * (current[8]))) + ((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[5] + current[9] - (((E::from(2_u64)) * (current[5])) * (current[9]))) + ((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[6] + current[10] - (((E::from(2_u64)) * (current[6])) * (current[10]))))) - (E::from(0_u64));
result[1] = (current[3]).exp(E::PositiveInteger::from(2_u64)) - (current[3]) - (E::from(0_u64));
result[2] = (current[4]).exp(E::PositiveInteger::from(2_u64)) - (current[4]) - (E::from(0_u64));
result[3] = (current[5]).exp(E::PositiveInteger::from(2_u64)) - (current[5]) - (E::from(0_u64));
result[4] = (current[6]).exp(E::PositiveInteger::from(2_u64)) - (current[6]) - (E::from(0_u64));
result[5] = (current[7]).exp(E::PositiveInteger::from(2_u64)) - (current[7]) - (E::from(0_u64));
result[6] = (current[8]).exp(E::PositiveInteger::from(2_u64)) - (current[8]) - (E::from(0_u64));
result[7] = (current[9]).exp(E::PositiveInteger::from(2_u64)) - (current[9]) - (E::from(0_u64));
result[8] = (current[10]).exp(E::PositiveInteger::from(2_u64)) - (current[10]) - (E::from(0_u64));
result[9] = (periodic_values[0]) * (current[1] - (((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[3]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[4]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[5]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[6]))) - (E::from(0_u64));
result[10] = (periodic_values[0]) * (current[2] - (((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[7]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[8]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[9]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[10]))) - (E::from(0_u64));
result[11] = (periodic_values[0]) * (current[11]) - (E::from(0_u64));
result[12] = (E::from(1_u64) - (current[0])) * (current[12] - ((current[11]) * (E::from(16_u64)) + (((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[3])) * (current[7]) + (((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[4])) * (current[8]) + (((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[5])) * (current[9]) + (((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[6])) * (current[10]))) + (current[0]) * (current[12] - ((current[11]) * (E::from(16_u64)) + ((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[3] + current[7] - (((E::from(2_u64)) * (current[3])) * (current[7]))) + ((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[4] + current[8] - (((E::from(2_u64)) * (current[4])) * (current[8]))) + ((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[5] + current[9] - (((E::from(2_u64)) * (current[5])) * (current[9]))) + ((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[6] + current[10] - (((E::from(2_u64)) * (current[6])) * (current[10]))))) - (E::from(0_u64));
result[13] = (periodic_values[1]) * (next[0] - (current[0])) - (E::from(0_u64));
result[14] = (periodic_values[1]) * (next[1] - ((current[1]) * (E::from(16_u64)) + ((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[3]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[4]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[5]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[6]))) - (E::from(0_u64));
result[15] = (periodic_values[1]) * (next[2] - ((current[2]) * (E::from(16_u64)) + ((E::from(2_u64)).exp(E::PositiveInteger::from(0_u64))) * (current[7]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(1_u64))) * (current[8]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(2_u64))) * (current[9]) + ((E::from(2_u64)).exp(E::PositiveInteger::from(3_u64))) * (current[10]))) - (E::from(0_u64));
result[16] = (periodic_values[1]) * (current[12] - (next[11])) - (E::from(0_u64));
}

fn evaluate_aux_transition<F, E>(&self, main_frame: &EvaluationFrame<F>, aux_frame: &EvaluationFrame<E>, _periodic_values: &[F], aux_rand_elements: &AuxTraceRandElements<E>, result: &mut [E])
Expand Down
15 changes: 8 additions & 7 deletions air-script/tests/constants/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,19 @@ impl Air for ConstantsAir {

fn get_assertions(&self) -> Vec<Assertion<Felt>> {
let mut result = Vec::new();
let last_step = self.last_step();
result.push(Assertion::single(0, 0, A));
result.push(Assertion::single(1, 0, (A) + ((B[0]) * (C[0][1]))));
result.push(Assertion::single(2, 0, ((B[0]) - (C[1][1])) * (A)));
result.push(Assertion::single(3, 0, ((((((A) + (B[0])) - (B[1])) + (C[0][0])) - (C[0][1])) + (C[1][0])) - (C[1][1])));
result.push(Assertion::single(1, 0, A + (B[0]) * (C[0][1])));
result.push(Assertion::single(2, 0, (B[0] - (C[1][1])) * (A)));
result.push(Assertion::single(3, 0, A + B[0] - (B[1]) + C[0][0] - (C[0][1]) + C[1][0] - (C[1][1])));
result
}

fn get_aux_assertions<E: FieldElement<BaseField = Felt>>(&self, aux_rand_elements: &AuxTraceRandElements<E>) -> Vec<Assertion<E>> {
let mut result = Vec::new();
result.push(Assertion::single(0, 0, (E::from(A)) + ((E::from(B[0])) * (E::from(C[0][1])))));
let last_step = self.last_step();
result.push(Assertion::single(0, last_step, (E::from(A)) - ((E::from(B[1])) * (E::from(C[0][0])))));
result.push(Assertion::single(0, 0, E::from(A) + (E::from(B[0])) * (E::from(C[0][1]))));
result.push(Assertion::single(0, last_step, E::from(A) - ((E::from(B[1])) * (E::from(C[0][0])))));
result
}

Expand All @@ -105,7 +106,7 @@ impl Air for ConstantsAir {
{
let current = aux_frame.current();
let next = aux_frame.next();
result[0] = next[0] - (current[0] + E::from(A) + (E::from(B[0])) * (E::from(C[0][1])));
result[1] = current[0] - (E::from(A) + (E::from(B[1])) * (E::from(C[1][1])));
result[0] = current[0] - (E::from(A) + (E::from(B[1])) * (E::from(C[1][1])));
result[1] = next[0] - (current[0] + E::from(A) + (E::from(B[0])) * (E::from(C[0][1])));
}
}
2 changes: 2 additions & 0 deletions air-script/tests/indexed_trace_access/indexed_trace_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ impl Air for IndexedTraceAccessAir {

fn get_assertions(&self) -> Vec<Assertion<Felt>> {
let mut result = Vec::new();
let last_step = self.last_step();
result.push(Assertion::single(0, 0, Felt::new(0)));
result
}

fn get_aux_assertions<E: FieldElement<BaseField = Felt>>(&self, aux_rand_elements: &AuxTraceRandElements<E>) -> Vec<Assertion<E>> {
let mut result = Vec::new();
let last_step = self.last_step();
result
}

Expand Down
3 changes: 3 additions & 0 deletions air-script/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ fn periodic_columns() {
expected.assert_eq(&generated_air);
}

/// TODO: restore this test after public inputs are re-implemented for boundary constraints in the
/// graph
#[test]
#[ignore]
fn pub_inputs() {
let generated_air = Test::new("tests/pub_inputs/pub_inputs.air".to_string())
.transpile()
Expand Down
2 changes: 2 additions & 0 deletions air-script/tests/periodic_columns/periodic_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ impl Air for PeriodicColumnsAir {

fn get_assertions(&self) -> Vec<Assertion<Felt>> {
let mut result = Vec::new();
let last_step = self.last_step();
result.push(Assertion::single(0, 0, Felt::new(0)));
result
}

fn get_aux_assertions<E: FieldElement<BaseField = Felt>>(&self, aux_rand_elements: &AuxTraceRandElements<E>) -> Vec<Assertion<E>> {
let mut result = Vec::new();
let last_step = self.last_step();
result
}

Expand Down
3 changes: 2 additions & 1 deletion air-script/tests/pub_inputs/pub_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ impl Air for PubInputsAir {

fn get_assertions(&self) -> Vec<Assertion<Felt>> {
let mut result = Vec::new();
let last_step = self.last_step();
result.push(Assertion::single(0, 0, self.stack_inputs[0]));
result.push(Assertion::single(1, 0, self.stack_inputs[1]));
result.push(Assertion::single(2, 0, self.stack_inputs[2]));
result.push(Assertion::single(3, 0, self.stack_inputs[3]));
let last_step = self.last_step();
result.push(Assertion::single(0, last_step, self.stack_outputs[0]));
result.push(Assertion::single(1, last_step, self.stack_outputs[1]));
result.push(Assertion::single(2, last_step, self.stack_outputs[2]));
Expand All @@ -86,6 +86,7 @@ impl Air for PubInputsAir {

fn get_aux_assertions<E: FieldElement<BaseField = Felt>>(&self, aux_rand_elements: &AuxTraceRandElements<E>) -> Vec<Assertion<E>> {
let mut result = Vec::new();
let last_step = self.last_step();
result
}

Expand Down
2 changes: 2 additions & 0 deletions air-script/tests/system/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ impl Air for SystemAir {

fn get_assertions(&self) -> Vec<Assertion<Felt>> {
let mut result = Vec::new();
let last_step = self.last_step();
result.push(Assertion::single(0, 0, Felt::new(0)));
result
}

fn get_aux_assertions<E: FieldElement<BaseField = Felt>>(&self, aux_rand_elements: &AuxTraceRandElements<E>) -> Vec<Assertion<E>> {
let mut result = Vec::new();
let last_step = self.last_step();
result
}

Expand Down
2 changes: 2 additions & 0 deletions air-script/tests/trace_col_groups/trace_col_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ impl Air for TraceColGroupAir {

fn get_assertions(&self) -> Vec<Assertion<Felt>> {
let mut result = Vec::new();
let last_step = self.last_step();
result
}

fn get_aux_assertions<E: FieldElement<BaseField = Felt>>(&self, aux_rand_elements: &AuxTraceRandElements<E>) -> Vec<Assertion<E>> {
let mut result = Vec::new();
let last_step = self.last_step();
result.push(Assertion::single(4, 0, E::from(0_u64)));
result
}
Expand Down
2 changes: 1 addition & 1 deletion air-script/tests/variables/variables.air
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ periodic_columns:
k0: [1, 1, 1, 1, 1, 1, 1, 0]

boundary_constraints:
enf a.first = stack_inputs[0]
enf a.first = 0
enf a.last = 1

integrity_constraints:
Expand Down
Loading

0 comments on commit cd08bd7

Please sign in to comment.