From bdc716ecb5ac317c86155d44e4630d7ca7e19685 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Tue, 20 Aug 2024 14:20:11 +0800 Subject: [PATCH 01/18] feat(prover): using circuits version replace hard fork name --- prover/config.json | 8 ++++-- prover/src/config.rs | 1 + prover/src/coordinator_client/types.rs | 1 + prover/src/prover.rs | 2 +- prover/src/types.rs | 2 ++ prover/src/zk_circuits_handler.rs | 38 ++++++++++++++------------ 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/prover/config.json b/prover/config.json index daaf989f53..a8e8e58cd9 100644 --- a/prover/config.json +++ b/prover/config.json @@ -3,16 +3,18 @@ "keystore_path": "keystore.json", "keystore_password": "prover-pwd", "db_path": "unique-db-path-for-prover-1", - "proof_type": 2, + "prover_type": 2, "low_version_circuit": { "hard_fork_name": "bernoulli", "params_path": "params", - "assets_path": "assets" + "assets_path": "assets", + "version": "" }, "high_version_circuit": { "hard_fork_name": "curie", "params_path": "params", - "assets_path": "assets" + "assets_path": "assets", + "version": "" }, "coordinator": { "base_url": "http://localhost:8555", diff --git a/prover/src/config.rs b/prover/src/config.rs index 4e3c1f2ccc..4c52225e9f 100644 --- a/prover/src/config.rs +++ b/prover/src/config.rs @@ -7,6 +7,7 @@ use crate::types::ProverType; #[derive(Debug, Serialize, Deserialize)] pub struct CircuitConfig { pub hard_fork_name: String, + pub circuits_version: String, pub params_path: String, pub assets_path: String, } diff --git a/prover/src/coordinator_client/types.rs b/prover/src/coordinator_client/types.rs index c646a9afd4..5ddf8381cc 100644 --- a/prover/src/coordinator_client/types.rs +++ b/prover/src/coordinator_client/types.rs @@ -69,6 +69,7 @@ pub struct GetTaskResponseData { pub task_type: TaskType, pub task_data: String, pub hard_fork_name: String, + pub circuits_version: Option, } #[derive(Serialize, Deserialize, Default)] diff --git a/prover/src/prover.rs b/prover/src/prover.rs index 7de83906e0..b629c52b6d 100644 --- a/prover/src/prover.rs +++ b/prover/src/prover.rs @@ -100,7 +100,7 @@ impl<'a> Prover<'a> { let handler: Rc> = self .circuits_handler_provider .borrow_mut() - .get_circuits_handler(&task.hard_fork_name) + .get_circuits_handler(&task.circuits_version) .context("failed to get circuit handler")?; self.do_prove(task, handler) } diff --git a/prover/src/types.rs b/prover/src/types.rs index 47f2724fc7..2eb5b6e788 100644 --- a/prover/src/types.rs +++ b/prover/src/types.rs @@ -110,6 +110,7 @@ pub struct Task { pub task_data: String, #[serde(default)] pub hard_fork_name: String, + pub circuits_version: String, } impl From for Task { @@ -120,6 +121,7 @@ impl From for Task { task_type: value.task_type, task_data: value.task_data, hard_fork_name: value.hard_fork_name, + circuits_version: value.circuits_version.unwrap_or("".to_string()), } } } diff --git a/prover/src/zk_circuits_handler.rs b/prover/src/zk_circuits_handler.rs index ab79cd765c..16affbdc1a 100644 --- a/prover/src/zk_circuits_handler.rs +++ b/prover/src/zk_circuits_handler.rs @@ -12,7 +12,7 @@ use darwin::DarwinHandler; use edison::EdisonHandler; use std::{cell::RefCell, collections::HashMap, rc::Rc}; -type HardForkName = String; +type CircuitsVersion = String; pub mod utils { pub fn encode_vk(vk: Vec) -> String { @@ -36,9 +36,9 @@ pub struct CircuitsHandlerProvider<'a> { prover_type: ProverType, config: &'a Config, geth_client: Option>>, - circuits_handler_builder_map: HashMap, + circuits_handler_builder_map: HashMap, - current_hard_fork_name: Option, + current_circuits_version: Option, current_circuit: Option>>, } @@ -48,7 +48,7 @@ impl<'a> CircuitsHandlerProvider<'a> { config: &'a Config, geth_client: Option>>, ) -> Result { - let mut m: HashMap = HashMap::new(); + let mut m: HashMap = HashMap::new(); fn handler_builder( prover_type: ProverType, @@ -56,8 +56,9 @@ impl<'a> CircuitsHandlerProvider<'a> { geth_client: Option>>, ) -> Result> { log::info!( - "now init zk circuits handler, hard_fork_name: {}", - &config.low_version_circuit.hard_fork_name + "now init zk circuits handler, hard_fork_name: {}, version: {}", + &config.low_version_circuit.hard_fork_name, + &config.low_version_circuit.circuits_version, ); AssetsDirEnvConfig::enable_first(); DarwinHandler::new( @@ -69,7 +70,7 @@ impl<'a> CircuitsHandlerProvider<'a> { .map(|handler| Box::new(handler) as Box) } m.insert( - config.low_version_circuit.hard_fork_name.clone(), + config.low_version_circuit.circuits_version.clone(), handler_builder, ); @@ -79,8 +80,9 @@ impl<'a> CircuitsHandlerProvider<'a> { geth_client: Option>>, ) -> Result> { log::info!( - "now init zk circuits handler, hard_fork_name: {}", - &config.high_version_circuit.hard_fork_name + "now init zk circuits handler, hard_fork_name: {}, version: {}", + &config.high_version_circuit.hard_fork_name, + &config.high_version_circuit.circuits_version ); AssetsDirEnvConfig::enable_second(); EdisonHandler::new( @@ -93,7 +95,7 @@ impl<'a> CircuitsHandlerProvider<'a> { } m.insert( - config.high_version_circuit.hard_fork_name.clone(), + config.high_version_circuit.circuits_version.clone(), next_handler_builder, ); @@ -102,7 +104,7 @@ impl<'a> CircuitsHandlerProvider<'a> { config, geth_client, circuits_handler_builder_map: m, - current_hard_fork_name: None, + current_circuits_version: None, current_circuit: None, }; @@ -111,10 +113,10 @@ impl<'a> CircuitsHandlerProvider<'a> { pub fn get_circuits_handler( &mut self, - hard_fork_name: &String, + circuits_version: &String, ) -> Result>> { - match &self.current_hard_fork_name { - Some(name) if name == hard_fork_name => { + match &self.current_circuits_version { + Some(version) if version == circuits_version => { log::info!("get circuits handler from cache"); if let Some(handler) = &self.current_circuit { Ok(handler.clone()) @@ -125,13 +127,13 @@ impl<'a> CircuitsHandlerProvider<'a> { } _ => { log::info!( - "failed to get circuits handler from cache, create a new one: {hard_fork_name}" + "failed to get circuits handler from cache, create a new one: {circuits_version}" ); - if let Some(builder) = self.circuits_handler_builder_map.get(hard_fork_name) { - log::info!("building circuits handler for {hard_fork_name}"); + if let Some(builder) = self.circuits_handler_builder_map.get(circuits_version) { + log::info!("building circuits handler for {circuits_version}"); let handler = builder(self.prover_type, self.config, self.geth_client.clone()) .expect("failed to build circuits handler"); - self.current_hard_fork_name = Some(hard_fork_name.clone()); + self.current_circuits_version = Some(circuits_version.clone()); let rc_handler = Rc::new(handler); self.current_circuit = Some(rc_handler.clone()); Ok(rc_handler) From f256f7535da7fad4a9021b003459479b1d8c6af7 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Tue, 20 Aug 2024 17:23:35 +0800 Subject: [PATCH 02/18] feat(coordinator): refactor libzkp && coordinator uses circuits version instead of hard fork --- common/libzkp/impl/Cargo.lock | 5 +- common/libzkp/impl/Cargo.toml | 1 + common/libzkp/impl/src/batch.rs | 64 ---------------- common/libzkp/impl/src/chunk.rs | 63 ---------------- common/libzkp/impl/src/lib.rs | 74 ++++++++++++++++++- common/libzkp/impl/src/types.rs | 22 ------ common/libzkp/impl/src/verifier.rs | 70 ++++++++++++++++++ common/libzkp/impl/src/verifier/darwin.rs | 49 ++++++++++++ common/libzkp/impl/src/verifier/edison.rs | 49 ++++++++++++ common/libzkp/interface/libzkp.h | 9 +-- coordinator/conf/config.json | 13 +++- coordinator/internal/config/config.go | 16 ++-- .../logic/submitproof/proof_receiver.go | 8 +- .../internal/logic/verifier/verifier.go | 51 +++++++++---- coordinator/internal/types/get_task.go | 11 +-- 15 files changed, 314 insertions(+), 191 deletions(-) delete mode 100644 common/libzkp/impl/src/batch.rs delete mode 100644 common/libzkp/impl/src/chunk.rs delete mode 100644 common/libzkp/impl/src/types.rs create mode 100644 common/libzkp/impl/src/verifier.rs create mode 100644 common/libzkp/impl/src/verifier/darwin.rs create mode 100644 common/libzkp/impl/src/verifier/edison.rs diff --git a/common/libzkp/impl/Cargo.lock b/common/libzkp/impl/Cargo.lock index caae228080..2df231e2b5 100644 --- a/common/libzkp/impl/Cargo.lock +++ b/common/libzkp/impl/Cargo.lock @@ -171,9 +171,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arc-swap" @@ -4628,6 +4628,7 @@ dependencies = [ name = "zkp" version = "0.1.0" dependencies = [ + "anyhow", "base64 0.13.1", "env_logger 0.9.3", "halo2_proofs", diff --git a/common/libzkp/impl/Cargo.toml b/common/libzkp/impl/Cargo.toml index 8927f41cbf..501f98a55a 100644 --- a/common/libzkp/impl/Cargo.toml +++ b/common/libzkp/impl/Cargo.toml @@ -37,6 +37,7 @@ once_cell = "1.19" serde = "1.0" serde_derive = "1.0" serde_json = "1.0.66" +anyhow = "1.0.86" [profile.test] opt-level = 3 diff --git a/common/libzkp/impl/src/batch.rs b/common/libzkp/impl/src/batch.rs deleted file mode 100644 index 61d248fb89..0000000000 --- a/common/libzkp/impl/src/batch.rs +++ /dev/null @@ -1,64 +0,0 @@ -use crate::utils::{c_char_to_str, c_char_to_vec, panic_catch}; -use libc::c_char; -use prover_v4::BatchProof as BatchProofLoVersion; -use prover_v5::{ - aggregator::Verifier as VerifierHiVersion, utils::init_env_and_log, - BatchProof as BatchProofHiVersion, BundleProof, -}; -use snark_verifier_sdk::verify_evm_calldata; -use std::{cell::OnceCell, env}; - -static mut VERIFIER: OnceCell = OnceCell::new(); - -/// # Safety -#[no_mangle] -pub unsafe extern "C" fn init_batch_verifier(params_dir: *const c_char, assets_dir: *const c_char) { - init_env_and_log("ffi_batch_verify"); - - let params_dir = c_char_to_str(params_dir); - let assets_dir = c_char_to_str(assets_dir); - - // TODO: add a settings in scroll-prover. - env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir); - let verifier_hi = VerifierHiVersion::from_dirs(params_dir, assets_dir); - - VERIFIER.set(verifier_hi).unwrap(); -} - -/// # Safety -#[no_mangle] -pub unsafe extern "C" fn verify_batch_proof( - proof: *const c_char, - fork_name: *const c_char, -) -> c_char { - let proof = c_char_to_vec(proof); - let fork_name_str = c_char_to_str(fork_name); - let fork_id = match fork_name_str { - "darwin" => 4, - "edison" => 5, - _ => { - log::warn!("unexpected fork_name {fork_name_str}, treated as edison"); - 5 - } - }; - let verified = panic_catch(|| { - if fork_id == 4 { - unimplemented!("todo"); - } else { - // Post upgrade #4 (Darwin), batch proofs are not EVM-verifiable. Instead they are - // halo2 proofs meant to be bundled recursively. - let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); - VERIFIER.get().unwrap().verify_batch_proof(&proof) - } - }); - verified.unwrap_or(false) as c_char -} - -/// # Safety -#[no_mangle] -pub unsafe extern "C" fn verify_bundle_proof(proof: *const c_char) -> c_char { - let proof = c_char_to_vec(proof); - let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); - let verified = panic_catch(|| VERIFIER.get().unwrap().verify_bundle_proof(proof)); - verified.unwrap_or(false) as c_char -} diff --git a/common/libzkp/impl/src/chunk.rs b/common/libzkp/impl/src/chunk.rs deleted file mode 100644 index cb781f3898..0000000000 --- a/common/libzkp/impl/src/chunk.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::utils::{c_char_to_str, c_char_to_vec, panic_catch}; -use libc::c_char; -use prover_v4::{zkevm::Verifier as VerifierLoVersion, ChunkProof as ChunkProofLoVersion}; -use prover_v5::{ - utils::init_env_and_log, zkevm::Verifier as VerifierHiVersion, - ChunkProof as ChunkProofHiVersion, -}; -use std::{cell::OnceCell, env}; - -static mut VERIFIER_LO_VERSION: OnceCell = OnceCell::new(); -static mut VERIFIER_HI_VERSION: OnceCell = OnceCell::new(); - -/// # Safety -#[no_mangle] -pub unsafe extern "C" fn init_chunk_verifier( - params_dir: *const c_char, - v4_assets_dir: *const c_char, - v5_assets_dir: *const c_char, -) { - init_env_and_log("ffi_chunk_verify"); - - let params_dir = c_char_to_str(params_dir); - let v4_assets_dir = c_char_to_str(v4_assets_dir); - let v5_assets_dir = c_char_to_str(v5_assets_dir); - - // TODO: add a settings in scroll-prover. - env::set_var("SCROLL_PROVER_ASSETS_DIR", v4_assets_dir); - let verifier_lo = VerifierLoVersion::from_dirs(params_dir, v4_assets_dir); - env::set_var("SCROLL_PROVER_ASSETS_DIR", v5_assets_dir); - let verifier_hi = VerifierHiVersion::from_dirs(params_dir, v5_assets_dir); - - VERIFIER_LO_VERSION.set(verifier_lo).unwrap(); - VERIFIER_HI_VERSION.set(verifier_hi).unwrap(); -} - -/// # Safety -#[no_mangle] -pub unsafe extern "C" fn verify_chunk_proof( - proof: *const c_char, - fork_name: *const c_char, -) -> c_char { - let proof = c_char_to_vec(proof); - - let fork_name_str = c_char_to_str(fork_name); - let fork_id = match fork_name_str { - "darwin" => 4, - "edison" => 5, - _ => { - log::warn!("unexpected fork_name {fork_name_str}, treated as edison"); - 5 - } - }; - let verified = panic_catch(|| { - if fork_id == 4 { - let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); - VERIFIER_LO_VERSION.get().unwrap().verify_chunk_proof(proof) - } else { - let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); - VERIFIER_HI_VERSION.get().unwrap().verify_chunk_proof(proof) - } - }); - verified.unwrap_or(false) as c_char -} diff --git a/common/libzkp/impl/src/lib.rs b/common/libzkp/impl/src/lib.rs index 674b696b90..fc653584e1 100644 --- a/common/libzkp/impl/src/lib.rs +++ b/common/libzkp/impl/src/lib.rs @@ -1,4 +1,72 @@ -mod batch; -mod chunk; -mod types; +mod verifier; mod utils; + +use prover_v5::utils::init_env_and_log; +use crate::utils::{c_char_to_str, c_char_to_vec}; +use libc::c_char; +use verifier::{TaskType, VerifierConfig}; + +/// # Safety +#[no_mangle] +pub unsafe extern "C" fn init( + config: *const c_char, +) { + init_env_and_log("ffi_init"); + + let config_str = c_char_to_str(config); + let verifier_config = serde_json::from_str::(config_str).unwrap(); + verifier::init(verifier_config); +} + +/// # Safety +#[no_mangle] +pub unsafe extern "C" fn verify_chunk_proof( + proof: *const c_char, + fork_name: *const c_char, + circuits_version: *const c_char, +) -> c_char { + verify_proof(proof, fork_name, circuits_version, TaskType::Chunk) +} + +fn verify_proof(proof: *const c_char, + _fork_name: *const c_char, + circuits_version: *const c_char, + task_type: TaskType, +) -> c_char { + let proof = c_char_to_vec(proof); + + let circuits_version_str = c_char_to_str(circuits_version); + let verifier = verifier::get_verifier(circuits_version_str); + + if let Err(e) = verifier { + log::warn!("failed to get verifier, error: {:#}", e); + return 0 as c_char; + } + match verifier.unwrap().verify(task_type, proof) { + Err(e) => { + log::error!("{:?} verify failed, error: {:#}", task_type, e); + false as c_char + } + Ok(result) => result as c_char + } +} + +/// # Safety +#[no_mangle] +pub unsafe extern "C" fn verify_batch_proof( + proof: *const c_char, + fork_name: *const c_char, + circuits_version: *const c_char, +) -> c_char { + verify_proof(proof, fork_name, circuits_version, TaskType::Batch) +} + +/// # Safety +#[no_mangle] +pub unsafe extern "C" fn verify_bundle_proof( + proof: *const c_char, + fork_name: *const c_char, + circuits_version: *const c_char, +) -> c_char { + verify_proof(proof, fork_name, circuits_version, TaskType::Bundle) +} \ No newline at end of file diff --git a/common/libzkp/impl/src/types.rs b/common/libzkp/impl/src/types.rs deleted file mode 100644 index 1d066a4282..0000000000 --- a/common/libzkp/impl/src/types.rs +++ /dev/null @@ -1,22 +0,0 @@ -use serde::{Deserialize, Serialize}; - -// Represents the result of a chunk proof checking operation. -// `ok` indicates whether the proof checking was successful. -// `error` provides additional details in case the check failed. -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct CheckChunkProofsResponse { - pub ok: bool, - #[serde(skip_serializing_if = "Option::is_none")] - pub error: Option, -} - -// Encapsulates the result from generating a proof. -// `message` holds the generated proof in byte slice format. -// `error` provides additional details in case the proof generation failed. -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ProofResult { - #[serde(skip_serializing_if = "Option::is_none")] - pub message: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub error: Option, -} diff --git a/common/libzkp/impl/src/verifier.rs b/common/libzkp/impl/src/verifier.rs new file mode 100644 index 0000000000..47eb42aa50 --- /dev/null +++ b/common/libzkp/impl/src/verifier.rs @@ -0,0 +1,70 @@ +mod darwin; +mod edison; + +use anyhow::{bail, Result}; +use darwin::DarwinVerifier; +use edison::EdisonVerifier; +use serde::{Deserialize, Serialize}; +use std::cell::OnceCell; + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum TaskType { + Chunk, + Batch, + Bundle, +} + +pub trait ProofVerifier { + fn verify(&self, task_type: TaskType, proof: Vec) -> Result; +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct CircuitConfig { + pub version: String, + pub params_path: String, + pub assets_path: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct VerifierConfig { + pub low_version_circuit: CircuitConfig, + pub high_version_circuit: CircuitConfig, +} + +type CircuitsVersion = String; + +struct VerifierPair(CircuitsVersion, Box); + +static mut VERIFIER_HIGH: OnceCell = OnceCell::new(); +static mut VERIFIER_LOW: OnceCell = OnceCell::new(); + +pub fn init(config: VerifierConfig) { + let low_conf = config.low_version_circuit; + let verifier = DarwinVerifier::new(&low_conf.params_path, &low_conf.assets_path); + + unsafe { + VERIFIER_LOW.set(VerifierPair(low_conf.version, Box::new(verifier))).unwrap_unchecked(); + } + let high_conf = config.high_version_circuit; + let verifier = EdisonVerifier::new(&high_conf.params_path, &high_conf.assets_path); + unsafe { + VERIFIER_HIGH.set(VerifierPair(high_conf.version, Box::new(verifier))).unwrap_unchecked(); + } +} + +pub fn get_verifier(circuits_version: &str) -> Result<&'static Box> { + unsafe { + if let Some(verifier) = VERIFIER_LOW.get() { + if verifier.0 == circuits_version { + return Ok(&verifier.1); + } + } + + if let Some(verifier) = VERIFIER_HIGH.get() { + if verifier.0 == circuits_version { + return Ok(&verifier.1); + } + } + } + bail!("failed to get verifier, key not found, {}", circuits_version) +} \ No newline at end of file diff --git a/common/libzkp/impl/src/verifier/darwin.rs b/common/libzkp/impl/src/verifier/darwin.rs new file mode 100644 index 0000000000..040c33ced7 --- /dev/null +++ b/common/libzkp/impl/src/verifier/darwin.rs @@ -0,0 +1,49 @@ +use super::{ProofVerifier, TaskType}; + +use anyhow::Result; + +use prover_v4::{zkevm::Verifier, aggregator::Verifier as AggVerifier, ChunkProof, BatchProof, BundleProof}; +use std::env; +use crate::utils::panic_catch; + + +pub struct DarwinVerifier { + verifier: Verifier, + agg_verifier: AggVerifier, +} + +impl DarwinVerifier { + pub fn new(params_dir: &str, assets_dir: &str) -> Self { + env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir); + let verifier = Verifier::from_dirs(params_dir, assets_dir); + + let agg_verifier = AggVerifier::from_dirs(params_dir, assets_dir); + + Self { + verifier, + agg_verifier, + } + } +} + +impl ProofVerifier for DarwinVerifier { + fn verify(&self, task_type: super::TaskType, proof: Vec) -> Result { + let result = panic_catch(|| { + match task_type { + TaskType::Chunk => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.verifier.verify_chunk_proof(proof) + }, + TaskType::Batch => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.agg_verifier.verify_batch_proof(&proof) + }, + TaskType::Bundle => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.agg_verifier.verify_bundle_proof(proof) + }, + } + }); + result.map_err(|e| anyhow::anyhow!(e)) + } +} \ No newline at end of file diff --git a/common/libzkp/impl/src/verifier/edison.rs b/common/libzkp/impl/src/verifier/edison.rs new file mode 100644 index 0000000000..bd16fa076f --- /dev/null +++ b/common/libzkp/impl/src/verifier/edison.rs @@ -0,0 +1,49 @@ +use super::{ProofVerifier, TaskType}; + +use anyhow::Result; + +use prover_v5::{zkevm::Verifier, aggregator::Verifier as AggVerifier, ChunkProof, BatchProof, BundleProof}; +use std::env; +use crate::utils::panic_catch; + + +pub struct EdisonVerifier { + verifier: Verifier, + agg_verifier: AggVerifier, +} + +impl EdisonVerifier { + pub fn new(params_dir: &str, assets_dir: &str) -> Self { + env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir); + let verifier = Verifier::from_dirs(params_dir, assets_dir); + + let agg_verifier = AggVerifier::from_dirs(params_dir, assets_dir); + + Self { + verifier, + agg_verifier, + } + } +} + +impl ProofVerifier for EdisonVerifier { + fn verify(&self, task_type: super::TaskType, proof: Vec) -> Result { + let result = panic_catch(|| { + match task_type { + TaskType::Chunk => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.verifier.verify_chunk_proof(proof) + }, + TaskType::Batch => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.agg_verifier.verify_batch_proof(&proof) + }, + TaskType::Bundle => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.agg_verifier.verify_bundle_proof(proof) + }, + } + }); + result.map_err(|e| anyhow::anyhow!(e)) + } +} \ No newline at end of file diff --git a/common/libzkp/interface/libzkp.h b/common/libzkp/interface/libzkp.h index 3b8c359a60..a70dc3748c 100644 --- a/common/libzkp/interface/libzkp.h +++ b/common/libzkp/interface/libzkp.h @@ -1,11 +1,10 @@ // BatchVerifier is used to: // - Verify a batch proof // - Verify a bundle proof -void init_batch_verifier(char* params_dir, char* assets_dir); +void init(char* config); -char verify_batch_proof(char* proof, char* fork_name); +char verify_batch_proof(char* proof, char* fork_name, char* circuits_version); -char verify_bundle_proof(char* proof); +char verify_bundle_proof(char* proof, char* fork_name, char* circuits_version); -void init_chunk_verifier(char* params_dir, char* v3_assets_dir, char* v4_assets_dir); -char verify_chunk_proof(char* proof, char* fork_name); +char verify_chunk_proof(char* proof, char* fork_name, char* circuits_version); diff --git a/coordinator/conf/config.json b/coordinator/conf/config.json index 15ae708f8d..b3979ad3ab 100644 --- a/coordinator/conf/config.json +++ b/coordinator/conf/config.json @@ -8,9 +8,16 @@ "verifier": { "fork_name": "bernoulli", "mock_mode": true, - "params_path": "", - "assets_path_lo": "", - "assets_path_hi": "" + "low_version_circuit": { + "params_path": "params", + "assets_path": "assets", + "version": "" + }, + "high_version_circuit": { + "params_path": "params", + "assets_path": "assets", + "version": "" + } }, "max_verifier_workers": 4, "min_prover_version": "v1.0.0" diff --git a/coordinator/internal/config/config.go b/coordinator/internal/config/config.go index cbe9ca02d8..b0d78b70aa 100644 --- a/coordinator/internal/config/config.go +++ b/coordinator/internal/config/config.go @@ -50,13 +50,19 @@ type Config struct { Auth *Auth `json:"auth"` } +// CircuitConfig circuit items. +type CircuitConfig struct { + ParamsPath string `json:"params_path"` + AssetsPath string `json:"assets_path"` + Version string `json:"version"` +} + // VerifierConfig load zk verifier config. type VerifierConfig struct { - ForkName string `json:"fork_name"` - MockMode bool `json:"mock_mode"` - ParamsPath string `json:"params_path"` - AssetsPathLo string `json:"assets_path_lo"` // lower version Verifier - AssetsPathHi string `json:"assets_path_hi"` // higher version Verifier + ForkName string `json:"fork_name"` + MockMode bool `json:"mock_mode"` + LowVersionCircuit *CircuitConfig `json:"low_version_circuit"` + HighVersionCircuit *CircuitConfig `json:"high_version_circuit"` } // NewConfig returns a new instance of Config. diff --git a/coordinator/internal/logic/submitproof/proof_receiver.go b/coordinator/internal/logic/submitproof/proof_receiver.go index c8450a7d54..65ee0614a0 100644 --- a/coordinator/internal/logic/submitproof/proof_receiver.go +++ b/coordinator/internal/logic/submitproof/proof_receiver.go @@ -169,25 +169,27 @@ func (m *ProofReceiverLogic) HandleZkProof(ctx *gin.Context, proofParameter coor return ErrGetHardForkNameFailed } + var circuitsVersion string + switch message.ProofType(proofParameter.TaskType) { case message.ProofTypeChunk: var chunkProof message.ChunkProof if unmarshalErr := json.Unmarshal([]byte(proofParameter.Proof), &chunkProof); unmarshalErr != nil { return unmarshalErr } - success, verifyErr = m.verifier.VerifyChunkProof(&chunkProof, hardForkName) + success, verifyErr = m.verifier.VerifyChunkProof(&chunkProof, hardForkName, circuitsVersion) case message.ProofTypeBatch: var batchProof message.BatchProof if unmarshalErr := json.Unmarshal([]byte(proofParameter.Proof), &batchProof); unmarshalErr != nil { return unmarshalErr } - success, verifyErr = m.verifier.VerifyBatchProof(&batchProof, hardForkName) + success, verifyErr = m.verifier.VerifyBatchProof(&batchProof, hardForkName, circuitsVersion) case message.ProofTypeBundle: var bundleProof message.BundleProof if unmarshalErr := json.Unmarshal([]byte(proofParameter.Proof), &bundleProof); unmarshalErr != nil { return unmarshalErr } - success, verifyErr = m.verifier.VerifyBundleProof(&bundleProof) + success, verifyErr = m.verifier.VerifyBundleProof(&bundleProof, hardForkName, circuitsVersion) } if verifyErr != nil || !success { diff --git a/coordinator/internal/logic/verifier/verifier.go b/coordinator/internal/logic/verifier/verifier.go index b394bfba92..130a71ecf3 100644 --- a/coordinator/internal/logic/verifier/verifier.go +++ b/coordinator/internal/logic/verifier/verifier.go @@ -27,6 +27,11 @@ import ( "scroll-tech/coordinator/internal/config" ) +type rustVerifierConfig struct { + LowVersionCircuit *config.CircuitConfig `json:"low_version_circuit"` + HighVersionCircuit *config.CircuitConfig `json:"high_version_circuit"` +} + // NewVerifier Sets up a rust ffi to call verify. func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { if cfg.MockMode { @@ -35,17 +40,23 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { bundleVKMap := map[string]string{cfg.ForkName: "mock_vk"} return &Verifier{cfg: cfg, ChunkVKMap: chunkVKMap, BatchVKMap: batchVKMap, BundleVkMap: bundleVKMap}, nil } - paramsPathStr := C.CString(cfg.ParamsPath) - assetsPathLoStr := C.CString(cfg.AssetsPathLo) - assetsPathHiStr := C.CString(cfg.AssetsPathHi) + verifierConfig := rustVerifierConfig{ + LowVersionCircuit: cfg.LowVersionCircuit, + HighVersionCircuit: cfg.HighVersionCircuit, + } + configBytes, err := json.Marshal(verifierConfig) + if err != nil { + return nil, err + } + + configStr := C.CString(string(configBytes)) + assetsPathHiStr := C.CString(cfg.HighVersionCircuit.AssetsPath) defer func() { - C.free(unsafe.Pointer(paramsPathStr)) - C.free(unsafe.Pointer(assetsPathLoStr)) + C.free(unsafe.Pointer(configStr)) C.free(unsafe.Pointer(assetsPathHiStr)) }() - C.init_batch_verifier(paramsPathStr, assetsPathHiStr) - C.init_chunk_verifier(paramsPathStr, assetsPathLoStr, assetsPathHiStr) + C.init() v := &Verifier{ cfg: cfg, @@ -54,15 +65,15 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { BundleVkMap: make(map[string]string), } - bundleVK, err := v.readVK(path.Join(cfg.AssetsPathHi, "vk_bundle.vkey")) + bundleVK, err := v.readVK(path.Join(cfg.HighVersionCircuit.AssetsPath, "vk_bundle.vkey")) if err != nil { return nil, err } - batchVK, err := v.readVK(path.Join(cfg.AssetsPathHi, "vk_batch.vkey")) + batchVK, err := v.readVK(path.Join(cfg.HighVersionCircuit.AssetsPath, "vk_batch.vkey")) if err != nil { return nil, err } - chunkVK, err := v.readVK(path.Join(cfg.AssetsPathHi, "vk_chunk.vkey")) + chunkVK, err := v.readVK(path.Join(cfg.HighVersionCircuit.AssetsPath, "vk_chunk.vkey")) if err != nil { return nil, err } @@ -77,7 +88,7 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { } // VerifyBatchProof Verify a ZkProof by marshaling it and sending it to the Halo2 Verifier. -func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName string) (bool, error) { +func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName, circuitsVersion string) (bool, error) { if v.cfg.MockMode { log.Info("Mock mode, batch verifier disabled") if string(proof.Proof) == InvalidTestProof { @@ -94,17 +105,19 @@ func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName string) log.Info("Start to verify batch proof", "forkName", forkName) proofStr := C.CString(string(buf)) forkNameStr := C.CString(forkName) + circuitsVersionStr := C.CString(circuitsVersion) defer func() { C.free(unsafe.Pointer(proofStr)) C.free(unsafe.Pointer(forkNameStr)) + C.free(unsafe.Pointer(circuitsVersionStr)) }() - verified := C.verify_batch_proof(proofStr, forkNameStr) + verified := C.verify_batch_proof(proofStr, forkNameStr, circuitsVersionStr) return verified != 0, nil } // VerifyChunkProof Verify a ZkProof by marshaling it and sending it to the Halo2 Verifier. -func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName string) (bool, error) { +func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName, circuitsVersion string) (bool, error) { if v.cfg.MockMode { log.Info("Mock mode, verifier disabled") if string(proof.Proof) == InvalidTestProof { @@ -121,17 +134,19 @@ func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName string) log.Info("Start to verify chunk proof", "forkName", forkName) proofStr := C.CString(string(buf)) forkNameStr := C.CString(forkName) + circuitsVersionStr := C.CString(circuitsVersion) defer func() { C.free(unsafe.Pointer(proofStr)) C.free(unsafe.Pointer(forkNameStr)) + C.free(unsafe.Pointer(circuitsVersionStr)) }() - verified := C.verify_chunk_proof(proofStr, forkNameStr) + verified := C.verify_chunk_proof(proofStr, forkNameStr, circuitsVersionStr) return verified != 0, nil } // VerifyBundleProof Verify a ZkProof for a bundle of batches, by marshaling it and verifying it via the EVM verifier. -func (v *Verifier) VerifyBundleProof(proof *message.BundleProof) (bool, error) { +func (v *Verifier) VerifyBundleProof(proof *message.BundleProof, forkName, circuitsVersion string) (bool, error) { if v.cfg.MockMode { log.Info("Mock mode, verifier disabled") if string(proof.Proof) == InvalidTestProof { @@ -146,12 +161,16 @@ func (v *Verifier) VerifyBundleProof(proof *message.BundleProof) (bool, error) { } proofStr := C.CString(string(buf)) + forkNameStr := C.CString(forkName) + circuitsVersionStr := C.CString(circuitsVersion) defer func() { C.free(unsafe.Pointer(proofStr)) + C.free(unsafe.Pointer(forkNameStr)) + C.free(unsafe.Pointer(circuitsVersionStr)) }() log.Info("Start to verify bundle proof ...") - verified := C.verify_bundle_proof(proofStr) + verified := C.verify_bundle_proof(proofStr, forkNameStr, circuitsVersionStr) return verified != 0, nil } diff --git a/coordinator/internal/types/get_task.go b/coordinator/internal/types/get_task.go index aba15007db..7236d793f9 100644 --- a/coordinator/internal/types/get_task.go +++ b/coordinator/internal/types/get_task.go @@ -9,9 +9,10 @@ type GetTaskParameter struct { // GetTaskSchema the schema data return to prover for get prover task type GetTaskSchema struct { - UUID string `json:"uuid"` - TaskID string `json:"task_id"` - TaskType int `json:"task_type"` - TaskData string `json:"task_data"` - HardForkName string `json:"hard_fork_name"` + UUID string `json:"uuid"` + TaskID string `json:"task_id"` + TaskType int `json:"task_type"` + TaskData string `json:"task_data"` + HardForkName string `json:"hard_fork_name"` + CircuitsVersion string `json:"circuits_version"` } From cbf6ec0f8e02c4066f2a5f5744f2d50753633a80 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Tue, 20 Aug 2024 17:39:37 +0800 Subject: [PATCH 03/18] fix bug --- coordinator/internal/logic/verifier/verifier.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coordinator/internal/logic/verifier/verifier.go b/coordinator/internal/logic/verifier/verifier.go index 130a71ecf3..2a616f126d 100644 --- a/coordinator/internal/logic/verifier/verifier.go +++ b/coordinator/internal/logic/verifier/verifier.go @@ -56,7 +56,7 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { C.free(unsafe.Pointer(assetsPathHiStr)) }() - C.init() + C.init(configStr) v := &Verifier{ cfg: cfg, From 5bd31f7bf261332b6c1b174042032c3aaf46a9f8 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Tue, 20 Aug 2024 21:35:34 +0800 Subject: [PATCH 04/18] coordinator add circuitsVersion field to get_task response --- .../logic/provertask/batch_prover_task.go | 17 ++++++++++------- .../logic/provertask/bundle_prover_task.go | 17 ++++++++++------- .../logic/provertask/chunk_prover_task.go | 17 ++++++++++------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/coordinator/internal/logic/provertask/batch_prover_task.go b/coordinator/internal/logic/provertask/batch_prover_task.go index b65b2b453b..f35c85a28b 100644 --- a/coordinator/internal/logic/provertask/batch_prover_task.go +++ b/coordinator/internal/logic/provertask/batch_prover_task.go @@ -125,6 +125,8 @@ func (bp *BatchProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato return nil, ErrCoordinatorInternalFailure } + var circuitsVersion string + proverTask := orm.ProverTask{ TaskID: batchTask.Hash, ProverPublicKey: taskCtx.PublicKey, @@ -144,7 +146,7 @@ func (bp *BatchProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato return nil, ErrCoordinatorInternalFailure } - taskMsg, err := bp.formatProverTask(ctx.Copy(), &proverTask, batchTask, hardForkName) + taskMsg, err := bp.formatProverTask(ctx.Copy(), &proverTask, batchTask, hardForkName, circuitsVersion) if err != nil { bp.recoverActiveAttempts(ctx, batchTask) log.Error("format prover task failure", "task_id", batchTask.Hash, "err", err) @@ -175,7 +177,7 @@ func (bp *BatchProverTask) hardForkName(ctx *gin.Context, batchTask *orm.Batch) return hardForkName, nil } -func (bp *BatchProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, batch *orm.Batch, hardForkName string) (*coordinatorType.GetTaskSchema, error) { +func (bp *BatchProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, batch *orm.Batch, hardForkName, circuitsVersion string) (*coordinatorType.GetTaskSchema, error) { // get chunk from db chunks, err := bp.chunkOrm.GetChunksByBatchHash(ctx, task.TaskID) if err != nil { @@ -221,11 +223,12 @@ func (bp *BatchProverTask) formatProverTask(ctx context.Context, task *orm.Prove } taskMsg := &coordinatorType.GetTaskSchema{ - UUID: task.UUID.String(), - TaskID: task.TaskID, - TaskType: int(message.ProofTypeBatch), - TaskData: string(chunkProofsBytes), - HardForkName: hardForkName, + UUID: task.UUID.String(), + TaskID: task.TaskID, + TaskType: int(message.ProofTypeBatch), + TaskData: string(chunkProofsBytes), + HardForkName: hardForkName, + CircuitsVersion: circuitsVersion, } return taskMsg, nil } diff --git a/coordinator/internal/logic/provertask/bundle_prover_task.go b/coordinator/internal/logic/provertask/bundle_prover_task.go index d244d2280b..07d38bd167 100644 --- a/coordinator/internal/logic/provertask/bundle_prover_task.go +++ b/coordinator/internal/logic/provertask/bundle_prover_task.go @@ -122,6 +122,8 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat return nil, ErrCoordinatorInternalFailure } + var circuitsVersion string + proverTask := orm.ProverTask{ TaskID: bundleTask.Hash, ProverPublicKey: taskCtx.PublicKey, @@ -141,7 +143,7 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat return nil, ErrCoordinatorInternalFailure } - taskMsg, err := bp.formatProverTask(ctx.Copy(), &proverTask, hardForkName) + taskMsg, err := bp.formatProverTask(ctx.Copy(), &proverTask, hardForkName, circuitsVersion) if err != nil { bp.recoverActiveAttempts(ctx, bundleTask) log.Error("format bundle prover task failure", "task_id", bundleTask.Hash, "err", err) @@ -178,7 +180,7 @@ func (bp *BundleProverTask) hardForkName(ctx *gin.Context, bundleTask *orm.Bundl return hardForkName, nil } -func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, hardForkName string) (*coordinatorType.GetTaskSchema, error) { +func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, hardForkName, circuitsVersion string) (*coordinatorType.GetTaskSchema, error) { // get bundle from db batches, err := bp.batchOrm.GetBatchesByBundleHash(ctx, task.TaskID) if err != nil { @@ -209,11 +211,12 @@ func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.Prov } taskMsg := &coordinatorType.GetTaskSchema{ - UUID: task.UUID.String(), - TaskID: task.TaskID, - TaskType: int(message.ProofTypeBundle), - TaskData: string(batchProofsBytes), - HardForkName: hardForkName, + UUID: task.UUID.String(), + TaskID: task.TaskID, + TaskType: int(message.ProofTypeBundle), + TaskData: string(batchProofsBytes), + HardForkName: hardForkName, + CircuitsVersion: circuitsVersion, } return taskMsg, nil } diff --git a/coordinator/internal/logic/provertask/chunk_prover_task.go b/coordinator/internal/logic/provertask/chunk_prover_task.go index b5527ff495..903a9a918f 100644 --- a/coordinator/internal/logic/provertask/chunk_prover_task.go +++ b/coordinator/internal/logic/provertask/chunk_prover_task.go @@ -120,6 +120,8 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato return nil, ErrCoordinatorInternalFailure } + var circuitsVersion string + proverTask := orm.ProverTask{ TaskID: chunkTask.Hash, ProverPublicKey: taskCtx.PublicKey, @@ -138,7 +140,7 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato return nil, ErrCoordinatorInternalFailure } - taskMsg, err := cp.formatProverTask(ctx.Copy(), &proverTask, hardForkName) + taskMsg, err := cp.formatProverTask(ctx.Copy(), &proverTask, hardForkName, circuitsVersion) if err != nil { cp.recoverActiveAttempts(ctx, chunkTask) log.Error("format prover task failure", "task_id", chunkTask.Hash, "err", err) @@ -164,7 +166,7 @@ func (cp *ChunkProverTask) hardForkName(ctx *gin.Context, chunkTask *orm.Chunk) return hardForkName, nil } -func (cp *ChunkProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, hardForkName string) (*coordinatorType.GetTaskSchema, error) { +func (cp *ChunkProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, hardForkName, circuitsVersion string) (*coordinatorType.GetTaskSchema, error) { // Get block hashes. blockHashes, dbErr := cp.blockOrm.GetL2BlockHashesByChunkHash(ctx, task.TaskID) if dbErr != nil || len(blockHashes) == 0 { @@ -180,11 +182,12 @@ func (cp *ChunkProverTask) formatProverTask(ctx context.Context, task *orm.Prove } proverTaskSchema := &coordinatorType.GetTaskSchema{ - UUID: task.UUID.String(), - TaskID: task.TaskID, - TaskType: int(message.ProofTypeChunk), - TaskData: string(blockHashesBytes), - HardForkName: hardForkName, + UUID: task.UUID.String(), + TaskID: task.TaskID, + TaskType: int(message.ProofTypeChunk), + TaskData: string(blockHashesBytes), + HardForkName: hardForkName, + CircuitsVersion: circuitsVersion, } return proverTaskSchema, nil From 3607a57c2303218581ba46f9ed0eec3f6b757dd0 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Tue, 20 Aug 2024 21:55:58 +0800 Subject: [PATCH 05/18] update embed vks from curie to darwin v0.12.0 --- coordinator/internal/logic/auth/login.go | 6 ++-- .../logic/verifier/legacy_vk/agg_vk.vkey | Bin 296 -> 0 bytes .../logic/verifier/legacy_vk/upgrade_vks.sh | 7 +++-- .../logic/verifier/legacy_vk/vk_batch.vkey | Bin 0 -> 296 bytes .../logic/verifier/legacy_vk/vk_bundle.vkey | Bin 0 -> 232 bytes .../{chunk_vk.vkey => vk_chunk.vkey} | Bin coordinator/internal/logic/verifier/types.go | 6 ++-- .../internal/logic/verifier/verifier.go | 28 +++++++++++------- 8 files changed, 28 insertions(+), 19 deletions(-) delete mode 100644 coordinator/internal/logic/verifier/legacy_vk/agg_vk.vkey create mode 100644 coordinator/internal/logic/verifier/legacy_vk/vk_batch.vkey create mode 100644 coordinator/internal/logic/verifier/legacy_vk/vk_bundle.vkey rename coordinator/internal/logic/verifier/legacy_vk/{chunk_vk.vkey => vk_chunk.vkey} (100%) diff --git a/coordinator/internal/logic/auth/login.go b/coordinator/internal/logic/auth/login.go index aa4268380e..4c1f229ece 100644 --- a/coordinator/internal/logic/auth/login.go +++ b/coordinator/internal/logic/auth/login.go @@ -35,15 +35,15 @@ func NewLoginLogic(db *gorm.DB, cfg *config.Config, vf *verifier.Verifier) *Logi challengeOrm: orm.NewChallenge(db), } - for _, vk := range vf.ChunkVKMap { + for vk := range vf.ChunkVKMap { l.chunkVks[vk] = struct{}{} } - for _, vk := range vf.BatchVKMap { + for vk := range vf.BatchVKMap { l.batchVKs[vk] = struct{}{} } - for _, vk := range vf.BundleVkMap { + for vk := range vf.BundleVkMap { l.bundleVks[vk] = struct{}{} } diff --git a/coordinator/internal/logic/verifier/legacy_vk/agg_vk.vkey b/coordinator/internal/logic/verifier/legacy_vk/agg_vk.vkey deleted file mode 100644 index 0b4ab2657c12a8b13e31d9d3a4e62042e41ba226..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 296 zcmV+@0oVQj000^Q000D6*)0m!0e9bUb-|;ooNw=N1c{kpy>1LQafpV6RkhrB9;RS~f&0+QK1&|+?v5-~PCb2doW uxy5p-!wzOIgiIig7HhFOAlnkxIN<0y>RJ9PIeJ7r8Z9#Oy<65|3OEL|nWxibG%)id=*ynTrdPV+tmQ`SUArChwU$P?>dQA! zip~yKmuQZp!oHWz;|POrR-Rl^(SKgM;RUrjqH>|!pkmA4Vp64Y19m!!A{m5YmIW)4 z1BT6jHVC0vDvWwvFMe7PC}>3PsWp3htUU1+gYzFkZaj{7oK6mfTJvRmEsy~yvlUwX u`!jG&J=jtH9vE%KkXU>2gwF>^Nl#Na_eghj1^q)93qvAc>1uuTQ-BDTXNf}q literal 0 HcmV?d00001 diff --git a/coordinator/internal/logic/verifier/legacy_vk/vk_bundle.vkey b/coordinator/internal/logic/verifier/legacy_vk/vk_bundle.vkey new file mode 100644 index 0000000000000000000000000000000000000000..df9ce5840baf4de786fc6a751c2bcb844f8184e0 GIT binary patch literal 232 zcmVUZ=?J3zGEe9`85D`-W(tC)Rdv4D}o>p0+>a`Vh`yRff zB}%o!?P*>l6T9|clwZ@IHisC17eWDO>Jbszay9TaYu7J@X7)_RkF7=z^gz(;B_dl< zP|p_Q8P9pSt)aHZC#6o^^)76*b+akH=#oH&?X<`*)`se&(4%G-Te*KfN3 literal 0 HcmV?d00001 diff --git a/coordinator/internal/logic/verifier/legacy_vk/chunk_vk.vkey b/coordinator/internal/logic/verifier/legacy_vk/vk_chunk.vkey similarity index 100% rename from coordinator/internal/logic/verifier/legacy_vk/chunk_vk.vkey rename to coordinator/internal/logic/verifier/legacy_vk/vk_chunk.vkey diff --git a/coordinator/internal/logic/verifier/types.go b/coordinator/internal/logic/verifier/types.go index 9d4fdba931..2d831d53ed 100644 --- a/coordinator/internal/logic/verifier/types.go +++ b/coordinator/internal/logic/verifier/types.go @@ -10,7 +10,7 @@ const InvalidTestProof = "this is a invalid proof" // Verifier represents a rust ffi to a halo2 verifier. type Verifier struct { cfg *config.VerifierConfig - ChunkVKMap map[string]string - BatchVKMap map[string]string - BundleVkMap map[string]string + ChunkVKMap map[string]struct{} + BatchVKMap map[string]struct{} + BundleVkMap map[string]struct{} } diff --git a/coordinator/internal/logic/verifier/verifier.go b/coordinator/internal/logic/verifier/verifier.go index 2a616f126d..dcc28ded6e 100644 --- a/coordinator/internal/logic/verifier/verifier.go +++ b/coordinator/internal/logic/verifier/verifier.go @@ -60,9 +60,9 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { v := &Verifier{ cfg: cfg, - ChunkVKMap: make(map[string]string), - BatchVKMap: make(map[string]string), - BundleVkMap: make(map[string]string), + ChunkVKMap: make(map[string]struct{}), + BatchVKMap: make(map[string]struct{}), + BundleVkMap: make(map[string]struct{}), } bundleVK, err := v.readVK(path.Join(cfg.HighVersionCircuit.AssetsPath, "vk_bundle.vkey")) @@ -77,9 +77,9 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { if err != nil { return nil, err } - v.BundleVkMap[cfg.ForkName] = bundleVK - v.BatchVKMap[cfg.ForkName] = batchVK - v.ChunkVKMap[cfg.ForkName] = chunkVK + v.BundleVkMap[bundleVK] = struct{}{} + v.BatchVKMap[batchVK] = struct{}{} + v.ChunkVKMap[chunkVK] = struct{}{} if err := v.loadEmbedVK(); err != nil { return nil, err @@ -190,19 +190,27 @@ func (v *Verifier) readVK(filePat string) (string, error) { var legacyVKFS embed.FS func (v *Verifier) loadEmbedVK() error { - batchVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/agg_vk.vkey") + chunkVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/vk_chunk.vkey") + if err != nil { + log.Error("load embed chunk vk failure", "err", err) + return err + } + + batchVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/vk_batch.vkey") if err != nil { log.Error("load embed batch vk failure", "err", err) return err } - chunkVkBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/chunk_vk.vkey") + bundleVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/vk_bundle.vkey") if err != nil { log.Error("load embed chunk vk failure", "err", err) return err } - v.BatchVKMap["curie"] = base64.StdEncoding.EncodeToString(batchVKBytes) - v.ChunkVKMap["curie"] = base64.StdEncoding.EncodeToString(chunkVkBytes) + v.ChunkVKMap[base64.StdEncoding.EncodeToString(chunkVKBytes)] = struct{}{} + v.BatchVKMap[base64.StdEncoding.EncodeToString(batchVKBytes)] = struct{}{} + v.BundleVkMap[base64.StdEncoding.EncodeToString(bundleVKBytes)] = struct{}{} + return nil } From 14d606bd1fb4efe5c4643f551bb5ca2eee792485 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Tue, 20 Aug 2024 22:20:33 +0800 Subject: [PATCH 06/18] fix lint issues --- common/libzkp/impl/src/lib.rs | 15 +++++---- common/libzkp/impl/src/verifier.rs | 14 ++++----- common/libzkp/impl/src/verifier/darwin.rs | 37 +++++++++++------------ common/libzkp/impl/src/verifier/edison.rs | 37 +++++++++++------------ prover/src/zk_circuits_handler/edison.rs | 1 - 5 files changed, 50 insertions(+), 54 deletions(-) diff --git a/common/libzkp/impl/src/lib.rs b/common/libzkp/impl/src/lib.rs index fc653584e1..868d9a3a3a 100644 --- a/common/libzkp/impl/src/lib.rs +++ b/common/libzkp/impl/src/lib.rs @@ -1,16 +1,14 @@ -mod verifier; mod utils; +mod verifier; -use prover_v5::utils::init_env_and_log; use crate::utils::{c_char_to_str, c_char_to_vec}; use libc::c_char; +use prover_v5::utils::init_env_and_log; use verifier::{TaskType, VerifierConfig}; /// # Safety #[no_mangle] -pub unsafe extern "C" fn init( - config: *const c_char, -) { +pub unsafe extern "C" fn init(config: *const c_char) { init_env_and_log("ffi_init"); let config_str = c_char_to_str(config); @@ -28,7 +26,8 @@ pub unsafe extern "C" fn verify_chunk_proof( verify_proof(proof, fork_name, circuits_version, TaskType::Chunk) } -fn verify_proof(proof: *const c_char, +fn verify_proof( + proof: *const c_char, _fork_name: *const c_char, circuits_version: *const c_char, task_type: TaskType, @@ -47,7 +46,7 @@ fn verify_proof(proof: *const c_char, log::error!("{:?} verify failed, error: {:#}", task_type, e); false as c_char } - Ok(result) => result as c_char + Ok(result) => result as c_char, } } @@ -69,4 +68,4 @@ pub unsafe extern "C" fn verify_bundle_proof( circuits_version: *const c_char, ) -> c_char { verify_proof(proof, fork_name, circuits_version, TaskType::Bundle) -} \ No newline at end of file +} diff --git a/common/libzkp/impl/src/verifier.rs b/common/libzkp/impl/src/verifier.rs index 47eb42aa50..41d0389987 100644 --- a/common/libzkp/impl/src/verifier.rs +++ b/common/libzkp/impl/src/verifier.rs @@ -5,7 +5,7 @@ use anyhow::{bail, Result}; use darwin::DarwinVerifier; use edison::EdisonVerifier; use serde::{Deserialize, Serialize}; -use std::cell::OnceCell; +use std::{cell::OnceCell, rc::Rc}; #[derive(Debug, Clone, Copy, PartialEq)] pub enum TaskType { @@ -33,7 +33,7 @@ pub struct VerifierConfig { type CircuitsVersion = String; -struct VerifierPair(CircuitsVersion, Box); +struct VerifierPair(CircuitsVersion, Rc>); static mut VERIFIER_HIGH: OnceCell = OnceCell::new(); static mut VERIFIER_LOW: OnceCell = OnceCell::new(); @@ -43,26 +43,26 @@ pub fn init(config: VerifierConfig) { let verifier = DarwinVerifier::new(&low_conf.params_path, &low_conf.assets_path); unsafe { - VERIFIER_LOW.set(VerifierPair(low_conf.version, Box::new(verifier))).unwrap_unchecked(); + VERIFIER_LOW.set(VerifierPair(low_conf.version, Rc::new(Box::new(verifier)))).unwrap_unchecked(); } let high_conf = config.high_version_circuit; let verifier = EdisonVerifier::new(&high_conf.params_path, &high_conf.assets_path); unsafe { - VERIFIER_HIGH.set(VerifierPair(high_conf.version, Box::new(verifier))).unwrap_unchecked(); + VERIFIER_HIGH.set(VerifierPair(high_conf.version, Rc::new(Box::new(verifier)))).unwrap_unchecked(); } } -pub fn get_verifier(circuits_version: &str) -> Result<&'static Box> { +pub fn get_verifier(circuits_version: &str) -> Result>> { unsafe { if let Some(verifier) = VERIFIER_LOW.get() { if verifier.0 == circuits_version { - return Ok(&verifier.1); + return Ok(verifier.1.clone()); } } if let Some(verifier) = VERIFIER_HIGH.get() { if verifier.0 == circuits_version { - return Ok(&verifier.1); + return Ok(verifier.1.clone()); } } } diff --git a/common/libzkp/impl/src/verifier/darwin.rs b/common/libzkp/impl/src/verifier/darwin.rs index 040c33ced7..9119b9b03d 100644 --- a/common/libzkp/impl/src/verifier/darwin.rs +++ b/common/libzkp/impl/src/verifier/darwin.rs @@ -2,10 +2,11 @@ use super::{ProofVerifier, TaskType}; use anyhow::Result; -use prover_v4::{zkevm::Verifier, aggregator::Verifier as AggVerifier, ChunkProof, BatchProof, BundleProof}; -use std::env; use crate::utils::panic_catch; - +use prover_v4::{ + aggregator::Verifier as AggVerifier, zkevm::Verifier, BatchProof, BundleProof, ChunkProof, +}; +use std::env; pub struct DarwinVerifier { verifier: Verifier, @@ -16,7 +17,7 @@ impl DarwinVerifier { pub fn new(params_dir: &str, assets_dir: &str) -> Self { env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir); let verifier = Verifier::from_dirs(params_dir, assets_dir); - + let agg_verifier = AggVerifier::from_dirs(params_dir, assets_dir); Self { @@ -28,22 +29,20 @@ impl DarwinVerifier { impl ProofVerifier for DarwinVerifier { fn verify(&self, task_type: super::TaskType, proof: Vec) -> Result { - let result = panic_catch(|| { - match task_type { - TaskType::Chunk => { - let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); - self.verifier.verify_chunk_proof(proof) - }, - TaskType::Batch => { - let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); - self.agg_verifier.verify_batch_proof(&proof) - }, - TaskType::Bundle => { - let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); - self.agg_verifier.verify_bundle_proof(proof) - }, + let result = panic_catch(|| match task_type { + TaskType::Chunk => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.verifier.verify_chunk_proof(proof) + } + TaskType::Batch => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.agg_verifier.verify_batch_proof(&proof) + } + TaskType::Bundle => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.agg_verifier.verify_bundle_proof(proof) } }); result.map_err(|e| anyhow::anyhow!(e)) } -} \ No newline at end of file +} diff --git a/common/libzkp/impl/src/verifier/edison.rs b/common/libzkp/impl/src/verifier/edison.rs index bd16fa076f..0c8c361c3a 100644 --- a/common/libzkp/impl/src/verifier/edison.rs +++ b/common/libzkp/impl/src/verifier/edison.rs @@ -2,10 +2,11 @@ use super::{ProofVerifier, TaskType}; use anyhow::Result; -use prover_v5::{zkevm::Verifier, aggregator::Verifier as AggVerifier, ChunkProof, BatchProof, BundleProof}; -use std::env; use crate::utils::panic_catch; - +use prover_v5::{ + aggregator::Verifier as AggVerifier, zkevm::Verifier, BatchProof, BundleProof, ChunkProof, +}; +use std::env; pub struct EdisonVerifier { verifier: Verifier, @@ -16,7 +17,7 @@ impl EdisonVerifier { pub fn new(params_dir: &str, assets_dir: &str) -> Self { env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir); let verifier = Verifier::from_dirs(params_dir, assets_dir); - + let agg_verifier = AggVerifier::from_dirs(params_dir, assets_dir); Self { @@ -28,22 +29,20 @@ impl EdisonVerifier { impl ProofVerifier for EdisonVerifier { fn verify(&self, task_type: super::TaskType, proof: Vec) -> Result { - let result = panic_catch(|| { - match task_type { - TaskType::Chunk => { - let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); - self.verifier.verify_chunk_proof(proof) - }, - TaskType::Batch => { - let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); - self.agg_verifier.verify_batch_proof(&proof) - }, - TaskType::Bundle => { - let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); - self.agg_verifier.verify_bundle_proof(proof) - }, + let result = panic_catch(|| match task_type { + TaskType::Chunk => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.verifier.verify_chunk_proof(proof) + } + TaskType::Batch => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.agg_verifier.verify_batch_proof(&proof) + } + TaskType::Bundle => { + let proof = serde_json::from_slice::(proof.as_slice()).unwrap(); + self.agg_verifier.verify_bundle_proof(proof) } }); result.map_err(|e| anyhow::anyhow!(e)) } -} \ No newline at end of file +} diff --git a/prover/src/zk_circuits_handler/edison.rs b/prover/src/zk_circuits_handler/edison.rs index 6f3428540d..cb032ff414 100644 --- a/prover/src/zk_circuits_handler/edison.rs +++ b/prover/src/zk_circuits_handler/edison.rs @@ -243,7 +243,6 @@ mod tests { use super::*; use crate::zk_circuits_handler::utils::encode_vk; use ethers_core::types::H256; - use prover_darwin::zkevm_circuits::witness::Block; use prover_edison::{ aggregator::eip4844, utils::chunk_trace_to_witness_block, BatchData, BatchHeader, MAX_AGG_SNARKS, From 5e15321bc29e7e942ae3a338fc217cf036fe3416 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Wed, 21 Aug 2024 11:29:25 +0800 Subject: [PATCH 07/18] utilize loginLogic init --- coordinator/internal/logic/auth/login.go | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/coordinator/internal/logic/auth/login.go b/coordinator/internal/logic/auth/login.go index 4c1f229ece..6e2eda84f9 100644 --- a/coordinator/internal/logic/auth/login.go +++ b/coordinator/internal/logic/auth/login.go @@ -27,27 +27,13 @@ type LoginLogic struct { // NewLoginLogic new a LoginLogic func NewLoginLogic(db *gorm.DB, cfg *config.Config, vf *verifier.Verifier) *LoginLogic { - l := &LoginLogic{ + return &LoginLogic{ cfg: cfg, - chunkVks: make(map[string]struct{}), - batchVKs: make(map[string]struct{}), - bundleVks: make(map[string]struct{}), + chunkVks: vf.ChunkVKMap, + batchVKs: vf.BatchVKMap, + bundleVks: vf.BundleVkMap, challengeOrm: orm.NewChallenge(db), } - - for vk := range vf.ChunkVKMap { - l.chunkVks[vk] = struct{}{} - } - - for vk := range vf.BatchVKMap { - l.batchVKs[vk] = struct{}{} - } - - for vk := range vf.BundleVkMap { - l.bundleVks[vk] = struct{}{} - } - - return l } // InsertChallengeString insert and check the challenge string is existed From acafdd73d32c811438b179481bac3b30d6cf3af7 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Wed, 21 Aug 2024 11:36:23 +0800 Subject: [PATCH 08/18] replace embed vks to config path --- .../logic/verifier/legacy_vk/upgrade_vks.sh | 12 -------- .../logic/verifier/legacy_vk/vk_batch.vkey | Bin 296 -> 0 bytes .../logic/verifier/legacy_vk/vk_bundle.vkey | Bin 232 -> 0 bytes .../logic/verifier/legacy_vk/vk_chunk.vkey | Bin 232 -> 0 bytes .../internal/logic/verifier/verifier.go | 29 ++++++------------ 5 files changed, 9 insertions(+), 32 deletions(-) delete mode 100755 coordinator/internal/logic/verifier/legacy_vk/upgrade_vks.sh delete mode 100644 coordinator/internal/logic/verifier/legacy_vk/vk_batch.vkey delete mode 100644 coordinator/internal/logic/verifier/legacy_vk/vk_bundle.vkey delete mode 100644 coordinator/internal/logic/verifier/legacy_vk/vk_chunk.vkey diff --git a/coordinator/internal/logic/verifier/legacy_vk/upgrade_vks.sh b/coordinator/internal/logic/verifier/legacy_vk/upgrade_vks.sh deleted file mode 100755 index c362314f04..0000000000 --- a/coordinator/internal/logic/verifier/legacy_vk/upgrade_vks.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -work_dir="$(dirname -- "${BASH_SOURCE[0]}")" -work_dir="$(cd -- "$work_dir" && pwd)" -echo $work_dir - -rm $work_dir/*.vkey - -version=release-v0.12.0 -wget https://circuit-release.s3.us-west-2.amazonaws.com/${version}/vk_chunk.vkey -O $work_dir/vk_chunk.vkey -wget https://circuit-release.s3.us-west-2.amazonaws.com/${version}/vk_batch.vkey -O $work_dir/vk_batch.vkey -wget https://circuit-release.s3.us-west-2.amazonaws.com/${version}/vk_bundle.vkey -O $work_dir/vk_bundle.vkey \ No newline at end of file diff --git a/coordinator/internal/logic/verifier/legacy_vk/vk_batch.vkey b/coordinator/internal/logic/verifier/legacy_vk/vk_batch.vkey deleted file mode 100644 index b3540d0f7919d4657d8560b352e5c72d6598dbcc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 296 zcmV+@0oVQj000^Q000D6*)0m!0e9bUb-|;ooNw=N1c{kpy3OEL|nWxibG%)id=*ynTrdPV+tmQ`SUArChwU$P?>dQA! zip~yKmuQZp!oHWz;|POrR-Rl^(SKgM;RUrjqH>|!pkmA4Vp64Y19m!!A{m5YmIW)4 z1BT6jHVC0vDvWwvFMe7PC}>3PsWp3htUU1+gYzFkZaj{7oK6mfTJvRmEsy~yvlUwX u`!jG&J=jtH9vE%KkXU>2gwF>^Nl#Na_eghj1^q)93qvAc>1uuTQ-BDTXNf}q diff --git a/coordinator/internal/logic/verifier/legacy_vk/vk_bundle.vkey b/coordinator/internal/logic/verifier/legacy_vk/vk_bundle.vkey deleted file mode 100644 index df9ce5840baf4de786fc6a751c2bcb844f8184e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 232 zcmVUZ=?J3zGEe9`85D`-W(tC)Rdv4D}o>p0+>a`Vh`yRff zB}%o!?P*>l6T9|clwZ@IHisC17eWDO>Jbszay9TaYu7J@X7)_RkF7=z^gz(;B_dl< zP|p_Q8P9pSt)aHZC#6o^^)76*b+akH=#oH&?X<`*)`se&(4%G-Te*KfN3 diff --git a/coordinator/internal/logic/verifier/legacy_vk/vk_chunk.vkey b/coordinator/internal/logic/verifier/legacy_vk/vk_chunk.vkey deleted file mode 100644 index 7318195ddf8c74c66cebcdf74c47c16342b57282..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 232 zcmVP000E?SU>?qvU-ICIsY=()&$zJzW3wVqMQ$FN&^z=0Nx)4N~$Rl zi0$Tg>Q|0DOdfKOwq@9W#o;9@<(Z$Bv*#gt>2le9QMlAIahs7MW{N!@OD4rxV#VJj zyQ*}h{HH;q@NYN3!cLhy%~ed4qFpf3RMhw(B2JOcpAc+JUBp?Xx3gQg$-|&p-CXp} ztnF!<1(Mi+1(*uy&g3G(EDB8-uz*SDB>cOQq31-dE^g>|90;X0k`cPjUY66i?_nmx iRI+5XxY3Av{`_ Date: Wed, 21 Aug 2024 11:53:12 +0800 Subject: [PATCH 09/18] fix compile bug --- coordinator/internal/logic/verifier/verifier.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coordinator/internal/logic/verifier/verifier.go b/coordinator/internal/logic/verifier/verifier.go index e52d312090..560a4697bb 100644 --- a/coordinator/internal/logic/verifier/verifier.go +++ b/coordinator/internal/logic/verifier/verifier.go @@ -33,9 +33,9 @@ type rustVerifierConfig struct { // NewVerifier Sets up a rust ffi to call verify. func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { if cfg.MockMode { - chunkVKMap := map[string]string{cfg.ForkName: "mock_vk"} - batchVKMap := map[string]string{cfg.ForkName: "mock_vk"} - bundleVKMap := map[string]string{cfg.ForkName: "mock_vk"} + chunkVKMap := map[string]struct{}{"mock_vk": struct{}{}} + batchVKMap := map[string]struct{}{"mock_vk": struct{}{}} + bundleVKMap := map[string]struct{}{"mock_vk": struct{}{}} return &Verifier{cfg: cfg, ChunkVKMap: chunkVKMap, BatchVKMap: batchVKMap, BundleVkMap: bundleVKMap}, nil } verifierConfig := rustVerifierConfig{ From 06489563bdbbd6bf69c0d7e2b029b0cf8fe6235c Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Wed, 21 Aug 2024 11:59:55 +0800 Subject: [PATCH 10/18] fix check issue in mock --- coordinator/internal/logic/verifier/mock.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/coordinator/internal/logic/verifier/mock.go b/coordinator/internal/logic/verifier/mock.go index 7615c51b6e..8af079d4f7 100644 --- a/coordinator/internal/logic/verifier/mock.go +++ b/coordinator/internal/logic/verifier/mock.go @@ -10,13 +10,13 @@ import ( // NewVerifier Sets up a mock verifier. func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { - batchVKMap := map[string]string{cfg.ForkName: "mock_vk"} - chunkVKMap := map[string]string{cfg.ForkName: "mock_vk"} + batchVKMap := map[string]struct{}{"mock_vk": struct{}{}} + chunkVKMap := map[string]struct{}{"mock_vk": struct{}{}} return &Verifier{cfg: cfg, ChunkVKMap: chunkVKMap, BatchVKMap: batchVKMap}, nil } // VerifyChunkProof return a mock verification result for a ChunkProof. -func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName string) (bool, error) { +func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName, circuitsVersion string) (bool, error) { if string(proof.Proof) == InvalidTestProof { return false, nil } @@ -24,7 +24,7 @@ func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName string) } // VerifyBatchProof return a mock verification result for a BatchProof. -func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName string) (bool, error) { +func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName, circuitsVersion string) (bool, error) { if string(proof.Proof) == InvalidTestProof { return false, nil } @@ -32,7 +32,7 @@ func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName string) } // VerifyBundleProof return a mock verification result for a BundleProof. -func (v *Verifier) VerifyBundleProof(proof *message.BundleProof) (bool, error) { +func (v *Verifier) VerifyBundleProof(proof *message.BundleProof, forkName, circuitsVersion string) (bool, error) { if string(proof.Proof) == InvalidTestProof { return false, nil } From 804a4367647e4d22936ca301087156f555876836 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Wed, 21 Aug 2024 12:03:15 +0800 Subject: [PATCH 11/18] fix lint issue in libzkp --- common/libzkp/impl/src/verifier.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/common/libzkp/impl/src/verifier.rs b/common/libzkp/impl/src/verifier.rs index 41d0389987..e585a23506 100644 --- a/common/libzkp/impl/src/verifier.rs +++ b/common/libzkp/impl/src/verifier.rs @@ -43,12 +43,16 @@ pub fn init(config: VerifierConfig) { let verifier = DarwinVerifier::new(&low_conf.params_path, &low_conf.assets_path); unsafe { - VERIFIER_LOW.set(VerifierPair(low_conf.version, Rc::new(Box::new(verifier)))).unwrap_unchecked(); + VERIFIER_LOW + .set(VerifierPair(low_conf.version, Rc::new(Box::new(verifier)))) + .unwrap_unchecked(); } let high_conf = config.high_version_circuit; let verifier = EdisonVerifier::new(&high_conf.params_path, &high_conf.assets_path); unsafe { - VERIFIER_HIGH.set(VerifierPair(high_conf.version, Rc::new(Box::new(verifier)))).unwrap_unchecked(); + VERIFIER_HIGH + .set(VerifierPair(high_conf.version, Rc::new(Box::new(verifier)))) + .unwrap_unchecked(); } } @@ -66,5 +70,8 @@ pub fn get_verifier(circuits_version: &str) -> Result> } } } - bail!("failed to get verifier, key not found, {}", circuits_version) -} \ No newline at end of file + bail!( + "failed to get verifier, key not found, {}", + circuits_version + ) +} From c6460c39324f816de14788723fc089bd92969896 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Wed, 21 Aug 2024 12:06:54 +0800 Subject: [PATCH 12/18] fix lint issue --- coordinator/internal/logic/verifier/mock.go | 4 ++-- coordinator/internal/logic/verifier/verifier.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/coordinator/internal/logic/verifier/mock.go b/coordinator/internal/logic/verifier/mock.go index 8af079d4f7..16e9e6666b 100644 --- a/coordinator/internal/logic/verifier/mock.go +++ b/coordinator/internal/logic/verifier/mock.go @@ -10,8 +10,8 @@ import ( // NewVerifier Sets up a mock verifier. func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { - batchVKMap := map[string]struct{}{"mock_vk": struct{}{}} - chunkVKMap := map[string]struct{}{"mock_vk": struct{}{}} + batchVKMap := map[string]struct{}{"mock_vk": {}} + chunkVKMap := map[string]struct{}{"mock_vk": {}} return &Verifier{cfg: cfg, ChunkVKMap: chunkVKMap, BatchVKMap: batchVKMap}, nil } diff --git a/coordinator/internal/logic/verifier/verifier.go b/coordinator/internal/logic/verifier/verifier.go index 560a4697bb..829151cae8 100644 --- a/coordinator/internal/logic/verifier/verifier.go +++ b/coordinator/internal/logic/verifier/verifier.go @@ -33,9 +33,9 @@ type rustVerifierConfig struct { // NewVerifier Sets up a rust ffi to call verify. func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { if cfg.MockMode { - chunkVKMap := map[string]struct{}{"mock_vk": struct{}{}} - batchVKMap := map[string]struct{}{"mock_vk": struct{}{}} - bundleVKMap := map[string]struct{}{"mock_vk": struct{}{}} + chunkVKMap := map[string]struct{}{"mock_vk": {}} + batchVKMap := map[string]struct{}{"mock_vk": {}} + bundleVKMap := map[string]struct{}{"mock_vk": {}} return &Verifier{cfg: cfg, ChunkVKMap: chunkVKMap, BatchVKMap: batchVKMap, BundleVkMap: bundleVKMap}, nil } verifierConfig := rustVerifierConfig{ From 9619d873a921a95d142ee6c32600e811dddf41da Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Thu, 22 Aug 2024 17:42:42 +0800 Subject: [PATCH 13/18] coordinator: remove circuits version from libzkp --- common/libzkp/impl/src/lib.rs | 20 +++++--------- common/libzkp/impl/src/verifier.rs | 27 ++++++++++--------- common/libzkp/interface/libzkp.h | 6 ++--- coordinator/conf/config.json | 5 ++-- coordinator/internal/config/config.go | 3 +-- .../logic/submitproof/proof_receiver.go | 8 +++--- .../internal/logic/verifier/verifier.go | 18 +++++-------- 7 files changed, 36 insertions(+), 51 deletions(-) diff --git a/common/libzkp/impl/src/lib.rs b/common/libzkp/impl/src/lib.rs index 868d9a3a3a..b15857d5a9 100644 --- a/common/libzkp/impl/src/lib.rs +++ b/common/libzkp/impl/src/lib.rs @@ -21,21 +21,15 @@ pub unsafe extern "C" fn init(config: *const c_char) { pub unsafe extern "C" fn verify_chunk_proof( proof: *const c_char, fork_name: *const c_char, - circuits_version: *const c_char, ) -> c_char { - verify_proof(proof, fork_name, circuits_version, TaskType::Chunk) + verify_proof(proof, fork_name, TaskType::Chunk) } -fn verify_proof( - proof: *const c_char, - _fork_name: *const c_char, - circuits_version: *const c_char, - task_type: TaskType, -) -> c_char { +fn verify_proof(proof: *const c_char, fork_name: *const c_char, task_type: TaskType) -> c_char { let proof = c_char_to_vec(proof); - let circuits_version_str = c_char_to_str(circuits_version); - let verifier = verifier::get_verifier(circuits_version_str); + let fork_name_str = c_char_to_str(fork_name); + let verifier = verifier::get_verifier(fork_name_str); if let Err(e) = verifier { log::warn!("failed to get verifier, error: {:#}", e); @@ -55,9 +49,8 @@ fn verify_proof( pub unsafe extern "C" fn verify_batch_proof( proof: *const c_char, fork_name: *const c_char, - circuits_version: *const c_char, ) -> c_char { - verify_proof(proof, fork_name, circuits_version, TaskType::Batch) + verify_proof(proof, fork_name, TaskType::Batch) } /// # Safety @@ -65,7 +58,6 @@ pub unsafe extern "C" fn verify_batch_proof( pub unsafe extern "C" fn verify_bundle_proof( proof: *const c_char, fork_name: *const c_char, - circuits_version: *const c_char, ) -> c_char { - verify_proof(proof, fork_name, circuits_version, TaskType::Bundle) + verify_proof(proof, fork_name, TaskType::Bundle) } diff --git a/common/libzkp/impl/src/verifier.rs b/common/libzkp/impl/src/verifier.rs index e585a23506..cea203cd95 100644 --- a/common/libzkp/impl/src/verifier.rs +++ b/common/libzkp/impl/src/verifier.rs @@ -20,7 +20,7 @@ pub trait ProofVerifier { #[derive(Debug, Serialize, Deserialize)] pub struct CircuitConfig { - pub version: String, + pub fork_name: String, pub params_path: String, pub assets_path: String, } @@ -31,9 +31,9 @@ pub struct VerifierConfig { pub high_version_circuit: CircuitConfig, } -type CircuitsVersion = String; +type HardForkName = String; -struct VerifierPair(CircuitsVersion, Rc>); +struct VerifierPair(HardForkName, Rc>); static mut VERIFIER_HIGH: OnceCell = OnceCell::new(); static mut VERIFIER_LOW: OnceCell = OnceCell::new(); @@ -44,34 +44,37 @@ pub fn init(config: VerifierConfig) { unsafe { VERIFIER_LOW - .set(VerifierPair(low_conf.version, Rc::new(Box::new(verifier)))) + .set(VerifierPair( + low_conf.fork_name, + Rc::new(Box::new(verifier)), + )) .unwrap_unchecked(); } let high_conf = config.high_version_circuit; let verifier = EdisonVerifier::new(&high_conf.params_path, &high_conf.assets_path); unsafe { VERIFIER_HIGH - .set(VerifierPair(high_conf.version, Rc::new(Box::new(verifier)))) + .set(VerifierPair( + high_conf.fork_name, + Rc::new(Box::new(verifier)), + )) .unwrap_unchecked(); } } -pub fn get_verifier(circuits_version: &str) -> Result>> { +pub fn get_verifier(fork_name: &str) -> Result>> { unsafe { if let Some(verifier) = VERIFIER_LOW.get() { - if verifier.0 == circuits_version { + if verifier.0 == fork_name { return Ok(verifier.1.clone()); } } if let Some(verifier) = VERIFIER_HIGH.get() { - if verifier.0 == circuits_version { + if verifier.0 == fork_name { return Ok(verifier.1.clone()); } } } - bail!( - "failed to get verifier, key not found, {}", - circuits_version - ) + bail!("failed to get verifier, key not found, {}", fork_name) } diff --git a/common/libzkp/interface/libzkp.h b/common/libzkp/interface/libzkp.h index a70dc3748c..51fee4f2ed 100644 --- a/common/libzkp/interface/libzkp.h +++ b/common/libzkp/interface/libzkp.h @@ -3,8 +3,8 @@ // - Verify a bundle proof void init(char* config); -char verify_batch_proof(char* proof, char* fork_name, char* circuits_version); +char verify_batch_proof(char* proof, char* fork_name); -char verify_bundle_proof(char* proof, char* fork_name, char* circuits_version); +char verify_bundle_proof(char* proof, char* fork_name); -char verify_chunk_proof(char* proof, char* fork_name, char* circuits_version); +char verify_chunk_proof(char* proof, char* fork_name); diff --git a/coordinator/conf/config.json b/coordinator/conf/config.json index b3979ad3ab..f3abe6c786 100644 --- a/coordinator/conf/config.json +++ b/coordinator/conf/config.json @@ -6,17 +6,16 @@ "batch_collection_time_sec": 180, "chunk_collection_time_sec": 180, "verifier": { - "fork_name": "bernoulli", "mock_mode": true, "low_version_circuit": { "params_path": "params", "assets_path": "assets", - "version": "" + "fork_name": "" }, "high_version_circuit": { "params_path": "params", "assets_path": "assets", - "version": "" + "fork_name": "" } }, "max_verifier_workers": 4, diff --git a/coordinator/internal/config/config.go b/coordinator/internal/config/config.go index b0d78b70aa..60fc481bd7 100644 --- a/coordinator/internal/config/config.go +++ b/coordinator/internal/config/config.go @@ -54,12 +54,11 @@ type Config struct { type CircuitConfig struct { ParamsPath string `json:"params_path"` AssetsPath string `json:"assets_path"` - Version string `json:"version"` + ForkName string `json:"fork_name"` } // VerifierConfig load zk verifier config. type VerifierConfig struct { - ForkName string `json:"fork_name"` MockMode bool `json:"mock_mode"` LowVersionCircuit *CircuitConfig `json:"low_version_circuit"` HighVersionCircuit *CircuitConfig `json:"high_version_circuit"` diff --git a/coordinator/internal/logic/submitproof/proof_receiver.go b/coordinator/internal/logic/submitproof/proof_receiver.go index 65ee0614a0..5daaf9e520 100644 --- a/coordinator/internal/logic/submitproof/proof_receiver.go +++ b/coordinator/internal/logic/submitproof/proof_receiver.go @@ -169,27 +169,25 @@ func (m *ProofReceiverLogic) HandleZkProof(ctx *gin.Context, proofParameter coor return ErrGetHardForkNameFailed } - var circuitsVersion string - switch message.ProofType(proofParameter.TaskType) { case message.ProofTypeChunk: var chunkProof message.ChunkProof if unmarshalErr := json.Unmarshal([]byte(proofParameter.Proof), &chunkProof); unmarshalErr != nil { return unmarshalErr } - success, verifyErr = m.verifier.VerifyChunkProof(&chunkProof, hardForkName, circuitsVersion) + success, verifyErr = m.verifier.VerifyChunkProof(&chunkProof, hardForkName) case message.ProofTypeBatch: var batchProof message.BatchProof if unmarshalErr := json.Unmarshal([]byte(proofParameter.Proof), &batchProof); unmarshalErr != nil { return unmarshalErr } - success, verifyErr = m.verifier.VerifyBatchProof(&batchProof, hardForkName, circuitsVersion) + success, verifyErr = m.verifier.VerifyBatchProof(&batchProof, hardForkName) case message.ProofTypeBundle: var bundleProof message.BundleProof if unmarshalErr := json.Unmarshal([]byte(proofParameter.Proof), &bundleProof); unmarshalErr != nil { return unmarshalErr } - success, verifyErr = m.verifier.VerifyBundleProof(&bundleProof, hardForkName, circuitsVersion) + success, verifyErr = m.verifier.VerifyBundleProof(&bundleProof, hardForkName) } if verifyErr != nil || !success { diff --git a/coordinator/internal/logic/verifier/verifier.go b/coordinator/internal/logic/verifier/verifier.go index 829151cae8..aecc87ef87 100644 --- a/coordinator/internal/logic/verifier/verifier.go +++ b/coordinator/internal/logic/verifier/verifier.go @@ -86,7 +86,7 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { } // VerifyBatchProof Verify a ZkProof by marshaling it and sending it to the Halo2 Verifier. -func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName, circuitsVersion string) (bool, error) { +func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName string) (bool, error) { if v.cfg.MockMode { log.Info("Mock mode, batch verifier disabled") if string(proof.Proof) == InvalidTestProof { @@ -103,19 +103,17 @@ func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName, circuit log.Info("Start to verify batch proof", "forkName", forkName) proofStr := C.CString(string(buf)) forkNameStr := C.CString(forkName) - circuitsVersionStr := C.CString(circuitsVersion) defer func() { C.free(unsafe.Pointer(proofStr)) C.free(unsafe.Pointer(forkNameStr)) - C.free(unsafe.Pointer(circuitsVersionStr)) }() - verified := C.verify_batch_proof(proofStr, forkNameStr, circuitsVersionStr) + verified := C.verify_batch_proof(proofStr, forkNameStr) return verified != 0, nil } // VerifyChunkProof Verify a ZkProof by marshaling it and sending it to the Halo2 Verifier. -func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName, circuitsVersion string) (bool, error) { +func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName string) (bool, error) { if v.cfg.MockMode { log.Info("Mock mode, verifier disabled") if string(proof.Proof) == InvalidTestProof { @@ -132,19 +130,17 @@ func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName, circuit log.Info("Start to verify chunk proof", "forkName", forkName) proofStr := C.CString(string(buf)) forkNameStr := C.CString(forkName) - circuitsVersionStr := C.CString(circuitsVersion) defer func() { C.free(unsafe.Pointer(proofStr)) C.free(unsafe.Pointer(forkNameStr)) - C.free(unsafe.Pointer(circuitsVersionStr)) }() - verified := C.verify_chunk_proof(proofStr, forkNameStr, circuitsVersionStr) + verified := C.verify_chunk_proof(proofStr, forkNameStr) return verified != 0, nil } // VerifyBundleProof Verify a ZkProof for a bundle of batches, by marshaling it and verifying it via the EVM verifier. -func (v *Verifier) VerifyBundleProof(proof *message.BundleProof, forkName, circuitsVersion string) (bool, error) { +func (v *Verifier) VerifyBundleProof(proof *message.BundleProof, forkName string) (bool, error) { if v.cfg.MockMode { log.Info("Mock mode, verifier disabled") if string(proof.Proof) == InvalidTestProof { @@ -160,15 +156,13 @@ func (v *Verifier) VerifyBundleProof(proof *message.BundleProof, forkName, circu proofStr := C.CString(string(buf)) forkNameStr := C.CString(forkName) - circuitsVersionStr := C.CString(circuitsVersion) defer func() { C.free(unsafe.Pointer(proofStr)) C.free(unsafe.Pointer(forkNameStr)) - C.free(unsafe.Pointer(circuitsVersionStr)) }() log.Info("Start to verify bundle proof ...") - verified := C.verify_bundle_proof(proofStr, forkNameStr, circuitsVersionStr) + verified := C.verify_bundle_proof(proofStr, forkNameStr) return verified != 0, nil } From 1a8d6fe7d128242b0ff2fd286cf28f04e605dbca Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Thu, 22 Aug 2024 17:48:43 +0800 Subject: [PATCH 14/18] prover&coordinator remove circuits version from get_task_response --- .../logic/provertask/batch_prover_task.go | 17 ++++------ .../logic/provertask/bundle_prover_task.go | 17 ++++------ .../logic/provertask/chunk_prover_task.go | 17 ++++------ coordinator/internal/types/get_task.go | 11 +++---- prover/src/coordinator_client/types.rs | 1 - prover/src/prover.rs | 2 +- prover/src/types.rs | 2 -- prover/src/zk_circuits_handler.rs | 32 +++++++++---------- 8 files changed, 43 insertions(+), 56 deletions(-) diff --git a/coordinator/internal/logic/provertask/batch_prover_task.go b/coordinator/internal/logic/provertask/batch_prover_task.go index f35c85a28b..b65b2b453b 100644 --- a/coordinator/internal/logic/provertask/batch_prover_task.go +++ b/coordinator/internal/logic/provertask/batch_prover_task.go @@ -125,8 +125,6 @@ func (bp *BatchProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato return nil, ErrCoordinatorInternalFailure } - var circuitsVersion string - proverTask := orm.ProverTask{ TaskID: batchTask.Hash, ProverPublicKey: taskCtx.PublicKey, @@ -146,7 +144,7 @@ func (bp *BatchProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato return nil, ErrCoordinatorInternalFailure } - taskMsg, err := bp.formatProverTask(ctx.Copy(), &proverTask, batchTask, hardForkName, circuitsVersion) + taskMsg, err := bp.formatProverTask(ctx.Copy(), &proverTask, batchTask, hardForkName) if err != nil { bp.recoverActiveAttempts(ctx, batchTask) log.Error("format prover task failure", "task_id", batchTask.Hash, "err", err) @@ -177,7 +175,7 @@ func (bp *BatchProverTask) hardForkName(ctx *gin.Context, batchTask *orm.Batch) return hardForkName, nil } -func (bp *BatchProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, batch *orm.Batch, hardForkName, circuitsVersion string) (*coordinatorType.GetTaskSchema, error) { +func (bp *BatchProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, batch *orm.Batch, hardForkName string) (*coordinatorType.GetTaskSchema, error) { // get chunk from db chunks, err := bp.chunkOrm.GetChunksByBatchHash(ctx, task.TaskID) if err != nil { @@ -223,12 +221,11 @@ func (bp *BatchProverTask) formatProverTask(ctx context.Context, task *orm.Prove } taskMsg := &coordinatorType.GetTaskSchema{ - UUID: task.UUID.String(), - TaskID: task.TaskID, - TaskType: int(message.ProofTypeBatch), - TaskData: string(chunkProofsBytes), - HardForkName: hardForkName, - CircuitsVersion: circuitsVersion, + UUID: task.UUID.String(), + TaskID: task.TaskID, + TaskType: int(message.ProofTypeBatch), + TaskData: string(chunkProofsBytes), + HardForkName: hardForkName, } return taskMsg, nil } diff --git a/coordinator/internal/logic/provertask/bundle_prover_task.go b/coordinator/internal/logic/provertask/bundle_prover_task.go index 07d38bd167..d244d2280b 100644 --- a/coordinator/internal/logic/provertask/bundle_prover_task.go +++ b/coordinator/internal/logic/provertask/bundle_prover_task.go @@ -122,8 +122,6 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat return nil, ErrCoordinatorInternalFailure } - var circuitsVersion string - proverTask := orm.ProverTask{ TaskID: bundleTask.Hash, ProverPublicKey: taskCtx.PublicKey, @@ -143,7 +141,7 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat return nil, ErrCoordinatorInternalFailure } - taskMsg, err := bp.formatProverTask(ctx.Copy(), &proverTask, hardForkName, circuitsVersion) + taskMsg, err := bp.formatProverTask(ctx.Copy(), &proverTask, hardForkName) if err != nil { bp.recoverActiveAttempts(ctx, bundleTask) log.Error("format bundle prover task failure", "task_id", bundleTask.Hash, "err", err) @@ -180,7 +178,7 @@ func (bp *BundleProverTask) hardForkName(ctx *gin.Context, bundleTask *orm.Bundl return hardForkName, nil } -func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, hardForkName, circuitsVersion string) (*coordinatorType.GetTaskSchema, error) { +func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, hardForkName string) (*coordinatorType.GetTaskSchema, error) { // get bundle from db batches, err := bp.batchOrm.GetBatchesByBundleHash(ctx, task.TaskID) if err != nil { @@ -211,12 +209,11 @@ func (bp *BundleProverTask) formatProverTask(ctx context.Context, task *orm.Prov } taskMsg := &coordinatorType.GetTaskSchema{ - UUID: task.UUID.String(), - TaskID: task.TaskID, - TaskType: int(message.ProofTypeBundle), - TaskData: string(batchProofsBytes), - HardForkName: hardForkName, - CircuitsVersion: circuitsVersion, + UUID: task.UUID.String(), + TaskID: task.TaskID, + TaskType: int(message.ProofTypeBundle), + TaskData: string(batchProofsBytes), + HardForkName: hardForkName, } return taskMsg, nil } diff --git a/coordinator/internal/logic/provertask/chunk_prover_task.go b/coordinator/internal/logic/provertask/chunk_prover_task.go index 903a9a918f..b5527ff495 100644 --- a/coordinator/internal/logic/provertask/chunk_prover_task.go +++ b/coordinator/internal/logic/provertask/chunk_prover_task.go @@ -120,8 +120,6 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato return nil, ErrCoordinatorInternalFailure } - var circuitsVersion string - proverTask := orm.ProverTask{ TaskID: chunkTask.Hash, ProverPublicKey: taskCtx.PublicKey, @@ -140,7 +138,7 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato return nil, ErrCoordinatorInternalFailure } - taskMsg, err := cp.formatProverTask(ctx.Copy(), &proverTask, hardForkName, circuitsVersion) + taskMsg, err := cp.formatProverTask(ctx.Copy(), &proverTask, hardForkName) if err != nil { cp.recoverActiveAttempts(ctx, chunkTask) log.Error("format prover task failure", "task_id", chunkTask.Hash, "err", err) @@ -166,7 +164,7 @@ func (cp *ChunkProverTask) hardForkName(ctx *gin.Context, chunkTask *orm.Chunk) return hardForkName, nil } -func (cp *ChunkProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, hardForkName, circuitsVersion string) (*coordinatorType.GetTaskSchema, error) { +func (cp *ChunkProverTask) formatProverTask(ctx context.Context, task *orm.ProverTask, hardForkName string) (*coordinatorType.GetTaskSchema, error) { // Get block hashes. blockHashes, dbErr := cp.blockOrm.GetL2BlockHashesByChunkHash(ctx, task.TaskID) if dbErr != nil || len(blockHashes) == 0 { @@ -182,12 +180,11 @@ func (cp *ChunkProverTask) formatProverTask(ctx context.Context, task *orm.Prove } proverTaskSchema := &coordinatorType.GetTaskSchema{ - UUID: task.UUID.String(), - TaskID: task.TaskID, - TaskType: int(message.ProofTypeChunk), - TaskData: string(blockHashesBytes), - HardForkName: hardForkName, - CircuitsVersion: circuitsVersion, + UUID: task.UUID.String(), + TaskID: task.TaskID, + TaskType: int(message.ProofTypeChunk), + TaskData: string(blockHashesBytes), + HardForkName: hardForkName, } return proverTaskSchema, nil diff --git a/coordinator/internal/types/get_task.go b/coordinator/internal/types/get_task.go index 7236d793f9..aba15007db 100644 --- a/coordinator/internal/types/get_task.go +++ b/coordinator/internal/types/get_task.go @@ -9,10 +9,9 @@ type GetTaskParameter struct { // GetTaskSchema the schema data return to prover for get prover task type GetTaskSchema struct { - UUID string `json:"uuid"` - TaskID string `json:"task_id"` - TaskType int `json:"task_type"` - TaskData string `json:"task_data"` - HardForkName string `json:"hard_fork_name"` - CircuitsVersion string `json:"circuits_version"` + UUID string `json:"uuid"` + TaskID string `json:"task_id"` + TaskType int `json:"task_type"` + TaskData string `json:"task_data"` + HardForkName string `json:"hard_fork_name"` } diff --git a/prover/src/coordinator_client/types.rs b/prover/src/coordinator_client/types.rs index 5ddf8381cc..c646a9afd4 100644 --- a/prover/src/coordinator_client/types.rs +++ b/prover/src/coordinator_client/types.rs @@ -69,7 +69,6 @@ pub struct GetTaskResponseData { pub task_type: TaskType, pub task_data: String, pub hard_fork_name: String, - pub circuits_version: Option, } #[derive(Serialize, Deserialize, Default)] diff --git a/prover/src/prover.rs b/prover/src/prover.rs index b629c52b6d..7de83906e0 100644 --- a/prover/src/prover.rs +++ b/prover/src/prover.rs @@ -100,7 +100,7 @@ impl<'a> Prover<'a> { let handler: Rc> = self .circuits_handler_provider .borrow_mut() - .get_circuits_handler(&task.circuits_version) + .get_circuits_handler(&task.hard_fork_name) .context("failed to get circuit handler")?; self.do_prove(task, handler) } diff --git a/prover/src/types.rs b/prover/src/types.rs index 2eb5b6e788..47f2724fc7 100644 --- a/prover/src/types.rs +++ b/prover/src/types.rs @@ -110,7 +110,6 @@ pub struct Task { pub task_data: String, #[serde(default)] pub hard_fork_name: String, - pub circuits_version: String, } impl From for Task { @@ -121,7 +120,6 @@ impl From for Task { task_type: value.task_type, task_data: value.task_data, hard_fork_name: value.hard_fork_name, - circuits_version: value.circuits_version.unwrap_or("".to_string()), } } } diff --git a/prover/src/zk_circuits_handler.rs b/prover/src/zk_circuits_handler.rs index 16affbdc1a..2974a64f02 100644 --- a/prover/src/zk_circuits_handler.rs +++ b/prover/src/zk_circuits_handler.rs @@ -12,7 +12,7 @@ use darwin::DarwinHandler; use edison::EdisonHandler; use std::{cell::RefCell, collections::HashMap, rc::Rc}; -type CircuitsVersion = String; +type HardForkName = String; pub mod utils { pub fn encode_vk(vk: Vec) -> String { @@ -36,9 +36,9 @@ pub struct CircuitsHandlerProvider<'a> { prover_type: ProverType, config: &'a Config, geth_client: Option>>, - circuits_handler_builder_map: HashMap, + circuits_handler_builder_map: HashMap, - current_circuits_version: Option, + current_fork_name: Option, current_circuit: Option>>, } @@ -48,7 +48,7 @@ impl<'a> CircuitsHandlerProvider<'a> { config: &'a Config, geth_client: Option>>, ) -> Result { - let mut m: HashMap = HashMap::new(); + let mut m: HashMap = HashMap::new(); fn handler_builder( prover_type: ProverType, @@ -58,7 +58,7 @@ impl<'a> CircuitsHandlerProvider<'a> { log::info!( "now init zk circuits handler, hard_fork_name: {}, version: {}", &config.low_version_circuit.hard_fork_name, - &config.low_version_circuit.circuits_version, + &config.low_version_circuit.hard_fork_name, ); AssetsDirEnvConfig::enable_first(); DarwinHandler::new( @@ -70,7 +70,7 @@ impl<'a> CircuitsHandlerProvider<'a> { .map(|handler| Box::new(handler) as Box) } m.insert( - config.low_version_circuit.circuits_version.clone(), + config.low_version_circuit.hard_fork_name.clone(), handler_builder, ); @@ -82,7 +82,7 @@ impl<'a> CircuitsHandlerProvider<'a> { log::info!( "now init zk circuits handler, hard_fork_name: {}, version: {}", &config.high_version_circuit.hard_fork_name, - &config.high_version_circuit.circuits_version + &config.high_version_circuit.hard_fork_name ); AssetsDirEnvConfig::enable_second(); EdisonHandler::new( @@ -95,7 +95,7 @@ impl<'a> CircuitsHandlerProvider<'a> { } m.insert( - config.high_version_circuit.circuits_version.clone(), + config.high_version_circuit.hard_fork_name.clone(), next_handler_builder, ); @@ -104,7 +104,7 @@ impl<'a> CircuitsHandlerProvider<'a> { config, geth_client, circuits_handler_builder_map: m, - current_circuits_version: None, + current_fork_name: None, current_circuit: None, }; @@ -113,10 +113,10 @@ impl<'a> CircuitsHandlerProvider<'a> { pub fn get_circuits_handler( &mut self, - circuits_version: &String, + hard_fork_name: &String, ) -> Result>> { - match &self.current_circuits_version { - Some(version) if version == circuits_version => { + match &self.current_fork_name { + Some(fork_name) if fork_name == hard_fork_name => { log::info!("get circuits handler from cache"); if let Some(handler) = &self.current_circuit { Ok(handler.clone()) @@ -127,13 +127,13 @@ impl<'a> CircuitsHandlerProvider<'a> { } _ => { log::info!( - "failed to get circuits handler from cache, create a new one: {circuits_version}" + "failed to get circuits handler from cache, create a new one: {hard_fork_name}" ); - if let Some(builder) = self.circuits_handler_builder_map.get(circuits_version) { - log::info!("building circuits handler for {circuits_version}"); + if let Some(builder) = self.circuits_handler_builder_map.get(hard_fork_name) { + log::info!("building circuits handler for {hard_fork_name}"); let handler = builder(self.prover_type, self.config, self.geth_client.clone()) .expect("failed to build circuits handler"); - self.current_circuits_version = Some(circuits_version.clone()); + self.current_fork_name = Some(hard_fork_name.clone()); let rc_handler = Rc::new(handler); self.current_circuit = Some(rc_handler.clone()); Ok(rc_handler) From ec40cbc8f311a9cc0625595645f07039c59e47d3 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Thu, 22 Aug 2024 17:58:12 +0800 Subject: [PATCH 15/18] rename edison to darwin_v2 --- common/libzkp/e2e-test.sh | 4 ++-- common/libzkp/impl/Cargo.toml | 2 +- common/libzkp/impl/src/verifier.rs | 6 +++--- .../src/verifier/{edison.rs => darwin_v2.rs} | 6 +++--- .../internal/logic/verifier/verifier_test.go | 6 +++--- prover/Cargo.toml | 2 +- prover/src/zk_circuits_handler.rs | 6 +++--- .../{edison.rs => darwin_v2.rs} | 16 ++++++++-------- 8 files changed, 24 insertions(+), 24 deletions(-) rename common/libzkp/impl/src/verifier/{edison.rs => darwin_v2.rs} (93%) rename prover/src/zk_circuits_handler/{edison.rs => darwin_v2.rs} (97%) diff --git a/common/libzkp/e2e-test.sh b/common/libzkp/e2e-test.sh index 2ba3d88460..a46a979f53 100644 --- a/common/libzkp/e2e-test.sh +++ b/common/libzkp/e2e-test.sh @@ -7,7 +7,7 @@ export RUST_LOG=debug export RUST_MIN_STACK=100000000 export PROVER_OUTPUT_DIR=test_zkp_test export SCROLL_PROVER_ASSETS_DIR=/assets/test_assets -export EDISON_TEST_DIR=/assets +export DARWIN_V2_TEST_DIR=/assets #export LD_LIBRARY_PATH=/:/usr/local/cuda/lib64 mkdir -p $PROVER_OUTPUT_DIR @@ -26,5 +26,5 @@ function build_test_bins() { build_test_bins rm -rf $PROVER_OUTPUT_DIR/* #rm -rf prover.log verifier.log -$REPO/prover/prover.test --exact zk_circuits_handler::edison::tests::test_circuits 2>&1 | tee prover.log +$REPO/prover/prover.test --exact zk_circuits_handler::darwin_v2::tests::test_circuits 2>&1 | tee prover.log $REPO/coordinator/verifier.test -test.v 2>&1 | tee verifier.log diff --git a/common/libzkp/impl/Cargo.toml b/common/libzkp/impl/Cargo.toml index 501f98a55a..6d4447bb54 100644 --- a/common/libzkp/impl/Cargo.toml +++ b/common/libzkp/impl/Cargo.toml @@ -26,7 +26,7 @@ snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", br # darwin prover_v4 = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.12.0", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] } -# edison +# darwin_v2 prover_v5 = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.13.0", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] } base64 = "0.13.0" diff --git a/common/libzkp/impl/src/verifier.rs b/common/libzkp/impl/src/verifier.rs index cea203cd95..a25e42123b 100644 --- a/common/libzkp/impl/src/verifier.rs +++ b/common/libzkp/impl/src/verifier.rs @@ -1,9 +1,9 @@ mod darwin; -mod edison; +mod darwin_v2; use anyhow::{bail, Result}; use darwin::DarwinVerifier; -use edison::EdisonVerifier; +use darwin_v2::DarwinV2Verifier; use serde::{Deserialize, Serialize}; use std::{cell::OnceCell, rc::Rc}; @@ -51,7 +51,7 @@ pub fn init(config: VerifierConfig) { .unwrap_unchecked(); } let high_conf = config.high_version_circuit; - let verifier = EdisonVerifier::new(&high_conf.params_path, &high_conf.assets_path); + let verifier = DarwinV2Verifier::new(&high_conf.params_path, &high_conf.assets_path); unsafe { VERIFIER_HIGH .set(VerifierPair( diff --git a/common/libzkp/impl/src/verifier/edison.rs b/common/libzkp/impl/src/verifier/darwin_v2.rs similarity index 93% rename from common/libzkp/impl/src/verifier/edison.rs rename to common/libzkp/impl/src/verifier/darwin_v2.rs index 0c8c361c3a..dadc075890 100644 --- a/common/libzkp/impl/src/verifier/edison.rs +++ b/common/libzkp/impl/src/verifier/darwin_v2.rs @@ -8,12 +8,12 @@ use prover_v5::{ }; use std::env; -pub struct EdisonVerifier { +pub struct DarwinV2Verifier { verifier: Verifier, agg_verifier: AggVerifier, } -impl EdisonVerifier { +impl DarwinV2Verifier { pub fn new(params_dir: &str, assets_dir: &str) -> Self { env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir); let verifier = Verifier::from_dirs(params_dir, assets_dir); @@ -27,7 +27,7 @@ impl EdisonVerifier { } } -impl ProofVerifier for EdisonVerifier { +impl ProofVerifier for DarwinV2Verifier { fn verify(&self, task_type: super::TaskType, proof: Vec) -> Result { let result = panic_catch(|| match task_type { TaskType::Chunk => { diff --git a/coordinator/internal/logic/verifier/verifier_test.go b/coordinator/internal/logic/verifier/verifier_test.go index 5e254bd35c..ed57a8f0ce 100644 --- a/coordinator/internal/logic/verifier/verifier_test.go +++ b/coordinator/internal/logic/verifier/verifier_test.go @@ -39,19 +39,19 @@ func TestFFI(t *testing.T) { as.NoError(err) chunkProof1 := readChunkProof(*chunkProofPath1, as) - chunkOk1, err := v.VerifyChunkProof(chunkProof1, "edison") + chunkOk1, err := v.VerifyChunkProof(chunkProof1, "darwin_v2") as.NoError(err) as.True(chunkOk1) t.Log("Verified chunk proof 1") chunkProof2 := readChunkProof(*chunkProofPath2, as) - chunkOk2, err := v.VerifyChunkProof(chunkProof2, "edison") + chunkOk2, err := v.VerifyChunkProof(chunkProof2, "darwin_v2") as.NoError(err) as.True(chunkOk2) t.Log("Verified chunk proof 2") batchProof := readBatchProof(*batchProofPath, as) - batchOk, err := v.VerifyBatchProof(batchProof, "edison") + batchOk, err := v.VerifyBatchProof(batchProof, "darwin_v2") as.NoError(err) as.True(batchOk) t.Log("Verified batch proof") diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 295a67ab36..96b60de9b9 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -30,7 +30,7 @@ ethers-providers = { git = "https://github.com/scroll-tech/ethers-rs.git", branc halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] } prover_darwin = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.12.0", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] } -prover_edison = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.13.0", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] } +prover_darwin_v2 = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.13.0", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] } base64 = "0.13.1" reqwest = { version = "0.12.4", features = ["gzip"] } reqwest-middleware = "0.3" diff --git a/prover/src/zk_circuits_handler.rs b/prover/src/zk_circuits_handler.rs index 2974a64f02..61ce90787e 100644 --- a/prover/src/zk_circuits_handler.rs +++ b/prover/src/zk_circuits_handler.rs @@ -1,5 +1,5 @@ mod darwin; -mod edison; +mod darwin_v2; use super::geth_client::GethClient; use crate::{ @@ -9,7 +9,7 @@ use crate::{ }; use anyhow::{bail, Result}; use darwin::DarwinHandler; -use edison::EdisonHandler; +use darwin_v2::DarwinV2Handler; use std::{cell::RefCell, collections::HashMap, rc::Rc}; type HardForkName = String; @@ -85,7 +85,7 @@ impl<'a> CircuitsHandlerProvider<'a> { &config.high_version_circuit.hard_fork_name ); AssetsDirEnvConfig::enable_second(); - EdisonHandler::new( + DarwinV2Handler::new( prover_type, &config.high_version_circuit.params_path, &config.high_version_circuit.assets_path, diff --git a/prover/src/zk_circuits_handler/edison.rs b/prover/src/zk_circuits_handler/darwin_v2.rs similarity index 97% rename from prover/src/zk_circuits_handler/edison.rs rename to prover/src/zk_circuits_handler/darwin_v2.rs index cb032ff414..9c7ce6910f 100644 --- a/prover/src/zk_circuits_handler/edison.rs +++ b/prover/src/zk_circuits_handler/darwin_v2.rs @@ -10,7 +10,7 @@ use serde::Deserialize; use crate::types::{CommonHash, Task}; use std::{cell::RefCell, cmp::Ordering, env, rc::Rc}; -use prover_edison::{ +use prover_darwin_v2::{ aggregator::Prover as BatchProver, check_chunk_hashes, zkevm::Prover as ChunkProver, BatchProof, BatchProvingTask, BlockTrace, BundleProof, BundleProvingTask, ChunkInfo, ChunkProof, ChunkProvingTask, @@ -38,14 +38,14 @@ fn get_block_number(block_trace: &BlockTrace) -> Option { } #[derive(Default)] -pub struct EdisonHandler { +pub struct DarwinV2Handler { chunk_prover: Option>, batch_prover: Option>, geth_client: Option>>, } -impl EdisonHandler { +impl DarwinV2Handler { pub fn new( prover_type: ProverType, params_dir: &str, @@ -207,7 +207,7 @@ impl EdisonHandler { } } -impl CircuitsHandler for EdisonHandler { +impl CircuitsHandler for DarwinV2Handler { fn get_vk(&self, task_type: TaskType) -> Option> { match task_type { TaskType::Chunk => self @@ -243,7 +243,7 @@ mod tests { use super::*; use crate::zk_circuits_handler::utils::encode_vk; use ethers_core::types::H256; - use prover_edison::{ + use prover_darwin_v2::{ aggregator::eip4844, utils::chunk_trace_to_witness_block, BatchData, BatchHeader, MAX_AGG_SNARKS, }; @@ -257,7 +257,7 @@ mod tests { static DEFAULT_WORK_DIR: &str = "/assets"; static WORK_DIR: LazyLock = LazyLock::new(|| { - std::env::var("EDISON_TEST_DIR") + std::env::var("DARWIN_V2_TEST_DIR") .unwrap_or(String::from(DEFAULT_WORK_DIR)) .trim_end_matches('/') .to_string() @@ -282,7 +282,7 @@ mod tests { #[test] fn test_circuits() -> Result<()> { let chunk_handler = - EdisonHandler::new(ProverType::Chunk, &PARAMS_PATH, &ASSETS_PATH, None)?; + DarwinV2Handler::new(ProverType::Chunk, &PARAMS_PATH, &ASSETS_PATH, None)?; let chunk_vk = chunk_handler.get_vk(TaskType::Chunk).unwrap(); @@ -308,7 +308,7 @@ mod tests { } let batch_handler = - EdisonHandler::new(ProverType::Batch, &PARAMS_PATH, &ASSETS_PATH, None)?; + DarwinV2Handler::new(ProverType::Batch, &PARAMS_PATH, &ASSETS_PATH, None)?; let batch_vk = batch_handler.get_vk(TaskType::Batch).unwrap(); check_vk(TaskType::Batch, batch_vk, "batch vk must be available"); let batch_task_detail = make_batch_task_detail(chunk_traces, chunk_proofs, None); From 5be6555f39bcac0d77f737540b2024533015c3c7 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Thu, 22 Aug 2024 18:01:55 +0800 Subject: [PATCH 16/18] remove unused lines --- prover/src/zk_circuits_handler.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/prover/src/zk_circuits_handler.rs b/prover/src/zk_circuits_handler.rs index 61ce90787e..491feca415 100644 --- a/prover/src/zk_circuits_handler.rs +++ b/prover/src/zk_circuits_handler.rs @@ -56,9 +56,8 @@ impl<'a> CircuitsHandlerProvider<'a> { geth_client: Option>>, ) -> Result> { log::info!( - "now init zk circuits handler, hard_fork_name: {}, version: {}", - &config.low_version_circuit.hard_fork_name, - &config.low_version_circuit.hard_fork_name, + "now init zk circuits handler, hard_fork_name: {}", + &config.low_version_circuit.hard_fork_name ); AssetsDirEnvConfig::enable_first(); DarwinHandler::new( @@ -80,8 +79,7 @@ impl<'a> CircuitsHandlerProvider<'a> { geth_client: Option>>, ) -> Result> { log::info!( - "now init zk circuits handler, hard_fork_name: {}, version: {}", - &config.high_version_circuit.hard_fork_name, + "now init zk circuits handler, hard_fork_name: {}", &config.high_version_circuit.hard_fork_name ); AssetsDirEnvConfig::enable_second(); From c415c1cf2d3c5e6f3192e112c569f7e06ddab5f9 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Thu, 22 Aug 2024 18:03:18 +0800 Subject: [PATCH 17/18] remove outdated lines in config --- prover/config.json | 6 ++---- prover/src/config.rs | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/prover/config.json b/prover/config.json index a8e8e58cd9..0a816360d5 100644 --- a/prover/config.json +++ b/prover/config.json @@ -7,14 +7,12 @@ "low_version_circuit": { "hard_fork_name": "bernoulli", "params_path": "params", - "assets_path": "assets", - "version": "" + "assets_path": "assets" }, "high_version_circuit": { "hard_fork_name": "curie", "params_path": "params", - "assets_path": "assets", - "version": "" + "assets_path": "assets" }, "coordinator": { "base_url": "http://localhost:8555", diff --git a/prover/src/config.rs b/prover/src/config.rs index 4c52225e9f..4e3c1f2ccc 100644 --- a/prover/src/config.rs +++ b/prover/src/config.rs @@ -7,7 +7,6 @@ use crate::types::ProverType; #[derive(Debug, Serialize, Deserialize)] pub struct CircuitConfig { pub hard_fork_name: String, - pub circuits_version: String, pub params_path: String, pub assets_path: String, } From 720dfb3e145be7e59a92033096a17e6025ab6920 Mon Sep 17 00:00:00 2001 From: Mengran Lan Date: Thu, 22 Aug 2024 18:11:16 +0800 Subject: [PATCH 18/18] fix compile error when using mock --- coordinator/internal/logic/verifier/mock.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coordinator/internal/logic/verifier/mock.go b/coordinator/internal/logic/verifier/mock.go index 16e9e6666b..5c4f1326ba 100644 --- a/coordinator/internal/logic/verifier/mock.go +++ b/coordinator/internal/logic/verifier/mock.go @@ -16,7 +16,7 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) { } // VerifyChunkProof return a mock verification result for a ChunkProof. -func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName, circuitsVersion string) (bool, error) { +func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName string) (bool, error) { if string(proof.Proof) == InvalidTestProof { return false, nil } @@ -24,7 +24,7 @@ func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName, circuit } // VerifyBatchProof return a mock verification result for a BatchProof. -func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName, circuitsVersion string) (bool, error) { +func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName string) (bool, error) { if string(proof.Proof) == InvalidTestProof { return false, nil } @@ -32,7 +32,7 @@ func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName, circuit } // VerifyBundleProof return a mock verification result for a BundleProof. -func (v *Verifier) VerifyBundleProof(proof *message.BundleProof, forkName, circuitsVersion string) (bool, error) { +func (v *Verifier) VerifyBundleProof(proof *message.BundleProof, forkName string) (bool, error) { if string(proof.Proof) == InvalidTestProof { return false, nil }