diff --git a/Cargo.lock b/Cargo.lock index 941fa01..bb55ee1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -861,9 +861,9 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" -version = "0.13.7" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9775b22bc152ad86a0cf23f0f348b884b26add12bf741e7ffc4d4ab2ab4d205" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -878,6 +878,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "env_logger" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -1248,6 +1261,7 @@ version = "0.1.0" dependencies = [ "bencher", "criterion", + "env_logger", "ethers-core", "halo2_proofs", "hex", @@ -1415,6 +1429,12 @@ dependencies = [ "hmac 0.8.1", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "iana-time-zone" version = "0.1.58" @@ -2620,6 +2640,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "termcolor" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +dependencies = [ + "winapi-util", +] + [[package]] name = "textwrap" version = "0.16.0" diff --git a/Cargo.toml b/Cargo.toml index e45d45b..535efa5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ log = "0.4" mpt-zktrie = { git = "https://github.com/scroll-tech/zkevm-circuits.git", rev = "7d9bc181953cfc6e7baf82ff0ce651281fd70a8a" } rand_chacha = "0.3.0" criterion = { version = "0.4", optional = true} +env_logger = "0.9.0" [patch."https://github.com/privacy-scaling-explorations/halo2.git"] halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "develop" } @@ -33,7 +34,8 @@ ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = " [features] # printout the layout of circuits for demo and some unittests print_layout = ["halo2_proofs/dev-graph"] -bench = [ "dep:criterion" ] +bench = [ "default", "dep:criterion" ] +default = ["halo2_proofs/mock-batch-inv", "halo2_proofs/parallel_syn"] [dev-dependencies] # mpt-zktrie = { path = "../scroll-circuits/zktrie" } diff --git a/src/constraint_builder/column.rs b/src/constraint_builder/column.rs index 45351e1..75d472f 100644 --- a/src/constraint_builder/column.rs +++ b/src/constraint_builder/column.rs @@ -1,4 +1,5 @@ use super::{BinaryQuery, Query}; +use halo2_proofs::plonk::Assigned; use halo2_proofs::{ arithmetic::FieldExt, circuit::{Region, Value}, @@ -101,6 +102,17 @@ impl AdviceColumn { ) .expect("failed assign_advice"); } + + pub fn assign_rational( + &self, + region: &mut Region<'_, F>, + offset: usize, + value: Assigned, + ) { + region + .assign_advice(|| "advice", self.0, offset, || Value::known(value)) + .expect("failed assign_advice"); + } } #[derive(Clone, Copy)] diff --git a/src/gadgets/is_zero.rs b/src/gadgets/is_zero.rs index 9fe7163..09602e9 100644 --- a/src/gadgets/is_zero.rs +++ b/src/gadgets/is_zero.rs @@ -1,4 +1,5 @@ use crate::constraint_builder::{AdviceColumn, BinaryQuery, ConstraintBuilder, Query}; +use halo2_proofs::plonk::Assigned; use halo2_proofs::{arithmetic::FieldExt, circuit::Region, plonk::ConstraintSystem}; use std::fmt::Debug; @@ -25,10 +26,10 @@ impl IsZeroGadget { ) where >::Error: Debug, { - self.inverse_or_zero.assign( + self.inverse_or_zero.assign_rational( region, offset, - value.try_into().unwrap().invert().unwrap_or(F::zero()), + Assigned::::from(value.try_into().unwrap()).invert(), ); } diff --git a/src/tests.rs b/src/tests.rs index 8c56186..03c333d 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -96,6 +96,7 @@ fn verifying_key_constant() { #[test] fn all_padding() { + env_logger::init(); mock_prove(vec![]); } @@ -765,6 +766,7 @@ fn empty_storage_type_1_update_c() { #[test] fn multiple_updates() { + env_logger::init(); let witness = vec![ ( MPTProofType::StorageChanged,