Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit a6acbf0

Browse files
committed
test
1 parent 552630b commit a6acbf0

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

integration-tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ff = "0.11"
2525
pretty_assertions = "1.0.0"
2626

2727
[features]
28-
default = []
28+
default = ["circuits"]
2929
rpc = []
3030
circuit_input_builder = []
3131
circuits = []

integration-tests/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ lazy_static! {
4747
Err(VarError::NotPresent) => GETH0_URL_DEFAULT.to_string(),
4848
Err(e) => panic!("Error in GETH0_URL env var: {:?}", e),
4949
};
50+
/// ..
51+
pub static ref START_BLOCK: usize = match env::var("START_BLOCK") {
52+
Ok(val) => str::parse::<usize>(&val).unwrap(),
53+
Err(VarError::NotPresent) => 1,
54+
Err(e) => panic!("Error in START_BLOCK env var: {:?}", e),
55+
};
56+
/// ..
57+
pub static ref END_BLOCK: usize = match env::var("END_BLOCK") {
58+
Ok(val) => str::parse::<usize>(&val).unwrap(),
59+
Err(VarError::NotPresent) => 8,
60+
Err(e) => panic!("Error in END_BLOCK env var: {:?}", e),
61+
};
5062
}
5163

5264
static LOG_INIT: Once = Once::new();

integration-tests/tests/circuits.rs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,60 @@
11
#![cfg(feature = "circuits")]
22

3-
use bus_mapping::circuit_input_builder::BuilderClient;
3+
use bus_mapping::circuit_input_builder::{BuilderClient, ExecState};
4+
use bus_mapping::evm::OpcodeId;
45
use bus_mapping::operation::OperationContainer;
56
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};
78
use lazy_static::lazy_static;
89
use log::trace;
910
use zkevm_circuits::evm_circuit::witness::RwMap;
1011
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,
1214
};
1315
use zkevm_circuits::state_circuit::StateCircuit;
1416

1517
lazy_static! {
1618
pub static ref GEN_DATA: GenDataOutput = GenDataOutput::load();
1719
}
1820

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+
1931
async fn test_evm_circuit_block(block_num: u64) {
2032
log::info!("test evm circuit, block number: {}", block_num);
2133
let cli = get_client();
2234
let cli = BuilderClient::new(cli).await.unwrap();
2335
let builder = cli.gen_inputs(block_num).await.unwrap();
2436

37+
if builder.block.txs.is_empty() {
38+
log::info!("skip empty block");
39+
return;
40+
}
41+
2542
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+
}
2758
}
2859

2960
async fn test_state_circuit_block(block_num: u64) {

0 commit comments

Comments
 (0)