Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty print polynomial constraint errors #683

Open
moreSocratic opened this issue Oct 18, 2022 · 2 comments
Open

Pretty print polynomial constraint errors #683

moreSocratic opened this issue Oct 18, 2022 · 2 comments
Labels
A-dev-tooling Area: Developer tooling A-errors Area: Error handling

Comments

@moreSocratic
Copy link

VerifyFailure currently produces long hard to read errors. It takes manual work to map cell values in the error back to the variables in the polynomial constraint. We should provide a pretty printed instance of the polynomial constraint with queries substituted for cell values.

E.g. a multiplication where the result cell has been erroneously assigned lhs * rhs + 1

vec![s_mul * (lhs * rhs - out)]

Currently we get errors like this:

        ConstraintNotSatisfied {
            constraint: Constraint {
                gate: Gate {
                    index: 0,
                    name: "mul",
                },
                index: 0,
                name: "",
            },
            location: InRegion {
                region: Region {
                    index: 3,
                    name: "mul",
                },
                offset: 0,
            },
            cell_values: [
                (
                    VirtualCell {
                        name: "",
                        column: Column {
                            column_type: Advice,
                            index: 0,
                        },
                        rotation: 0,
                    },
                    "0x2",
                ),
                (
                    VirtualCell {
                        name: "",
                        column: Column {
                            column_type: Advice,
                            index: 0,
                        },
                        rotation: 1,
                    },
                    "0x7",
                ),
                (
                    VirtualCell {
                        name: "",
                        column: Column {
                            column_type: Advice,
                            index: 1,
                        },
                        rotation: 0,
                    },
                    "0x3",
                ),
            ],
        },

I'd like to also get a pretty printed version of the error above:

Constraint "mull" not satisfied in region "mul" at offset 0
 s_mul * (lhs * rhs - out)
 = 1 * (2 * 3 - 7)
 = -1

#681 is a step towards being able to pretty print, but is insufficient for the example above.
Queries at rotations having different variable names, and substitution of simple selectors (s_mul) require extending queries and or the Expression AST with metadata.

@str4d
Copy link
Contributor

str4d commented Oct 18, 2022

Have you tried using MockProver::assert_satisfied instead of MockProver::verify? assert_satisfied pretty-prints the errors (except for permutation errors IIRC which haven't had a pretty printer implemented yet) before panicking. verify returns the typed errors and doesn't print anything because it is enabling the caller to programmatically introspect the errors (e.g. to check that an expected error does occur for some test circuit) rather than visually do so.

@moreSocratic
Copy link
Author

moreSocratic commented Oct 18, 2022

I had not, That's a lot better. The only real improvement would be preserving variable names.

@str4d str4d added A-dev-tooling Area: Developer tooling A-errors Area: Error handling labels Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dev-tooling Area: Developer tooling A-errors Area: Error handling
Projects
None yet
Development

No branches or pull requests

2 participants