|
1 | 1 | #![cfg(feature = "circuits")]
|
2 | 2 |
|
3 |
| -use bus_mapping::circuit_input_builder::BuilderClient; |
| 3 | +use bus_mapping::circuit_input_builder::{BuilderClient, ExecState}; |
| 4 | +use bus_mapping::evm::OpcodeId; |
4 | 5 | use bus_mapping::operation::OperationContainer;
|
5 | 6 | use halo2_proofs::dev::MockProver;
|
6 |
| -use integration_tests::{get_client, log_init, GenDataOutput}; |
| 7 | +use integration_tests::{get_client, log_init, GenDataOutput, END_BLOCK, START_BLOCK}; |
7 | 8 | use lazy_static::lazy_static;
|
8 | 9 | use log::trace;
|
9 | 10 | use zkevm_circuits::evm_circuit::witness::RwMap;
|
10 | 11 | use zkevm_circuits::evm_circuit::{
|
11 |
| - test::run_test_circuit_complete_fixed_table, witness::block_convert, |
| 12 | + test::run_test_circuit_complete_fixed_table, test::run_test_circuit_incomplete_fixed_table, |
| 13 | + witness::block_convert, |
12 | 14 | };
|
13 | 15 | use zkevm_circuits::state_circuit::StateCircuit;
|
14 | 16 |
|
15 | 17 | lazy_static! {
|
16 | 18 | pub static ref GEN_DATA: GenDataOutput = GenDataOutput::load();
|
17 | 19 | }
|
18 | 20 |
|
| 21 | +#[tokio::test] |
| 22 | +async fn test_evm_circuit_all_block() { |
| 23 | + log_init(); |
| 24 | + let start: usize = *START_BLOCK; |
| 25 | + let end: usize = *END_BLOCK; |
| 26 | + for blk in start..=end { |
| 27 | + test_evm_circuit_block(blk as u64).await; |
| 28 | + } |
| 29 | +} |
| 30 | + |
19 | 31 | async fn test_evm_circuit_block(block_num: u64) {
|
20 | 32 | log::info!("test evm circuit, block number: {}", block_num);
|
21 | 33 | let cli = get_client();
|
22 | 34 | let cli = BuilderClient::new(cli).await.unwrap();
|
23 | 35 | let builder = cli.gen_inputs(block_num).await.unwrap();
|
24 | 36 |
|
| 37 | + if builder.block.txs.is_empty() { |
| 38 | + log::info!("skip empty block"); |
| 39 | + return; |
| 40 | + } |
| 41 | + |
25 | 42 | let block = block_convert(&builder.block, &builder.code_db);
|
26 |
| - run_test_circuit_complete_fixed_table(block).expect("evm_circuit verification failed"); |
| 43 | + let need_bitwise_lookup = builder.block.txs.iter().any(|tx| { |
| 44 | + tx.steps().iter().any(|step| { |
| 45 | + matches!( |
| 46 | + step.exec_state, |
| 47 | + ExecState::Op(OpcodeId::ADD) |
| 48 | + | ExecState::Op(OpcodeId::OR) |
| 49 | + | ExecState::Op(OpcodeId::XOR) |
| 50 | + ) |
| 51 | + }) |
| 52 | + }); |
| 53 | + if need_bitwise_lookup { |
| 54 | + run_test_circuit_complete_fixed_table(block).expect("evm_circuit verification failed"); |
| 55 | + } else { |
| 56 | + run_test_circuit_incomplete_fixed_table(block).expect("evm_circuit verification failed"); |
| 57 | + } |
27 | 58 | }
|
28 | 59 |
|
29 | 60 | async fn test_state_circuit_block(block_num: u64) {
|
|
0 commit comments