Witgen: Improve error messages

This commit is contained in:
Georg Wiese
2023-09-01 20:11:37 +02:00
committed by GitHub
parent 6388e4dd49
commit 5b3252fb86
2 changed files with 29 additions and 14 deletions

View File

@@ -167,24 +167,20 @@ impl<'a, T: FieldElement> Machine<'a, T> for BlockMachine<'a, T> {
fixed_data: &FixedData<T>,
fixed_lookup: &mut FixedLookup<T>,
) -> HashMap<String, Vec<T>> {
if self.data.len() < 2 * self.block_size {
log::warn!(
"Filling empty blocks with zeros, because the block machine is never used. \
This might violate some internal constraints."
);
}
let mut data = transpose_rows(std::mem::take(&mut self.data), &self.witness_cols)
.into_iter()
.map(|(id, mut values)| {
// For all constraints to be satisfied, unused cells have to be filled with valid values.
// We do this, we construct a default block, by repeating the first input to the block machine.
if values.len() < 2 * self.block_size {
log::warn!("Filling empty blocks with zeros, because the block machine is never used. \
This might violate some internal constraints.");
}
values.resize(fixed_data.degree as usize, None);
let second_block_values = values
.iter()
.skip(self.block_size)
.take(self.block_size);
let second_block_values = values.iter().skip(self.block_size).take(self.block_size);
// The first block is a dummy block (filled mostly with None), the second block is the first block
// resulting of an actual evaluation.
@@ -193,8 +189,14 @@ impl<'a, T: FieldElement> Machine<'a, T> for BlockMachine<'a, T> {
// As a result, the default block consists of values of the first block if they are set, otherwise
// the values of the second block.
// TODO: Determine the row-extend per column
let default_block = values.iter().take(self.block_size).zip(second_block_values).map(
|(first_block, second_block)| first_block.or(*second_block).unwrap_or_default()).collect::<Vec<_>>();
let default_block = values
.iter()
.take(self.block_size)
.zip(second_block_values)
.map(|(first_block, second_block)| {
first_block.or(*second_block).unwrap_or_default()
})
.collect::<Vec<_>>();
let values = values
.into_iter()

View File

@@ -92,10 +92,11 @@ impl<'a, T: FieldElement> Processor<'a, T> {
let mut progress = false;
for identity in &self.identities {
// Create row pair
let global_row_index = self.row_offset + i as u64;
let row_pair = RowPair::new(
&self.data[i],
&self.data[i + 1],
self.row_offset + i as u64,
global_row_index,
self.fixed_data,
UnknownStrategy::Unknown,
);
@@ -106,6 +107,18 @@ impl<'a, T: FieldElement> Processor<'a, T> {
.process_identity(identity, &row_pair)
.map_err(|e| {
log::warn!("Error in identity: {identity}");
log::warn!(
"Known values in current row (local: {i}, global {global_row_index}):\n{}",
self.data[i].render_values(false),
);
if identity.contains_next_ref() {
log::warn!(
"Known values in next row (local: {}, global {}):\n{}",
i + 1,
global_row_index + 1,
self.data[i + 1].render_values(false),
);
}
e
})?;