From b5124fa08027a385a4da4fbb36c8c64a4373ef10 Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Fri, 23 Aug 2024 15:52:31 +0200 Subject: [PATCH] fix: output block proof to array format (#536) --- zero_bin/prover/src/lib.rs | 10 ++++++---- zero_bin/tools/prove_rpc.sh | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/zero_bin/prover/src/lib.rs b/zero_bin/prover/src/lib.rs index 117bbffd9..7207cbcaf 100644 --- a/zero_bin/prover/src/lib.rs +++ b/zero_bin/prover/src/lib.rs @@ -235,7 +235,7 @@ pub async fn prove( // or alternatively return proof as function result. let return_proof: Option = if let Some(output_dir) = proof_output_dir { - write_proof_to_dir(output_dir, &proof).await?; + write_proof_to_dir(output_dir, proof.clone()).await?; None } else { Some(proof.clone()) @@ -259,7 +259,7 @@ pub async fn prove( // or alternatively return proof as function result. let return_proof: Option = if let Some(output_dir) = proof_output_dir { - write_proof_to_dir(output_dir, &proof).await?; + write_proof_to_dir(output_dir, proof.clone()).await?; None } else { Some(proof.clone()) @@ -285,11 +285,13 @@ pub async fn prove( } /// Write the proof to the `output_dir` directory. -async fn write_proof_to_dir(output_dir: PathBuf, proof: &GeneratedBlockProof) -> Result<()> { - let proof_serialized = serde_json::to_vec(proof)?; +async fn write_proof_to_dir(output_dir: PathBuf, proof: GeneratedBlockProof) -> Result<()> { let block_proof_file_path = generate_block_proof_file_name(&output_dir.to_str(), proof.b_height); + // Serialize as a single element array to match the expected format. + let proof_serialized = serde_json::to_vec(&vec![proof])?; + if let Some(parent) = block_proof_file_path.parent() { tokio::fs::create_dir_all(parent).await?; } diff --git a/zero_bin/tools/prove_rpc.sh b/zero_bin/tools/prove_rpc.sh index 0bc6ce211..941521a3c 100755 --- a/zero_bin/tools/prove_rpc.sh +++ b/zero_bin/tools/prove_rpc.sh @@ -153,8 +153,7 @@ if [ "$RUN_VERIFICATION" = true ]; then proof_file_name=$PROOF_OUTPUT_DIR/b$END_BLOCK.zkproof echo "Verifying the proof of the latest block in the interval:" $proof_file_name - echo [ > $PROOF_OUTPUT_DIR/proofs.json && cat $proof_file_name >> $PROOF_OUTPUT_DIR/proofs.json && echo ] >> $PROOF_OUTPUT_DIR/proofs.json - cargo r --release --bin verifier -- -f $PROOF_OUTPUT_DIR/proofs.json > $PROOF_OUTPUT_DIR/verify.out 2>&1 + cargo r --release --bin verifier -- -f $proof_file_name > $PROOF_OUTPUT_DIR/verify.out 2>&1 if grep -q 'All proofs verified successfully!' $PROOF_OUTPUT_DIR/verify.out; then echo "All proofs verified successfully!";