privacy-scaling-explorations / halo2

https://privacy-scaling-explorations.github.io/halo2/
Other
202 stars 122 forks source link

Stack trace in Error::Synthesize #294

Open ed255 opened 6 months ago

ed255 commented 6 months ago

In https://github.com/privacy-scaling-explorations/halo2/pull/290 I plan to split the Error type into one for the frontend and one for the backend. In a weekly call Adria proposed that we incorporate stack traces on synthesize errors in order to make it easier to debug synthesize errors (which currently don't contain any information context).

One possible crate we can explore is https://github.com/eyre-rs/eyre

adria0 commented 6 months ago

Usually:

But it's everything somehow mixed, or I do not see the logic of generating panics or returns errors in the current library. Anyway, let's say that in the case of Halo2, probably, the only error that really matters is in the proof verification, panic'ing or returning error in proof generation is just ok.

What is not implemented is something like SynthesisWithBackTrace(std::backtrace::Backtrace), and really does not seem to have any sense at all. So I'm now in the side of, if developer wants a stack trace for Error::Synthesis, just generating an Error::Other

    pub fn synthesis_with_backtrace() -> Self {
        let backtrace = std::backtrace::Backtrace::force_capture();
        Error::Other(backtrace.to_string())
    }

because Synthesis error is very localized in the Halo2 library (in only 2 places) and you can add panic! there in the case that you need it.