From d35a97114c10a0d59336222f4568cfdf88f7cc29 Mon Sep 17 00:00:00 2001 From: Zhang Junyu Date: Sun, 21 Apr 2024 14:03:23 +0000 Subject: [PATCH 1/9] bugfix: frame_table: fix Return to Arbitary Address --- crates/zkwasm/src/circuits/etable/assign.rs | 31 +++++++------- crates/zkwasm/src/circuits/etable/mod.rs | 42 ++++++++++++------- .../circuits/etable/op_configure/op_call.rs | 6 ++- .../etable/op_configure/op_call_indirect.rs | 5 ++- .../circuits/etable/op_configure/op_return.rs | 9 ++-- crates/zkwasm/src/circuits/jtable/assign.rs | 19 +++++---- .../zkwasm/src/circuits/jtable/configure.rs | 9 +++- crates/zkwasm/src/circuits/jtable/mod.rs | 3 ++ 8 files changed, 81 insertions(+), 43 deletions(-) diff --git a/crates/zkwasm/src/circuits/etable/assign.rs b/crates/zkwasm/src/circuits/etable/assign.rs index 304edcf78..a1ed8badf 100644 --- a/crates/zkwasm/src/circuits/etable/assign.rs +++ b/crates/zkwasm/src/circuits/etable/assign.rs @@ -1,9 +1,11 @@ use ark_std::end_timer; use ark_std::start_timer; +use ark_std::Zero; use halo2_proofs::arithmetic::FieldExt; use halo2_proofs::circuit::Cell; use halo2_proofs::plonk::Error; use log::debug; +use num_bigint::BigUint; use specs::configure_table::ConfigureTable; use specs::itable::InstructionTable; use specs::itable::OpcodeClassPlain; @@ -37,14 +39,12 @@ impl EventTableChip { op_configs: &BTreeMap>>, itable: &InstructionTable, event_table: &EventTableWithMemoryInfo, - ) -> Vec<(u32, u32)> { + ) -> Vec<(u32, BigUint)> { let mut rest_ops = vec![]; - event_table - .0 - .iter() - .rev() - .fold((0, 0), |(rest_mops_sum, rest_jops_sum), entry| { + event_table.0.iter().rev().fold( + (0, BigUint::zero()), + |(rest_mops_sum, rest_jops_sum), entry| { let instruction = entry.eentry.get_instruction(itable); let op_config = op_configs.get(&((&instruction.opcode).into())).unwrap(); @@ -54,10 +54,11 @@ impl EventTableChip { rest_jops_sum + op_config.0.jops(), ); - rest_ops.push(acc); + rest_ops.push(acc.clone()); acc - }); + }, + ); rest_ops.reverse(); @@ -99,7 +100,7 @@ impl EventTableChip { &self, ctx: &mut Context<'_, F>, rest_mops: u32, - rest_jops: u32, + rest_jops: &BigUint, ) -> Result<(Cell, Cell), Error> { let rest_mops_cell = self .config @@ -111,7 +112,7 @@ impl EventTableChip { .config .common_config .rest_jops_cell - .assign(ctx, F::from(rest_jops as u64))?; + .assign(ctx, bn_to_field(rest_jops))?; Ok((rest_mops_cell.cell(), rest_mops_jell.cell())) } @@ -124,7 +125,7 @@ impl EventTableChip { event_table: &EventTableWithMemoryInfo, configure_table: &ConfigureTable, fid_of_entry: u32, - rest_ops: Vec<(u32, u32)>, + rest_ops: Vec<(u32, BigUint)>, ) -> Result<(Cell, Cell, Cell), Error> { macro_rules! assign_advice { ($cell:ident, $value:expr) => { @@ -274,7 +275,7 @@ impl EventTableChip { .collect::>(); println!("instruction length {}", instructions.len()); - let chunk_len = instructions.len() / 4; + let chunk_len = instructions.len() / 8; let chunk_len = if chunk_len == 0 { instructions.len() } else { @@ -329,7 +330,7 @@ impl EventTableChip { self.config .common_config .rest_jops_cell - .assign(ctx, F::from(*rest_jops as u64))?; + .assign(ctx, bn_to_field(rest_jops))?; self.config .common_config .input_index_cell @@ -447,7 +448,9 @@ impl EventTableChip { let (rest_mops_cell, rest_jops_cell) = self.assign_rest_ops_first_step( ctx, rest_ops.first().map_or(0u32, |(rest_mops, _)| *rest_mops), - rest_ops.first().map_or(0u32, |(_, rest_jops)| *rest_jops), + rest_ops + .first() + .map_or(&BigUint::zero(), |(_, rest_jops)| rest_jops), )?; ctx.reset(); diff --git a/crates/zkwasm/src/circuits/etable/mod.rs b/crates/zkwasm/src/circuits/etable/mod.rs index 1ee8ecc68..981447bf5 100644 --- a/crates/zkwasm/src/circuits/etable/mod.rs +++ b/crates/zkwasm/src/circuits/etable/mod.rs @@ -46,6 +46,7 @@ use crate::foreign::wasm_input_helper::etable_op_configure::ETableWasmInputHelpe use crate::foreign::EventTableForeignCallConfigBuilder; use crate::foreign::ForeignTableConfig; use crate::foreign::InternalHostPluginBuilder; +use ark_std::Zero; use halo2_proofs::arithmetic::FieldExt; use halo2_proofs::plonk::Advice; use halo2_proofs::plonk::Column; @@ -54,6 +55,7 @@ use halo2_proofs::plonk::Error; use halo2_proofs::plonk::Expression; use halo2_proofs::plonk::Fixed; use halo2_proofs::plonk::VirtualCells; +use num_bigint::BigUint; use specs::encode::instruction_table::encode_instruction_table_entry; use specs::etable::EventTableEntry; use specs::itable::OpcodeClass; @@ -78,7 +80,7 @@ pub struct EventTableCommonConfig { ops: [AllocatedBitCell; OP_CAPABILITY], rest_mops_cell: AllocatedCommonRangeCell, - rest_jops_cell: AllocatedCommonRangeCell, + rest_jops_cell: AllocatedUnlimitedCell, pub(crate) input_index_cell: AllocatedCommonRangeCell, pub(crate) context_input_index_cell: AllocatedCommonRangeCell, pub(crate) context_output_index_cell: AllocatedCommonRangeCell, @@ -142,8 +144,8 @@ pub trait EventTableOpcodeConfig { fn jops_expr(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { None } - fn jops(&self) -> u32 { - 0 + fn jops(&self) -> BigUint { + BigUint::zero() } fn mops(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { None @@ -241,7 +243,7 @@ impl EventTableConfig { let enabled_cell = allocator.alloc_bit_cell(); let rest_mops_cell = allocator.alloc_common_range_cell(); - let rest_jops_cell = allocator.alloc_common_range_cell(); + let rest_jops_cell = allocator.alloc_unlimited_cell(); let input_index_cell = allocator.alloc_common_range_cell(); let context_input_index_cell = allocator.alloc_common_range_cell(); let context_output_index_cell = allocator.alloc_common_range_cell(); @@ -255,16 +257,28 @@ impl EventTableConfig { let maximal_memory_pages_cell = allocator.alloc_common_range_cell(); // We only need to enable equality for the cells of states - let used_common_range_cells_for_state = allocator - .free_cells - .get(&EventTableCellType::CommonRange) - .unwrap(); - allocator.enable_equality( - meta, - &EventTableCellType::CommonRange, - used_common_range_cells_for_state.0 - + (used_common_range_cells_for_state.1 != 0) as usize, - ); + { + let used_common_range_cells_for_state = allocator + .free_cells + .get(&EventTableCellType::CommonRange) + .unwrap(); + allocator.enable_equality( + meta, + &EventTableCellType::CommonRange, + used_common_range_cells_for_state.0 + + (used_common_range_cells_for_state.1 != 0) as usize, + ); + + let used_unlimited_cells_for_state = allocator + .free_cells + .get(&EventTableCellType::Unlimited) + .unwrap(); + allocator.enable_equality( + meta, + &EventTableCellType::Unlimited, + used_unlimited_cells_for_state.0 + (used_unlimited_cells_for_state.1 != 0) as usize, + ); + } let itable_lookup_cell = allocator.alloc_unlimited_cell(); let brtable_lookup_cell = allocator.alloc_unlimited_cell(); diff --git a/crates/zkwasm/src/circuits/etable/op_configure/op_call.rs b/crates/zkwasm/src/circuits/etable/op_configure/op_call.rs index 3f6e88976..128a00964 100644 --- a/crates/zkwasm/src/circuits/etable/op_configure/op_call.rs +++ b/crates/zkwasm/src/circuits/etable/op_configure/op_call.rs @@ -15,6 +15,8 @@ use halo2_proofs::arithmetic::FieldExt; use halo2_proofs::plonk::Error; use halo2_proofs::plonk::Expression; use halo2_proofs::plonk::VirtualCells; +use num_bigint::BigUint; +use num_traits::One; use specs::encode::frame_table::encode_frame_table_entry; use specs::encode::opcode::encode_call; use specs::step::StepInfo; @@ -98,8 +100,8 @@ impl EventTableOpcodeConfig for CallConfig { Some(constant_from!(1)) } - fn jops(&self) -> u32 { - 1 + fn jops(&self) -> BigUint { + BigUint::one() } fn next_frame_id( diff --git a/crates/zkwasm/src/circuits/etable/op_configure/op_call_indirect.rs b/crates/zkwasm/src/circuits/etable/op_configure/op_call_indirect.rs index 3cd28e4fe..58326dfd2 100644 --- a/crates/zkwasm/src/circuits/etable/op_configure/op_call_indirect.rs +++ b/crates/zkwasm/src/circuits/etable/op_configure/op_call_indirect.rs @@ -16,6 +16,7 @@ use halo2_proofs::plonk::Error; use halo2_proofs::plonk::Expression; use halo2_proofs::plonk::VirtualCells; use num_bigint::BigUint; +use num_traits::One; use specs::encode::br_table::encode_elem_entry; use specs::encode::frame_table::encode_frame_table_entry; use specs::encode::opcode::encode_call_indirect; @@ -188,8 +189,8 @@ impl EventTableOpcodeConfig for CallIndirectConfig { Some(constant_from!(1)) } - fn jops(&self) -> u32 { - 1 + fn jops(&self) -> BigUint { + BigUint::one() } fn next_frame_id( diff --git a/crates/zkwasm/src/circuits/etable/op_configure/op_return.rs b/crates/zkwasm/src/circuits/etable/op_configure/op_return.rs index c3b6e9574..48c3b430f 100644 --- a/crates/zkwasm/src/circuits/etable/op_configure/op_return.rs +++ b/crates/zkwasm/src/circuits/etable/op_configure/op_return.rs @@ -6,18 +6,21 @@ use crate::circuits::etable::EventTableOpcodeConfig; use crate::circuits::etable::EventTableOpcodeConfigBuilder; use crate::circuits::jtable::expression::JtableLookupEntryEncode; use crate::circuits::jtable::JumpTableConfig; +use crate::circuits::jtable::JOPS_SEPARATE; use crate::circuits::utils::bn_to_field; use crate::circuits::utils::step_status::StepStatus; use crate::circuits::utils::table_entry::EventTableEntryWithMemoryInfo; use crate::circuits::utils::Context; use crate::constant; use crate::constant_from; +use crate::constant_from_bn; use halo2_proofs::arithmetic::FieldExt; use halo2_proofs::plonk::Error; use halo2_proofs::plonk::Expression; use halo2_proofs::plonk::VirtualCells; use num_bigint::BigUint; use num_bigint::ToBigUint; +use num_traits::One; use specs::encode::frame_table::encode_frame_table_entry; use specs::etable::EventTableEntry; use specs::itable::OpcodeClass; @@ -206,11 +209,11 @@ impl EventTableOpcodeConfig for ReturnConfig { } fn jops_expr(&self, _meta: &mut VirtualCells<'_, F>) -> Option> { - Some(constant_from!(self.jops())) + Some(constant_from_bn!(&self.jops())) } - fn jops(&self) -> u32 { - 1 + fn jops(&self) -> BigUint { + BigUint::one() << JOPS_SEPARATE } fn next_frame_id( diff --git a/crates/zkwasm/src/circuits/jtable/assign.rs b/crates/zkwasm/src/circuits/jtable/assign.rs index 89fab14ca..3580e6dcd 100644 --- a/crates/zkwasm/src/circuits/jtable/assign.rs +++ b/crates/zkwasm/src/circuits/jtable/assign.rs @@ -1,11 +1,14 @@ use halo2_proofs::arithmetic::FieldExt; use halo2_proofs::circuit::Cell; use halo2_proofs::plonk::Error; +use num_bigint::BigUint; +use num_traits::One; use specs::jtable::JumpTable; use specs::jtable::StaticFrameEntry; use super::JtableOffset; use super::JumpTableChip; +use super::JOPS_SEPARATE; use crate::circuits::utils::bn_to_field; use crate::circuits::utils::Context; @@ -64,7 +67,7 @@ impl JumpTableChip { fn assign_static_entries( &self, ctx: &mut Context<'_, F>, - rest_jops: &mut u64, + rest_jops: &mut BigUint, static_entries: &Vec, ) -> Result, Error> { let mut static_entries = static_entries.clone(); @@ -108,7 +111,7 @@ impl JumpTableChip { || "jtable rest", self.config.data, ctx.offset, - || Ok((*rest_jops).into()), + || Ok(bn_to_field(rest_jops)), )?; ctx.next(); @@ -126,7 +129,7 @@ impl JumpTableChip { cells.push((enable_cell, entry_cell)); if entry.enable { - *rest_jops -= 1; + *rest_jops -= BigUint::one() << JOPS_SEPARATE; } } @@ -136,11 +139,11 @@ impl JumpTableChip { fn assign_jtable_entries( &self, ctx: &mut Context<'_, F>, - rest_jops: &mut u64, + rest_jops: &mut BigUint, jtable: &JumpTable, ) -> Result<(), Error> { for entry in jtable.entries().iter() { - let rest_f = (*rest_jops).into(); + let rest_f = bn_to_field(rest_jops); let entry_f = bn_to_field(&entry.encode()); ctx.region.assign_advice( @@ -167,7 +170,7 @@ impl JumpTableChip { )?; ctx.next(); - *rest_jops -= 2; + *rest_jops -= (BigUint::one() << JOPS_SEPARATE) + BigUint::one(); } { @@ -213,7 +216,9 @@ impl JumpTableChip { self.init(ctx)?; ctx.reset(); - let mut rest_jops = jtable.entries().len() as u64 * 2 + static_entries.len() as u64; + let mut rest_jops = BigUint::one() * jtable.entries().len() + + (BigUint::one() << JOPS_SEPARATE) + * (BigUint::from((static_entries.len() + jtable.entries().len()) as u64)); let frame_table_start_jump_cells = self.assign_static_entries(ctx, &mut rest_jops, static_entries)?; diff --git a/crates/zkwasm/src/circuits/jtable/configure.rs b/crates/zkwasm/src/circuits/jtable/configure.rs index 3a4554711..742d0beab 100644 --- a/crates/zkwasm/src/circuits/jtable/configure.rs +++ b/crates/zkwasm/src/circuits/jtable/configure.rs @@ -1,6 +1,9 @@ use super::JumpTableConfig; +use crate::circuits::jtable::JOPS_SEPARATE; +use crate::circuits::utils::bn_to_field; use crate::circuits::Lookup; use crate::constant_from; +use crate::constant_from_bn; use crate::fixed_curr; use halo2_proofs::arithmetic::FieldExt; use halo2_proofs::plonk::Advice; @@ -8,6 +11,8 @@ use halo2_proofs::plonk::Column; use halo2_proofs::plonk::ConstraintSystem; use halo2_proofs::plonk::Expression; use halo2_proofs::plonk::VirtualCells; +use num_bigint::BigUint; +use num_traits::One; pub trait JTableConstraint { fn configure(&self, meta: &mut ConstraintSystem) { @@ -43,7 +48,9 @@ impl JTableConstraint for JumpTableConfig { fn configure_rest_jops_decrease(&self, meta: &mut ConstraintSystem) { meta.create_gate("c3. jtable rest decrease", |meta| { vec![ - (self.rest(meta) - self.next_rest(meta) - constant_from!(2) + (self.rest(meta) + - self.next_rest(meta) + - constant_from_bn!(&((BigUint::one() << JOPS_SEPARATE) + BigUint::one())) + self.static_bit(meta)) * self.enable(meta) * fixed_curr!(meta, self.sel), diff --git a/crates/zkwasm/src/circuits/jtable/mod.rs b/crates/zkwasm/src/circuits/jtable/mod.rs index a4cd595e2..c2f839ff6 100644 --- a/crates/zkwasm/src/circuits/jtable/mod.rs +++ b/crates/zkwasm/src/circuits/jtable/mod.rs @@ -10,6 +10,9 @@ mod assign; mod configure; pub(crate) mod expression; +// high 128 bit counts 'return' instructions, low 128 bit counts 'call' instructions. +pub(crate) const JOPS_SEPARATE: usize = 128; + pub enum JtableOffset { JtableOffsetEnable = 0, JtableOffsetRest = 1, From 4eb335c61f057d6caf8ebde8f38b1cca37166966 Mon Sep 17 00:00:00 2001 From: Zhang Junyu Date: Thu, 25 Apr 2024 14:11:19 +0000 Subject: [PATCH 2/9] remove the dependency of halo2aggregator-s --- Cargo.lock | 8 +- Cargo.toml | 2 +- crates/cli/Cargo.toml | 1 - crates/cli/src/app_builder.rs | 4 +- crates/cli/src/exec.rs | 70 +++++++------ crates/host/Cargo.toml | 1 - crates/playground/Cargo.lock | 1 - crates/zkwasm/Cargo.toml | 1 - crates/zkwasm/src/lib.rs | 1 - crates/zkwasm/src/loader/mod.rs | 167 +++++++++++++++++--------------- 10 files changed, 126 insertions(+), 130 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b079eeb8e..6ec26406d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -353,7 +353,7 @@ dependencies = [ [[package]] name = "circuits-batcher" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/continuation-batcher.git#174d270816af2fd19fb28e509b84845325d70792" +source = "git+https://github.com/DelphinusLab/continuation-batcher.git#b26f281c2f7e4d673e873f2c05accd29952eb332" dependencies = [ "anyhow", "ark-std 0.4.0", @@ -630,7 +630,6 @@ dependencies = [ "delphinus-zkwasm", "env_logger", "halo2_proofs", - "halo2aggregator-s", "hex", "log", "md5", @@ -653,7 +652,6 @@ dependencies = [ "downcast-rs", "ff", "halo2_proofs", - "halo2aggregator-s", "hex", "lazy_static", "log", @@ -686,7 +684,6 @@ dependencies = [ "downcast-rs", "ff", "halo2_proofs", - "halo2aggregator-s", "hex", "lazy_static", "log", @@ -3519,7 +3516,7 @@ dependencies = [ [[package]] name = "zkwasm-prover" version = "0.1.0" -source = "git+ssh://git@github.com/xgaozoyoe/zkWasm-prover.git#4e37b117d4976f2261b00de1cc72f864e5a933b9" +source = "git+https://github.com/DelphinusLab/zkWasm-prover.git#5f352e1852cc27af47378c4a355d36d000edecb1" dependencies = [ "ark-std 0.4.0", "cc", @@ -3532,5 +3529,4 @@ dependencies = [ "libc", "rand", "rayon", - "thread_local", ] diff --git a/Cargo.toml b/Cargo.toml index 3fbdcb3da..19e418300 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ resolver = "2" [workspace.dependencies] anyhow = { version = "1.0.68", features = ["backtrace"] } cfg-if = "1.0.0" -halo2aggregator-s = { git = "https://github.com/DelphinusLab/halo2aggregator-s.git", features = ["unsafe"] } halo2_proofs = { git = "https://github.com/DelphinusLab/halo2-gpu-specific.git", default-features = true } parity-wasm = { version = "0.42.0", features = ["sign_ext"] } wasmi = { path = "third-party/wasmi" } @@ -15,3 +14,4 @@ zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circ [profile.dev] opt-level = 3 + diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 51b182824..0fa5fbd4f 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -20,7 +20,6 @@ serde_json = "1.0" delphinus-zkwasm = { path = "../zkwasm" } delphinus-host = { path = "../host" } anyhow.workspace = true -halo2aggregator-s.workspace = true halo2_proofs.workspace = true wasmi.workspace = true circuits-batcher.workspace = true diff --git a/crates/cli/src/app_builder.rs b/crates/cli/src/app_builder.rs index dfb7857bb..80c8beef9 100644 --- a/crates/cli/src/app_builder.rs +++ b/crates/cli/src/app_builder.rs @@ -154,14 +154,14 @@ pub trait AppBuilder: CommandBuilder { wasm_binary, (), phantom_functions, - &output_dir, + ¶m_dir, ), HostMode::STANDARD => exec_image_checksum::( zkwasm_k, wasm_binary, HostEnvConfig::default(), phantom_functions, - &output_dir, + ¶m_dir, ), }, diff --git a/crates/cli/src/exec.rs b/crates/cli/src/exec.rs index 640413bfd..78f865150 100644 --- a/crates/cli/src/exec.rs +++ b/crates/cli/src/exec.rs @@ -1,5 +1,6 @@ use anyhow::Result; use circuits_batcher::args::HashType::Poseidon; +use circuits_batcher::args::OpenSchema; use circuits_batcher::proof::ParamsCache; use circuits_batcher::proof::ProofGenerationInfo; use circuits_batcher::proof::ProofInfo; @@ -8,12 +9,12 @@ use circuits_batcher::proof::ProvingKeyCache; use delphinus_zkwasm::loader::ZkWasmLoader; use delphinus_zkwasm::runtime::host::HostEnvBuilder; use halo2_proofs::pairing::bn256::Bn256; -use halo2_proofs::plonk::verify_proof_with_shplonk; -use halo2_proofs::plonk::SingleVerifier; +use halo2_proofs::pairing::bn256::G1Affine; +use halo2_proofs::poly::commitment::Params; use halo2_proofs::poly::commitment::ParamsVerifier; -use halo2aggregator_s::circuits::utils::load_or_build_unsafe_params; -use halo2aggregator_s::transcript::poseidon::PoseidonRead; use log::info; +use std::fs::File; +use std::io; use std::io::Write; use std::path::PathBuf; @@ -29,22 +30,27 @@ pub fn exec_setup( ) -> Result<()> { info!("Setup Params and VerifyingKey"); - macro_rules! prepare_params { - ($k: expr) => {{ - let params_path = ¶m_dir.join(format!("K{}.params", $k)); + let prepare_params = |k: u32| { + let params_path = ¶m_dir.join(format!("K{}.params", k)); - if params_path.exists() { - info!("Found Params with K = {} at {:?}", $k, params_path); - } else { - info!("Create Params with K = {} to {:?}", $k, params_path); - } + if params_path.exists() { + info!("Found Params with K = {} at {:?}", k, params_path); - load_or_build_unsafe_params::($k, Some(params_path)) - }}; - } + Ok::<_, io::Error>(Params::read(&mut File::open(params_path)?)?) + } else { + info!("Create Params with K = {} to {:?}", k, params_path); + + let params = Params::::unsafe_setup::(k); + + let mut fd = std::fs::File::create(params_path)?; + params.write(&mut fd)?; + + Ok(params) + } + }; - let params = prepare_params!(zkwasm_k); - prepare_params!(aggregate_k); + let params = prepare_params(zkwasm_k)?; + prepare_params(aggregate_k)?; // Setup ZkWasm Vkey { @@ -75,7 +81,7 @@ pub fn exec_image_checksum( wasm_binary: Vec, hostenv: Builder::HostConfig, phantom_functions: Vec, - output_dir: &PathBuf, + params_dir: &PathBuf, ) -> Result<()> where Builder: HostEnvBuilder, @@ -86,10 +92,9 @@ where phantom_functions, )?; - let params = load_or_build_unsafe_params::( - zkwasm_k, - Some(&output_dir.join(format!("K{}.params", zkwasm_k))), - ); + let params = Params::read(&mut File::open( + ¶ms_dir.join(format!("K{}.params", zkwasm_k)), + )?)?; let checksum = loader.checksum(¶ms, hostenv)?; assert_eq!(checksum.len(), 1); @@ -98,7 +103,7 @@ where println!("image checksum: {:?}", checksum); let mut fd = - std::fs::File::create(&output_dir.join(format!("checksum.data",)).as_path()).unwrap(); + std::fs::File::create(¶ms_dir.join(format!("checksum.data",)).as_path()).unwrap(); write!(fd, "{:?}", checksum)?; @@ -170,7 +175,7 @@ pub fn exec_create_proof( &mut pkey_cache, &mut param_cache, circuits_batcher::args::HashType::Poseidon, - circuits_batcher::args::OpenSchema::GWC, + OpenSchema::GWC, ); prover.save_proof_data(&vec![instances], &transcript, output_dir); @@ -193,10 +198,9 @@ pub fn exec_verify_proof( let proofloadinfo = ProofGenerationInfo::load(&load_info); let proofs: Vec> = ProofInfo::load_proof(&output_dir, ¶m_dir, &proofloadinfo); - let params = load_or_build_unsafe_params::( - proofloadinfo.k as u32, - Some(¶m_dir.join(format!("K{}.params", proofloadinfo.k))), - ); + let params = Params::read(&mut File::open( + ¶m_dir.join(format!("K{}.params", proofloadinfo.k)), + )?)?; let mut public_inputs_size = 0; for proof in proofs.iter() { public_inputs_size = usize::max( @@ -210,15 +214,7 @@ pub fn exec_verify_proof( let params_verifier: ParamsVerifier = params.verifier(public_inputs_size).unwrap(); for (_, proof) in proofs.into_iter().enumerate() { - let strategy = SingleVerifier::new(¶ms_verifier); - verify_proof_with_shplonk::( - ¶ms_verifier, - &proof.vkey, - strategy, - &[&proof.instances.iter().map(|x| &x[..]).collect::>()[..]], - &mut PoseidonRead::init(&proof.transcripts[..]), - ) - .unwrap(); + proof.verify_proof(¶ms_verifier, OpenSchema::GWC)?; } info!("Verifing proof passed"); diff --git a/crates/host/Cargo.toml b/crates/host/Cargo.toml index 15ee420da..761243b7b 100644 --- a/crates/host/Cargo.toml +++ b/crates/host/Cargo.toml @@ -29,7 +29,6 @@ sha2 = "0.10.6" poseidon = { git = "https://github.com/DelphinusLab/poseidon" } anyhow.workspace = true -halo2aggregator-s.workspace = true halo2_proofs.workspace = true parity-wasm.workspace = true wasmi.workspace = true diff --git a/crates/playground/Cargo.lock b/crates/playground/Cargo.lock index 8ea6d013e..3b6e5788d 100644 --- a/crates/playground/Cargo.lock +++ b/crates/playground/Cargo.lock @@ -566,7 +566,6 @@ dependencies = [ "downcast-rs", "ff", "halo2_proofs", - "halo2aggregator-s", "hex", "lazy_static", "log", diff --git a/crates/zkwasm/Cargo.toml b/crates/zkwasm/Cargo.toml index ef089fb6a..c5c6c3ceb 100644 --- a/crates/zkwasm/Cargo.toml +++ b/crates/zkwasm/Cargo.toml @@ -29,7 +29,6 @@ rayon = "1.5" anyhow.workspace = true cfg-if.workspace = true -halo2aggregator-s.workspace = true halo2_proofs.workspace = true parity-wasm.workspace = true wasmi.workspace = true diff --git a/crates/zkwasm/src/lib.rs b/crates/zkwasm/src/lib.rs index 9cc6ffcc8..d9b90c19c 100644 --- a/crates/zkwasm/src/lib.rs +++ b/crates/zkwasm/src/lib.rs @@ -19,5 +19,4 @@ extern crate lazy_static; extern crate downcast_rs; pub extern crate halo2_proofs; -pub extern crate halo2aggregator_s; pub extern crate zkwasm_host_circuits; diff --git a/crates/zkwasm/src/loader/mod.rs b/crates/zkwasm/src/loader/mod.rs index d7796eedb..2b9578f55 100644 --- a/crates/zkwasm/src/loader/mod.rs +++ b/crates/zkwasm/src/loader/mod.rs @@ -2,18 +2,11 @@ use anyhow::Result; use halo2_proofs::arithmetic::MultiMillerLoop; use halo2_proofs::dev::MockProver; use halo2_proofs::plonk::keygen_vk; -use halo2_proofs::plonk::verify_proof_with_shplonk; -use halo2_proofs::plonk::SingleVerifier; use halo2_proofs::plonk::VerifyingKey; use halo2_proofs::poly::commitment::Params; -use halo2_proofs::poly::commitment::ParamsVerifier; use log::warn; use std::marker::PhantomData; -use halo2aggregator_s::circuits::utils::load_or_create_proof; -use halo2aggregator_s::circuits::utils::TranscriptHash; -use halo2aggregator_s::transcript::poseidon::PoseidonRead; - use specs::ExecutionTable; use specs::Tables; use wasmi::tracer::Tracer; @@ -216,84 +209,19 @@ impl> ZkWasmLoader, - instances: &Vec, - ) -> Result<()> { - let prover = MockProver::run(self.k, circuit, vec![instances.clone()])?; - assert_eq!(prover.verify(), Ok(())); - - Ok(()) - } - - pub fn create_proof( - &self, - params: &Params, - vkey: VerifyingKey, - circuit: ZkWasmCircuit, - instances: &Vec, - ) -> Result> { - Ok(load_or_create_proof::( - ¶ms, - vkey, - circuit, - &[instances], - None, - TranscriptHash::Poseidon, - false, - true, - )) - } - pub fn init_env(&self) -> Result<()> { init_zkwasm_runtime(self.k); Ok(()) } - pub fn verify_proof( + pub fn mock_test( &self, - params: &Params, - vkey: VerifyingKey, - instances: Vec, - proof: Vec, - #[cfg(feature = "uniform-circuit")] config: EnvBuilder::HostConfig, + circuit: &ZkWasmCircuit, + instances: &Vec, ) -> Result<()> { - let params_verifier: ParamsVerifier = params.verifier(instances.len()).unwrap(); - let strategy = SingleVerifier::new(¶ms_verifier); - - verify_proof_with_shplonk( - ¶ms_verifier, - &vkey, - strategy, - &[&[&instances]], - &mut PoseidonRead::init(&proof[..]), - ) - .unwrap(); - - #[cfg(feature = "uniform-circuit")] - { - use crate::circuits::image_table::IMAGE_COL_NAME; - use halo2_proofs::plonk::get_advice_commitments_from_transcript; - - let img_col_idx = vkey - .cs - .named_advices - .iter() - .find(|(k, _)| k == IMAGE_COL_NAME) - .unwrap() - .1; - let img_col_commitment: Vec = - get_advice_commitments_from_transcript::( - &vkey, - &mut PoseidonRead::init(&proof[..]), - ) - .unwrap(); - let checksum = self.checksum(params, config)?; - - assert!(vec![img_col_commitment[img_col_idx as usize]] == checksum) - } + let prover = MockProver::run(self.k, circuit, vec![instances.clone()])?; + assert_eq!(prover.verify(), Ok(())); Ok(()) } @@ -301,12 +229,22 @@ impl> ZkWasmLoader { + pub fn create_proof( + &self, + params: &Params, + pk: &ProvingKey, + circuit: ZkWasmCircuit, + instances: &Vec, + ) -> Result> { + let mut transcript = Blake2bWrite::init(vec![]); + + create_proof( + params, + pk, + &[circuit], + &[&[&instances[..]]], + OsRng, + &mut transcript, + )?; + + Ok(transcript.finalize()) + } + + pub fn verify_proof( + &self, + params: &Params, + vkey: &VerifyingKey, + instances: Vec, + proof: Vec, + #[cfg(feature = "uniform-circuit")] config: EnvBuilder::HostConfig, + ) -> Result<()> { + use halo2_proofs::plonk::verify_proof; + + let params_verifier: ParamsVerifier = params.verifier(instances.len()).unwrap(); + let strategy = SingleVerifier::new(¶ms_verifier); + + verify_proof( + ¶ms_verifier, + &vkey, + strategy, + &[&[&instances]], + &mut Blake2bRead::init(&proof[..]), + ) + .unwrap(); + + #[cfg(feature = "uniform-circuit")] + { + use crate::circuits::image_table::IMAGE_COL_NAME; + use halo2_proofs::plonk::get_advice_commitments_from_transcript; + + let img_col_idx = vkey + .cs + .named_advices + .iter() + .find(|(k, _)| k == IMAGE_COL_NAME) + .unwrap() + .1; + let img_col_commitment: Vec = + get_advice_commitments_from_transcript::( + &vkey, + &mut PoseidonRead::init(&proof[..]), + ) + .unwrap(); + let checksum = self.checksum(params, config)?; + + assert!(vec![img_col_commitment[img_col_idx as usize]] == checksum) + } + + Ok(()) + } + pub(crate) fn bench_test(&self, circuit: ZkWasmCircuit, instances: Vec) { fn prepare_param(k: u32) -> Params { let path = PathBuf::from(format!("test_param.{}.data", k)); @@ -344,11 +351,13 @@ mod tests { let params = prepare_param(self.k); let vkey = self.create_vkey(¶ms, ()).unwrap(); + let pkey = keygen_pk(¶ms, vkey, &circuit).unwrap(); let proof = self - .create_proof(¶ms, vkey.clone(), circuit, &instances) + .create_proof(¶ms, &pkey, circuit, &instances) + .unwrap(); + self.verify_proof(¶ms, pkey.get_vk(), instances, proof) .unwrap(); - self.verify_proof(¶ms, vkey, instances, proof).unwrap(); } } } From 79bfd9819934bbb632db59f6baefdfe37a314108 Mon Sep 17 00:00:00 2001 From: Sinka Date: Wed, 10 Apr 2024 20:41:28 +0800 Subject: [PATCH 3/9] support proof recorder in host merkle --- Cargo.lock | 16 +++++---- Cargo.toml | 2 +- crates/cli/src/app_builder.rs | 2 ++ crates/cli/test_cli.sh | 8 ++--- crates/host/src/host/merkle_helper/merkle.rs | 37 ++++++++++++++++---- crates/host/src/lib.rs | 20 ++++++++--- 6 files changed, 62 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ec26406d..f1d34ae17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -353,7 +353,7 @@ dependencies = [ [[package]] name = "circuits-batcher" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/continuation-batcher.git#b26f281c2f7e4d673e873f2c05accd29952eb332" +source = "git+https://github.com/DelphinusLab/continuation-batcher.git#060c8d7885c7459f91440c9d1b1f23b22bc3d473" dependencies = [ "anyhow", "ark-std 0.4.0", @@ -1159,12 +1159,12 @@ dependencies = [ [[package]] name = "halo2aggregator-s" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/halo2aggregator-s.git#747788c3331014d8854ed4746c51a1582e5271c1" +source = "git+https://github.com/DelphinusLab/halo2aggregator-s.git?tag=1.0.0#35026092b90743d0e37689bd21444c250e64a9d4" dependencies = [ "ark-std 0.4.0", "blake2b_simd", "halo2_proofs", - "halo2ecc-s 0.3.2 (git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.4.0)", + "halo2ecc-s 0.3.2 (git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.5.6#3b8b424f)", "lazy_static", "num-bigint", "num-integer", @@ -1177,8 +1177,9 @@ dependencies = [ [[package]] name = "halo2ecc-s" version = "0.3.2" -source = "git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.4.0#eef56995f5729083d54b89faa30d5f90277acc22" +source = "git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.5.6#3b8b424f#3b8b424f009fd945fc982f530ed29b555f8002e6" dependencies = [ + "ark-std 0.4.0", "halo2_proofs", "num-bigint", "num-integer", @@ -1188,8 +1189,9 @@ dependencies = [ [[package]] name = "halo2ecc-s" version = "0.3.2" -source = "git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.4.0#eef56995f5729083d54b89faa30d5f90277acc22" +source = "git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.5.6#3b8b424f#3b8b424f009fd945fc982f530ed29b555f8002e6" dependencies = [ + "ark-std 0.4.0", "halo2_proofs", "num-bigint", "num-integer", @@ -3487,7 +3489,7 @@ dependencies = [ [[package]] name = "zkwasm-host-circuits" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/zkWasm-host-circuits.git#d32de5ec45141c030d335b473cf9333fa405aebc" +source = "git+https://github.com/DelphinusLab/zkWasm-host-circuits.git?branch=synthesize-helper#b49ed7e13c723290ffcad0a7aa5efd093dc4b48a" dependencies = [ "ark-std 0.3.0", "cfg-if 1.0.0", @@ -3495,7 +3497,7 @@ dependencies = [ "clap", "ff", "halo2_proofs", - "halo2ecc-s 0.3.2 (git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.4.0)", + "halo2ecc-s 0.3.2 (git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.5.6#3b8b424f)", "hex", "itertools", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 19e418300..eaa7e29c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ halo2_proofs = { git = "https://github.com/DelphinusLab/halo2-gpu-specific.git", parity-wasm = { version = "0.42.0", features = ["sign_ext"] } wasmi = { path = "third-party/wasmi" } circuits-batcher = { git = "https://github.com/DelphinusLab/continuation-batcher.git" } -zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git" } +zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git", branch="synthesize-helper" } [profile.dev] opt-level = 3 diff --git a/crates/cli/src/app_builder.rs b/crates/cli/src/app_builder.rs index 80c8beef9..38c8a81ee 100644 --- a/crates/cli/src/app_builder.rs +++ b/crates/cli/src/app_builder.rs @@ -202,6 +202,7 @@ pub trait AppBuilder: CommandBuilder { context_outputs: context_output.clone(), indexed_witness: Rc::new(RefCell::new(HashMap::new())), tree_db: None, + merkle_proof_recorder: None, }, HostEnvConfig::default(), )?; @@ -255,6 +256,7 @@ pub trait AppBuilder: CommandBuilder { context_outputs: context_out.clone(), indexed_witness: Rc::new(RefCell::new(HashMap::new())), tree_db: None, + merkle_proof_recorder: None, }, HostEnvConfig::default(), )?; diff --git a/crates/cli/test_cli.sh b/crates/cli/test_cli.sh index 5206903b0..d68502fc2 100755 --- a/crates/cli/test_cli.sh +++ b/crates/cli/test_cli.sh @@ -7,8 +7,8 @@ rm -rf params/*.data rm -rf output/*.data # Single test -RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm setup -RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm checksum +RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm setup +RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm checksum -RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-prove --public 133:i64 --public 2:i64 -RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-verify +RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-prove --public 133:i64 --public 2:i64 +RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-verify diff --git a/crates/host/src/host/merkle_helper/merkle.rs b/crates/host/src/host/merkle_helper/merkle.rs index b3a3ab5e9..f8a5b88b9 100644 --- a/crates/host/src/host/merkle_helper/merkle.rs +++ b/crates/host/src/host/merkle_helper/merkle.rs @@ -4,6 +4,7 @@ use delphinus_zkwasm::runtime::host::ForeignContext; use delphinus_zkwasm::runtime::host::ForeignStatics; use halo2_proofs::pairing::bn256::Fr; use std::cell::RefCell; +use std::io::Write; use std::rc::Rc; use wasmi::tracer::Observer; use zkwasm_host_circuits::circuits::host::HostOpSelector; @@ -19,6 +20,7 @@ use zkwasm_host_circuits::host::ForeignInst::MerkleSet; use zkwasm_host_circuits::host::ForeignInst::MerkleSetRoot; use zkwasm_host_circuits::host::Reduce; use zkwasm_host_circuits::host::ReduceRule; +use zkwasm_host_circuits::proof::write_merkle_proof; const MERKLE_TREE_HEIGHT: usize = 32; @@ -33,6 +35,7 @@ pub struct MerkleContext { pub mongo_merkle: Option>, pub mongo_datahash: datahelper::MongoDataHash, pub tree_db: Option>>, + pub proof_recorder: Option>>, pub used_round: usize, } @@ -41,7 +44,10 @@ fn new_reduce(rules: Vec>) -> Reduce { } impl MerkleContext { - pub fn new(tree_db: Option>>) -> Self { + pub fn new( + tree_db: Option>>, + proof_recorder: Option>>, + ) -> Self { MerkleContext { set_root: new_reduce(vec![ReduceRule::Bytes(vec![], 4)]), get_root: new_reduce(vec![ReduceRule::Bytes(vec![], 4)]), @@ -53,6 +59,7 @@ impl MerkleContext { mongo_merkle: None, mongo_datahash: datahelper::MongoDataHash::construct([0; 32], tree_db.clone()), tree_db, + proof_recorder, used_round: 0, } } @@ -112,8 +119,13 @@ impl MerkleContext { .as_mut() .expect("merkle db not initialized"); let hash = self.set.rules[0].bytes_value().unwrap(); - mt.update_leaf_data_with_proof(index, &hash) + let proof = mt + .update_leaf_data_with_proof(index, &hash) .expect("Unexpected failure: update leaf with proof fail"); + self.proof_recorder.as_mut().map(|v| { + let mut writer = v.borrow_mut(); + write_merkle_proof(&mut *writer, proof); + }); } } @@ -124,9 +136,15 @@ impl MerkleContext { .mongo_merkle .as_ref() .expect("merkle db not initialized"); - let (leaf, _) = mt + let (leaf, proof) = mt .get_leaf_with_proof(index) .expect("Unexpected failure: get leaf fail"); + + self.proof_recorder.as_mut().map(|v| { + let mut writer = v.borrow_mut(); + write_merkle_proof(&mut *writer, proof); + }); + let values = leaf.data_as_u64(); if self.data_cursor == 0 { self.data = values; @@ -149,10 +167,15 @@ impl ForeignContext for MerkleContext { } use specs::external_host_call_table::ExternalHostCallSignature; -pub fn register_merkle_foreign(env: &mut HostEnv, tree_db: Option>>) { - let foreign_merkle_plugin = env - .external_env - .register_plugin("foreign_merkle", Box::new(MerkleContext::new(tree_db))); +pub fn register_merkle_foreign( + env: &mut HostEnv, + tree_db: Option>>, + proof_recorder: Option>>, +) { + let foreign_merkle_plugin = env.external_env.register_plugin( + "foreign_merkle", + Box::new(MerkleContext::new(tree_db, proof_recorder)), + ); env.external_env.register_function( "merkle_setroot", diff --git a/crates/host/src/lib.rs b/crates/host/src/lib.rs index fa75a9b34..b543010f8 100644 --- a/crates/host/src/lib.rs +++ b/crates/host/src/lib.rs @@ -14,6 +14,7 @@ use delphinus_zkwasm::runtime::host::HostEnvBuilder; use serde::Deserialize; use serde::Serialize; use std::collections::HashMap; +use std::io::Write; use std::sync::Arc; use std::sync::Mutex; use zkwasm_host_circuits::host::db::TreeDB; @@ -32,6 +33,8 @@ pub struct ExecutionArg { pub indexed_witness: Rc>>>, /// db src pub tree_db: Option>>, + /// merkle_proof_tracker: + pub merkle_proof_recorder: Option>>, } impl ContextOutput for ExecutionArg { @@ -60,7 +63,12 @@ impl Default for HostEnvConfig { } impl HostEnvConfig { - fn register_ops(&self, env: &mut HostEnv, tree_db: Option>>) { + fn register_ops( + &self, + env: &mut HostEnv, + tree_db: Option>>, + merkle_proof_recorder: Option>>, + ) { for op in &self.ops { match op { OpType::BLS381PAIR => host::ecc_helper::bls381::pair::register_blspair_foreign(env), @@ -69,7 +77,11 @@ impl HostEnvConfig { OpType::BN256SUM => host::ecc_helper::bn254::sum::register_bn254sum_foreign(env), OpType::POSEIDONHASH => host::hash_helper::poseidon::register_poseidon_foreign(env), OpType::MERKLE => { - host::merkle_helper::merkle::register_merkle_foreign(env, tree_db.clone()); + host::merkle_helper::merkle::register_merkle_foreign( + env, + tree_db.clone(), + merkle_proof_recorder.clone(), + ); host::merkle_helper::datacache::register_datacache_foreign( env, tree_db.clone(), @@ -96,7 +108,7 @@ impl HostEnvBuilder for StandardHostEnvBuilder { register_require_foreign(&mut env); register_log_foreign(&mut env); register_context_foreign(&mut env, vec![], Arc::new(Mutex::new(vec![]))); - envconfig.register_ops(&mut env, None); + envconfig.register_ops(&mut env, None, None); host::witness_helper::register_witness_foreign( &mut env, Rc::new(RefCell::new(HashMap::new())), @@ -114,7 +126,7 @@ impl HostEnvBuilder for StandardHostEnvBuilder { register_log_foreign(&mut env); register_context_foreign(&mut env, arg.context_inputs, arg.context_outputs); host::witness_helper::register_witness_foreign(&mut env, arg.indexed_witness); - envconfig.register_ops(&mut env, arg.tree_db); + envconfig.register_ops(&mut env, arg.tree_db, arg.merkle_proof_recorder); env.finalize(); (env, wasm_runtime_io) From 1a4433cf708222d61fdd9cc2bd9bf349a9c36177 Mon Sep 17 00:00:00 2001 From: EvanHan Date: Tue, 21 May 2024 16:22:51 +0800 Subject: [PATCH 4/9] Revert "support proof recorder in host merkle" This reverts commit 79bfd9819934bbb632db59f6baefdfe37a314108. --- Cargo.lock | 16 ++++----- Cargo.toml | 2 +- crates/cli/src/app_builder.rs | 2 -- crates/cli/test_cli.sh | 8 ++--- crates/host/src/host/merkle_helper/merkle.rs | 37 ++++---------------- crates/host/src/lib.rs | 20 +++-------- 6 files changed, 23 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f1d34ae17..6ec26406d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -353,7 +353,7 @@ dependencies = [ [[package]] name = "circuits-batcher" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/continuation-batcher.git#060c8d7885c7459f91440c9d1b1f23b22bc3d473" +source = "git+https://github.com/DelphinusLab/continuation-batcher.git#b26f281c2f7e4d673e873f2c05accd29952eb332" dependencies = [ "anyhow", "ark-std 0.4.0", @@ -1159,12 +1159,12 @@ dependencies = [ [[package]] name = "halo2aggregator-s" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/halo2aggregator-s.git?tag=1.0.0#35026092b90743d0e37689bd21444c250e64a9d4" +source = "git+https://github.com/DelphinusLab/halo2aggregator-s.git#747788c3331014d8854ed4746c51a1582e5271c1" dependencies = [ "ark-std 0.4.0", "blake2b_simd", "halo2_proofs", - "halo2ecc-s 0.3.2 (git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.5.6#3b8b424f)", + "halo2ecc-s 0.3.2 (git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.4.0)", "lazy_static", "num-bigint", "num-integer", @@ -1177,9 +1177,8 @@ dependencies = [ [[package]] name = "halo2ecc-s" version = "0.3.2" -source = "git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.5.6#3b8b424f#3b8b424f009fd945fc982f530ed29b555f8002e6" +source = "git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.4.0#eef56995f5729083d54b89faa30d5f90277acc22" dependencies = [ - "ark-std 0.4.0", "halo2_proofs", "num-bigint", "num-integer", @@ -1189,9 +1188,8 @@ dependencies = [ [[package]] name = "halo2ecc-s" version = "0.3.2" -source = "git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.5.6#3b8b424f#3b8b424f009fd945fc982f530ed29b555f8002e6" +source = "git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.4.0#eef56995f5729083d54b89faa30d5f90277acc22" dependencies = [ - "ark-std 0.4.0", "halo2_proofs", "num-bigint", "num-integer", @@ -3489,7 +3487,7 @@ dependencies = [ [[package]] name = "zkwasm-host-circuits" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/zkWasm-host-circuits.git?branch=synthesize-helper#b49ed7e13c723290ffcad0a7aa5efd093dc4b48a" +source = "git+https://github.com/DelphinusLab/zkWasm-host-circuits.git#d32de5ec45141c030d335b473cf9333fa405aebc" dependencies = [ "ark-std 0.3.0", "cfg-if 1.0.0", @@ -3497,7 +3495,7 @@ dependencies = [ "clap", "ff", "halo2_proofs", - "halo2ecc-s 0.3.2 (git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.5.6#3b8b424f)", + "halo2ecc-s 0.3.2 (git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.4.0)", "hex", "itertools", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index eaa7e29c7..19e418300 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ halo2_proofs = { git = "https://github.com/DelphinusLab/halo2-gpu-specific.git", parity-wasm = { version = "0.42.0", features = ["sign_ext"] } wasmi = { path = "third-party/wasmi" } circuits-batcher = { git = "https://github.com/DelphinusLab/continuation-batcher.git" } -zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git", branch="synthesize-helper" } +zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git" } [profile.dev] opt-level = 3 diff --git a/crates/cli/src/app_builder.rs b/crates/cli/src/app_builder.rs index 38c8a81ee..80c8beef9 100644 --- a/crates/cli/src/app_builder.rs +++ b/crates/cli/src/app_builder.rs @@ -202,7 +202,6 @@ pub trait AppBuilder: CommandBuilder { context_outputs: context_output.clone(), indexed_witness: Rc::new(RefCell::new(HashMap::new())), tree_db: None, - merkle_proof_recorder: None, }, HostEnvConfig::default(), )?; @@ -256,7 +255,6 @@ pub trait AppBuilder: CommandBuilder { context_outputs: context_out.clone(), indexed_witness: Rc::new(RefCell::new(HashMap::new())), tree_db: None, - merkle_proof_recorder: None, }, HostEnvConfig::default(), )?; diff --git a/crates/cli/test_cli.sh b/crates/cli/test_cli.sh index d68502fc2..5206903b0 100755 --- a/crates/cli/test_cli.sh +++ b/crates/cli/test_cli.sh @@ -7,8 +7,8 @@ rm -rf params/*.data rm -rf output/*.data # Single test -RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm setup -RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm checksum +RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm setup +RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm checksum -RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-prove --public 133:i64 --public 2:i64 -RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-verify +RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-prove --public 133:i64 --public 2:i64 +RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-verify diff --git a/crates/host/src/host/merkle_helper/merkle.rs b/crates/host/src/host/merkle_helper/merkle.rs index f8a5b88b9..b3a3ab5e9 100644 --- a/crates/host/src/host/merkle_helper/merkle.rs +++ b/crates/host/src/host/merkle_helper/merkle.rs @@ -4,7 +4,6 @@ use delphinus_zkwasm::runtime::host::ForeignContext; use delphinus_zkwasm::runtime::host::ForeignStatics; use halo2_proofs::pairing::bn256::Fr; use std::cell::RefCell; -use std::io::Write; use std::rc::Rc; use wasmi::tracer::Observer; use zkwasm_host_circuits::circuits::host::HostOpSelector; @@ -20,7 +19,6 @@ use zkwasm_host_circuits::host::ForeignInst::MerkleSet; use zkwasm_host_circuits::host::ForeignInst::MerkleSetRoot; use zkwasm_host_circuits::host::Reduce; use zkwasm_host_circuits::host::ReduceRule; -use zkwasm_host_circuits::proof::write_merkle_proof; const MERKLE_TREE_HEIGHT: usize = 32; @@ -35,7 +33,6 @@ pub struct MerkleContext { pub mongo_merkle: Option>, pub mongo_datahash: datahelper::MongoDataHash, pub tree_db: Option>>, - pub proof_recorder: Option>>, pub used_round: usize, } @@ -44,10 +41,7 @@ fn new_reduce(rules: Vec>) -> Reduce { } impl MerkleContext { - pub fn new( - tree_db: Option>>, - proof_recorder: Option>>, - ) -> Self { + pub fn new(tree_db: Option>>) -> Self { MerkleContext { set_root: new_reduce(vec![ReduceRule::Bytes(vec![], 4)]), get_root: new_reduce(vec![ReduceRule::Bytes(vec![], 4)]), @@ -59,7 +53,6 @@ impl MerkleContext { mongo_merkle: None, mongo_datahash: datahelper::MongoDataHash::construct([0; 32], tree_db.clone()), tree_db, - proof_recorder, used_round: 0, } } @@ -119,13 +112,8 @@ impl MerkleContext { .as_mut() .expect("merkle db not initialized"); let hash = self.set.rules[0].bytes_value().unwrap(); - let proof = mt - .update_leaf_data_with_proof(index, &hash) + mt.update_leaf_data_with_proof(index, &hash) .expect("Unexpected failure: update leaf with proof fail"); - self.proof_recorder.as_mut().map(|v| { - let mut writer = v.borrow_mut(); - write_merkle_proof(&mut *writer, proof); - }); } } @@ -136,15 +124,9 @@ impl MerkleContext { .mongo_merkle .as_ref() .expect("merkle db not initialized"); - let (leaf, proof) = mt + let (leaf, _) = mt .get_leaf_with_proof(index) .expect("Unexpected failure: get leaf fail"); - - self.proof_recorder.as_mut().map(|v| { - let mut writer = v.borrow_mut(); - write_merkle_proof(&mut *writer, proof); - }); - let values = leaf.data_as_u64(); if self.data_cursor == 0 { self.data = values; @@ -167,15 +149,10 @@ impl ForeignContext for MerkleContext { } use specs::external_host_call_table::ExternalHostCallSignature; -pub fn register_merkle_foreign( - env: &mut HostEnv, - tree_db: Option>>, - proof_recorder: Option>>, -) { - let foreign_merkle_plugin = env.external_env.register_plugin( - "foreign_merkle", - Box::new(MerkleContext::new(tree_db, proof_recorder)), - ); +pub fn register_merkle_foreign(env: &mut HostEnv, tree_db: Option>>) { + let foreign_merkle_plugin = env + .external_env + .register_plugin("foreign_merkle", Box::new(MerkleContext::new(tree_db))); env.external_env.register_function( "merkle_setroot", diff --git a/crates/host/src/lib.rs b/crates/host/src/lib.rs index b543010f8..fa75a9b34 100644 --- a/crates/host/src/lib.rs +++ b/crates/host/src/lib.rs @@ -14,7 +14,6 @@ use delphinus_zkwasm::runtime::host::HostEnvBuilder; use serde::Deserialize; use serde::Serialize; use std::collections::HashMap; -use std::io::Write; use std::sync::Arc; use std::sync::Mutex; use zkwasm_host_circuits::host::db::TreeDB; @@ -33,8 +32,6 @@ pub struct ExecutionArg { pub indexed_witness: Rc>>>, /// db src pub tree_db: Option>>, - /// merkle_proof_tracker: - pub merkle_proof_recorder: Option>>, } impl ContextOutput for ExecutionArg { @@ -63,12 +60,7 @@ impl Default for HostEnvConfig { } impl HostEnvConfig { - fn register_ops( - &self, - env: &mut HostEnv, - tree_db: Option>>, - merkle_proof_recorder: Option>>, - ) { + fn register_ops(&self, env: &mut HostEnv, tree_db: Option>>) { for op in &self.ops { match op { OpType::BLS381PAIR => host::ecc_helper::bls381::pair::register_blspair_foreign(env), @@ -77,11 +69,7 @@ impl HostEnvConfig { OpType::BN256SUM => host::ecc_helper::bn254::sum::register_bn254sum_foreign(env), OpType::POSEIDONHASH => host::hash_helper::poseidon::register_poseidon_foreign(env), OpType::MERKLE => { - host::merkle_helper::merkle::register_merkle_foreign( - env, - tree_db.clone(), - merkle_proof_recorder.clone(), - ); + host::merkle_helper::merkle::register_merkle_foreign(env, tree_db.clone()); host::merkle_helper::datacache::register_datacache_foreign( env, tree_db.clone(), @@ -108,7 +96,7 @@ impl HostEnvBuilder for StandardHostEnvBuilder { register_require_foreign(&mut env); register_log_foreign(&mut env); register_context_foreign(&mut env, vec![], Arc::new(Mutex::new(vec![]))); - envconfig.register_ops(&mut env, None, None); + envconfig.register_ops(&mut env, None); host::witness_helper::register_witness_foreign( &mut env, Rc::new(RefCell::new(HashMap::new())), @@ -126,7 +114,7 @@ impl HostEnvBuilder for StandardHostEnvBuilder { register_log_foreign(&mut env); register_context_foreign(&mut env, arg.context_inputs, arg.context_outputs); host::witness_helper::register_witness_foreign(&mut env, arg.indexed_witness); - envconfig.register_ops(&mut env, arg.tree_db, arg.merkle_proof_recorder); + envconfig.register_ops(&mut env, arg.tree_db); env.finalize(); (env, wasm_runtime_io) From e75ce962a0417bf1ae511951fb35370933d2a3c3 Mon Sep 17 00:00:00 2001 From: EvanHan Date: Tue, 21 May 2024 16:27:46 +0800 Subject: [PATCH 5/9] update k in test_cli.sh --- crates/cli/test_cli.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/cli/test_cli.sh b/crates/cli/test_cli.sh index 5206903b0..d68502fc2 100755 --- a/crates/cli/test_cli.sh +++ b/crates/cli/test_cli.sh @@ -7,8 +7,8 @@ rm -rf params/*.data rm -rf output/*.data # Single test -RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm setup -RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm checksum +RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm setup +RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm checksum -RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-prove --public 133:i64 --public 2:i64 -RUST_LOG=info cargo run --release --features cuda -- --host default -k 18 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-verify +RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-prove --public 133:i64 --public 2:i64 +RUST_LOG=info cargo run --release --features cuda -- --host default -k 22 --function zkmain --param ./params --output ./output --wasm ../zkwasm/wasm/wasm_output.wasm single-verify From 5d79d64933bce95be6823510585514dca8f79391 Mon Sep 17 00:00:00 2001 From: sinka Date: Tue, 28 May 2024 14:25:44 +1000 Subject: [PATCH 6/9] minor fix a performance issue of uncessary calling get_leaf_with_proof --- crates/host/src/host/merkle_helper/merkle.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/host/src/host/merkle_helper/merkle.rs b/crates/host/src/host/merkle_helper/merkle.rs index b3a3ab5e9..32114fb55 100644 --- a/crates/host/src/host/merkle_helper/merkle.rs +++ b/crates/host/src/host/merkle_helper/merkle.rs @@ -124,14 +124,14 @@ impl MerkleContext { .mongo_merkle .as_ref() .expect("merkle db not initialized"); - let (leaf, _) = mt - .get_leaf_with_proof(index) - .expect("Unexpected failure: get leaf fail"); - let values = leaf.data_as_u64(); if self.data_cursor == 0 { + let (leaf, _) = mt + .get_leaf_with_proof(index) + .expect("Unexpected failure: get leaf fail"); + let values = leaf.data_as_u64(); self.data = values; } - let v = values[self.data_cursor]; + let v = self.data[self.data_cursor]; self.data_cursor += 1; return v; } From 2f8c1d2a6071f1d9d55a58d61fa304e24d7bdfc7 Mon Sep 17 00:00:00 2001 From: sinka Date: Tue, 28 May 2024 14:30:57 +1000 Subject: [PATCH 7/9] move print-trace to profile features --- Cargo.lock | 6 +++--- crates/cli/Cargo.toml | 4 ++-- crates/host/Cargo.toml | 3 ++- crates/zkwasm/Cargo.toml | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ec26406d..59ab37e58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -623,7 +623,7 @@ name = "delphinus-cli" version = "0.1.0" dependencies = [ "anyhow", - "ark-std 0.3.0", + "ark-std 0.4.0", "circuits-batcher", "clap", "delphinus-host", @@ -646,7 +646,7 @@ name = "delphinus-host" version = "0.1.0" dependencies = [ "anyhow", - "ark-std 0.3.0", + "ark-std 0.4.0", "bitvec", "delphinus-zkwasm", "downcast-rs", @@ -678,7 +678,7 @@ name = "delphinus-zkwasm" version = "0.1.0" dependencies = [ "anyhow", - "ark-std 0.3.0", + "ark-std 0.4.0", "bitvec", "cfg-if 1.0.0", "downcast-rs", diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 0fa5fbd4f..b76c8c99a 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ark-std = { version = "0.3.0", features = ["print-trace"] } +ark-std = { version = "0.4.0"} env_logger = "0.9.3" log = "0.4.17" md5 = "0.7.0" @@ -29,4 +29,4 @@ default = [] perf = ["circuits-batcher/perf"] cuda = ["delphinus-zkwasm/cuda"] uniform-circuit = ["delphinus-zkwasm/uniform-circuit"] - +profile = ["ark-std/print-trace"] diff --git a/crates/host/Cargo.toml b/crates/host/Cargo.toml index 761243b7b..e7a4d381f 100644 --- a/crates/host/Cargo.toml +++ b/crates/host/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ark-std = { version = "0.3.0", features = ["print-trace"] } +ark-std = { version = "0.4.0"} bitvec = "1.0.1" downcast-rs = "1.2.0" hex = "0.4.3" @@ -42,3 +42,4 @@ rusty-fork = "0.3.0" [features] default = [] cuda = ["halo2_proofs/cuda", "specs/cuda"] +profile = ["ark-std/print-trace"] diff --git a/crates/zkwasm/Cargo.toml b/crates/zkwasm/Cargo.toml index c5c6c3ceb..c49373865 100644 --- a/crates/zkwasm/Cargo.toml +++ b/crates/zkwasm/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ark-std = { version = "0.3.0", features = ["print-trace"] } +ark-std = { version = "0.4.0"} bitvec = "1.0.1" downcast-rs = "1.2.0" hex = "0.4.3" @@ -43,4 +43,5 @@ rusty-fork = "0.3.0" [features] default = [] cuda = ["halo2_proofs/cuda", "specs/cuda"] +profile = ["ark-std/print-trace"] uniform-circuit = [] From cc66e1f9b79364df28592db0483f548603665d51 Mon Sep 17 00:00:00 2001 From: Sinka Date: Tue, 19 Mar 2024 08:36:03 +0800 Subject: [PATCH 8/9] zkwasm for explorer v1.1 --- crates/cli/src/exec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cli/src/exec.rs b/crates/cli/src/exec.rs index 78f865150..ecfb54198 100644 --- a/crates/cli/src/exec.rs +++ b/crates/cli/src/exec.rs @@ -175,7 +175,7 @@ pub fn exec_create_proof( &mut pkey_cache, &mut param_cache, circuits_batcher::args::HashType::Poseidon, - OpenSchema::GWC, + circuits_batcher::args::OpenSchema::Shplonk, ); prover.save_proof_data(&vec![instances], &transcript, output_dir); From 342fa95cc38900c00755d19f9767dd3f255d601d Mon Sep 17 00:00:00 2001 From: sinka Date: Thu, 8 Aug 2024 21:02:25 +1000 Subject: [PATCH 9/9] bump zkwasm-host-circuit --- Cargo.lock | 16 +++++++++------- Cargo.toml | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59ab37e58..2b3456808 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,9 +71,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" dependencies = [ "backtrace", ] @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "halo2ecc-s" version = "0.3.2" -source = "git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.4.0#eef56995f5729083d54b89faa30d5f90277acc22" +source = "git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.4.0#eef56995f5729083d54b89faa30d5f90277acc22" dependencies = [ "halo2_proofs", "num-bigint", @@ -1188,8 +1188,9 @@ dependencies = [ [[package]] name = "halo2ecc-s" version = "0.3.2" -source = "git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.4.0#eef56995f5729083d54b89faa30d5f90277acc22" +source = "git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.5.7#c6b5e8e190431c1206cbdc4b13228eb7bc409283" dependencies = [ + "ark-std 0.4.0", "halo2_proofs", "num-bigint", "num-integer", @@ -3487,15 +3488,16 @@ dependencies = [ [[package]] name = "zkwasm-host-circuits" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/zkWasm-host-circuits.git#d32de5ec45141c030d335b473cf9333fa405aebc" +source = "git+https://github.com/DelphinusLab/zkWasm-host-circuits.git?branch=xgao/dynamic-db-uri#5b253d62e68ef0c227cc4aa3fc99cf35f81c583d" dependencies = [ - "ark-std 0.3.0", + "anyhow", + "ark-std 0.4.0", "cfg-if 1.0.0", "circuits-batcher", "clap", "ff", "halo2_proofs", - "halo2ecc-s 0.3.2 (git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.4.0)", + "halo2ecc-s 0.3.2 (git+https://github.com/DelphinusLab/halo2ecc-s.git?tag=bisect-lookup-0.5.7)", "hex", "itertools", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 19e418300..dd0c51694 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,13 +4,13 @@ exclude = ["third-party/wasmi", "crates/playground"] resolver = "2" [workspace.dependencies] -anyhow = { version = "1.0.68", features = ["backtrace"] } +anyhow = { version = "1.0.86", features = ["backtrace"] } cfg-if = "1.0.0" halo2_proofs = { git = "https://github.com/DelphinusLab/halo2-gpu-specific.git", default-features = true } parity-wasm = { version = "0.42.0", features = ["sign_ext"] } wasmi = { path = "third-party/wasmi" } circuits-batcher = { git = "https://github.com/DelphinusLab/continuation-batcher.git" } -zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git" } +zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git", branch="xgao/dynamic-db-uri" } [profile.dev] opt-level = 3