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

Update halo2 dependency to v2023_04_20 #1374

Merged
merged 7 commits into from
May 4, 2023
Merged

Conversation

ed255
Copy link
Member

@ed255 ed255 commented Apr 28, 2023

Description

Update halo2 to the latest dependency, which contains some changes affecting the ff trait.

Issue Link

Resolve #1366

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Rationale

I've extended the Field trait we define in eth_types to contain the common traits used in different places, to avoid having a custom list of traits in each function.

@github-actions github-actions bot added crate-bus-mapping Issues related to the bus-mapping workspace member crate-circuit-benchmarks Issues related to the circuit-benchmarks workspace member crate-eth-types Issues related to the eth-types workspace member crate-gadgets Issues related to the gadgets workspace member crate-integration-tests Issues related to the integration-tests workspace member crate-keccak Issues related to the keccak workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member T-bench Type: benchmark improvements labels Apr 28, 2023
@ed255 ed255 force-pushed the feature/update-halo2-v2023_04_20 branch 6 times, most recently from fb9da38 to f483bec Compare April 28, 2023 14:29
@ed255 ed255 marked this pull request as draft April 28, 2023 14:54
@ed255
Copy link
Member Author

ed255 commented Apr 28, 2023

Currently many tests are failing at a new assertion from halo2 mock prover assignment here:
https://github.com/privacy-scaling-explorations/halo2/blob/17e9765c199670534c0299c96128d0464a188d0b/halo2_proofs/src/dev.rs#L466
This assert panics when a cell is re-assigned with a different value. I have observed panics in three places:

  • evm_circuit: The assignment is coming from StoredExpression / CachedRegion. I need to look further why cells are re-assigned with different values
  • state_circuit: Negative tests do re-assignment of different values on purpose, so it's not clear how this can be fixed
  • tx_circuit: I haven't checked it yet

@CPerezz
Copy link
Member

CPerezz commented May 2, 2023

Need help with that?

@ed255
Copy link
Member Author

ed255 commented May 2, 2023

Need help with that?

I think I do 🥲
So far I have solved the failures in the tx_circuit. They were unrelated to cell re-assignment.
I've also checked the evm_circuit failure. So here's a summary of where we are:

In privacy-scaling-explorations/halo2#129 Han introduced a check for the mock prover advice assignment with the following comment: Inconsistent assignment between different phases.. As far as I see the check also applies when doing inconsistent assignment in the same phase. Now we have:

  • evm_circuit: The assignment is coming from StoredExpression / CachedRegion. To assign each execution step, we do an optimistic assignment of the next step because sometimes expressions in the current step need values of the next one. I say optimistic because there are some values of the next step that are not known yet, so we first do an assignment that may not be correct, and then re-do it with the correct values.
  • state_circuit: Negative tests do re-assignment of different values on purpose, so it's not clear how this can be fixed

Both cases seem reasonable to me, and they are not friendly to the re-assignment with different value check. So I would like help on ideas to proceed!

I have thought about using the Cached region to first store all the assignments (where we can re-assign freely), and after everything is assigned, we do the real assignment. I think this would add a lot of unneeded complexity. Moreover, the assignment function returns an AssignedCell which can't be constructed outside of halo2

The other option that comes to my mind is to disable the re-assignment check, maybe with a toggle in the MockProver, or something like that, and then we can disable it for the EVM and state circuits tests. Nevertheless that means we lose the original feature.

A final option is to redo the feature to make the MockProver complain on reassignment with different values, only when the new assignment is in a different phase. For that we would need to store the phase of each assignment, which would add some overhead.

@CPerezz
Copy link
Member

CPerezz commented May 3, 2023

I have thought about using the Cached region to first store all the assignments (where we can re-assign freely), and after everything is assigned, we do the real assignment. I think this would add a lot of unneeded complexity. Moreover, the assignment function returns an AssignedCell which can't be constructed outside of halo2

Agree this is not a way.

The other option that comes to my mind is to disable the re-assignment check, maybe with a toggle in the MockProver, or something like that, and then we can disable it for the EVM and state circuits tests. Nevertheless that means we lose the original feature.

A final option is to redo the feature to make the MockProver complain on reassignment with different values, only when the new assignment is in a different phase. For that we would need to store the phase of each assignment, which would add some overhead.

Do we really want the check?? It just seems there's no good solution for the state circuit case. Let's just get ridd of it for now?

@ed255 ed255 force-pushed the feature/update-halo2-v2023_04_20 branch from 29d2d89 to 4d1544d Compare May 3, 2023 15:10
@ed255 ed255 marked this pull request as ready for review May 3, 2023 15:10
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! Nice work! Just some nits that could be ignored, and also a question about halo2 dependency.

gadgets/src/less_than.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/copy_circuit.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/copy_circuit.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/copy_circuit/test.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/tx_circuit/sign_verify.rs Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
ed255 added 6 commits May 4, 2023 11:38
Path to a recent commit from halo2 that contains a removal of an aggresive
check that caused many tests to fail, eventhough the tests and the circuits are
OK.  See privacy-scaling-explorations/halo2#179

Cargo doesn't support patching a git repository to point to the same repository
with different branch/rev/tag.  So I'm abusing the fact that previously our
github organization was `appliedzkp` to trick Cargo into thinking it's a
different git repo (but it's just an alias from github).
@ed255 ed255 force-pushed the feature/update-halo2-v2023_04_20 branch from 5000d53 to da4d798 Compare May 4, 2023 13:16
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.

All LGTM now!

Copy link
Contributor

@davidnevadoc davidnevadoc left a comment

Choose a reason for hiding this comment

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

All LGTM 👍

zkevm-circuits/src/bytecode_circuit/test.rs Show resolved Hide resolved
@ed255 ed255 added this pull request to the merge queue May 4, 2023
Merged via the queue into main with commit b8ae7af May 4, 2023
@CPerezz CPerezz deleted the feature/update-halo2-v2023_04_20 branch May 4, 2023 15:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate-bus-mapping Issues related to the bus-mapping workspace member crate-circuit-benchmarks Issues related to the circuit-benchmarks workspace member crate-eth-types Issues related to the eth-types workspace member crate-gadgets Issues related to the gadgets workspace member crate-integration-tests Issues related to the integration-tests workspace member crate-keccak Issues related to the keccak workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member T-bench Type: benchmark improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade Halo2 version to v2023_04_20
4 participants