Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory machine witgen: Handle unknown address #708

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions executor/src/witgen/eval_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ pub enum IncompleteCause<K = usize> {
NonConstantQueryMatchScrutinee,
/// Query element is not constant.
NonConstantQueryElement,
/// A required argument was not provided
NonConstantRequiredArgument(&'static str),
/// The left selector in a lookup is not constant. Example: `x * {1} in [{1}]` where `x` is not constant.
NonConstantLeftSelector,
/// A value to be written is not constant. TODO: should this be covered by another case? it's used for memory
NonConstantWriteValue,
/// An expression cannot be evaluated.
ExpressionEvaluationUnimplemented(String),
/// A value is not found on the left side of a match. Example: `match x {1 => 2, 3 => 4}` where `x == 0`
Expand Down
17 changes: 10 additions & 7 deletions executor/src/witgen/machines/double_sorted_witness_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,15 @@ impl<T: FieldElement> DoubleSortedWitnesses<T> {
}
_ => panic!(),
};
let addr = left[0].constant_value().ok_or_else(|| {
format!(
"Address must be known: {} = {}",
left[0], right.expressions[0]
)
})?;
let addr = match left[0].constant_value() {
Some(v) => v,
None => {
return Ok(EvalValue::incomplete(
IncompleteCause::NonConstantRequiredArgument("m_addr"),
))
}
};

if addr.to_degree() >= self.degree {
return Err(format!(
"Memory access to too large address: 0x{addr:x} (must be less than 0x{:x})",
Expand Down Expand Up @@ -218,7 +221,7 @@ impl<T: FieldElement> DoubleSortedWitnesses<T> {
Some(v) => v,
None => {
return Ok(EvalValue::incomplete(
IncompleteCause::NonConstantWriteValue,
IncompleteCause::NonConstantRequiredArgument("m_value"),
))
}
};
Expand Down