Skip to content

Commit

Permalink
Small fixes to rpc and common modules (#629)
Browse files Browse the repository at this point in the history
* fix: do not abort on witness fetching

* fix: properly deserialize proofs

* Remove unrelated code

* Apply comment
  • Loading branch information
Nashtare authored Sep 16, 2024
1 parent 3ef67fd commit e1def1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 8 additions & 2 deletions zero_bin/common/src/fs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::fs::File;
use std::path::PathBuf;

use anyhow::anyhow;
use proof_gen::proof_types::GeneratedBlockProof;

pub fn generate_block_proof_file_name(directory: &Option<&str>, block_height: u64) -> PathBuf {
Expand All @@ -17,6 +18,11 @@ pub fn get_previous_proof(path: Option<PathBuf>) -> anyhow::Result<Option<Genera
let path = path.unwrap();
let file = File::open(path)?;
let des = &mut serde_json::Deserializer::from_reader(&file);
let proof: GeneratedBlockProof = serde_path_to_error::deserialize(des)?;
Ok(Some(proof))
let proof: Vec<GeneratedBlockProof> = serde_path_to_error::deserialize(des)?;
// Individual proofs are serialized as vector to match other output formats.
if proof.len() != 1 {
return Err(anyhow!("Invalid proof format, expected vector of generated block proofs with a single element."));
}

Ok(Some(proof[0].to_owned()))
}
2 changes: 0 additions & 2 deletions zero_bin/rpc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use rpc::{retry::build_http_retry_provider, RpcType};
use tracing_subscriber::{prelude::*, EnvFilter};
use url::Url;
use zero_bin_common::block_interval::BlockIntervalStream;
use zero_bin_common::pre_checks::check_previous_proof_and_checkpoint;
use zero_bin_common::provider::CachedProvider;
use zero_bin_common::version;
use zero_bin_common::{block_interval::BlockInterval, prover_state::persistence::CIRCUIT_VERSION};
Expand Down Expand Up @@ -88,7 +87,6 @@ where
let checkpoint_block_number = params
.checkpoint_block_number
.unwrap_or(params.start_block - 1);
check_previous_proof_and_checkpoint(checkpoint_block_number, &None, params.start_block)?;

let block_interval = BlockInterval::Range(params.start_block..params.end_block + 1);
let mut block_prover_inputs = Vec::new();
Expand Down

0 comments on commit e1def1b

Please sign in to comment.