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

[WIP] Halo2 24-08-2022 tag update#724

Merged
CPerezz merged 20 commits into
mainfrom
halo2_24_08_2022_update
Sep 1, 2022
Merged

[WIP] Halo2 24-08-2022 tag update#724
CPerezz merged 20 commits into
mainfrom
halo2_24_08_2022_update

Conversation

@CPerezz
Copy link
Copy Markdown
Contributor

@CPerezz CPerezz commented Aug 31, 2022

This PR does several things although all follow the same rationale.

Resolves: #702

As decided on
#634
we're going to use the bit-approach merged there. And so, most of the
circuits here are no longer required/ will be added back when needed.
@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-prover Issues related to the prover workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member T-bench Type: benchmark improvements labels Aug 31, 2022
The first attempt to update the `prover` crate was to basically use full
generics everywhere.

The issue is that we ended up hitting trait safety and the complexity
started to increase significantly.
Hence, since we are always using the same commitment scheme and curve,
it's easier to switch to concrete types.
@CPerezz CPerezz force-pushed the halo2_24_08_2022_update branch from 7d101a7 to eef1d1f Compare August 31, 2022 12:02
@github-actions github-actions Bot removed the crate-prover Issues related to the prover workspace member label Aug 31, 2022
@CPerezz CPerezz marked this pull request as ready for review August 31, 2022 16:16
@CPerezz
Copy link
Copy Markdown
Contributor Author

CPerezz commented Aug 31, 2022

d2ed5bb should fix the issue of composition table is not set, bit lenght: 8. But it doesn't.

I was under the impression that the load of the RangeChip tables was the issue inside of the SignVerify and therefore Tx configs.
I'll need to look at this more carefully tomorrow. Maybe @han0110 has some hint on what can be causing the issue as he did the re-write of the halo2wrong main gate.

@han0110 han0110 self-requested a review September 1, 2022 03:15
@CPerezz
Copy link
Copy Markdown
Contributor Author

CPerezz commented Sep 1, 2022

d2ed5bb should fix the issue of composition table is not set, bit lenght: 8. But it doesn't.

I was under the impression that the load of the RangeChip tables was the issue inside of the SignVerify and therefore Tx configs. I'll need to look at this more carefully tomorrow. Maybe @han0110 has some hint on what can be causing the issue as he did the re-write of the halo2wrong main gate.

d2ed5bb should fix the issue of composition table is not set, bit lenght: 8. But it doesn't.

I was under the impression that the load of the RangeChip tables was the issue inside of the SignVerify and therefore Tx configs. I'll need to look at this more carefully tomorrow. Maybe @han0110 has some hint on what can be causing the issue as he did the re-write of the halo2wrong main gate.

Fixed in 7d753bb.
Now the last error is related to unsatisfied constraints in the signature verification.

Comment thread circuit-benchmarks/src/state_circuit.rs Outdated
Comment thread circuit-benchmarks/src/state_circuit.rs Outdated
Comment thread circuit-benchmarks/src/super_circuit.rs Outdated
Comment thread circuit-benchmarks/src/super_circuit.rs Outdated
Comment thread circuit-benchmarks/src/tx_circuit.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/util/common_gadget.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/util/math_gadget.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/util/math_gadget.rs Outdated
Comment thread zkevm-circuits/src/keccak_circuit/keccak_packed.rs Outdated
Comment thread eth-types/src/sign_types.rs Outdated
@ChihChengLiang ChihChengLiang self-requested a review September 1, 2022 10:18
Co-authored-by: Han <tinghan0110@gmail.com>
@CPerezz
Copy link
Copy Markdown
Contributor Author

CPerezz commented Sep 1, 2022

I highly appreciate all the details you found @han0110 .

I copy pasted the expect messages and did not realize that the types changed..
Also, the error was indeed in the Compressed usage. Thanks for working on it to help me close this!

@CPerezz CPerezz requested a review from han0110 September 1, 2022 11:19
Copy link
Copy Markdown
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

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

LGTM with some nitpicks. Great PR, this can unblock many other prs

Comment thread zkevm-circuits/Cargo.toml

[dependencies]
halo2_proofs = { version = "0.1.0-beta.1" }
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", tag = "v2022_08_19" }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we still need to change here if we already patched halo2_proofs in the [patch.crates-io] section of root Cargo.toml? I remember that's how we did in #555 right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tied here and Cargo is not able to resolve it..

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't so important but I got it to resolve correctly by also updating the version from "0.1.0-beta.1" to "0.2.0"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wow Thanks! I've never seen this behaviour in Cargo. It should also work with 0.1.0-beta no?? LOL

Thanks anyway @pinkiebell . Filled #729 with it!

Comment thread keccak256/src/lib.rs

pub mod arith_helpers;
pub mod circuit;
pub mod common;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How come we still keep some parts of the keccak crate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need them to perform the hashes outside of the circuit and compute witnesses in the CircuitInputBuilder still :)

region,
offset,
Some(if index == pair_index {
Value::known(if index == pair_index {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we now have an expressive way to turn bool to F?

Suggested change
Value::known(if index == pair_index {
Value::known(F::from(index == pair_index))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No that I know.. THe only is F::from(bool as u64)

self.target_odd.assign(
region,
offset,
Value::known(if odd { F::one() } else { F::zero() }),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Value::known(if odd { F::one() } else { F::zero() }),
Value::known(F::from(odd)),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ditto

@CPerezz CPerezz force-pushed the halo2_24_08_2022_update branch from 217398b to 543fa54 Compare September 1, 2022 16:43
@github-actions github-actions Bot removed the crate-bus-mapping Issues related to the bus-mapping workspace member label Sep 1, 2022
@CPerezz CPerezz force-pushed the halo2_24_08_2022_update branch from f46d44f to e4a724d Compare September 1, 2022 17:05
@github-actions github-actions Bot added the crate-bus-mapping Issues related to the bus-mapping workspace member label Sep 1, 2022
Copy link
Copy Markdown
Contributor

@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! Thanks for this great work!

@CPerezz CPerezz merged commit 2783eba into main Sep 1, 2022
@CPerezz CPerezz deleted the halo2_24_08_2022_update branch September 1, 2022 17:36
@CPerezz CPerezz mentioned this pull request Sep 1, 2022
2 tasks
CPerezz added a commit that referenced this pull request Sep 2, 2022
In #724 the patch wasn't working with `0.1.0-beta` so it was left as
TODO.

But thanks to @pinkiebell who pointed out that it was required to bump
the base dep in the multiple Cargo.tomls this was solved.
jonathanpwang pushed a commit to jonathanpwang/zkevm-circuits that referenced this pull request Dec 29, 2022
* change: Update halo2 tag version in all Cargo.toml

* change: Use `Value` instead of `AssignedCell`.

* remove: Strip keccak circuits from the repo

As decided on
privacy-ethereum#634
we're going to use the bit-approach merged there. And so, most of the
circuits here are no longer required/ will be added back when needed.

* tmp

* fix: RegionCtx new API adoption without &mut holding

* change: Use KZG, SHPLONK and Bn256 instead of generics

The first attempt to update the `prover` crate was to basically use full
generics everywhere.

The issue is that we ended up hitting trait safety and the complexity
started to increase significantly.
Hence, since we are always using the same commitment scheme and curve,
it's easier to switch to concrete types.

* remove: Delete prover crate as was migrated to zkevm-chain

* remove: Remove legacy keccak bench file

* remove: Remove `group` dep from all crates Cargo.toml

* update: Port circuit-benchmarks to latest halo2 version

* update: Port integration-tests to newest halo2 release

* Fix errors in zkevm-circuits tests

* fix: Errors introduced in `main` branch merge

* fix: Load range_chip tables in SignVerigy and Tx Configs

* Fix Synthesis and lookup table errors

* fix: Apply suggestions from @han0110 review

Co-authored-by: Han <tinghan0110@gmail.com>

* Fix Signature errors introduced on Compressed treatment

* fix: Fix tests and address review comments

Co-authored-by: Han <tinghan0110@gmail.com>
lispc added a commit that referenced this pull request Aug 28, 2023
* fix returndatacopy len

* lint
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 dependency to latest release

4 participants