From 829c72058ede6b0a27caa55f39c3b31981c3fef0 Mon Sep 17 00:00:00 2001 From: rhaoio Date: Fri, 15 Mar 2024 13:18:08 +1100 Subject: [PATCH 1/6] compile but cli unfinished --- Cargo.lock | 78 +++++++++++++++++++++++++-------- Cargo.toml | 2 +- crates/cli/Cargo.toml | 2 +- crates/cli/src/exec.rs | 42 +++++++++++------- crates/host/Cargo.toml | 2 +- crates/zkwasm/Cargo.toml | 2 +- crates/zkwasm/src/loader/mod.rs | 1 + third-party/wasmi | 2 +- 8 files changed, 91 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3b0c01cc..80c44029f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,6 +89,16 @@ dependencies = [ "rand", ] +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + [[package]] name = "arrayref" version = "0.3.7" @@ -313,10 +323,10 @@ dependencies = [ [[package]] name = "circuits-batcher" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/continuation-batcher.git#8376e7de916b165c8e4965b9b8933e0f3095b50a" +source = "git+https://github.com/DelphinusLab/continuation-batcher.git?branch=polish-structure#fc9ecb88fd6f364996d25a3d03dbd2eb0030dd07" dependencies = [ "anyhow", - "ark-std", + "ark-std 0.4.0", "bitvec", "clap", "downcast-rs", @@ -324,7 +334,6 @@ dependencies = [ "ff", "halo2_proofs", "halo2aggregator-s", - "halo2ecc-s", "hex", "lazy_static", "log", @@ -335,12 +344,12 @@ dependencies = [ "num-derive", "num-integer", "num-traits", - "poseidon", "quote", "rand", "serde", "serde_json", "sha2", + "sha3", "strum", "strum_macros", "uuid", @@ -563,7 +572,7 @@ name = "delphinus-cli" version = "0.1.0" dependencies = [ "anyhow", - "ark-std", + "ark-std 0.3.0", "circuits-batcher", "clap", "delphinus-host", @@ -587,7 +596,7 @@ name = "delphinus-host" version = "0.1.0" dependencies = [ "anyhow", - "ark-std", + "ark-std 0.3.0", "bitvec", "delphinus-zkwasm", "downcast-rs", @@ -620,7 +629,7 @@ name = "delphinus-zkwasm" version = "0.1.0" dependencies = [ "anyhow", - "ark-std", + "ark-std 0.3.0", "bitvec", "cfg-if 1.0.0", "downcast-rs", @@ -729,9 +738,9 @@ source = "git+https://github.com/lanbones/ec-gpu#165d1dd6215f6fd1dd85c83cf430ff5 [[package]] name = "ec-gpu-gen" version = "0.4.0" -source = "git+https://github.com/lanbones/ec-gpu?branch=halo2-opt-v2#784eda53754a5344f75e4b3c533361d628ad1402" +source = "git+https://github.com/lanbones/ec-gpu?branch=halo2-opt-v2#5481be558da026bb9bddcd5807f973f6b1a8346e" dependencies = [ - "ark-std", + "ark-std 0.3.0", "bitvec", "crossbeam-channel", "ec-gpu", @@ -1072,9 +1081,9 @@ dependencies = [ [[package]] name = "halo2_proofs" version = "0.1.0-beta.1" -source = "git+https://github.com/DelphinusLab/halo2-gpu-specific.git#9ac108049b488df640eecdd5eb18751062442898" +source = "git+https://github.com/DelphinusLab/halo2-gpu-specific.git#74d45bbbee691e48cfccd51d561c25c4096d52ac" dependencies = [ - "ark-std", + "ark-std 0.4.0", "blake2b_simd", "bumpalo", "cfg-if 0.1.10", @@ -1084,6 +1093,7 @@ dependencies = [ "ff", "group", "lazy_static", + "log", "memmap", "num", "num-bigint", @@ -1100,17 +1110,18 @@ dependencies = [ [[package]] name = "halo2aggregator-s" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/halo2aggregator-s.git?branch=main#4fc143e5a10a77cb24f31c0b792ec9a01d1bfd34" +source = "git+https://github.com/DelphinusLab/halo2aggregator-s.git?branch=explorer-integration#eb2329050971f00a6fc2f2a1416b80d2f91f69a4" dependencies = [ - "ark-std", + "ark-std 0.4.0", "blake2b_simd", "halo2_proofs", - "halo2ecc-s", + "halo2ecc-s 0.3.2 (git+https://github.com/lanbones/halo2ecc-s.git?branch=no-select-chip)", "lazy_static", "num-bigint", "num-integer", "poseidon", "sha2", + "sha3", "tera", ] @@ -1125,6 +1136,18 @@ dependencies = [ "rayon", ] +[[package]] +name = "halo2ecc-s" +version = "0.3.2" +source = "git+https://github.com/lanbones/halo2ecc-s.git?branch=no-select-chip#2fc9b6017892bec85e52c30c5fa8aa169b36936b" +dependencies = [ + "halo2_proofs", + "num-bigint", + "num-integer", + "rayon", + "sha3", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1363,6 +1386,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1902,7 +1934,7 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "poseidon" version = "0.2.0" -source = "git+https://github.com/lanbones/poseidon#df8891073182c5c6cc1e2e7f9d2f4297d3c1565d" +source = "git+https://github.com/lanbones/poseidon#58835e054512ad7833df6d20479e9e0e034a073b" dependencies = [ "halo2_proofs", "subtle", @@ -2369,6 +2401,16 @@ dependencies = [ "digest", ] +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -3316,15 +3358,15 @@ dependencies = [ [[package]] name = "zkwasm-host-circuits" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/zkWasm-host-circuits.git?branch=main#e3a2eff4583b2fd8be7fc3e54f2789cbfbfd72d4" +source = "git+https://github.com/DelphinusLab/zkWasm-host-circuits.git?branch=keccak-test#e75054f9ede9cfdd91b1ca67f592273f7f3a6390" dependencies = [ - "ark-std", + "ark-std 0.3.0", "cfg-if 1.0.0", "circuits-batcher", "clap", "ff", "halo2_proofs", - "halo2ecc-s", + "halo2ecc-s 0.3.2 (git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.3.3)", "hex", "itertools", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 7fecb380b..dd00b33e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ exclude = ["third-party/wasmi", "crates/playground"] [workspace.dependencies] anyhow = { version = "1.0.68", features = ["backtrace"] } cfg-if = "1.0.0" -halo2aggregator-s = { git = "https://github.com/DelphinusLab/halo2aggregator-s.git", branch = "main", features = ["unsafe"] } +halo2aggregator-s = { git = "https://github.com/DelphinusLab/halo2aggregator-s.git", branch="explorer-integration", 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" } diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 31ebcb4eb..713fb4976 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -23,7 +23,7 @@ anyhow.workspace = true halo2aggregator-s.workspace = true halo2_proofs.workspace = true wasmi.workspace = true -circuits-batcher = { git = "https://github.com/DelphinusLab/continuation-batcher.git" } +circuits-batcher = { git = "https://github.com/DelphinusLab/continuation-batcher.git", branch="polish-structure" } [features] default = [] diff --git a/crates/cli/src/exec.rs b/crates/cli/src/exec.rs index d0022df47..67d8a45b4 100644 --- a/crates/cli/src/exec.rs +++ b/crates/cli/src/exec.rs @@ -1,8 +1,9 @@ use anyhow::Result; -use circuits_batcher::proof::CircuitInfo; + use circuits_batcher::proof::ParamsCache; use circuits_batcher::proof::ProofInfo; use circuits_batcher::proof::ProofLoadInfo; +use circuits_batcher::proof::ProofPieceInfo; use circuits_batcher::proof::ProvingKeyCache; use delphinus_zkwasm::circuits::ZkWasmCircuit; use delphinus_zkwasm::loader::ZkWasmLoader; @@ -156,25 +157,30 @@ pub fn exec_create_proof( info!("Mock test passed"); } - let circuit: CircuitInfo> = CircuitInfo::new( - circuit, - prefix.to_string(), - vec![instances], - zkwasm_k as usize, - circuits_batcher::args::HashType::Poseidon, - ); + let prover: ProofPieceInfo = ProofPieceInfo::new(prefix.to_string(), 0, zkwasm_k); + + + + + // let circuit: CircuitInfo> = CircuitInfo::new( + // circuit, + // prefix.to_string(), + // vec![instances], + // zkwasm_k as usize, + // circuits_batcher::args::HashType::Poseidon, + // ); - // save the proof load info for the zkwasm circuit - circuit.proofloadinfo.save(output_dir); + // // save the proof load info for the zkwasm circuit + // circuit.proofloadinfo.save(output_dir); - // Cli saves zkwasm.0.instance.data as the - // first instance file for .loadinfo - // Thus we provide arg index = 0 to generate a - // proof with the first instance file - let mut param_cache = ParamsCache::new(5); - let mut pkey_cache = ProvingKeyCache::new(5); + // // Cli saves zkwasm.0.instance.data as the + // // first instance file for .loadinfo + // // Thus we provide arg index = 0 to generate a + // // proof with the first instance file + // let mut param_cache = ParamsCache::new(5); + // let mut pkey_cache = ProvingKeyCache::new(5); - circuit.exec_create_proof(output_dir, param_dir, &mut pkey_cache, 0, &mut param_cache); + // circuit.exec_create_proof(output_dir, param_dir, &mut pkey_cache, 0, &mut param_cache); info!("Proof has been created."); @@ -213,6 +219,8 @@ pub fn exec_verify_proof( &proof.instances, proof.transcripts.clone(), TranscriptHash::Poseidon, + false, + &vec![], ); } info!("Verifing proof passed"); diff --git a/crates/host/Cargo.toml b/crates/host/Cargo.toml index 9311d9d05..e96b46f16 100644 --- a/crates/host/Cargo.toml +++ b/crates/host/Cargo.toml @@ -35,7 +35,7 @@ parity-wasm.workspace = true wasmi.workspace = true # TODO put the host circuits into features -zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git", branch="main" } +zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git", branch="keccak-test" } [dev-dependencies] rusty-fork = "0.3.0" diff --git a/crates/zkwasm/Cargo.toml b/crates/zkwasm/Cargo.toml index 2f79adb85..b5db4878a 100644 --- a/crates/zkwasm/Cargo.toml +++ b/crates/zkwasm/Cargo.toml @@ -35,7 +35,7 @@ wasmi.workspace = true # TODO put the host circuits into features -zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git", branch="main" } +zkwasm-host-circuits = { git = "https://github.com/DelphinusLab/zkWasm-host-circuits.git", branch="keccak-test" } [dev-dependencies] rusty-fork = "0.3.0" diff --git a/crates/zkwasm/src/loader/mod.rs b/crates/zkwasm/src/loader/mod.rs index 4e96e9b50..e6804aea7 100644 --- a/crates/zkwasm/src/loader/mod.rs +++ b/crates/zkwasm/src/loader/mod.rs @@ -243,6 +243,7 @@ impl> ZkWasmLoader Date: Sat, 16 Mar 2024 00:20:45 +1100 Subject: [PATCH 2/6] try with min k 1 --- crates/zkwasm/src/circuits/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/zkwasm/src/circuits/config.rs b/crates/zkwasm/src/circuits/config.rs index cb948eab8..f07a5f660 100644 --- a/crates/zkwasm/src/circuits/config.rs +++ b/crates/zkwasm/src/circuits/config.rs @@ -3,7 +3,7 @@ use std::sync::Mutex; pub const POW_TABLE_POWER_START: u64 = 128; -pub const MIN_K: u32 = 18; +pub const MIN_K: u32 = 1; const MAX_K: u32 = 25; lazy_static! { From 91fc39165e4bef9b5c68ba09df8ab0f510e458d4 Mon Sep 17 00:00:00 2001 From: rhaoio Date: Sat, 16 Mar 2024 15:32:26 +1100 Subject: [PATCH 3/6] bump commits --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 80c44029f..143b0bc31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,7 +323,7 @@ dependencies = [ [[package]] name = "circuits-batcher" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/continuation-batcher.git?branch=polish-structure#fc9ecb88fd6f364996d25a3d03dbd2eb0030dd07" +source = "git+https://github.com/DelphinusLab/continuation-batcher.git?branch=polish-structure#7c4f3910b92b295f637a0c5f7898b08603f996af" dependencies = [ "anyhow", "ark-std 0.4.0", From 76aaa56292a8f318409e8d8e6c8edbff9ad5695e Mon Sep 17 00:00:00 2001 From: rhaoio Date: Mon, 18 Mar 2024 16:05:28 +1100 Subject: [PATCH 4/6] 18 min --- crates/zkwasm/src/circuits/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/zkwasm/src/circuits/config.rs b/crates/zkwasm/src/circuits/config.rs index f07a5f660..cb948eab8 100644 --- a/crates/zkwasm/src/circuits/config.rs +++ b/crates/zkwasm/src/circuits/config.rs @@ -3,7 +3,7 @@ use std::sync::Mutex; pub const POW_TABLE_POWER_START: u64 = 128; -pub const MIN_K: u32 = 1; +pub const MIN_K: u32 = 18; const MAX_K: u32 = 25; lazy_static! { From ddaa8a15a18f3dd252dbf5502ee59a5a61449c45 Mon Sep 17 00:00:00 2001 From: rhaoio Date: Mon, 18 Mar 2024 17:27:36 +1100 Subject: [PATCH 5/6] cargo fmt --- crates/cli/src/exec.rs | 3 --- crates/zkwasm/src/loader/mod.rs | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/cli/src/exec.rs b/crates/cli/src/exec.rs index 67d8a45b4..67a9165b3 100644 --- a/crates/cli/src/exec.rs +++ b/crates/cli/src/exec.rs @@ -159,9 +159,6 @@ pub fn exec_create_proof( let prover: ProofPieceInfo = ProofPieceInfo::new(prefix.to_string(), 0, zkwasm_k); - - - // let circuit: CircuitInfo> = CircuitInfo::new( // circuit, // prefix.to_string(), diff --git a/crates/zkwasm/src/loader/mod.rs b/crates/zkwasm/src/loader/mod.rs index e6804aea7..5172a3f25 100644 --- a/crates/zkwasm/src/loader/mod.rs +++ b/crates/zkwasm/src/loader/mod.rs @@ -243,7 +243,7 @@ impl> ZkWasmLoader Date: Mon, 18 Mar 2024 17:58:05 +1100 Subject: [PATCH 6/6] bump halo2 aggregator commit --- crates/playground/Cargo.lock | 74 ++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 16 deletions(-) diff --git a/crates/playground/Cargo.lock b/crates/playground/Cargo.lock index 88716ebba..c99de1b6f 100644 --- a/crates/playground/Cargo.lock +++ b/crates/playground/Cargo.lock @@ -80,6 +80,16 @@ dependencies = [ "rand", ] +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + [[package]] name = "arrayref" version = "0.3.7" @@ -301,10 +311,10 @@ dependencies = [ [[package]] name = "circuits-batcher" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/continuation-batcher.git#7b486f9eef386c6262fe0d812cb62cc031c0c753" +source = "git+https://github.com/DelphinusLab/continuation-batcher.git?branch=polish-structure#571508f1b812b213763b7ef0dd7745c4092b3250" dependencies = [ "anyhow", - "ark-std", + "ark-std 0.4.0", "bitvec", "clap", "downcast-rs", @@ -312,7 +322,6 @@ dependencies = [ "ff", "halo2_proofs", "halo2aggregator-s", - "halo2ecc-s", "hex", "lazy_static", "log", @@ -323,12 +332,12 @@ dependencies = [ "num-derive", "num-integer", "num-traits", - "poseidon", "quote", "rand", "serde", "serde_json", "sha2", + "sha3", "strum", "strum_macros", "uuid", @@ -551,7 +560,7 @@ name = "delphinus-zkwasm" version = "0.1.0" dependencies = [ "anyhow", - "ark-std", + "ark-std 0.3.0", "bitvec", "cfg-if 1.0.0", "downcast-rs", @@ -659,9 +668,9 @@ source = "git+https://github.com/lanbones/ec-gpu#165d1dd6215f6fd1dd85c83cf430ff5 [[package]] name = "ec-gpu-gen" version = "0.4.0" -source = "git+https://github.com/lanbones/ec-gpu?branch=halo2-opt-v2#784eda53754a5344f75e4b3c533361d628ad1402" +source = "git+https://github.com/lanbones/ec-gpu?branch=halo2-opt-v2#5481be558da026bb9bddcd5807f973f6b1a8346e" dependencies = [ - "ark-std", + "ark-std 0.3.0", "bitvec", "crossbeam-channel", "ec-gpu", @@ -981,9 +990,9 @@ dependencies = [ [[package]] name = "halo2_proofs" version = "0.1.0-beta.1" -source = "git+https://github.com/DelphinusLab/halo2-gpu-specific.git#64ccffddc97faff24a00d248270fe84f6693c130" +source = "git+https://github.com/DelphinusLab/halo2-gpu-specific.git#74d45bbbee691e48cfccd51d561c25c4096d52ac" dependencies = [ - "ark-std", + "ark-std 0.4.0", "blake2b_simd", "bumpalo", "cfg-if 0.1.10", @@ -993,6 +1002,7 @@ dependencies = [ "ff", "group", "lazy_static", + "log", "memmap", "num", "num-bigint", @@ -1009,17 +1019,18 @@ dependencies = [ [[package]] name = "halo2aggregator-s" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/halo2aggregator-s.git?branch=main#953bbbd50ee05211e2395e69c9760095b80f6408" +source = "git+https://github.com/DelphinusLab/halo2aggregator-s.git?branch=explorer-integration#eb2329050971f00a6fc2f2a1416b80d2f91f69a4" dependencies = [ - "ark-std", + "ark-std 0.4.0", "blake2b_simd", "halo2_proofs", - "halo2ecc-s", + "halo2ecc-s 0.3.2 (git+https://github.com/lanbones/halo2ecc-s.git?branch=no-select-chip)", "lazy_static", "num-bigint", "num-integer", "poseidon", "sha2", + "sha3", "tera", ] @@ -1034,6 +1045,18 @@ dependencies = [ "rayon", ] +[[package]] +name = "halo2ecc-s" +version = "0.3.2" +source = "git+https://github.com/lanbones/halo2ecc-s.git?branch=no-select-chip#2fc9b6017892bec85e52c30c5fa8aa169b36936b" +dependencies = [ + "halo2_proofs", + "num-bigint", + "num-integer", + "rayon", + "sha3", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1252,6 +1275,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1762,7 +1794,7 @@ dependencies = [ [[package]] name = "poseidon" version = "0.2.0" -source = "git+https://github.com/lanbones/poseidon#df8891073182c5c6cc1e2e7f9d2f4297d3c1565d" +source = "git+https://github.com/lanbones/poseidon#58835e054512ad7833df6d20479e9e0e034a073b" dependencies = [ "halo2_proofs", "subtle", @@ -2227,6 +2259,16 @@ dependencies = [ "digest", ] +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -3093,15 +3135,15 @@ dependencies = [ [[package]] name = "zkwasm-host-circuits" version = "0.1.0" -source = "git+https://github.com/DelphinusLab/zkWasm-host-circuits.git?branch=main#61c52e13667291b360783139e85aa499458eb06d" +source = "git+https://github.com/DelphinusLab/zkWasm-host-circuits.git?branch=keccak-test#4c1aefa84fb4c66022dc5537177c8279630b4373" dependencies = [ - "ark-std", + "ark-std 0.3.0", "cfg-if 1.0.0", "circuits-batcher", "clap", "ff", "halo2_proofs", - "halo2ecc-s", + "halo2ecc-s 0.3.2 (git+https://github.com/lanbones/halo2ecc-s.git?tag=bisect-lookup-0.3.3)", "hex", "itertools", "lazy_static",