Skip to content

Commit

Permalink
Merge pull request #290 from 0xPolygonMiden/tohrnii-fix
Browse files Browse the repository at this point in the history
fix(ir): fix columns size for vector trace access
  • Loading branch information
grjte authored May 2, 2023
2 parents db86cfc + 54829c6 commit cb8fe39
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
14 changes: 10 additions & 4 deletions air-script/tests/evaluators/evaluators.air
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
def EvaluatorsAir

ev is_unchanged([x]):
ev are_unchanged([x, y, z]):
enf x' = x
enf y' = y
enf z' = z

ev is_binary([x]):
enf x^2 = x

ev are_all_binary([c[3]]):
enf c^2 = c for c in c

trace_columns:
main: [b]
main: [b, c[3], d[3]]

public_inputs:
stack_inputs: [16]
Expand All @@ -16,5 +21,6 @@ boundary_constraints:
enf b.first = 0

integrity_constraints:
enf is_unchanged([b])
enf is_binary([b])
enf are_unchanged([b, c[1], d[2]])
enf is_binary([b])
enf are_all_binary([c])
9 changes: 7 additions & 2 deletions air-script/tests/evaluators/evaluators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Air for EvaluatorsAir {
}

fn new(trace_info: TraceInfo, public_inputs: PublicInputs, options: WinterProofOptions) -> Self {
let main_degrees = vec![TransitionConstraintDegree::new(1), TransitionConstraintDegree::new(2)];
let main_degrees = vec![TransitionConstraintDegree::new(1), TransitionConstraintDegree::new(1), TransitionConstraintDegree::new(1), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2), TransitionConstraintDegree::new(2)];
let aux_degrees = vec![];
let num_main_assertions = 1;
let num_aux_assertions = 0;
Expand Down Expand Up @@ -76,7 +76,12 @@ impl Air for EvaluatorsAir {
let main_current = frame.current();
let main_next = frame.next();
result[0] = main_next[0] - main_current[0];
result[1] = main_current[0].exp(E::PositiveInteger::from(2_u64)) - main_current[0];
result[1] = main_next[2] - main_current[2];
result[2] = main_next[6] - main_current[6];
result[3] = main_current[0].exp(E::PositiveInteger::from(2_u64)) - main_current[0];
result[4] = main_current[1].exp(E::PositiveInteger::from(2_u64)) - main_current[1];
result[5] = main_current[2].exp(E::PositiveInteger::from(2_u64)) - main_current[2];
result[6] = main_current[3].exp(E::PositiveInteger::from(2_u64)) - main_current[3];
}

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
13 changes: 12 additions & 1 deletion ir/src/symbol_table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,21 @@ impl SymbolTable {
}
};

let size = match symbol_access.access_type() {
AccessType::Default => columns.size(),
AccessType::Vector(_) => 1,
_ => {
return Err(SemanticError::invalid_access_type(
symbol,
symbol_access.access_type(),
));
}
};

Ok(TraceAccess::new(
columns.trace_segment(),
col_offset,
columns.size(),
size,
symbol_access.offset(),
))
}
Expand Down

0 comments on commit cb8fe39

Please sign in to comment.