Skip to content

Commit

Permalink
Gather all test-related into test mod. (privacy-scaling-explorations#…
Browse files Browse the repository at this point in the history
…1300)

### Issue Link

* First mentioned in privacy-scaling-explorations#953 

* Pr link
This is the second pr for this. The older one privacy-scaling-explorations#1003 is abandoned as
there are too much conflicts.


### Contents
* Gather test related into test mod.
* Gather most of the `impl Circuit` into `dev.mod`
This is for distinct the `test-circuits` and the test features. privacy-scaling-explorations#1144
  • Loading branch information
SuccinctPaul authored Apr 10, 2023
1 parent 8aed587 commit 0e76d2b
Show file tree
Hide file tree
Showing 46 changed files with 1,953 additions and 1,908 deletions.
2 changes: 1 addition & 1 deletion circuit-benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.gi
ark-std = { version = "0.3", features = ["print-trace"] }
zkevm-circuits = { path = "../zkevm-circuits", features = ["test"]}
keccak256 = { path = "../keccak256" }
bus-mapping = { path = "../bus-mapping" }
bus-mapping = { path = "../bus-mapping", features = ["test"] }
rand_xorshift = "0.3"
rand = "0.8"
itertools = "0.10"
Expand Down
6 changes: 3 additions & 3 deletions circuit-benchmarks/src/bytecode_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod tests {
use std::env::var;
use zkevm_circuits::bytecode_circuit::bytecode_unroller::{unroll, UnrolledBytecode};

use zkevm_circuits::bytecode_circuit::circuit::BytecodeCircuit;
use zkevm_circuits::bytecode_circuit::TestBytecodeCircuit;

#[cfg_attr(not(feature = "benches"), ignore)]
#[test]
Expand All @@ -51,7 +51,7 @@ mod tests {
let bytecodes_num: usize = max_bytecode_row_num / bytecode_len;

// Create the circuit
let bytecode_circuit = BytecodeCircuit::<Fr>::new(
let bytecode_circuit = TestBytecodeCircuit::<Fr>::new(
fillup_codebytes(bytecodes_num, bytecode_len),
2usize.pow(degree),
);
Expand Down Expand Up @@ -88,7 +88,7 @@ mod tests {
Challenge255<G1Affine>,
XorShiftRng,
Blake2bWrite<Vec<u8>, G1Affine, Challenge255<G1Affine>>,
BytecodeCircuit<Fr>,
TestBytecodeCircuit<Fr>,
>(
&general_params,
&pk,
Expand Down
6 changes: 3 additions & 3 deletions circuit-benchmarks/src/copy_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod tests {
use rand_xorshift::XorShiftRng;
use std::env::var;
use zkevm_circuits::{
copy_circuit::CopyCircuit,
copy_circuit::TestCopyCircuit,
evm_circuit::witness::{block_convert, Block},
util::SubCircuit,
};
Expand All @@ -52,7 +52,7 @@ mod tests {

// Create the circuit
let block = generate_full_events_block(degree);
let circuit = CopyCircuit::<Fr>::new_from_block(&block);
let circuit = TestCopyCircuit::<Fr>::new_from_block(&block);

// Bench setup generation
let setup_message = format!("{} {} with degree = {}", BENCHMARK_ID, setup_prfx, degree);
Expand All @@ -79,7 +79,7 @@ mod tests {
Challenge255<G1Affine>,
XorShiftRng,
Blake2bWrite<Vec<u8>, G1Affine, Challenge255<G1Affine>>,
CopyCircuit<Fr>,
TestCopyCircuit<Fr>,
>(&general_params, &pk, &[circuit], &[], rng, &mut transcript)
.expect("proof generation should not fail");
let proof = transcript.finalize();
Expand Down
6 changes: 3 additions & 3 deletions circuit-benchmarks/src/evm_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod evm_circ_benches {
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::env::var;
use zkevm_circuits::evm_circuit::{witness::block_convert, EvmCircuit};
use zkevm_circuits::evm_circuit::{witness::block_convert, TestEvmCircuit};

#[cfg_attr(not(feature = "benches"), ignore)]
#[test]
Expand Down Expand Up @@ -56,7 +56,7 @@ mod evm_circ_benches {

let block = block_convert(&builder.block, &builder.code_db).unwrap();

let circuit = EvmCircuit::<Fr>::new(block);
let circuit = TestEvmCircuit::<Fr>::new(block);
let mut rng = XorShiftRng::from_seed([
0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06,
0xbc, 0xe5,
Expand Down Expand Up @@ -87,7 +87,7 @@ mod evm_circ_benches {
Challenge255<G1Affine>,
XorShiftRng,
Blake2bWrite<Vec<u8>, G1Affine, Challenge255<G1Affine>>,
EvmCircuit<Fr>,
TestEvmCircuit<Fr>,
>(
&general_params,
&pk,
Expand Down
6 changes: 3 additions & 3 deletions circuit-benchmarks/src/exp_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod tests {
use std::env::var;
use zkevm_circuits::{
evm_circuit::witness::{block_convert, Block},
exp_circuit::ExpCircuit,
exp_circuit::TestExpCircuit,
};

#[cfg_attr(not(feature = "benches"), ignore)]
Expand All @@ -50,7 +50,7 @@ mod tests {
let base = Word::from(132);
let exponent = Word::from(27);
let block = generate_full_events_block(degree, base, exponent);
let circuit = ExpCircuit::<Fr>::new(
let circuit = TestExpCircuit::<Fr>::new(
block.exp_events.clone(),
block.circuits_params.max_exp_steps,
);
Expand Down Expand Up @@ -86,7 +86,7 @@ mod tests {
Challenge255<G1Affine>,
XorShiftRng,
Blake2bWrite<Vec<u8>, G1Affine, Challenge255<G1Affine>>,
ExpCircuit<Fr>,
TestExpCircuit<Fr>,
>(
&general_params,
&pk,
Expand Down
6 changes: 3 additions & 3 deletions circuit-benchmarks/src/packed_multi_keccak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod tests {
use rand::SeedableRng;
use rand_xorshift::XorShiftRng;
use std::env::var;
use zkevm_circuits::keccak_circuit::KeccakCircuit;
use zkevm_circuits::keccak_circuit::TestKeccakCircuit;

#[cfg_attr(not(feature = "benches"), ignore)]
#[test]
Expand All @@ -41,7 +41,7 @@ mod tests {
let inputs = vec![(0u8..135).collect::<Vec<_>>(); 3];

// Create the circuit. Leave last dozens of rows for blinding.
let circuit = KeccakCircuit::new(2usize.pow(degree) - 64, inputs);
let circuit = TestKeccakCircuit::new(2usize.pow(degree) - 64, inputs);

// Initialize the polynomial commitment parameters
let mut rng = XorShiftRng::from_seed([
Expand Down Expand Up @@ -74,7 +74,7 @@ mod tests {
Challenge255<G1Affine>,
XorShiftRng,
Blake2bWrite<Vec<u8>, G1Affine, Challenge255<G1Affine>>,
KeccakCircuit<Fr>,
TestKeccakCircuit<Fr>,
>(
&general_params,
&pk,
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lazy_static = "1.4"
ethers = { version = "0.17.0", features = ["ethers-solc"] }
serde_json = "1.0.66"
serde = { version = "1.0.130", features = ["derive"] }
bus-mapping = { path = "../bus-mapping" }
bus-mapping = { path = "../bus-mapping" , features = ["test"] }
eth-types = { path = "../eth-types" }
zkevm-circuits = { path = "../zkevm-circuits", features = ["test"] }
tokio = { version = "1.13", features = ["macros", "rt-multi-thread"] }
Expand Down
28 changes: 14 additions & 14 deletions integration-tests/src/integration_test_circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ use rand_xorshift::XorShiftRng;
use std::{collections::HashMap, marker::PhantomData, sync::Mutex};
use tokio::sync::Mutex as TokioMutex;
use zkevm_circuits::{
bytecode_circuit::circuit::BytecodeCircuit,
copy_circuit::CopyCircuit,
evm_circuit::EvmCircuit,
exp_circuit::ExpCircuit,
keccak_circuit::KeccakCircuit,
state_circuit::StateCircuit,
bytecode_circuit::TestBytecodeCircuit,
copy_circuit::TestCopyCircuit,
evm_circuit::TestEvmCircuit,
exp_circuit::TestExpCircuit,
keccak_circuit::TestKeccakCircuit,
state_circuit::TestStateCircuit,
super_circuit::SuperCircuit,
tx_circuit::TxCircuit,
tx_circuit::TestTxCircuit,
util::SubCircuit,
witness::{block_convert, Block},
};
Expand Down Expand Up @@ -95,35 +95,35 @@ lazy_static! {

lazy_static! {
/// Integration test for EVM circuit
pub static ref EVM_CIRCUIT_TEST: TokioMutex<IntegrationTest<EvmCircuit<Fr>>> =
pub static ref EVM_CIRCUIT_TEST: TokioMutex<IntegrationTest<TestEvmCircuit<Fr>>> =
TokioMutex::new(IntegrationTest::new("EVM", EVM_CIRCUIT_DEGREE));

/// Integration test for State circuit
pub static ref STATE_CIRCUIT_TEST: TokioMutex<IntegrationTest<StateCircuit<Fr>>> =
pub static ref STATE_CIRCUIT_TEST: TokioMutex<IntegrationTest<TestStateCircuit<Fr>>> =
TokioMutex::new(IntegrationTest::new("State", STATE_CIRCUIT_DEGREE));

/// Integration test for State circuit
pub static ref TX_CIRCUIT_TEST: TokioMutex<IntegrationTest<TxCircuit<Fr>>> =
pub static ref TX_CIRCUIT_TEST: TokioMutex<IntegrationTest<TestTxCircuit<Fr>>> =
TokioMutex::new(IntegrationTest::new("Tx", TX_CIRCUIT_DEGREE));

/// Integration test for Bytecode circuit
pub static ref BYTECODE_CIRCUIT_TEST: TokioMutex<IntegrationTest<BytecodeCircuit<Fr>>> =
pub static ref BYTECODE_CIRCUIT_TEST: TokioMutex<IntegrationTest<TestBytecodeCircuit<Fr>>> =
TokioMutex::new(IntegrationTest::new("Bytecode", BYTECODE_CIRCUIT_DEGREE));

/// Integration test for Copy circuit
pub static ref COPY_CIRCUIT_TEST: TokioMutex<IntegrationTest<CopyCircuit<Fr>>> =
pub static ref COPY_CIRCUIT_TEST: TokioMutex<IntegrationTest<TestCopyCircuit<Fr>>> =
TokioMutex::new(IntegrationTest::new("Copy", COPY_CIRCUIT_DEGREE));

/// Integration test for Keccak circuit
pub static ref KECCAK_CIRCUIT_TEST: TokioMutex<IntegrationTest<KeccakCircuit<Fr>>> =
pub static ref KECCAK_CIRCUIT_TEST: TokioMutex<IntegrationTest<TestKeccakCircuit<Fr>>> =
TokioMutex::new(IntegrationTest::new("Keccak", KECCAK_CIRCUIT_DEGREE));

/// Integration test for Copy circuit
pub static ref SUPER_CIRCUIT_TEST: TokioMutex<IntegrationTest<SuperCircuit::<Fr, MAX_TXS, MAX_CALLDATA, TEST_MOCK_RANDOMNESS>>> =
TokioMutex::new(IntegrationTest::new("Super", SUPER_CIRCUIT_DEGREE));

/// Integration test for Exp circuit
pub static ref EXP_CIRCUIT_TEST: TokioMutex<IntegrationTest<ExpCircuit::<Fr>>> =
pub static ref EXP_CIRCUIT_TEST: TokioMutex<IntegrationTest<TestExpCircuit::<Fr>>> =
TokioMutex::new(IntegrationTest::new("Exp", EXP_CIRCUIT_DEGREE));
}

Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ serde_json = "1.0.78"

[features]
default = []
test = ["ethers-signers", "mock"]
test = ["ethers-signers", "mock", "bus-mapping/test"]
test-circuits = []
warn-unimplemented = ["eth-types/warn-unimplemented"]
9 changes: 7 additions & 2 deletions zkevm-circuits/src/bytecode_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
pub mod bytecode_unroller;
/// Bytecode circuit
pub mod circuit;
pub(crate) mod param;

#[cfg(any(feature = "test", test, feature = "test-circuits"))]
mod dev;
/// Bytecode circuit tester
#[cfg(any(feature = "test", test))]
pub mod dev;
pub(crate) mod param;
mod test;
#[cfg(any(feature = "test", test, feature = "test-circuits"))]
pub use dev::BytecodeCircuit as TestBytecodeCircuit;
Loading

0 comments on commit 0e76d2b

Please sign in to comment.