zksecurity / noname

Noname: a programming language to write zkapps
https://zksecurity.github.io/noname/
193 stars 50 forks source link

feat: log builtin #193

Closed katat closed 1 month ago

katat commented 1 month ago

This is a logging feature to help debugging.

Usage:

let sum = var1 + var2;
log(sum); 

It should print something like:

---log span: Span { filename_id: 1, start: 147, len: 7 }---
typ: Some(Field { constant: false })
mutable: false
cvar: v_2 + v_1

Because it is a builtin function, so it only accesses to the info at compilation time.

It is quite common to check the values behind these variables. So we could record the cell var index at the backend, and print out the relevant witness values when generating witnesses.

mimoo commented 1 month ago

so two things:

  1. I think at some point we'll want a real format syntax like in rust (e.g. log("{sum}"))
  2. we should distinguish debugging runtime value and type information, here it looks more like a log("{}", typeof(sum)) (or perhaps we could have a separate log_type function)