From 5fbd0c461df14b4622e915d3c70482ad707ceb04 Mon Sep 17 00:00:00 2001 From: CPerezz Date: Mon, 15 Aug 2022 16:39:10 +0200 Subject: [PATCH 1/3] change: Fixed value usage for randomness fields in tests --- circuit-benchmarks/src/tx_circuit.rs | 2 +- integration-tests/tests/circuits.rs | 2 +- zkevm-circuits/src/evm_circuit/witness.rs | 2 +- zkevm-circuits/src/state_circuit/test.rs | 6 +++--- zkevm-circuits/src/super_circuit.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/circuit-benchmarks/src/tx_circuit.rs b/circuit-benchmarks/src/tx_circuit.rs index f5f1fbd16c..7b681583d2 100644 --- a/circuit-benchmarks/src/tx_circuit.rs +++ b/circuit-benchmarks/src/tx_circuit.rs @@ -59,7 +59,7 @@ mod tests { s: word!("0x61159fa4664b698ea7d518526c96cd94cf4d8adf418000754be106a3a133f866"), }]; - let randomness = Fr::random(&mut rng); + let randomness = Fr::from(0xcafeu64); let mut instance: Vec> = (1..POW_RAND_SIZE + 1) .map(|exp| vec![randomness.pow(&[exp as u64, 0, 0, 0]); MAX_TXS * VERIF_HEIGHT]) .collect(); diff --git a/integration-tests/tests/circuits.rs b/integration-tests/tests/circuits.rs index b80dc2b5c0..f88fc102e7 100644 --- a/integration-tests/tests/circuits.rs +++ b/integration-tests/tests/circuits.rs @@ -52,7 +52,7 @@ async fn test_state_circuit_block(block_num: u64) { ..Default::default() }); - let randomness = Fr::rand(); + let randomness = Fr::from(0xcafeu64); let circuit = StateCircuit::::new(randomness, rw_map, 1 << 16); let power_of_randomness = circuit.instance(); diff --git a/zkevm-circuits/src/evm_circuit/witness.rs b/zkevm-circuits/src/evm_circuit/witness.rs index 2851c97d8b..4385ed878a 100644 --- a/zkevm-circuits/src/evm_circuit/witness.rs +++ b/zkevm-circuits/src/evm_circuit/witness.rs @@ -1398,7 +1398,7 @@ pub fn block_convert( code_db: &bus_mapping::state_db::CodeDB, ) -> Block { Block { - randomness: Fr::rand(), + randomness: Fr::from(0xcafeu64), context: block.into(), rws: RwMap::from(&block.container), txs: block diff --git a/zkevm-circuits/src/state_circuit/test.rs b/zkevm-circuits/src/state_circuit/test.rs index 9caa98de4f..48e5c27c3a 100644 --- a/zkevm-circuits/src/state_circuit/test.rs +++ b/zkevm-circuits/src/state_circuit/test.rs @@ -91,7 +91,7 @@ fn test_state_circuit_ok( ..Default::default() }); - let randomness = Fr::rand(); + let randomness = Fr::from(0xcafeu64); let circuit = StateCircuit::::new(randomness, rw_map, N_ROWS); let power_of_randomness = circuit.instance(); @@ -109,7 +109,7 @@ fn degree() { #[test] fn verifying_key_independent_of_rw_length() { - let randomness = Fr::rand(); + let randomness = Fr::from(0xcafeu64); let degree = 17; let params = Params::::unsafe_setup::(degree); @@ -981,7 +981,7 @@ fn bad_initial_tx_receipt_value() { } fn prover(rows: Vec, overrides: HashMap<(AdviceColumn, isize), Fr>) -> MockProver { - let randomness = Fr::rand(); + let randomness = Fr::from(0xcafeu64); let circuit = StateCircuit:: { randomness, rows, diff --git a/zkevm-circuits/src/super_circuit.rs b/zkevm-circuits/src/super_circuit.rs index c9e1013163..03bd19bb82 100644 --- a/zkevm-circuits/src/super_circuit.rs +++ b/zkevm-circuits/src/super_circuit.rs @@ -426,7 +426,7 @@ mod super_circuit_tests { .handle_block(&block.eth_block, &block.geth_traces) .expect("could not handle block tx"); let mut block = block_convert(&builder.block, &builder.code_db); - block.randomness = Fr::random(&mut rng); + block.randomness = Fr::from(0xcafeu64); let aux_generator = ::CurveExt::random(&mut rng).to_affine(); From 3f7e47175381be0f0744ed515ab9c1f1f30ccc7f Mon Sep 17 00:00:00 2001 From: CPerezz Date: Mon, 15 Aug 2022 16:42:22 +0200 Subject: [PATCH 2/3] Remove unused imports --- zkevm-circuits/src/state_circuit/test.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/zkevm-circuits/src/state_circuit/test.rs b/zkevm-circuits/src/state_circuit/test.rs index 48e5c27c3a..e9fb24ed22 100644 --- a/zkevm-circuits/src/state_circuit/test.rs +++ b/zkevm-circuits/src/state_circuit/test.rs @@ -14,7 +14,6 @@ use eth_types::{ use gadgets::binary_number::AsBits; use halo2_proofs::poly::commitment::Params; use halo2_proofs::{ - arithmetic::BaseExt, dev::{MockProver, VerifyFailure}, pairing::bn256::{Bn256, Fr, G1Affine}, plonk::{keygen_vk, Advice, Circuit, Column, ConstraintSystem}, From 0a2d370eb947fb1512324883103ae1d9ce7b0ac5 Mon Sep 17 00:00:00 2001 From: CPerezz Date: Mon, 15 Aug 2022 17:15:14 +0200 Subject: [PATCH 3/3] remove unused deps --- circuit-benchmarks/src/tx_circuit.rs | 2 +- integration-tests/tests/circuits.rs | 1 - zkevm-circuits/src/evm_circuit/witness.rs | 2 +- zkevm-circuits/src/super_circuit.rs | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/circuit-benchmarks/src/tx_circuit.rs b/circuit-benchmarks/src/tx_circuit.rs index 7b681583d2..03ed22aca6 100644 --- a/circuit-benchmarks/src/tx_circuit.rs +++ b/circuit-benchmarks/src/tx_circuit.rs @@ -7,7 +7,7 @@ mod tests { use env_logger::Env; use eth_types::{address, geth_types::Transaction, word, Bytes}; use group::{Curve, Group}; - use halo2_proofs::arithmetic::{BaseExt, CurveAffine, Field}; + use halo2_proofs::arithmetic::{BaseExt, CurveAffine}; use halo2_proofs::plonk::{create_proof, keygen_pk, keygen_vk, verify_proof, SingleVerifier}; use halo2_proofs::{ pairing::bn256::{Bn256, Fr, G1Affine}, diff --git a/integration-tests/tests/circuits.rs b/integration-tests/tests/circuits.rs index f88fc102e7..e44206027f 100644 --- a/integration-tests/tests/circuits.rs +++ b/integration-tests/tests/circuits.rs @@ -27,7 +27,6 @@ async fn test_evm_circuit_block(block_num: u64) { } async fn test_state_circuit_block(block_num: u64) { - use halo2_proofs::arithmetic::BaseExt; use halo2_proofs::pairing::bn256::Fr; log::info!("test state circuit, block number: {}", block_num); diff --git a/zkevm-circuits/src/evm_circuit/witness.rs b/zkevm-circuits/src/evm_circuit/witness.rs index 4385ed878a..c542237cbb 100644 --- a/zkevm-circuits/src/evm_circuit/witness.rs +++ b/zkevm-circuits/src/evm_circuit/witness.rs @@ -20,7 +20,7 @@ use bus_mapping::{ use eth_types::{evm_types::OpcodeId, ToWord}; use eth_types::{Address, Field, ToLittleEndian, ToScalar, Word}; use eth_types::{ToAddress, U256}; -use halo2_proofs::arithmetic::{BaseExt, FieldExt}; +use halo2_proofs::arithmetic::FieldExt; use halo2_proofs::pairing::bn256::Fr; use itertools::Itertools; use sha3::{Digest, Keccak256}; diff --git a/zkevm-circuits/src/super_circuit.rs b/zkevm-circuits/src/super_circuit.rs index 03bd19bb82..ff7eddf79b 100644 --- a/zkevm-circuits/src/super_circuit.rs +++ b/zkevm-circuits/src/super_circuit.rs @@ -290,7 +290,7 @@ mod super_circuit_tests { }; use ethers_signers::{LocalWallet, Signer}; use group::{Curve, Group}; - use halo2_proofs::arithmetic::{CurveAffine, Field as Halo2Field}; + use halo2_proofs::arithmetic::CurveAffine; use halo2_proofs::dev::{MockProver, VerifyFailure}; use halo2_proofs::pairing::bn256::Fr; use mock::{TestContext, MOCK_CHAIN_ID};