diff --git a/Cargo.lock b/Cargo.lock index 7b11a834e..9943609e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ [[package]] name = "aggregator" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.11.0rc4#7185563568cfee69b65ec7ee9437259b08159dac" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/refactor-prover#7e95b94898e8b90ae98fdf2aaf29678d56844f73" dependencies = [ "ark-std 0.3.0", "bitstream-io", @@ -553,7 +553,7 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "bus-mapping" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.11.0rc4#7185563568cfee69b65ec7ee9437259b08159dac" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/refactor-prover#7e95b94898e8b90ae98fdf2aaf29678d56844f73" dependencies = [ "eth-types", "ethers-core", @@ -1216,7 +1216,7 @@ dependencies = [ [[package]] name = "eth-types" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.11.0rc4#7185563568cfee69b65ec7ee9437259b08159dac" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/refactor-prover#7e95b94898e8b90ae98fdf2aaf29678d56844f73" dependencies = [ "base64 0.13.1", "ethers-core", @@ -1372,7 +1372,7 @@ dependencies = [ [[package]] name = "external-tracer" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.11.0rc4#7185563568cfee69b65ec7ee9437259b08159dac" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/refactor-prover#7e95b94898e8b90ae98fdf2aaf29678d56844f73" dependencies = [ "eth-types", "geth-utils", @@ -1554,7 +1554,7 @@ dependencies = [ [[package]] name = "gadgets" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.11.0rc4#7185563568cfee69b65ec7ee9437259b08159dac" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/refactor-prover#7e95b94898e8b90ae98fdf2aaf29678d56844f73" dependencies = [ "eth-types", "halo2_proofs", @@ -1576,7 +1576,7 @@ dependencies = [ [[package]] name = "geth-utils" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.11.0rc4#7185563568cfee69b65ec7ee9437259b08159dac" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/refactor-prover#7e95b94898e8b90ae98fdf2aaf29678d56844f73" dependencies = [ "env_logger", "gobuild", @@ -2373,7 +2373,7 @@ dependencies = [ [[package]] name = "mock" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.11.0rc4#7185563568cfee69b65ec7ee9437259b08159dac" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/refactor-prover#7e95b94898e8b90ae98fdf2aaf29678d56844f73" dependencies = [ "eth-types", "ethers-core", @@ -2388,7 +2388,7 @@ dependencies = [ [[package]] name = "mpt-zktrie" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.11.0rc4#7185563568cfee69b65ec7ee9437259b08159dac" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/refactor-prover#7e95b94898e8b90ae98fdf2aaf29678d56844f73" dependencies = [ "eth-types", "halo2curves", @@ -2890,7 +2890,7 @@ dependencies = [ [[package]] name = "prover" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.11.0rc4#7185563568cfee69b65ec7ee9437259b08159dac" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/refactor-prover#7e95b94898e8b90ae98fdf2aaf29678d56844f73" dependencies = [ "aggregator", "anyhow", @@ -4665,7 +4665,7 @@ dependencies = [ [[package]] name = "zkevm-circuits" version = "0.1.0" -source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.11.0rc4#7185563568cfee69b65ec7ee9437259b08159dac" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=feat/refactor-prover#7e95b94898e8b90ae98fdf2aaf29678d56844f73" dependencies = [ "array-init", "bus-mapping", diff --git a/Cargo.toml b/Cargo.toml index da9f7a4d5..bf96f205c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,8 +27,8 @@ serde_json = "1.0" tokio = { version = "1.32", features = ["full"] } halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } -prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.11.0rc4", default-features = false, features = ["parallel_syn", "scroll"] } -zkevm-circuits = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.11.0rc4", default-features = false, features = ["parallel_syn", "scroll"] } +prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "feat/refactor-prover", default-features = false, features = ["parallel_syn", "scroll"] } +zkevm-circuits = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch ="feat/refactor-prover", default-features = false, features = ["parallel_syn", "scroll", "l1_fee_curie"] } integration = { path = "integration" } diff --git a/Makefile b/Makefile index 3c60f96e7..84184cd90 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ test-chunk-prove: @cargo test --features prove_verify --release test_chunk_prove_verify test-e2e-prove: - @cargo test --features prove_verify --release test_e2e_prove_verify + @cargo test --release -p integration --test e2e_tests test_e2e_prove_verify test-pi: @cargo test --features prove_verify --release test_batch_pi diff --git a/README.md b/README.md index cd227a70a..3561664eb 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,6 @@ cargo install svm-rs svm install 0.8.19 ``` -Fetch git-submodule of test traces -```shell -git submodule init -git submodule update --checkout -``` - Download all setup params, degree `20`, `24` and `26` are used in [config](https://github.com/scroll-tech/scroll-prover/tree/main/integration/configs). Could only download params of degree `26`, but it may affect performance (when downsizing params). ```shell @@ -48,12 +42,6 @@ And there are other tests: Could use the following command to run binaries locally. -If run into linking issues you may need to run -```shell -cp `find ./target/release/ | grep libzktrie.so` /usr/local/lib/ -``` -To move the zktrielib into a path where your linker could locate it. - Run zkevm prover to generate chunk proof (work directory is `./integration`) ```shell cargo build --release --bin zkevm_prove @@ -80,17 +68,6 @@ Could specify arguments as cargo run --release --bin zkevm_verify -- --params=params --proof=proof_data ``` -### Scripts - -- If you have read access for DB, could run command to generate full-proof for batch tests: -``` -export DB_HOST= -export DB_USER= -export DB_NAME= - -sh scripts/gen_full_chunk_proofs.sh BATCH_INDEX -``` - ### Dockers - `docker/chunk-prover` is used to build and run GPU chunk-prover. diff --git a/bin/src/zkevm_prove.rs b/bin/src/zkevm_prove.rs index 7b22bde2e..86b6ae960 100644 --- a/bin/src/zkevm_prove.rs +++ b/bin/src/zkevm_prove.rs @@ -2,6 +2,7 @@ use clap::Parser; use prover::{ utils::{get_block_trace_from_file, init_env_and_log}, zkevm::Prover, + ChunkProvingTask, }; use std::{env, fs, path::PathBuf, time::Instant}; @@ -32,24 +33,29 @@ fn main() { let args = Args::parse(); let mut prover = Prover::from_dirs(&args.params_path, &args.assets_path); - let mut traces = Vec::new(); + let mut block_traces = Vec::new(); let trace_path = PathBuf::from(&args.trace_path); if trace_path.is_dir() { for entry in fs::read_dir(trace_path).unwrap() { let path = entry.unwrap().path(); if path.is_file() && path.to_str().unwrap().ends_with(".json") { let block_trace = get_block_trace_from_file(path.to_str().unwrap()); - traces.push(block_trace); + block_traces.push(block_trace); } } } else { let block_trace = get_block_trace_from_file(trace_path.to_str().unwrap()); - traces.push(block_trace); + block_traces.push(block_trace); } let now = Instant::now(); prover - .gen_chunk_proof(traces, Some("zkevm"), None, Some(&output_dir)) + .gen_chunk_proof( + ChunkProvingTask { block_traces }, + Some("zkevm"), + None, + Some(&output_dir), + ) .expect("cannot generate chunk snark"); log::info!( "finish generating chunk snark, elapsed: {:?}", diff --git a/integration/Cargo.toml b/integration/Cargo.toml index 202319b01..078bd230a 100644 --- a/integration/Cargo.toml +++ b/integration/Cargo.toml @@ -11,15 +11,13 @@ itertools.workspace = true log.workspace = true log4rs.workspace = true rand.workspace = true +serde.workspace = true +serde_derive.workspace = true halo2_proofs.workspace = true prover.workspace = true zkevm-circuits.workspace = true -[dev-dependencies] -serde.workspace = true -serde_derive.workspace = true - [features] default = ["prove_verify"] prove_verify = [] diff --git a/integration/src/test_util.rs b/integration/src/test_util.rs index 092442b08..4abf6c7c8 100644 --- a/integration/src/test_util.rs +++ b/integration/src/test_util.rs @@ -5,8 +5,10 @@ use prover::{ }; mod capacity_checker; -pub mod mock_plonk; mod proof; +mod types; + +pub use prover::types::BatchProvingTask; pub use capacity_checker::{ ccc_as_signer, ccc_by_chunk, prepare_circuit_capacity_checker, pretty_print_row_usage, @@ -20,46 +22,30 @@ pub use proof::{ pub const ASSETS_DIR: &str = "./test_assets"; pub const PARAMS_DIR: &str = "./params"; -pub fn load_block_traces_for_test() -> (Vec, Vec) { +pub fn load_chunk_for_test() -> (Vec, Vec) { let trace_path: String = read_env_var( "TRACE_PATH", "./tests/extra_traces/batch_495/chunk_495/block_8802.json".to_string(), ); + load_chunk(&trace_path) +} + +pub fn load_chunk(trace_path: &str) -> (Vec, Vec) { let paths: Vec = if !std::fs::metadata(&trace_path).unwrap().is_dir() { - vec![trace_path] + vec![trace_path.to_string()] } else { - load_chunk_traces(&trace_path).0 + // Nested dirs are not allowed + let mut file_names: Vec = glob(&format!("{trace_path}/*.json")) + .unwrap() + .map(|p| p.unwrap().to_str().unwrap().to_string()) + .collect(); + file_names.sort_by_key(|s| { + // Remove the ".json" suffix and parse the remaining part as an integer + s.trim_end_matches(".json").parse::().unwrap() + }); + file_names }; log::info!("test cases traces: {:?}", paths); let traces: Vec<_> = paths.iter().map(get_block_trace_from_file).collect(); (paths, traces) } - -fn load_chunk_traces(chunk_dir: &str) -> (Vec, Vec) { - // Nested dirs are not allowed - let file_names: Vec = glob(&format!("{chunk_dir}/*.json")) - .unwrap() - .map(|p| p.unwrap().to_str().unwrap().to_string()) - .collect(); - log::info!("test chunk with {:?}", file_names); - let mut names_and_traces = file_names - .into_iter() - .map(|trace_path| { - let trace: BlockTrace = get_block_trace_from_file(trace_path.clone()); - ( - trace_path, - trace.clone(), - trace.header.number.unwrap().as_u64(), - ) - }) - .collect::>(); - names_and_traces.sort_by(|a, b| a.2.cmp(&b.2)); - log::info!( - "sorted: {:?}", - names_and_traces - .iter() - .map(|(f, _, _)| f.clone()) - .collect::>() - ); - names_and_traces.into_iter().map(|(f, t, _)| (f, t)).unzip() -} diff --git a/integration/src/test_util/mock_plonk.rs b/integration/src/test_util/mock_plonk.rs deleted file mode 100644 index a788c1c8a..000000000 --- a/integration/src/test_util/mock_plonk.rs +++ /dev/null @@ -1,160 +0,0 @@ -//! A module for Mock Plonk circuit. -use halo2_proofs::{ - circuit::{Layouter, SimpleFloorPlanner, Value}, - halo2curves::bn256::Fr, - plonk::{Advice, Circuit, Column, ConstraintSystem, Error, Fixed, Instance}, - poly::Rotation, -}; -use prover::{zkevm::circuit::TargetCircuit, CircuitExt, WitnessBlock}; -use rand::RngCore; - -pub struct MockPlonkCircuit { - pub circuit: StandardPlonk, -} - -impl TargetCircuit for MockPlonkCircuit { - /// The actual inner circuit that implements Circuit trait. - type Inner = StandardPlonk; - - /// Name tag of the circuit. - /// This tag will be used as a key to index the circuit. - /// It is therefore important that the name is unique. - fn name() -> String { - "standard plonk".into() - } - - /// Generate a dummy circuit with an empty trace. - /// This is useful for generating vk and pk. - fn dummy_inner_circuit() -> Self::Inner - where - Self: Sized, - { - StandardPlonk(Fr::zero()) - } - - /// Build the inner circuit and the instances from the witness block - fn from_witness_block( - _witness_block: &WitnessBlock, - ) -> anyhow::Result<(Self::Inner, Vec>)> - where - Self: Sized, - { - unimplemented!() - } -} - -#[derive(Clone, Copy)] -pub struct StandardPlonkConfig { - a: Column, - b: Column, - c: Column, - q_a: Column, - q_b: Column, - q_c: Column, - q_ab: Column, - constant: Column, - #[allow(dead_code)] - instance: Column, -} - -impl StandardPlonkConfig { - fn configure(meta: &mut ConstraintSystem) -> Self { - let [a, b, c] = [(); 3].map(|_| meta.advice_column()); - let [q_a, q_b, q_c, q_ab, constant] = [(); 5].map(|_| meta.fixed_column()); - let instance = meta.instance_column(); - - [a, b, c].map(|column| meta.enable_equality(column)); - - meta.create_gate( - "q_a·a + q_b·b + q_c·c + q_ab·a·b + constant + instance = 0", - |meta| { - let [a, b, c] = [a, b, c].map(|column| meta.query_advice(column, Rotation::cur())); - let [q_a, q_b, q_c, q_ab, constant] = [q_a, q_b, q_c, q_ab, constant] - .map(|column| meta.query_fixed(column, Rotation::cur())); - let instance = meta.query_instance(instance, Rotation::cur()); - Some( - q_a * a.clone() - + q_b * b.clone() - + q_c * c - + q_ab * a * b - + constant - + instance, - ) - }, - ); - - StandardPlonkConfig { - a, - b, - c, - q_a, - q_b, - q_c, - q_ab, - constant, - instance, - } - } -} - -#[derive(Clone, Copy, Default, Debug)] -pub struct StandardPlonk(Fr); - -impl StandardPlonk { - pub fn rand(mut rng: R) -> Self { - Self(Fr::from(rng.next_u32() as u64)) - } -} - -impl CircuitExt for StandardPlonk { - fn num_instance(&self) -> Vec { - vec![1] - } - - fn instances(&self) -> Vec> { - vec![vec![self.0]] - } -} - -impl Circuit for StandardPlonk { - type Config = StandardPlonkConfig; - type FloorPlanner = SimpleFloorPlanner; - - fn without_witnesses(&self) -> Self { - Self::default() - } - - fn configure(meta: &mut ConstraintSystem) -> Self::Config { - meta.set_minimum_degree(4); - StandardPlonkConfig::configure(meta) - } - - fn synthesize( - &self, - config: Self::Config, - mut layouter: impl Layouter, - ) -> Result<(), Error> { - layouter.assign_region( - || "", - |mut region| { - region.assign_advice(|| "", config.a, 0, || Value::known(self.0))?; - region.assign_fixed(|| "", config.q_a, 0, || Value::known(-Fr::one()))?; - region.assign_advice(|| "", config.a, 1, || Value::known(-Fr::from(5u64)))?; - for (idx, column) in (1..).zip([ - config.q_a, - config.q_b, - config.q_c, - config.q_ab, - config.constant, - ]) { - region.assign_fixed(|| "", column, 1, || Value::known(Fr::from(idx as u64)))?; - } - let a = region.assign_advice(|| "", config.a, 2, || Value::known(Fr::one()))?; - a.copy_advice(|| "", &mut region, config.b, 3)?; - a.copy_advice(|| "", &mut region, config.c, 4)?; - - Ok(()) - }, - ) - } -} diff --git a/integration/src/test_util/proof.rs b/integration/src/test_util/proof.rs index c86ad86f6..22b3b095f 100644 --- a/integration/src/test_util/proof.rs +++ b/integration/src/test_util/proof.rs @@ -9,7 +9,7 @@ use std::env; pub fn gen_and_verify_batch_proofs(agg_prover: &mut Prover, layer3_snark: Snark, output_dir: &str) { let evm_proof = gen_and_verify_normal_and_evm_proofs( - &mut agg_prover.inner, + &mut agg_prover.prover_impl, LayerId::Layer4, layer3_snark, Some(output_dir), @@ -24,13 +24,13 @@ pub fn gen_and_verify_chunk_proofs( output_dir: &str, ) { let normal_proof = gen_and_verify_normal_and_evm_proofs( - &mut zkevm_prover.inner, + &mut zkevm_prover.prover_impl, LayerId::Layer2, layer1_snark, Some(output_dir), ) .0; - verify_chunk_proof(&zkevm_prover.inner, normal_proof, output_dir); + verify_chunk_proof(&zkevm_prover.prover_impl, normal_proof, output_dir); } pub fn gen_and_verify_normal_and_evm_proofs( diff --git a/integration/src/test_util/types.rs b/integration/src/test_util/types.rs new file mode 100644 index 000000000..6841c090b --- /dev/null +++ b/integration/src/test_util/types.rs @@ -0,0 +1,3 @@ +pub use prover::types::{BatchProvingTask, ChunkProvingTask}; +use prover::ChunkProof; +use serde::{Deserialize, Serialize}; diff --git a/integration/tests/batch_tests.rs b/integration/tests/batch_tests.rs index dae93464e..8741c24ba 100644 --- a/integration/tests/batch_tests.rs +++ b/integration/tests/batch_tests.rs @@ -1,8 +1,7 @@ -use integration::test_util::{gen_and_verify_batch_proofs, PARAMS_DIR}; +use integration::test_util::{gen_and_verify_batch_proofs, BatchProvingTask, PARAMS_DIR}; use prover::{ - aggregator::Prover, proof::from_json_file, utils::init_env_and_log, ChunkHash, ChunkProof, + aggregator::Prover, io::from_json_file, utils::init_env_and_log, ChunkHash, ChunkProof, }; -use serde_derive::{Deserialize, Serialize}; use std::{env, fs, path::PathBuf}; #[cfg(feature = "prove_verify")] @@ -11,7 +10,8 @@ fn test_batch_prove_verify() { let output_dir = init_env_and_log("batch_tests"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let chunk_hashes_proofs = load_chunk_hashes_and_proofs("tests/test_data", "1", &output_dir); + let chunk_hashes_proofs = + load_chunk_hashes_and_proofs("tests/test_data/full_proof_1.json", &output_dir); let mut batch_prover = new_batch_prover(&output_dir); prove_and_verify_batch(&output_dir, &mut batch_prover, chunk_hashes_proofs); } @@ -22,7 +22,8 @@ fn test_batches_with_each_chunk_num_prove_verify() { let output_dir = init_env_and_log("batches_with_each_chunk_num_tests"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let chunk_hashes_proofs = load_chunk_hashes_and_proofs("tests/test_data", "2", &output_dir); + let chunk_hashes_proofs = + load_chunk_hashes_and_proofs("tests/test_data/full_proof_1.json", &output_dir); let mut batch_prover = new_batch_prover(&output_dir); // Iterate over chunk proofs to test with 1 - 15 chunks (in a batch). @@ -38,18 +39,13 @@ fn test_batches_with_each_chunk_num_prove_verify() { ); } } -#[derive(Debug, Deserialize, Serialize)] -struct BatchTaskDetail { - chunk_proofs: Vec, -} fn load_chunk_hashes_and_proofs( - dir: &str, - filename: &str, + batch_task_file: &str, output_dir: &str, ) -> Vec<(ChunkHash, ChunkProof)> { - let batch_task_detail: BatchTaskDetail = from_json_file(dir, filename).unwrap(); - let chunk_hashes_proofs: Vec<_> = batch_task_detail.chunk_proofs[..] + let batch: BatchProvingTask = from_json_file(batch_task_file).unwrap(); + let chunk_hashes_proofs: Vec<_> = batch.chunk_proofs[..] .iter() .cloned() .map(|p| (p.chunk_hash.clone().unwrap(), p)) diff --git a/integration/tests/chunk_tests.rs b/integration/tests/chunk_tests.rs index 91949d8db..4f52c0432 100644 --- a/integration/tests/chunk_tests.rs +++ b/integration/tests/chunk_tests.rs @@ -1,5 +1,5 @@ use integration::test_util::{ - gen_and_verify_chunk_proofs, load_block_traces_for_test, ASSETS_DIR, PARAMS_DIR, + gen_and_verify_chunk_proofs, load_chunk_for_test, ASSETS_DIR, PARAMS_DIR, }; use prover::{ utils::{chunk_trace_to_witness_block, init_env_and_log}, @@ -13,7 +13,7 @@ fn test_chunk_prove_verify() { let output_dir = init_env_and_log("chunk_tests"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let chunk_trace = load_block_traces_for_test().1; + let chunk_trace = load_chunk_for_test().1; log::info!("Loaded chunk trace"); let witness_block = chunk_trace_to_witness_block(chunk_trace).unwrap(); @@ -25,7 +25,7 @@ fn test_chunk_prove_verify() { // Load or generate compression wide snark (layer-1). let layer1_snark = zkevm_prover - .inner + .prover_impl .load_or_gen_last_chunk_snark("layer1", &witness_block, None, Some(&output_dir)) .unwrap(); diff --git a/integration/tests/e2e_tests.rs b/integration/tests/e2e_tests.rs index c5b0364b1..ff57dbc29 100644 --- a/integration/tests/e2e_tests.rs +++ b/integration/tests/e2e_tests.rs @@ -1,22 +1,30 @@ use integration::test_util::{ - gen_and_verify_batch_proofs, load_block_traces_for_test, ASSETS_DIR, PARAMS_DIR, + gen_and_verify_batch_proofs, load_chunk, load_chunk_for_test, BatchProvingTask, ASSETS_DIR, + PARAMS_DIR, }; use prover::{ aggregator::Prover, utils::{chunk_trace_to_witness_block, init_env_and_log, read_env_var}, - zkevm, BatchHash, ChunkHash, ChunkProof, + zkevm, BatchHash, ChunkHash, ChunkProvingTask, }; use std::env; -fn load_batch() -> anyhow::Result> { +fn load_test_batch() -> anyhow::Result> { let batch_dir = read_env_var("TRACE_PATH", "./tests/extra_traces/batch_25".to_string()); + load_batch(&batch_dir) +} + +fn load_batch(batch_dir: &str) -> anyhow::Result> { let mut sorted_dirs: Vec = std::fs::read_dir(batch_dir)? .filter_map(|entry| entry.ok()) .map(|entry| entry.path()) .filter(|path| path.is_dir()) .map(|path| path.to_string_lossy().into_owned()) .collect::>(); - sorted_dirs.sort(); + sorted_dirs.sort_by_key(|s| { + // Remove the "chunk_" prefix and parse the remaining part as an integer + s.trim_start_matches("chunk_").parse::().unwrap() + }); let fast = false; if fast { sorted_dirs.truncate(1); @@ -29,7 +37,7 @@ fn load_batch() -> anyhow::Result> { fn test_batch_pi_consistency() { let output_dir = init_env_and_log("batch_pi"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let trace_paths = load_batch().unwrap(); + let trace_paths = load_test_batch().unwrap(); log_batch_pi(&trace_paths); } @@ -39,45 +47,38 @@ fn test_e2e_prove_verify() { let output_dir = init_env_and_log("agg_tests"); log::info!("Initialized ENV and created output-dir {output_dir}"); - let trace_paths = load_batch().unwrap(); - let chunk_hashes_proofs = gen_chunk_hashes_and_proofs(&output_dir, &trace_paths); + let chunk_dirs = load_batch("./tests/extra_traces/batch_5").unwrap(); + let batch = gen_chunk_hashes_and_proofs(&output_dir, &chunk_dirs); let mut batch_prover = new_batch_prover(&output_dir); - prove_and_verify_batch(&output_dir, &mut batch_prover, chunk_hashes_proofs); + prove_and_verify_batch(&output_dir, &mut batch_prover, batch); } -fn gen_chunk_hashes_and_proofs( - output_dir: &str, - trace_paths: &[String], -) -> Vec<(ChunkHash, ChunkProof)> { - let mut zkevm_prover = zkevm::Prover::from_dirs(PARAMS_DIR, ASSETS_DIR); - log::info!("Constructed zkevm prover"); - - let chunk_traces: Vec<_> = trace_paths +fn gen_chunk_hashes_and_proofs(output_dir: &str, chunk_dirs: &[String]) -> BatchProvingTask { + let chunks: Vec<_> = chunk_dirs .iter() - .map(|trace_path| { - env::set_var("TRACE_PATH", trace_path); - load_block_traces_for_test().1 - }) + .map(|chunk_dir| load_chunk(chunk_dir).1) .collect(); - let chunk_hashes_proofs = chunk_traces + let mut zkevm_prover = zkevm::Prover::from_dirs(PARAMS_DIR, ASSETS_DIR); + log::info!("Constructed zkevm prover"); + let chunk_proofs: Vec<_> = chunks .into_iter() .enumerate() - .map(|(i, chunk_trace)| { - let witness_block = chunk_trace_to_witness_block(chunk_trace.clone()).unwrap(); - let chunk_hash = ChunkHash::from_witness_block(&witness_block, false); - - let proof = zkevm_prover - .gen_chunk_proof(chunk_trace, Some(&i.to_string()), None, Some(output_dir)) - .unwrap(); - - (chunk_hash, proof) + .map(|(i, block_traces)| { + zkevm_prover + .gen_chunk_proof( + ChunkProvingTask { block_traces }, + Some(&i.to_string()), + None, + Some(output_dir), + ) + .unwrap() }) .collect(); - log::info!("Generated chunk hashes and proofs"); - chunk_hashes_proofs + log::info!("Generated chunk proofs"); + BatchProvingTask { chunk_proofs } } fn log_batch_pi(trace_paths: &[String]) { @@ -86,7 +87,7 @@ fn log_batch_pi(trace_paths: &[String]) { .iter() .map(|trace_path| { env::set_var("TRACE_PATH", trace_path); - load_block_traces_for_test().1 + load_chunk_for_test().1 }) .collect(); @@ -130,12 +131,13 @@ fn new_batch_prover(assets_dir: &str) -> Prover { prover } -fn prove_and_verify_batch( - output_dir: &str, - batch_prover: &mut Prover, - chunk_hashes_proofs: Vec<(ChunkHash, ChunkProof)>, -) { +fn prove_and_verify_batch(output_dir: &str, batch_prover: &mut Prover, batch: BatchProvingTask) { // Load or generate aggregation snark (layer-3). + let chunk_hashes_proofs: Vec<_> = batch.chunk_proofs[..] + .iter() + .cloned() + .map(|p| (p.chunk_hash.clone().unwrap(), p)) + .collect(); let layer3_snark = batch_prover .load_or_gen_last_agg_snark("agg", chunk_hashes_proofs, Some(output_dir)) .unwrap(); diff --git a/integration/tests/extra_traces/batch_5/chunk_5/6.json b/integration/tests/extra_traces/batch_5/chunk_5/6.json new file mode 100644 index 000000000..658997a65 --- /dev/null +++ b/integration/tests/extra_traces/batch_5/chunk_5/6.json @@ -0,0 +1,259 @@ +{ + "chainID": 222222, + "version": "5.3.25-mainnet-70d54023", + "coinbase": { + "address": "0x5300000000000000000000000000000000000005", + "nonce": 0, + "balance": "0x2fbf9bd9c82b", + "keccakCodeHash": "0x3733510decd4cdde078e264666d17cac208f9f9e93fc0a43b02921be5cf5726f", + "poseidonCodeHash": "0x1c0bc998c1d4a23089705ffaa44e274d41dec1eb01993b5f65202cf9c80d31bb", + "codeSize": 1956 + }, + "header": { + "parentHash": "0xac380892ebb3b15452b1b94e0f498b48992a06701bfd13b480bd84ceb0dac4bc", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0x0000000000000000000000000000000000000000", + "stateRoot": "0x0af9298416b575f10b08d79126a26ab340d481684f43979e404dd67e9a15a6a7", + "transactionsRoot": "0xd0f251cc0c54e6b25ed2029cdf3afc5b9d228aaadc992c31449ec6e459c6fd9f", + "receiptsRoot": "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x2", + "number": "0x6", + "gasLimit": "0x989680", + "gasUsed": "0x5208", + "timestamp": "0x66557a2d", + "extraData": "0xd883050319846765746888676f312e32302e31856c696e757800000000000000c061632395a6575791fb65af97f1f04091936e772eac4dfa2b758434e41d85810f0da6caeef43dd750763474928406242b90349db6a318019cfe2d8f3223264201", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "baseFeePerGas": "0x8f0d180", + "withdrawalsRoot": null, + "hash": "0xf8950f20c53171c12a109075aa3706118b178d8d58ae8eff2be87d463323c820", + "blobGasUsed": null, + "excessBlobGas": null, + "parentBeaconBlockRoot": null + }, + "transactions": [ + { + "type": 0, + "nonce": 4, + "txHash": "0x6c2baa5ba12ca2df89f09b38387f8b593dd5fbd8b417ed56da5447fd414ab892", + "gas": 100000, + "gasPrice": "0x1dcd6500", + "gasTipCap": "0x1dcd6500", + "gasFeeCap": "0x1dcd6500", + "from": "0x6f4c950442e1af093bcff730381e63ae9171b87a", + "to": "0x6f4c950442e1af093bcff730381e63ae9171b87a", + "chainId": "0x3640e", + "value": "0x0", + "data": "0x", + "isCreate": false, + "accessList": null, + "v": "0x6c840", + "r": "0x9e6f9e178f2fa69137d280de03be33048d533b2c107d3c50e883634c14e53ab2", + "s": "0x6b372c7272205aeb6f4de482b139552abd78aa7abce2cc1ea940e765de707f9" + } + ], + "storageTrace": { + "rootBefore": "0x183865732d4570aa1e8c610682ba5fd2380cda2d73ed946c6dfb389576892e67", + "rootAfter": "0x0af9298416b575f10b08d79126a26ab340d481684f43979e404dd67e9a15a6a7", + "proofs": { + "0x5300000000000000000000000000000000000000": [ + "0x09149717512c02479e10ad55dab819f4ddf6d8d1cf304508a2e54febe665ff99b325d10b95f9840b0aae7328a79306494170985fce1f383bcf011b2dcc04e74731", + "0x0722ae79d6e75ad494bd88905963080ce8b7f972d406148a828d3920474cee6fdd163336396af4ab08c8e36542e885a1e6d158e12441840fd51871b44c7ee56090", + "0x0700000000000000000000000000000000000000000000000000000000000000000525c2dbd58291d73647d2c76100c05d4cfa4dffaa3dd721e93a5f37facbceb1", + "0x070000000000000000000000000000000000000000000000000000000000000000133a06fc1d0f38c1826f2d9eecd527b0b18a656447f8de58c5936ba3b5601629", + "0x08250a120d3d9bf0ebf618e11c67af64ce68e92058e8984fb378b5794e041edaeb0000000000000000000000000000000000000000000000000000000000000000", + "0x06005a1c3d32c83abeeb31eed268704e7ae310d7143b0556be43fb2c374970e26b0b25a0da18ff8a0ed5c6ead5a5728e06caf41b2a73aaea75353303d21c59a77f", + "0x0408389bdcf35fead34d26ac16f4638b31e82714ffb6d7c083a1afda53ed6d240e05080000000000000000000000000000000000000000000000000680000000000000000000000000000000000000000000000000000000000000000000000000000000001535ec02969e7f3c1c1bb629e0f64718cd8abdac1d1e20f165b8eb2472b850e37f6f0daf66a63b4d504fabde8e9fa491ff678bf22082d8fee03ac3064fcf7de9083c136cb0e27c3434a6f2b4839eac2167e39fd4c47a0a83923668e3abcf3b0800", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ], + "0x5300000000000000000000000000000000000002": [ + "0x09149717512c02479e10ad55dab819f4ddf6d8d1cf304508a2e54febe665ff99b325d10b95f9840b0aae7328a79306494170985fce1f383bcf011b2dcc04e74731", + "0x091e99056dc32c3f820f7fbdf5cede540e657bafc7a524c8c7d7a635ef26030b4e062a4c282c18639fe749f2c42adfa1cdd3d905b3600761e238a994fb9c694813", + "0x081614a5fd0e9ccd6183d7cd615117a0098d116997bf842989813be5895ec3c0630000000000000000000000000000000000000000000000000000000000000000", + "0x061619481825c25f5bcaed30f59a93b542822f15467b03e49952c85ce545a49b7c24249c2c337de6e365d15d763e2e212cee48e64ed3b66d39307d78d577788c4c", + "0x04139a6815e4d1fb05c969e6a8036aa5cc06b88751d713326d681bd90448ea64c905080000000000000000000000000000000000000000000000000be30000000000000000000000000000000000000000000000000000000000000000000000000000000028fe772db0d7e4f92ebe8b405d09a52475d592ad3ec17772ba9090c8ee6cc20bee9f30e418d9004456193e3ec3033703c36cf9ef68642d4f50f707772892b417032cd39b43a4fdff5e05188949f8f9d9f236208cebc9f5725713d11c491f38d1205300000000000000000000000000000000000002000000000000000000000000", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ], + "0x5300000000000000000000000000000000000005": [ + "0x09149717512c02479e10ad55dab819f4ddf6d8d1cf304508a2e54febe665ff99b325d10b95f9840b0aae7328a79306494170985fce1f383bcf011b2dcc04e74731", + "0x091e99056dc32c3f820f7fbdf5cede540e657bafc7a524c8c7d7a635ef26030b4e062a4c282c18639fe749f2c42adfa1cdd3d905b3600761e238a994fb9c694813", + "0x081614a5fd0e9ccd6183d7cd615117a0098d116997bf842989813be5895ec3c0630000000000000000000000000000000000000000000000000000000000000000", + "0x061619481825c25f5bcaed30f59a93b542822f15467b03e49952c85ce545a49b7c24249c2c337de6e365d15d763e2e212cee48e64ed3b66d39307d78d577788c4c", + "0x04287b801ba8950befe82147f88e71eff6b85eb921845d754c9c2a165a4ec86791050800000000000000000000000000000000000000000000000007a4000000000000000000000000000000000000000000000000000000000000000000002632e314a000115580ad2939ba6fc167ac1446d9edb371ed767e0830666d3c3311d43e335b893733510decd4cdde078e264666d17cac208f9f9e93fc0a43b02921be5cf5726f1c0bc998c1d4a23089705ffaa44e274d41dec1eb01993b5f65202cf9c80d31bb205300000000000000000000000000000000000005000000000000000000000000", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ], + "0x6f4c950442e1Af093BcfF730381E63Ae9171b87a": [ + "0x09149717512c02479e10ad55dab819f4ddf6d8d1cf304508a2e54febe665ff99b325d10b95f9840b0aae7328a79306494170985fce1f383bcf011b2dcc04e74731", + "0x0722ae79d6e75ad494bd88905963080ce8b7f972d406148a828d3920474cee6fdd163336396af4ab08c8e36542e885a1e6d158e12441840fd51871b44c7ee56090", + "0x0700000000000000000000000000000000000000000000000000000000000000000525c2dbd58291d73647d2c76100c05d4cfa4dffaa3dd721e93a5f37facbceb1", + "0x070000000000000000000000000000000000000000000000000000000000000000133a06fc1d0f38c1826f2d9eecd527b0b18a656447f8de58c5936ba3b5601629", + "0x08250a120d3d9bf0ebf618e11c67af64ce68e92058e8984fb378b5794e041edaeb0000000000000000000000000000000000000000000000000000000000000000", + "0x06005a1c3d32c83abeeb31eed268704e7ae310d7143b0556be43fb2c374970e26b0b25a0da18ff8a0ed5c6ead5a5728e06caf41b2a73aaea75353303d21c59a77f", + "0x04301f15bc8e20aaff13d28665677737a7eef1627b6f0ed8ccd70c7c41b1e0e02e0508000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000008ac6fcd1a6d360000000000000000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4702098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864206f4c950442e1af093bcff730381e63ae9171b87a000000000000000000000000", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ] + }, + "storageProofs": { + "0x5300000000000000000000000000000000000000": { + "0x0000000000000000000000000000000000000000000000000000000000000000": [ + "0x0419626faff81a051367b2267b26b9a8d2f10a7394e11a1b0902ee447cd1f9e174010100000000000000000000000000006f4c950442e1af093bcff730381e63ae9171b87a00", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ] + }, + "0x5300000000000000000000000000000000000002": { + "0x0000000000000000000000000000000000000000000000000000000000000001": [ + "0x0910a2fcedf4da81233c1b1e1f299a8c561021c4673c10025f0be07fb87b7134b326ee6cd6a3b6f182a42cecdc5a94705e46c16308f2211554b58362369c73a524", + "0x07176aa37002031d48e4565e96214d82ef7150f0dbcdc5be48fd8278d66992442b1bdd3f8720b1308f967cd62fe34457c66840cd58597355257b5a858dc469de94", + "0x04064ef33f6d7044a6aa1458b710bb24a531e379030cf6ca490d84fff1d8e79c940101000000000000000000000000000000000000000000000000000000000035ba5d7b55200000000000000000000000000000000000000000000000000000000000000006", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ], + "0x0000000000000000000000000000000000000000000000000000000000000002": [ + "0x0910a2fcedf4da81233c1b1e1f299a8c561021c4673c10025f0be07fb87b7134b326ee6cd6a3b6f182a42cecdc5a94705e46c16308f2211554b58362369c73a524", + "0x07176aa37002031d48e4565e96214d82ef7150f0dbcdc5be48fd8278d66992442b1bdd3f8720b1308f967cd62fe34457c66840cd58597355257b5a858dc469de94", + "0x04064ef33f6d7044a6aa1458b710bb24a531e379030cf6ca490d84fff1d8e79c940101000000000000000000000000000000000000000000000000000000000035ba5d7b55200000000000000000000000000000000000000000000000000000000000000006", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ], + "0x0000000000000000000000000000000000000000000000000000000000000003": [ + "0x0910a2fcedf4da81233c1b1e1f299a8c561021c4673c10025f0be07fb87b7134b326ee6cd6a3b6f182a42cecdc5a94705e46c16308f2211554b58362369c73a524", + "0x070000000000000000000000000000000000000000000000000000000000000000134237077b319750bb4c5c431d4d511cc55fd1aca8c7e3a4a0a22debc50dc9a9", + "0x07000000000000000000000000000000000000000000000000000000000000000008789d1c0d8b900eab689004b3fcccbc93ae88cd8e8382423f40f1ffce72f364", + "0x05", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ], + "0x0000000000000000000000000000000000000000000000000000000000000005": [ + "0x0910a2fcedf4da81233c1b1e1f299a8c561021c4673c10025f0be07fb87b7134b326ee6cd6a3b6f182a42cecdc5a94705e46c16308f2211554b58362369c73a524", + "0x070000000000000000000000000000000000000000000000000000000000000000134237077b319750bb4c5c431d4d511cc55fd1aca8c7e3a4a0a22debc50dc9a9", + "0x07000000000000000000000000000000000000000000000000000000000000000008789d1c0d8b900eab689004b3fcccbc93ae88cd8e8382423f40f1ffce72f364", + "0x062194fe58e6d1ad1d47e456669e173164641f2373ef9c1905a98ee4bc812169b6282ea57a113f14d170b1e403109b34477ae61488963313dd66980e1e8c0dc90a", + "0x041aed9d52b6e3489c0ea97983a6dc4fbad57507090547dc83b8830c2ddb885777010100000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000005", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ], + "0x0000000000000000000000000000000000000000000000000000000000000006": [ + "0x0910a2fcedf4da81233c1b1e1f299a8c561021c4673c10025f0be07fb87b7134b326ee6cd6a3b6f182a42cecdc5a94705e46c16308f2211554b58362369c73a524", + "0x07176aa37002031d48e4565e96214d82ef7150f0dbcdc5be48fd8278d66992442b1bdd3f8720b1308f967cd62fe34457c66840cd58597355257b5a858dc469de94", + "0x04064ef33f6d7044a6aa1458b710bb24a531e379030cf6ca490d84fff1d8e79c940101000000000000000000000000000000000000000000000000000000000035ba5d7b55200000000000000000000000000000000000000000000000000000000000000006", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ], + "0x0000000000000000000000000000000000000000000000000000000000000007": [ + "0x0910a2fcedf4da81233c1b1e1f299a8c561021c4673c10025f0be07fb87b7134b326ee6cd6a3b6f182a42cecdc5a94705e46c16308f2211554b58362369c73a524", + "0x07176aa37002031d48e4565e96214d82ef7150f0dbcdc5be48fd8278d66992442b1bdd3f8720b1308f967cd62fe34457c66840cd58597355257b5a858dc469de94", + "0x08304919e3840274fd961059cc56451a6493fbb030bb2c16f30809287ecb7a9c3a0000000000000000000000000000000000000000000000000000000000000000", + "0x0611804c13b7dd74fd1fc8b03a912348ec7eda8603d7a0db97475b468d4dec2f130b6cabf64ef0b2a8be287bc93a37d325fa6925c73d565b849ea1f4193866d9fe", + "0x040d1e80106f23933567a7c4881177b5d6c45a3f319feafe560a28df75769db9ba010100000000000000000000000000000000000000000000000000000000000018e38a4c200000000000000000000000000000000000000000000000000000000000000007", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ], + "0x0000000000000000000000000000000000000000000000000000000000000008": [ + "0x0910a2fcedf4da81233c1b1e1f299a8c561021c4673c10025f0be07fb87b7134b326ee6cd6a3b6f182a42cecdc5a94705e46c16308f2211554b58362369c73a524", + "0x070000000000000000000000000000000000000000000000000000000000000000134237077b319750bb4c5c431d4d511cc55fd1aca8c7e3a4a0a22debc50dc9a9", + "0x07000000000000000000000000000000000000000000000000000000000000000008789d1c0d8b900eab689004b3fcccbc93ae88cd8e8382423f40f1ffce72f364", + "0x062194fe58e6d1ad1d47e456669e173164641f2373ef9c1905a98ee4bc812169b6282ea57a113f14d170b1e403109b34477ae61488963313dd66980e1e8c0dc90a", + "0x0412c0c59f64422dd5b7ce259c4aa62e9bf4e2bcc4f0da068e332b9f4e502ba38f010100000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000008", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ] + } + } + }, + "txStorageTraces": [ + { + "rootBefore": "0x183865732d4570aa1e8c610682ba5fd2380cda2d73ed946c6dfb389576892e67", + "rootAfter": "0x0af9298416b575f10b08d79126a26ab340d481684f43979e404dd67e9a15a6a7", + "proofs": { + "0x5300000000000000000000000000000000000005": [ + "0x09149717512c02479e10ad55dab819f4ddf6d8d1cf304508a2e54febe665ff99b325d10b95f9840b0aae7328a79306494170985fce1f383bcf011b2dcc04e74731", + "0x091e99056dc32c3f820f7fbdf5cede540e657bafc7a524c8c7d7a635ef26030b4e062a4c282c18639fe749f2c42adfa1cdd3d905b3600761e238a994fb9c694813", + "0x081614a5fd0e9ccd6183d7cd615117a0098d116997bf842989813be5895ec3c0630000000000000000000000000000000000000000000000000000000000000000", + "0x061619481825c25f5bcaed30f59a93b542822f15467b03e49952c85ce545a49b7c24249c2c337de6e365d15d763e2e212cee48e64ed3b66d39307d78d577788c4c", + "0x04287b801ba8950befe82147f88e71eff6b85eb921845d754c9c2a165a4ec86791050800000000000000000000000000000000000000000000000007a4000000000000000000000000000000000000000000000000000000000000000000002632e314a000115580ad2939ba6fc167ac1446d9edb371ed767e0830666d3c3311d43e335b893733510decd4cdde078e264666d17cac208f9f9e93fc0a43b02921be5cf5726f1c0bc998c1d4a23089705ffaa44e274d41dec1eb01993b5f65202cf9c80d31bb205300000000000000000000000000000000000005000000000000000000000000", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ], + "0x6f4c950442e1Af093BcfF730381E63Ae9171b87a": [ + "0x09149717512c02479e10ad55dab819f4ddf6d8d1cf304508a2e54febe665ff99b325d10b95f9840b0aae7328a79306494170985fce1f383bcf011b2dcc04e74731", + "0x0722ae79d6e75ad494bd88905963080ce8b7f972d406148a828d3920474cee6fdd163336396af4ab08c8e36542e885a1e6d158e12441840fd51871b44c7ee56090", + "0x0700000000000000000000000000000000000000000000000000000000000000000525c2dbd58291d73647d2c76100c05d4cfa4dffaa3dd721e93a5f37facbceb1", + "0x070000000000000000000000000000000000000000000000000000000000000000133a06fc1d0f38c1826f2d9eecd527b0b18a656447f8de58c5936ba3b5601629", + "0x08250a120d3d9bf0ebf618e11c67af64ce68e92058e8984fb378b5794e041edaeb0000000000000000000000000000000000000000000000000000000000000000", + "0x06005a1c3d32c83abeeb31eed268704e7ae310d7143b0556be43fb2c374970e26b0b25a0da18ff8a0ed5c6ead5a5728e06caf41b2a73aaea75353303d21c59a77f", + "0x04301f15bc8e20aaff13d28665677737a7eef1627b6f0ed8ccd70c7c41b1e0e02e0508000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000008ac6fcd1a6d360000000000000000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4702098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864206f4c950442e1af093bcff730381e63ae9171b87a000000000000000000000000", + "0x5448495320495320534f4d45204d4147494320425954455320464f5220534d54206d3172525867503278704449" + ] + } + } + ], + "executionResults": [ + { + "l1DataFee": "0x2b", + "gas": 21000, + "failed": false, + "returnValue": "", + "from": { + "address": "0x6f4c950442e1af093bcff730381e63ae9171b87a", + "nonce": 4, + "balance": "0x8ac6fcd1a6d36000", + "keccakCodeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "poseidonCodeHash": "0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864", + "codeSize": 0 + }, + "to": { + "address": "0x6f4c950442e1af093bcff730381e63ae9171b87a", + "nonce": 4, + "balance": "0x8ac6fcd1a6d36000", + "keccakCodeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "poseidonCodeHash": "0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864", + "codeSize": 0 + }, + "accountAfter": [ + { + "address": "0x6f4c950442e1af093bcff730381e63ae9171b87a", + "nonce": 5, + "balance": "0x8ac6f344ee0e37d5", + "keccakCodeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "poseidonCodeHash": "0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864", + "codeSize": 0 + }, + { + "address": "0x6f4c950442e1af093bcff730381e63ae9171b87a", + "nonce": 5, + "balance": "0x8ac6f344ee0e37d5", + "keccakCodeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "poseidonCodeHash": "0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864", + "codeSize": 0 + }, + { + "address": "0x5300000000000000000000000000000000000005", + "nonce": 0, + "balance": "0x2fbf9bd9c82b", + "keccakCodeHash": "0x3733510decd4cdde078e264666d17cac208f9f9e93fc0a43b02921be5cf5726f", + "poseidonCodeHash": "0x1c0bc998c1d4a23089705ffaa44e274d41dec1eb01993b5f65202cf9c80d31bb", + "codeSize": 1956 + } + ], + "poseidonCodeHash": "0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864", + "byteCode": "0x", + "structLogs": [], + "callTrace": { + "type": "CALL", + "from": "0x6f4c950442e1af093bcff730381e63ae9171b87a", + "to": "0x6f4c950442e1af093bcff730381e63ae9171b87a", + "value": "0x0", + "gas": "0x13498", + "gasUsed": "0x0", + "input": "0x", + "output": "0x" + }, + "prestate": { + "0x5300000000000000000000000000000000000005": { + "balance": "0x2632e314a000", + "code": "0x6080604052600436106100ab5760003560e01c806384411d651161006457806384411d65146101845780638da5cb5b1461019a5780639e7adc79146101ba578063f2fde38b146101da578063feec756c146101fa578063ff4f35461461021a57600080fd5b80632e1a7d4d146100b75780633cb747bf146100d95780633ccfd60b14610116578063457e1a491461012b57806366d003ac1461014f578063715018a61461016f57600080fd5b366100b257005b600080fd5b3480156100c357600080fd5b506100d76100d2366004610682565b61023a565b005b3480156100e557600080fd5b506002546100f9906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561012257600080fd5b506100d76103ff565b34801561013757600080fd5b5061014160015481565b60405190815260200161010d565b34801561015b57600080fd5b506003546100f9906001600160a01b031681565b34801561017b57600080fd5b506100d761040c565b34801561019057600080fd5b5061014160045481565b3480156101a657600080fd5b506000546100f9906001600160a01b031681565b3480156101c657600080fd5b506100d76101d536600461069b565b610442565b3480156101e657600080fd5b506100d76101f536600461069b565b6104be565b34801561020657600080fd5b506100d761021536600461069b565b610547565b34801561022657600080fd5b506100d7610235366004610682565b6105c3565b6001548110156102ca5760405162461bcd60e51b815260206004820152604a60248201527f4665655661756c743a207769746864726177616c20616d6f756e74206d75737460448201527f2062652067726561746572207468616e206d696e696d756d20776974686472616064820152691dd85b08185b5bdd5b9d60b21b608482015260a4015b60405180910390fd5b478082111561032e5760405162461bcd60e51b815260206004820152602a60248201527f4665655661756c743a20696e73756666696369656e742062616c616e636520746044820152696f20776974686472617760b01b60648201526084016102c1565b6004805483019055600354604080518481526001600160a01b0390921660208301523382820152517fc8a211cc64b6ed1b50595a9fcb1932b6d1e5a6e8ef15b60e5b1f988ea9086bba9181900360600190a1600254600354604080516020810182526000808252915163b2267a7b60e01b81526001600160a01b039485169463b2267a7b9488946103c99491909216928592906004016106cb565b6000604051808303818588803b1580156103e257600080fd5b505af11580156103f6573d6000803e3d6000fd5b50505050505050565b476104098161023a565b50565b6000546001600160a01b031633146104365760405162461bcd60e51b81526004016102c190610737565b6104406000610632565b565b6000546001600160a01b0316331461046c5760405162461bcd60e51b81526004016102c190610737565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f1c928c417a10a21c3cddad148c5dba5d710e4b1442d6d8a36de345935ad8461290600090a35050565b6000546001600160a01b031633146104e85760405162461bcd60e51b81526004016102c190610737565b6001600160a01b03811661053e5760405162461bcd60e51b815260206004820152601d60248201527f6e6577206f776e657220697320746865207a65726f206164647265737300000060448201526064016102c1565b61040981610632565b6000546001600160a01b031633146105715760405162461bcd60e51b81526004016102c190610737565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f7e1e96961a397c8aa26162fe259cc837afc95e33aad4945ddc61c18dabb7a6ad90600090a35050565b6000546001600160a01b031633146105ed5760405162461bcd60e51b81526004016102c190610737565b600180549082905560408051828152602081018490527f0d3c80219fe57713b9f9c83d1e51426792d0c14d8e330e65b102571816140965910160405180910390a15050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561069457600080fd5b5035919050565b6000602082840312156106ad57600080fd5b81356001600160a01b03811681146106c457600080fd5b9392505050565b60018060a01b038516815260006020858184015260806040840152845180608085015260005b8181101561070d5786810183015185820160a0015282016106f1565b50600060a0828601015260a0601f19601f8301168501019250505082606083015295945050505050565b60208082526017908201527f63616c6c6572206973206e6f7420746865206f776e657200000000000000000060408201526060019056fea2646970667358221220063c6c384f745ebcacfdd13320e5b9a50687aae43ff14566761f56273111b97e64736f6c63430008100033" + }, + "0x6f4c950442e1af093bcff730381e63ae9171b87a": { + "balance": "0x8ac6cf581e963fd5", + "code": "0x", + "nonce": 4 + } + } + } + ], + "withdraw_trie_root": "0x0000000000000000000000000000000000000000000000000000000000000000", + "startL1QueueIndex": 0 +} diff --git a/integration/tests/inner_tests.rs b/integration/tests/inner_tests.rs index 10f67ea8a..795181882 100644 --- a/integration/tests/inner_tests.rs +++ b/integration/tests/inner_tests.rs @@ -1,4 +1,4 @@ -use integration::test_util::{load_block_traces_for_test, PARAMS_DIR}; +use integration::test_util::{load_chunk_for_test, PARAMS_DIR}; use prover::{ inner::{Prover, Verifier}, utils::init_env_and_log, @@ -12,7 +12,7 @@ fn test_inner_prove_verify() { let output_dir = init_env_and_log(test_name); log::info!("Initialized ENV and created output-dir {output_dir}"); - let chunk_trace = load_block_traces_for_test().1; + let chunk_trace = load_chunk_for_test().1; log::info!("Loaded chunk trace"); let mut prover = Prover::::from_params_dir(PARAMS_DIR); diff --git a/integration/tests/integration.rs b/integration/tests/integration.rs index b1b71b303..13a05c733 100644 --- a/integration/tests/integration.rs +++ b/integration/tests/integration.rs @@ -2,7 +2,7 @@ use halo2_proofs::{ plonk::{keygen_pk2, keygen_vk}, poly::commitment::Params, }; -use integration::test_util::{load_block_traces_for_test, PARAMS_DIR}; +use integration::test_util::{load_chunk_for_test, PARAMS_DIR}; use prover::{ config::INNER_DEGREE, io::serialize_vk, @@ -45,7 +45,7 @@ fn test_cs_same_for_vk_consistent() { "Dummy super cicuit" ); - let block_trace = load_block_traces_for_test().1; + let block_trace = load_chunk_for_test().1; let real_circuit = SuperCircuit::from_block_traces(block_trace).unwrap().0; let pk = keygen_pk2(¶ms, &real_circuit).unwrap(); @@ -62,7 +62,7 @@ fn test_deterministic() { use halo2_proofs::dev::MockProver; init_env_and_log("integration"); type C = SuperCircuit; - let block_trace = load_block_traces_for_test().1; + let block_trace = load_chunk_for_test().1; let circuit1 = C::from_block_traces(block_trace.clone()).unwrap().0; let prover1 = MockProver::<_>::run(*INNER_DEGREE, &circuit1, circuit1.instance()).unwrap(); @@ -100,7 +100,7 @@ fn test_vk_same() { "./tests/extra_traces/batch_25/chunk_113".to_string(), ]; std::env::set_var("TRACE_PATH", p1); - let block_trace1 = load_block_traces_for_test().1; + let block_trace1 = load_chunk_for_test().1; std::env::set_var("TRACE_PATH", p2); //let block_trace2 = load_block_traces_for_test().1; diff --git a/integration/tests/mock_tests.rs b/integration/tests/mock_tests.rs index c64a329fc..d47f902a7 100644 --- a/integration/tests/mock_tests.rs +++ b/integration/tests/mock_tests.rs @@ -1,4 +1,4 @@ -use integration::test_util::load_block_traces_for_test; +use integration::test_util::load_chunk_for_test; use prover::{inner::Prover, utils::init_env_and_log, zkevm::circuit::SuperCircuit}; #[cfg(feature = "prove_verify")] @@ -6,6 +6,6 @@ use prover::{inner::Prover, utils::init_env_and_log, zkevm::circuit::SuperCircui fn test_mock_prove() { init_env_and_log("mock_tests"); - let block_traces = load_block_traces_for_test().1; + let block_traces = load_chunk_for_test().1; Prover::::mock_prove_target_circuit_chunk(block_traces).unwrap(); } diff --git a/integration/tests/unit_tests.rs b/integration/tests/unit_tests.rs index 989c37d31..f2354746d 100644 --- a/integration/tests/unit_tests.rs +++ b/integration/tests/unit_tests.rs @@ -1,7 +1,7 @@ // Fast tests which can be finished within minutes use integration::test_util::{ - ccc_as_signer, load_block_traces_for_test, prepare_circuit_capacity_checker, + ccc_as_signer, load_chunk_for_test, prepare_circuit_capacity_checker, run_circuit_capacity_checker, }; use prover::{ @@ -24,7 +24,7 @@ fn test_capacity_checker() { init_env_and_log("integration"); prepare_circuit_capacity_checker(); - let block_traces = load_block_traces_for_test().1; + let block_traces = load_chunk_for_test().1; let full = false; let batch_id = 0; @@ -44,7 +44,7 @@ fn estimate_circuit_rows() { init_env_and_log("integration"); prepare_circuit_capacity_checker(); - let (_, block_trace) = load_block_traces_for_test(); + let (_, block_trace) = load_chunk_for_test(); let witness_block = block_traces_to_witness_block(block_trace).unwrap(); log::info!("estimating used rows"); let row_usage = ::Inner::min_num_rows_block_subcircuits(&witness_block); diff --git a/release.sh b/release.sh index 17579df07..a1cf4d65b 100644 --- a/release.sh +++ b/release.sh @@ -1,5 +1,5 @@ -IN=integration/outputs/agg_tests_20240527_051045 -OUT=release-v0.11.0rc0 +IN=integration/outputs/agg_tests_20240530_134631 +OUT=release-v0.11.0rc5 mkdir -p $OUT cp $IN/chunk_chunk_0.protocol $OUT/chunk.protocol