diff --git a/Cargo.lock b/Cargo.lock index cab9efe6..ba27be6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -795,6 +795,19 @@ dependencies = [ "termcolor", ] +[[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" @@ -1158,6 +1171,7 @@ name = "halo2-mpt-circuits" version = "0.1.0" dependencies = [ "bencher", + "env_logger 0.9.3", "ethers-core", "halo2_proofs", "hex", @@ -1210,7 +1224,7 @@ dependencies = [ "blake2b_simd", "cfg-if 0.1.10", "crossbeam", - "env_logger", + "env_logger 0.8.4", "ff 0.12.1", "group 0.12.1", "halo2curves 0.3.1 (git+https://github.com/scroll-tech/halo2curves.git?branch=0.3.1-derive-serde)", diff --git a/Cargo.toml b/Cargo.toml index 18cecdd1..a5bded41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ num-bigint = "0.4" hex = "0.4" thiserror = "1.0" log = "0.4" +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" } @@ -30,6 +31,7 @@ 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"] +default = ["halo2_proofs/mock-batch-inv", "halo2_proofs/parallel_syn"] [dev-dependencies] mpt-zktrie = { git = "https://github.com/scroll-tech/zkevm-circuits.git", rev = "7d9bc181953cfc6e7baf82ff0ce651281fd70a8a" } diff --git a/src/constraint_builder/column.rs b/src/constraint_builder/column.rs index 45351e16..75d472f3 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 9fe7163d..09602e9e 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 0ea9df52..c97c1cd4 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -147,6 +147,7 @@ fn verifying_key_constant() { #[test] fn all_padding() { + env_logger::init(); mock_prove(vec![]); } @@ -816,6 +817,7 @@ fn empty_storage_type_1_update_c() { #[test] fn multiple_updates() { + env_logger::init(); let witness = vec![ ( MPTProofType::StorageChanged,