Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

fix: Mock Challenges with different values #930

Merged
merged 2 commits into from
Nov 24, 2022
Merged

Conversation

CPerezz
Copy link
Member

@CPerezz CPerezz commented Nov 24, 2022

As mentioned in #926, the Challenges::mock function was not adding different values for the Challenges. Therefore, a new function has been added that allows mocking by passing two different values (one per each challenge).

This allows to keep the API we previously had and also, reduce the need to send always 2 values when only 1 can be passed.

Resolves: #926

I considered to do a Trait-based approach by ussing Add<Output=Self> but Expression<F> does not implement this trait. Same happens for Challenge (the one in Halo2).
Therefore, the easiest way to not break the current API and also, not ask for 2 values when we don't need them to be different (everywhere minus Keccak) is to introduce a new function.

@CPerezz CPerezz requested a review from han0110 November 24, 2022 13:10
@github-actions
Copy link

👋 Comment on this pull request with /test to trigger the integration tests.

@github-actions github-actions bot added the crate-zkevm-circuits Issues related to the zkevm-circuits workspace member label Nov 24, 2022
Copy link
Collaborator

@han0110 han0110 left a comment

Choose a reason for hiding this comment

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

LGTM! Although I think we could just remove the old one and always require 2 different mock randomness, but this also makes it flexible.

@CPerezz
Copy link
Member Author

CPerezz commented Nov 24, 2022

@han0110 will do so then. It just annoys me a lot that we can't just take one and add X to it to det the second one..

But will just require 2 and that's all! Thanks!

As mentioned in #926, the `Challenges::mock` function was not adding
different values for the `Challenges`. Therefore, a new function has
been added that allows mocking by passing two different values (one per
each challenge).

This allows to keep the API we previously had and also, reduce the need
to send always 2 values when only 1 can be passed.

Resolves: #926
@CPerezz
Copy link
Member Author

CPerezz commented Nov 24, 2022

Just rebased. Will merge as soon as CI passes.

Copy link
Member

@ed255 ed255 left a comment

Choose a reason for hiding this comment

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

LGTM! But I have one quick question: I thought the point of this fix was to use different values for each challenge with the mock prover, but you're using block.randomness in both. Is it because it fails when the randomnesses are different?

@CPerezz
Copy link
Member Author

CPerezz commented Nov 24, 2022

LGTM! But I have one quick question: I thought the point of this fix was to use different values for each challenge with the mock prover, but you're using block.randomness in both. Is it because it fails when the randomnesses are different?

The only place where the two are needed is Keccak circuit AFAIK. In the rest of places, I left the same code/config as we had before.

@CPerezz CPerezz merged commit d3a53ab into main Nov 24, 2022
@CPerezz CPerezz deleted the fix_challenges_mocking branch November 24, 2022 16:55
RainFallsSilent pushed a commit to dompute/zkevm-circuits that referenced this pull request Sep 14, 2023
…ions#930)

* wip: preliminary work sig circuit/lookp

* feat: handle panics and edge cases in sig circuit

* fix: handle v not boolean

* fix: fq modulus not assigned and bus-mapping handle overflowing r/s

* fix: sig_v handle invalid values (lookup) and is_valid dev_load fix

* refactor (review comment)

* fix: no sig table lookup for invalid sig_v

* remove wrong test case (assertion fail)
KimiWu123 pushed a commit that referenced this pull request Dec 25, 2023
* wip: preliminary work sig circuit/lookp

* feat: handle panics and edge cases in sig circuit

* fix: handle v not boolean

* fix: fq modulus not assigned and bus-mapping handle overflowing r/s

* fix: sig_v handle invalid values (lookup) and is_valid dev_load fix

* refactor (review comment)

* fix: no sig table lookup for invalid sig_v

* remove wrong test case (assertion fail)
KimiWu123 pushed a commit that referenced this pull request Dec 28, 2023
* wip: preliminary work sig circuit/lookp

* feat: handle panics and edge cases in sig circuit

* fix: handle v not boolean

* fix: fq modulus not assigned and bus-mapping handle overflowing r/s

* fix: sig_v handle invalid values (lookup) and is_valid dev_load fix

* refactor (review comment)

* fix: no sig table lookup for invalid sig_v

* remove wrong test case (assertion fail)
KimiWu123 pushed a commit that referenced this pull request Jan 4, 2024
* wip: preliminary work sig circuit/lookp

* feat: handle panics and edge cases in sig circuit

* fix: handle v not boolean

* fix: fq modulus not assigned and bus-mapping handle overflowing r/s

* fix: sig_v handle invalid values (lookup) and is_valid dev_load fix

* refactor (review comment)

* fix: no sig table lookup for invalid sig_v

* remove wrong test case (assertion fail)
KimiWu123 pushed a commit that referenced this pull request Jan 26, 2024
* wip: preliminary work sig circuit/lookp

* feat: handle panics and edge cases in sig circuit

* fix: handle v not boolean

* fix: fq modulus not assigned and bus-mapping handle overflowing r/s

* fix: sig_v handle invalid values (lookup) and is_valid dev_load fix

* refactor (review comment)

* fix: no sig table lookup for invalid sig_v

* remove wrong test case (assertion fail)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate-zkevm-circuits Issues related to the zkevm-circuits workspace member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undesired behaviour of Challenges::mock for testing multi-challenge circuits
3 participants