Skip to content

Commit 9c49171

Browse files
committed
Print debugging info if a pod does not verify
1 parent abce0af commit 9c49171

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/backends/plonky2/mock_main/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,22 @@ impl Pod for MockMainPod {
430430
self.operations[i]
431431
.deref(&self.statements[..input_statement_offset + i])
432432
.unwrap()
433-
.check(&self.params, &s.clone().try_into().unwrap())
433+
.check_and_print(&self.params, &s.clone().try_into().unwrap())
434434
})
435435
.collect::<Result<Vec<_>>>()
436436
.unwrap();
437+
if !ids_match {
438+
println!("Verification failed: POD ID is incorrect.");
439+
}
440+
if !has_type_statement {
441+
println!("Verification failed: POD does not have type statement.");
442+
}
443+
if !value_ofs_unique {
444+
println!("Verification failed: Repeated ValueOf");
445+
}
446+
if !statement_check.iter().all(|b| *b) {
447+
println!("Verification failed: Statement did not check.")
448+
}
437449
ids_match && has_type_statement && value_ofs_unique & statement_check.into_iter().all(|b| b)
438450
}
439451
fn id(&self) -> PodId {

src/middleware/operation.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,15 @@ impl Operation {
308308
.map(|(pred, st_args)| Statement::from_args(pred, st_args));
309309
x.transpose()
310310
}
311+
/// Checks the given operation against a statement, and prints information if the check does not pass
312+
pub fn check_and_print(&self, params: &Params, output_statement: &Statement) -> Result<bool> {
313+
let valid: bool = self.check(params, output_statement)?;
314+
if !valid {
315+
println!("Check failed on the following statement");
316+
println!("{}", output_statement);
317+
}
318+
Ok(valid)
319+
}
311320
/// Checks the given operation against a statement.
312321
pub fn check(&self, _params: &Params, output_statement: &Statement) -> Result<bool> {
313322
use Statement::*;

0 commit comments

Comments
 (0)