From 209d9526f7c5f37cf28273e89a801b6dac30cd7c Mon Sep 17 00:00:00 2001 From: gavin-ygy Date: Mon, 4 Nov 2024 10:09:40 +0800 Subject: [PATCH] Perfect sdk err (#32) * new snark proof * update host program * fix the user_data zero in the public_inputs * update host program * update host program * update host program * update host * update host * update host * update host * update host * update sdk * update sdk * update sdk * update sdk * update sdk * update sdk * update sdk * update host * update host * update host * update host * update host * update host * update host * update host * update host * update host * zkm and gnark updating * update host * update host * update sdk * update sdk * update contract * update contract * update contract * update contract * update contract * update host * update host * update host * add sdk readme * update sdk's readme * update sdk's readme * add log for hash(bincong(public_inputs)) * update sdk * update contract * update contract * update contract * update contract * update the host * update the host * update host * update host * update host * update host * update host * update host * update host * update contract * update the readme and host * update the readme and host * update the readme and host * update readme * update readme * perfect the host * perfect the host * perfect the host * perfect the host * perfect the host * perfect the host * perfect the readme * update the host * fix CI/CD error * fix CI/CD error * fix CI/CD error * perfect the SDK's error message * update sdk * update host * fix CI/CD error --------- Co-authored-by: [gavin-ygy] <[gavin.ygy@gmail.com]> --- host-program/run-network-proving.sh | 2 +- host-program/src/bin/zkm-prove.rs | 18 +++++++++++++----- sdk/src/network/prover.rs | 6 +++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/host-program/run-network-proving.sh b/host-program/run-network-proving.sh index d5eb469b..bf2ebd88 100755 --- a/host-program/run-network-proving.sh +++ b/host-program/run-network-proving.sh @@ -9,7 +9,7 @@ BASEDIR=$(cd $(dirname $0); pwd) export LD_LIBRARY_PATH=$BASEDIR/../sdk/src/local/libsnark:$LD_LIBRARY_PATH ##Modify it according your template export CA_CERT_PATH=tool/ca.pem export PRIVATE_KEY=xxxx ##The private key corresponding to the public key when registering in the https://www.zkm.io/apply -export ENDPOINT=https://152.32.186.45:20002 ##the test entry of zkm proving network +export ENDPOINT=https://152.32.186.45:20002 ##the test entry of zkm proof network export ZKM_PROVER=network export RUST_LOG=info export SEG_SIZE=262144 diff --git a/host-program/src/bin/zkm-prove.rs b/host-program/src/bin/zkm-prove.rs index a4c6df66..d0435ec9 100644 --- a/host-program/src/bin/zkm-prove.rs +++ b/host-program/src/bin/zkm-prove.rs @@ -34,6 +34,7 @@ async fn main() -> Result<(), Box> { let args_parameter = env::var("ARGS").unwrap_or("data-to-hash".to_string()); let json_path = env::var("JSON_PATH").expect("JSON PATH is missing"); let proof_results_path = env::var("PROOF_RESULTS_PATH").unwrap_or("../contracts".to_string()); + let zkm_prover = env::var("ZKM_PROVER").expect("ZKM PROVER is missing"); log::info!("new prover client."); let prover_client = ProverClient::new().await; @@ -67,11 +68,18 @@ async fn main() -> Result<(), Box> { Ok(Some(prover_result)) => { if !execute_only2 { if prover_result.proof_with_public_inputs.is_empty() { - log::info!( - "Fail: snark_proof_with_public_inputs.len() is : {}.Please try setting SEG_SIZE={}", - prover_result.proof_with_public_inputs.len(), seg_size2/2 - ); - return Err("SEG_SIZE is excessively large".into()); + if zkm_prover.to_lowercase() == *"local".to_string() { + //local proving + log::info!("Fail: please try setting SEG_SIZE={}", seg_size2 / 2); + return Err("SEG_SIZE is excessively large".into()); + } else { + //network proving + log::info!( + "Fail: the SEG_SIZE={} out of the range of the proof network's.", + seg_size2 + ); + return Err("SEG_SIZE is out of the range of the proof network's".into()); + } } //1.snark proof let output_dir = format!("{}/verifier", proof_results_path); diff --git a/sdk/src/network/prover.rs b/sdk/src/network/prover.rs index a94bca81..5eaa96dd 100644 --- a/sdk/src/network/prover.rs +++ b/sdk/src/network/prover.rs @@ -172,7 +172,11 @@ impl Prover for NetworkProver { "generate_proof failed status: {}", get_status_response.status ); - return Ok(None); + //return Ok(None); + return Err(anyhow::anyhow!( + "generate_proof failed status: {}", + get_status_response.status + )); } } }