Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

fix(brillig): Stall if a Brillig input array is not fully solved #226

Merged
merged 1 commit into from
Apr 24, 2023
Merged
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
19 changes: 11 additions & 8 deletions acvm/src/pwg/brillig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ impl BrilligSolver {
}
}
BrilligInputs::Array(id, expr_arr) => {
let id_as_value: Value =
Value { typ: Typ::Field, inner: FieldElement::from(*id as u128) };
// Push value of the array id as a register
input_register_values.push(id_as_value.into());

// Attempt to fetch all array input values
let mut continue_eval = true;
let mut array_heap: BTreeMap<usize, Value> = BTreeMap::new();
for (i, expr) in expr_arr.into_iter().enumerate() {
Expand All @@ -82,19 +78,26 @@ impl BrilligSolver {
break;
}
}
input_memory.insert(id_as_value, ArrayHeap { memory_map: array_heap });

// If an array value is missing exit the input solver and do not insert the array id as an input register
if !continue_eval {
break;
}

let id_as_value: Value =
Value { typ: Typ::Field, inner: FieldElement::from(*id as u128) };
// Push value of the array id as a register
input_register_values.push(id_as_value.into());

input_memory.insert(id_as_value, ArrayHeap { memory_map: array_heap });
}
}
}

if input_register_values.len() != brillig.inputs.len() {
let jabber_input =
let brillig_input =
brillig.inputs.last().expect("Infallible: cannot reach this point if no inputs");
let expr = match jabber_input {
let expr = match brillig_input {
BrilligInputs::Simple(expr) => expr,
BrilligInputs::Array(_, expr_arr) => {
expr_arr.last().expect("Infallible: cannot reach this point if no inputs")
Expand Down