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

Improve mock prover errors printing #182

Merged
merged 6 commits into from
Sep 4, 2024
Merged

Conversation

zemse
Copy link
Collaborator

@zemse zemse commented Sep 3, 2024

  • fmt Goldilocks(18446744069414584319) as -2 as well as Sum Product expressions.
  • include instance id and relevant wit in.

Before

AssertEqualError "test_assert_zero_1/require_equal/a + 1 == b": Left != Right
Left: GoldilocksExt2([Goldilocks(4), Goldilocks(0)])
Right: GoldilocksExt2([Goldilocks(5), Goldilocks(0)])
Left Expression: ScaledSum(WitIn(1), Constant(Goldilocks(1)), Constant(Goldilocks(0)))
Right Expression: Sum(ScaledSum(WitIn(0), Constant(Goldilocks(1)), Constant(Goldilocks(0))), Constant(Goldilocks(1)))

AssertZeroError "test_assert_zero_1/require_zero/c - 2 == 0": Evaluated expression is not zero
Expression: Sum(ScaledSum(WitIn(2), Constant(Goldilocks(1)), Constant(Goldilocks(0))), Constant(Goldilocks(18446744069414584319)))
Evaluation: GoldilocksExt2([Goldilocks(18446744069414584322), Goldilocks(0)])

LookupError "test_lookup_1/assert_u5/assert u5": Evaluated expression does not exist in T vector
Expression: ScaledSum(WitIn(0), Challenge(1, 1, GoldilocksExt2([Goldilocks(1), Goldilocks(0)]), GoldilocksExt2([Goldilocks(0), Goldilocks(0)])), Challenge(0, 1, GoldilocksExt2([Goldilocks(1), Goldilocks(0)]), GoldilocksExt2([Goldilocks(0), Goldilocks(0)])))
Evaluation: GoldilocksExt2([Goldilocks(1000001), Goldilocks(0)])

After

AssertEqualError "test_assert_zero_1/require_equal/a + 1 == b"
Left: GoldilocksExt2[4,0] != Right: GoldilocksExt2[5,0]
Left Expression: 1 * WitIn(1) + 0
Right Expression: 1 * WitIn(0) + 0 + 1
Inst[0]: WitIn(1)=4,WitIn(0)=4

AssertZeroError "test_assert_zero_1/require_zero/c - 2 == 0": Evaluated expression is not zero
Expression: 1 * WitIn(2) + 0 + (-2)
Evaluation: GoldilocksExt2[1,0] != 0
Inst[1]: WitIn(2)=3

LookupError "test_lookup_1/assert_u5/assert u5": Evaluated expression does not exist in T vector
Expression: Challenge(1) * WitIn(0) + Challenge(0)
Evaluation: GoldilocksExt2[1000001,0]
Inst[1]: WitIn(0)=1000

@zemse zemse requested a review from hero78119 September 3, 2024 08:45
Copy link
Collaborator

@hero78119 hero78119 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job for improving the readiblity of error message 👍 👍

Just left some optionally optimisation suggestion

  • some imperative programming style e.g. alloc vec![]; for xxxx {push sth to vec} can either Vec::with_capacity() in advance or use functional style iter().map(||xxxxx).collect()
  • some left over comments can be clean up

ceno_zkvm/src/scheme/mock_prover.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@hero78119 hero78119 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@hero78119 hero78119 merged commit d17b8e7 into scroll-tech:master Sep 4, 2024
4 checks passed
@zemse zemse deleted the mock-prover branch September 23, 2024 19:07
hero78119 added a commit that referenced this pull request Sep 30, 2024
- fmt `Goldilocks(18446744069414584319)` as `-2` as well as `Sum`
`Product` expressions.
- include instance id and relevant wit in.

### Before

```
AssertEqualError "test_assert_zero_1/require_equal/a + 1 == b": Left != Right
Left: GoldilocksExt2([Goldilocks(4), Goldilocks(0)])
Right: GoldilocksExt2([Goldilocks(5), Goldilocks(0)])
Left Expression: ScaledSum(WitIn(1), Constant(Goldilocks(1)), Constant(Goldilocks(0)))
Right Expression: Sum(ScaledSum(WitIn(0), Constant(Goldilocks(1)), Constant(Goldilocks(0))), Constant(Goldilocks(1)))

AssertZeroError "test_assert_zero_1/require_zero/c - 2 == 0": Evaluated expression is not zero
Expression: Sum(ScaledSum(WitIn(2), Constant(Goldilocks(1)), Constant(Goldilocks(0))), Constant(Goldilocks(18446744069414584319)))
Evaluation: GoldilocksExt2([Goldilocks(18446744069414584322), Goldilocks(0)])

LookupError "test_lookup_1/assert_u5/assert u5": Evaluated expression does not exist in T vector
Expression: ScaledSum(WitIn(0), Challenge(1, 1, GoldilocksExt2([Goldilocks(1), Goldilocks(0)]), GoldilocksExt2([Goldilocks(0), Goldilocks(0)])), Challenge(0, 1, GoldilocksExt2([Goldilocks(1), Goldilocks(0)]), GoldilocksExt2([Goldilocks(0), Goldilocks(0)])))
Evaluation: GoldilocksExt2([Goldilocks(1000001), Goldilocks(0)])
```

### After

```
AssertEqualError "test_assert_zero_1/require_equal/a + 1 == b"
Left: GoldilocksExt2[4,0] != Right: GoldilocksExt2[5,0]
Left Expression: 1 * WitIn(1) + 0
Right Expression: 1 * WitIn(0) + 0 + 1
Inst[0]: WitIn(1)=4,WitIn(0)=4

AssertZeroError "test_assert_zero_1/require_zero/c - 2 == 0": Evaluated expression is not zero
Expression: 1 * WitIn(2) + 0 + (-2)
Evaluation: GoldilocksExt2[1,0] != 0
Inst[1]: WitIn(2)=3

LookupError "test_lookup_1/assert_u5/assert u5": Evaluated expression does not exist in T vector
Expression: Challenge(1) * WitIn(0) + Challenge(0)
Evaluation: GoldilocksExt2[1000001,0]
Inst[1]: WitIn(0)=1000
```

---------

Co-authored-by: Ming <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants