Skip to content

Commit

Permalink
Increase max_rws in CircuitParams::default (privacy-scaling-explorati…
Browse files Browse the repository at this point in the history
…ons#862)

- Increase the default max_rws in CircutParams so that less tests require a
  custom value, from 256 to 1000.
- Enable integration tests on Pull Request because they are fast enough
  (currently integration tests takes ~7m while unit tests take ~9m)

Co-authored-by: Zhang Zhuo <[email protected]>
  • Loading branch information
ed255 and lispc authored Nov 1, 2022
1 parent 6984977 commit b645b98
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 97 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Integration Tests

on:
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
push:
branches:
- main
Expand Down
2 changes: 1 addition & 1 deletion bus-mapping/src/circuit_input_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Default for CircuitsParams {
/// Default values for most of the unit tests of the Circuit Parameters
fn default() -> Self {
CircuitsParams {
max_rws: 256,
max_rws: 1000,
max_txs: 1,
}
}
Expand Down
19 changes: 2 additions & 17 deletions bus-mapping/src/evm/opcodes/return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ fn handle_create(

#[cfg(test)]
mod return_tests {
use crate::circuit_input_builder::CircuitsParams;
use crate::mock::BlockData;
use eth_types::geth_types::GethData;
use eth_types::{bytecode, word};
Expand Down Expand Up @@ -273,14 +272,7 @@ mod return_tests {
.unwrap()
.into();

let mut builder = BlockData::new_from_geth_data_with_params(
block.clone(),
CircuitsParams {
max_rws: 512,
..Default::default()
},
)
.new_circuit_input_builder();
let mut builder = BlockData::new_from_geth_data(block.clone()).new_circuit_input_builder();
builder
.handle_block(&block.eth_block, &block.geth_traces)
.unwrap();
Expand Down Expand Up @@ -338,14 +330,7 @@ mod return_tests {
.unwrap()
.into();

let mut builder = BlockData::new_from_geth_data_with_params(
block.clone(),
CircuitsParams {
max_rws: 512,
..Default::default()
},
)
.new_circuit_input_builder();
let mut builder = BlockData::new_from_geth_data(block.clone()).new_circuit_input_builder();
builder
.handle_block(&block.eth_block, &block.geth_traces)
.unwrap();
Expand Down
19 changes: 2 additions & 17 deletions bus-mapping/src/evm/opcodes/returndatacopy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ impl Opcode for Returndatacopy {

#[cfg(test)]
mod return_tests {
use crate::circuit_input_builder::CircuitsParams;
use crate::mock::BlockData;
use eth_types::geth_types::GethData;
use eth_types::{bytecode, word};
Expand Down Expand Up @@ -112,14 +111,7 @@ mod return_tests {
.unwrap()
.into();

let mut builder = BlockData::new_from_geth_data_with_params(
block.clone(),
CircuitsParams {
max_rws: 512,
..Default::default()
},
)
.new_circuit_input_builder();
let mut builder = BlockData::new_from_geth_data(block.clone()).new_circuit_input_builder();
builder
.handle_block(&block.eth_block, &block.geth_traces)
.unwrap();
Expand Down Expand Up @@ -183,14 +175,7 @@ mod return_tests {
.unwrap()
.into();

let mut builder = BlockData::new_from_geth_data_with_params(
block.clone(),
CircuitsParams {
max_rws: 512,
..Default::default()
},
)
.new_circuit_input_builder();
let mut builder = BlockData::new_from_geth_data(block.clone()).new_circuit_input_builder();
builder
.handle_block(&block.eth_block, &block.geth_traces)
.unwrap();
Expand Down
12 changes: 9 additions & 3 deletions integration-tests/tests/circuit_input_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ lazy_static! {

async fn test_circuit_input_builder_block(block_num: u64) {
let cli = get_client();
let cli = BuilderClient::new(cli, CircuitsParams::default())
.await
.unwrap();
let cli = BuilderClient::new(
cli,
CircuitsParams {
max_rws: 16384,
max_txs: 1,
},
)
.await
.unwrap();

// 1. Query geth for Block, Txs and TxExecTraces
let (eth_block, geth_trace) = cli.get_block(block_num).await.unwrap();
Expand Down
25 changes: 10 additions & 15 deletions integration-tests/tests/circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ lazy_static! {
pub static ref GEN_DATA: GenDataOutput = GenDataOutput::load();
}

const CIRCUITS_PARAMS: CircuitsParams = CircuitsParams {
max_rws: 16384,
max_txs: 4,
};

async fn test_evm_circuit_block(block_num: u64) {
log::info!("test evm circuit, block number: {}", block_num);
let cli = get_client();
let cli = BuilderClient::new(cli, CircuitsParams::default())
.await
.unwrap();
let cli = BuilderClient::new(cli, CIRCUITS_PARAMS).await.unwrap();
let (builder, _) = cli.gen_inputs(block_num).await.unwrap();

let block = block_convert(&builder.block, &builder.code_db);
Expand All @@ -44,9 +47,7 @@ async fn test_evm_circuit_block(block_num: u64) {
async fn test_state_circuit_block(block_num: u64) {
log::info!("test state circuit, block number: {}", block_num);
let cli = get_client();
let cli = BuilderClient::new(cli, CircuitsParams::default())
.await
.unwrap();
let cli = BuilderClient::new(cli, CIRCUITS_PARAMS).await.unwrap();
let (builder, _) = cli.gen_inputs(block_num).await.unwrap();

// Generate state proof
Expand Down Expand Up @@ -79,9 +80,7 @@ async fn test_tx_circuit_block(block_num: u64) {

log::info!("test tx circuit, block number: {}", block_num);
let cli = get_client();
let cli = BuilderClient::new(cli, CircuitsParams::default())
.await
.unwrap();
let cli = BuilderClient::new(cli, CIRCUITS_PARAMS).await.unwrap();

let (_, eth_block) = cli.gen_inputs(block_num).await.unwrap();
let txs: Vec<_> = eth_block
Expand Down Expand Up @@ -113,9 +112,7 @@ pub async fn test_bytecode_circuit_block(block_num: u64) {

log::info!("test bytecode circuit, block number: {}", block_num);
let cli = get_client();
let cli = BuilderClient::new(cli, CircuitsParams::default())
.await
.unwrap();
let cli = BuilderClient::new(cli, CIRCUITS_PARAMS).await.unwrap();
let (builder, _) = cli.gen_inputs(block_num).await.unwrap();
let bytecodes: Vec<Vec<u8>> = builder.code_db.0.values().cloned().collect();

Expand All @@ -127,9 +124,7 @@ pub async fn test_copy_circuit_block(block_num: u64) {

log::info!("test copy circuit, block number: {}", block_num);
let cli = get_client();
let cli = BuilderClient::new(cli, CircuitsParams::default())
.await
.unwrap();
let cli = BuilderClient::new(cli, CIRCUITS_PARAMS).await.unwrap();
let (builder, _) = cli.gen_inputs(block_num).await.unwrap();
let block = block_convert(&builder.block, &builder.code_db);

Expand Down
27 changes: 3 additions & 24 deletions zkevm-circuits/src/evm_circuit/execution/calldatacopy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ impl<F: Field> ExecutionGadget<F> for CallDataCopyGadget<F> {

#[cfg(test)]
mod test {
use crate::{evm_circuit::test::rand_bytes, test_util::run_test_circuits_with_params};
use bus_mapping::circuit_input_builder::CircuitsParams;
use crate::{evm_circuit::test::rand_bytes, test_util::run_test_circuits};
use eth_types::{bytecode, ToWord, Word};
use mock::test_ctx::{helpers::*, TestContext};

Expand Down Expand Up @@ -288,17 +287,7 @@ mod test {
)
.unwrap();

assert_eq!(
run_test_circuits_with_params(
ctx,
None,
CircuitsParams {
max_rws: 1024,
..Default::default()
}
),
Ok(())
);
assert_eq!(run_test_circuits(ctx, None,), Ok(()));
}

fn test_ok_internal(
Expand Down Expand Up @@ -354,17 +343,7 @@ mod test {
)
.unwrap();

assert_eq!(
run_test_circuits_with_params(
ctx,
None,
CircuitsParams {
max_rws: 1024,
..Default::default()
}
),
Ok(())
);
assert_eq!(run_test_circuits(ctx, None,), Ok(()));
}

#[test]
Expand Down
9 changes: 2 additions & 7 deletions zkevm-circuits/src/evm_circuit/execution/codecopy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,10 @@ impl<F: Field> ExecutionGadget<F> for CodeCopyGadget<F> {

#[cfg(test)]
mod tests {
use bus_mapping::circuit_input_builder::CircuitsParams;
use eth_types::{bytecode, Word};
use mock::TestContext;

use crate::test_util::run_test_circuits_with_params;
use crate::test_util::run_test_circuits;

fn test_ok(memory_offset: usize, code_offset: usize, size: usize, large: bool) {
let mut code = bytecode! {};
Expand All @@ -222,13 +221,9 @@ mod tests {
code.append(&tail);

assert_eq!(
run_test_circuits_with_params(
run_test_circuits(
TestContext::<2, 1>::simple_ctx_with_bytecode(code).unwrap(),
None,
CircuitsParams {
max_rws: 1024,
..Default::default()
}
),
Ok(()),
);
Expand Down
17 changes: 4 additions & 13 deletions zkevm-circuits/src/evm_circuit/execution/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,11 @@ impl<F: Field> ExecutionGadget<F> for LogGadget<F> {

#[cfg(test)]
mod test {
use bus_mapping::circuit_input_builder::CircuitsParams;
use eth_types::{evm_types::OpcodeId, Bytecode, Word};
use mock::TestContext;
use rand::Rng;

use crate::test_util::run_test_circuits_with_params;
use crate::test_util::run_test_circuits;

//TODO:add is_persistent = false cases
#[test]
Expand Down Expand Up @@ -346,13 +345,9 @@ mod test {
code_prepare.append(&code);

assert_eq!(
run_test_circuits_with_params(
run_test_circuits(
TestContext::<2, 1>::simple_ctx_with_bytecode(code_prepare).unwrap(),
None,
CircuitsParams {
max_rws: 512,
..Default::default()
}
None
),
Ok(()),
);
Expand Down Expand Up @@ -405,13 +400,9 @@ mod test {
code_prepare.append(&code);

assert_eq!(
run_test_circuits_with_params(
run_test_circuits(
TestContext::<2, 1>::simple_ctx_with_bytecode(code_prepare).unwrap(),
None,
CircuitsParams {
max_rws: 1024,
..Default::default()
}
),
Ok(()),
);
Expand Down

0 comments on commit b645b98

Please sign in to comment.