Skip to content

Commit

Permalink
refactor: Replace dbg! macro with log::debug across modules
Browse files Browse the repository at this point in the history
- Replaced usage of `dbg!` debugging macros with `log::debug` across various files,
- Included `dbg_macro` to the list of project-wide clippy lints for code quality assurance.
  • Loading branch information
huitseeker committed Aug 17, 2023
1 parent 2ffa799 commit af155ce
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 20 deletions.
1 change: 1 addition & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xclippy = [
"clippy", "--workspace", "--all-targets", "--",
"-Wclippy::all",
"-Wclippy::dbg_macro",
"-Wclippy::match_same_arms",
"-Wclippy::cast_lossless",
"-Wclippy::disallowed_methods",
Expand Down
6 changes: 5 additions & 1 deletion src/circuit/circuit_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4940,7 +4940,11 @@ fn car_cdr_named<F: LurkField, CS: ConstraintSystem<F>>(
)?;

if cons_not_dummy.get_value().unwrap_or(false) && !real_cons.get_value().unwrap_or(true) {
dbg!(maybe_cons.hash().get_value(), &allocated_digest.get_value());
log::debug!(
"{:?} {:?}",
maybe_cons.hash().get_value(),
&allocated_digest.get_value()
);
panic!(
"tried to take car_cdr of a non-dummy cons ({:?}) but supplied wrong value",
name
Expand Down
2 changes: 1 addition & 1 deletion src/circuit/gadgets/hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl<'a, F: LurkField> AllocatedContWitness<'a, F> {
if !expect_dummy {
match allocated_name {
Err(_) => {
dbg!(&self.witness);
log::debug!("{:?}", &self.witness);
panic!("requested {:?} but found a dummy allocation", name)
}
Ok(alloc_name) => {
Expand Down
2 changes: 1 addition & 1 deletion src/circuit/gadgets/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl<F: LurkField> AllocatedPtr<F> {
implies!(cs, not_dummy, &cons_is_real);

if not_dummy.get_value().unwrap_or(false) && !cons_is_real.get_value().unwrap_or(true) {
dbg!(name);
log::debug!("{:?}", name);
panic!("uh oh!");
}

Expand Down
2 changes: 1 addition & 1 deletion src/eval/reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ fn reduce_with_witness_inner<F: LurkField, C: Coprocessor<F>>(

// `fun_form` must be a function or potentially evaluate to one.
if !fun_form.is_potentially(ExprTag::Fun) {
dbg!("not potentially fun");
log::debug!("{}", "not potentially fun");
Control::Error(expr, env)
} else if args.is_nil() {
Control::Return(
Expand Down
10 changes: 5 additions & 5 deletions src/eval/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2515,29 +2515,29 @@ fn op_syntax_error<T: Op + Copy>() {

{
let expr = format!("({name} . 1)");
dbg!(&expr);
log::debug!("{:?}", &expr);
test_aux::<Coproc<Fr>>(s, &expr, None, None, Some(error), None, 1, None);
}

if !op.supports_arity(0) {
let expr = format!("({name})");
dbg!(&expr);
log::debug!("{:?}", &expr);
test_aux::<Coproc<Fr>>(s, &expr, None, None, Some(error), None, 1, None);
}
if !op.supports_arity(1) {
let expr = format!("({name} 123)");
dbg!(&expr);
log::debug!("{:?}", &expr);
test_aux::<Coproc<Fr>>(s, &expr, None, None, Some(error), None, 1, None);
}
if !op.supports_arity(2) {
let expr = format!("({name} 123 456)");
dbg!(&expr);
log::debug!("{:?}", &expr);
test_aux::<Coproc<Fr>>(s, &expr, None, None, Some(error), None, 1, None);
}

if !op.supports_arity(3) {
let expr = format!("({name} 123 456 789)");
dbg!(&expr);
log::debug!("{:?}", &expr);
let iterations = if op.supports_arity(2) { 2 } else { 1 };
test_aux::<Coproc<Fr>>(s, &expr, None, None, Some(error), None, iterations, None);
}
Expand Down
2 changes: 1 addition & 1 deletion src/hash_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl<F: LurkField> HashWitness<ConsName, Cons<F>, MAX_CONSES_PER_REDUCTION, F> {
if !store.ptr_eq(&hash.cons, &nil).unwrap() {
use crate::writer::Write;
let cons = hash.cons.fmt_to_string(store, state);
dbg!(hash.cons, cons, name, existing_name);
log::debug!("{:?} {:?} {:?} {:?}", hash.cons, cons, name, existing_name);
panic!("duplicate");
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/proof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ pub fn verify_sequential_css<F: LurkField + Copy, C: Coprocessor<F>>(
for (i, (multiframe, cs)) in css.iter().enumerate() {
if let Some(prev) = previous_frame {
if !prev.precedes(multiframe) {
dbg!(i, "not preceeding frame");
log::debug!("{} {}", i, "not preceeding frame");
return Ok(false);
}
}
if !cs.is_satisfied() {
dbg!(i, "cs not satisfied");
log::debug!("{} {}", i, "cs not satisfied");
return Ok(false);
}

let public_inputs = multiframe.public_inputs();
if !cs.verify(&public_inputs) {
dbg!(i, "cs not verified");
log::debug!("{} {}", i, "cs not verified");
return Ok(false);
}
previous_frame = Some(multiframe);
Expand Down
12 changes: 6 additions & 6 deletions src/proof/nova.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ pub mod tests {

let res = proof.verify(&pp, num_steps, &z0, &zi);
if res.is_err() {
dbg!(&res);
log::debug!("{:?}", &res);
}
assert!(res.unwrap());

Expand Down Expand Up @@ -578,7 +578,7 @@ pub mod tests {
if unsat.is_some() {
// For some reason, this isn't getting printed from within the implementation as expected.
// Since we always want to know this information, if the condition occurs, just print it here.
dbg!(unsat);
log::debug!("{:?}", unsat);
}
assert!(cs.is_satisfied());
assert!(cs.verify(&multiframe.public_inputs()));
Expand Down Expand Up @@ -1169,23 +1169,23 @@ pub mod tests {

if !op.supports_arity(0) {
let expr = format!("({name})");
dbg!(&expr);
log::debug!("{:?}", &expr);
test_aux::<Coproc<Fr>>(s, &expr, None, None, Some(error), None, 1, None);
}
if !op.supports_arity(1) {
let expr = format!("({name} 123)");
dbg!(&expr);
log::debug!("{:?}", &expr);
test_aux::<Coproc<Fr>>(s, &expr, None, None, Some(error), None, 1, None);
}
if !op.supports_arity(2) {
let expr = format!("({name} 123 456)");
dbg!(&expr);
log::debug!("{:?}", &expr);
test_aux::<Coproc<Fr>>(s, &expr, None, None, Some(error), None, 1, None);
}

if !op.supports_arity(3) {
let expr = format!("({name} 123 456 789)");
dbg!(&expr);
log::debug!("{:?}", &expr);
let iterations = if op.supports_arity(2) { 2 } else { 1 };
test_aux::<Coproc<Fr>>(s, &expr, None, None, Some(error), None, iterations, None);
}
Expand Down
2 changes: 1 addition & 1 deletion src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ pub mod test {
let sym1 = store.car(&expr).unwrap();
let sss = store.fetch_sym(&sym);
let hash = store.hash_expr(&sym);
dbg!(&sym1, &sss, &hash);
log::debug!("{:?} {:?} {:?}", &sym1, &sss, &hash);

assert_eq!(sym, sym1);
}
Expand Down

0 comments on commit af155ce

Please sign in to comment.