From 91a9c11a76388fce2de62271d344f2c2952b3aa3 Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Tue, 11 Jun 2024 16:18:32 +0200 Subject: [PATCH 01/10] fix: discard intermediary proofs --- leader/src/jerigon.rs | 29 ++++++++++++++++------------- tools/prove_blocks.sh | 4 ++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/leader/src/jerigon.rs b/leader/src/jerigon.rs index f3cf1e74..78fe7985 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/jerigon.rs @@ -5,7 +5,7 @@ use std::{ }; use alloy::providers::RootProvider; -use anyhow::Result; +use anyhow::{anyhow, Result}; use common::block_interval::BlockInterval; use paladin::runtime::Runtime; use proof_gen::proof_types::GeneratedBlockProof; @@ -27,21 +27,24 @@ pub(crate) async fn jerigon_main( ) .await?; - let block_proofs = prover_input + // We keep only last block proof from the interval. It contains + // all the necessary information to verify the whole interval. + let last_block_proof = prover_input .prove(&runtime, previous_proof, save_inputs_on_error) - .await?; + .await? + .into_iter() + .last() + .ok_or_else(|| anyhow!("No block proof generated"))?; runtime.close().await?; - for block_proof in block_proofs { - let block_proof_str = serde_json::to_vec(&block_proof)?; - write_proof( - block_proof_str, - proof_output_dir_opt.clone().map(|mut path| { - path.push(format!("b{}.zkproof", block_proof.b_height)); - path - }), - )?; - } + let last_block_proof_serialized = serde_json::to_vec(&last_block_proof)?; + write_proof( + last_block_proof_serialized, + proof_output_dir_opt.clone().map(|mut path| { + path.push(format!("b{}.zkproof", last_block_proof.b_height)); + path + }), + )?; Ok(()) } diff --git a/tools/prove_blocks.sh b/tools/prove_blocks.sh index 62766157..bc9fe755 100755 --- a/tools/prove_blocks.sh +++ b/tools/prove_blocks.sh @@ -81,7 +81,7 @@ fi if [[ $5 == "test_only" ]]; then # test only run echo "Proving blocks ${BLOCK_INTERVAL} in a test_only mode now... (Total: ${TOT_BLOCKS})" - cargo r --release --features test_only --bin leader -- --runtime in-memory --load-strategy on-demand jerigon --rpc-url "$NODE_RPC_URL" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG > $OUT_LOG_PATH 2>&1 + cargo r --release --features test_only --bin leader -- --runtime in-memory --load-strategy on-demand jerigon --rpc-url "$NODE_RPC_URL" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG 2>&1 > $OUT_LOG_PATH if grep 'Successfully generated witness for block' $OUT_LOG_PATH; then echo "Success - Note this was just a test, not a proof" # Remove the log on success if we don't want to keep it. @@ -96,7 +96,7 @@ if [[ $5 == "test_only" ]]; then else # normal run echo "Proving blocks ${BLOCK_INTERVAL} now... (Total: ${TOT_BLOCKS})" - cargo r --release --bin leader -- --runtime in-memory --load-strategy on-demand jerigon --rpc-url "$3" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG > $OUT_LOG_PATH 2>&1 + cargo r --release --bin leader -- --runtime in-memory --load-strategy on-demand jerigon --rpc-url "$3" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG 2>&1 > $OUT_LOG_PATH retVal=$? if [ $retVal -ne 0 ]; then From 45488dc950d16a358fa8b4dca16ebaf0604fcf74 Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Tue, 11 Jun 2024 19:28:37 +0200 Subject: [PATCH 02/10] fix: write intermediate proofs on creation --- Cargo.lock | 1 + leader/src/cli.rs | 9 +++++++ leader/src/jerigon.rs | 60 +++++++++++++++++-------------------------- leader/src/main.rs | 16 +++++++----- prover/Cargo.toml | 1 + prover/src/lib.rs | 39 ++++++++++++++++++++++++++-- 6 files changed, 82 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9217b871..3af52fd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3439,6 +3439,7 @@ dependencies = [ "proof_gen", "ruint", "serde", + "serde_json", "tokio", "trace_decoder", "tracing", diff --git a/leader/src/cli.rs b/leader/src/cli.rs index 06a71b61..96f2c072 100644 --- a/leader/src/cli.rs +++ b/leader/src/cli.rs @@ -54,6 +54,15 @@ pub(crate) enum Command { /// to determine the blockchain node polling interval. #[arg(short, long, env = "ZERO_BIN_BLOCK_TIME", default_value_t = 2000)] block_time: u64, + /// Keep intermediate proofs. Default action is to + /// delete them after the final proof is generated. + #[arg( + short, + long, + env = "ZERO_BIN_KEEP_INTERMEDIATE_PROOFS", + default_value_t = false + )] + keep_intermediate_proofs: bool, }, /// Reads input from HTTP and writes output to a directory. Http { diff --git a/leader/src/jerigon.rs b/leader/src/jerigon.rs index 78fe7985..53ef6cb3 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/jerigon.rs @@ -1,8 +1,4 @@ -use std::{ - fs::{create_dir_all, File}, - io::Write, - path::PathBuf, -}; +use std::path::PathBuf; use alloy::providers::RootProvider; use anyhow::{anyhow, Result}; @@ -10,55 +6,47 @@ use common::block_interval::BlockInterval; use paladin::runtime::Runtime; use proof_gen::proof_types::GeneratedBlockProof; +#[derive(Debug, Default)] +pub(crate) struct JerigonParams { + pub checkpoint_block_number: u64, + pub previous_proof: Option, + pub proof_output_dir: Option, + pub save_inputs_on_error: bool, + pub keep_intermediate_proofs: bool, +} + /// The main function for the jerigon mode. pub(crate) async fn jerigon_main( runtime: Runtime, rpc_url: &str, block_interval: BlockInterval, - checkpoint_block_number: u64, - previous_proof: Option, - proof_output_dir_opt: Option, - save_inputs_on_error: bool, + mut params: JerigonParams, ) -> Result<()> { let prover_input = rpc::prover_input( RootProvider::new_http(rpc_url.parse()?), block_interval, - checkpoint_block_number.into(), + params.checkpoint_block_number.into(), ) .await?; - // We keep only last block proof from the interval. It contains - // all the necessary information to verify the whole interval. - let last_block_proof = prover_input - .prove(&runtime, previous_proof, save_inputs_on_error) + // If `keep_intermediate_proofs` is not set we only keep the last block + // proof from the interval. It contains all the necessary information to + // verify the whole sequence. + let _last_block_proof = prover_input + .prove( + &runtime, + params.previous_proof.take(), + params.save_inputs_on_error, + params.proof_output_dir, + ) .await? .into_iter() .last() .ok_or_else(|| anyhow!("No block proof generated"))?; runtime.close().await?; - let last_block_proof_serialized = serde_json::to_vec(&last_block_proof)?; - write_proof( - last_block_proof_serialized, - proof_output_dir_opt.clone().map(|mut path| { - path.push(format!("b{}.zkproof", last_block_proof.b_height)); - path - }), - )?; - Ok(()) -} - -fn write_proof(proof: Vec, proof_output_dir_opt: Option) -> Result<()> { - match proof_output_dir_opt { - Some(p) => { - if let Some(parent) = p.parent() { - create_dir_all(parent)?; - } - - let mut f = File::create(p)?; - f.write_all(&proof)?; - } - None => std::io::stdout().write_all(&proof)?, + if !params.keep_intermediate_proofs { + //todo remove all proof files except the last one } Ok(()) diff --git a/leader/src/main.rs b/leader/src/main.rs index f03822c6..a34f051c 100644 --- a/leader/src/main.rs +++ b/leader/src/main.rs @@ -11,6 +11,7 @@ use paladin::runtime::Runtime; use proof_gen::proof_types::GeneratedBlockProof; use tracing::info; +use crate::jerigon::{jerigon_main, JerigonParams}; use crate::utils::get_package_version; mod cli; @@ -93,6 +94,7 @@ async fn main() -> Result<()> { proof_output_dir, save_inputs_on_error, block_time, + keep_intermediate_proofs, } => { let previous_proof = get_previous_proof(previous_proof)?; let mut block_interval = BlockInterval::new(&block_interval)?; @@ -106,15 +108,17 @@ async fn main() -> Result<()> { } info!("Proving interval {block_interval}"); - - jerigon::jerigon_main( + jerigon_main( runtime, &rpc_url, block_interval, - checkpoint_block_number, - previous_proof, - proof_output_dir, - save_inputs_on_error, + JerigonParams { + checkpoint_block_number, + previous_proof, + proof_output_dir, + save_inputs_on_error, + keep_intermediate_proofs, + }, ) .await?; } diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 05dc591d..ff5c1227 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -18,6 +18,7 @@ anyhow = { workspace = true } futures = { workspace = true } alloy.workspace = true tokio = {workspace = true} +serde_json = {workspace = true} ruint = { version = "1.12.1", features = ["num-traits", "primitive-types"] } ops = { path = "../ops" } common = { path = "../common" } diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 9f0d528d..0d572061 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -1,7 +1,8 @@ use std::future::Future; +use std::path::PathBuf; use alloy::primitives::U256; -use anyhow::Result; +use anyhow::{Context, Result}; use futures::{future::BoxFuture, stream::FuturesOrdered, FutureExt, TryFutureExt, TryStreamExt}; use num_traits::ToPrimitive as _; use ops::TxProof; @@ -11,6 +12,7 @@ use paladin::{ }; use proof_gen::proof_types::GeneratedBlockProof; use serde::{Deserialize, Serialize}; +use tokio::io::AsyncWriteExt; use tokio::sync::oneshot; use trace_decoder::{ processed_block_trace::ProcessingMeta, @@ -133,6 +135,7 @@ impl ProverInput { runtime: &Runtime, previous_proof: Option, save_inputs_on_error: bool, + proof_output_dir: Option, ) -> Result> { let mut prev: Option>> = previous_proof.map(|proof| Box::pin(futures::future::ok(proof)) as BoxFuture<_>); @@ -147,11 +150,15 @@ impl ProverInput { let (tx, rx) = oneshot::channel::(); // Prove the block + let proof_output_dir = proof_output_dir.clone(); let fut = block .prove(runtime, prev.take(), save_inputs_on_error) - .then(|proof| async { + .then(move |proof| async move { let proof = proof?; + // Write latest generated proof to disk + ProverInput::write_proof(proof_output_dir, &proof).await?; + if tx.send(proof.clone()).is_err() { anyhow::bail!("Failed to send proof"); } @@ -168,4 +175,32 @@ impl ProverInput { results.try_collect().await } + + /// Write the proof to the disk (if `output_dir` is provided) or stdout. + pub(crate) async fn write_proof( + output_dir: Option, + proof: &GeneratedBlockProof, + ) -> Result<()> { + let proof_serialized = serde_json::to_vec(proof)?; + let block_proof_file_path = output_dir.map(|mut path| { + path.push(format!("b{}.zkproof", proof.b_height)); + path + }); + match block_proof_file_path { + Some(p) => { + if let Some(parent) = p.parent() { + tokio::fs::create_dir_all(parent).await?; + } + + let mut f = tokio::fs::File::create(p).await?; + f.write_all(&proof_serialized) + .await + .context("Failed to write proof to disk") + } + None => tokio::io::stdout() + .write_all(&proof_serialized) + .await + .context("Failed to write proof to stdout"), + } + } } From 07e78a3a4a7c9a09eb5b0105bbd9d99e68abf22f Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Tue, 11 Jun 2024 19:36:37 +0200 Subject: [PATCH 03/10] fix: return list of blocks proved --- leader/src/jerigon.rs | 12 ++++++------ prover/src/lib.rs | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/leader/src/jerigon.rs b/leader/src/jerigon.rs index 53ef6cb3..38559c6f 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/jerigon.rs @@ -1,10 +1,11 @@ use std::path::PathBuf; use alloy::providers::RootProvider; -use anyhow::{anyhow, Result}; +use anyhow::Result; use common::block_interval::BlockInterval; use paladin::runtime::Runtime; use proof_gen::proof_types::GeneratedBlockProof; +use tracing::info; #[derive(Debug, Default)] pub(crate) struct JerigonParams { @@ -32,19 +33,18 @@ pub(crate) async fn jerigon_main( // If `keep_intermediate_proofs` is not set we only keep the last block // proof from the interval. It contains all the necessary information to // verify the whole sequence. - let _last_block_proof = prover_input + let proved_blocks = prover_input .prove( &runtime, params.previous_proof.take(), params.save_inputs_on_error, params.proof_output_dir, ) - .await? - .into_iter() - .last() - .ok_or_else(|| anyhow!("No block proof generated"))?; + .await?; runtime.close().await?; + info!("Proved blocks: {proved_blocks:?}"); + if !params.keep_intermediate_proofs { //todo remove all proof files except the last one } diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 0d572061..c9f657d7 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -1,7 +1,7 @@ use std::future::Future; use std::path::PathBuf; -use alloy::primitives::U256; +use alloy::primitives::{BlockNumber, U256}; use anyhow::{Context, Result}; use futures::{future::BoxFuture, stream::FuturesOrdered, FutureExt, TryFutureExt, TryStreamExt}; use num_traits::ToPrimitive as _; @@ -136,7 +136,7 @@ impl ProverInput { previous_proof: Option, save_inputs_on_error: bool, proof_output_dir: Option, - ) -> Result> { + ) -> Result> { let mut prev: Option>> = previous_proof.map(|proof| Box::pin(futures::future::ok(proof)) as BoxFuture<_>); @@ -155,15 +155,16 @@ impl ProverInput { .prove(runtime, prev.take(), save_inputs_on_error) .then(move |proof| async move { let proof = proof?; + let block_number = proof.b_height; // Write latest generated proof to disk ProverInput::write_proof(proof_output_dir, &proof).await?; - if tx.send(proof.clone()).is_err() { + if tx.send(proof).is_err() { anyhow::bail!("Failed to send proof"); } - Ok(proof) + Ok(block_number) }) .boxed(); From 3f655fcbe9f7ccc98cf55fb3e66925c3bc2adeec Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Wed, 12 Jun 2024 13:48:39 +0200 Subject: [PATCH 04/10] fix: remove files --- common/src/fs.rs | 7 +++++++ common/src/lib.rs | 1 + leader/src/jerigon.rs | 18 +++++++++++++++--- prover/src/lib.rs | 7 +++---- 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 common/src/fs.rs diff --git a/common/src/fs.rs b/common/src/fs.rs new file mode 100644 index 00000000..7603f510 --- /dev/null +++ b/common/src/fs.rs @@ -0,0 +1,7 @@ +use std::path::PathBuf; + +pub fn generate_block_proof_file_name(directory: &Option<&str>, block_height: u64) -> PathBuf { + let mut path = PathBuf::from(directory.unwrap_or("")); + path.push(format!("b{}.zkproof", block_height)); + path +} diff --git a/common/src/lib.rs b/common/src/lib.rs index 635eba33..1b0b18e9 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,4 +1,5 @@ pub mod block_interval; pub mod debug_utils; +pub mod fs; pub mod parsing; pub mod prover_state; diff --git a/leader/src/jerigon.rs b/leader/src/jerigon.rs index 38559c6f..eb8e9908 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/jerigon.rs @@ -3,9 +3,10 @@ use std::path::PathBuf; use alloy::providers::RootProvider; use anyhow::Result; use common::block_interval::BlockInterval; +use common::fs::generate_block_proof_file_name; use paladin::runtime::Runtime; use proof_gen::proof_types::GeneratedBlockProof; -use tracing::info; +use tracing::{error, info}; #[derive(Debug, Default)] pub(crate) struct JerigonParams { @@ -38,7 +39,7 @@ pub(crate) async fn jerigon_main( &runtime, params.previous_proof.take(), params.save_inputs_on_error, - params.proof_output_dir, + params.proof_output_dir.clone(), ) .await?; runtime.close().await?; @@ -46,7 +47,18 @@ pub(crate) async fn jerigon_main( info!("Proved blocks: {proved_blocks:?}"); if !params.keep_intermediate_proofs { - //todo remove all proof files except the last one + if let Some(proof_output_dir) = params.proof_output_dir.as_ref() { + proved_blocks + .into_iter() + .rev() + .skip(1) + .map(|b| generate_block_proof_file_name(&proof_output_dir.to_str(), b)) + .for_each(|path| { + if let Err(e) = std::fs::remove_file(path) { + error!("Failed to remove intermediate proof file: {e}"); + } + }); + } } Ok(()) diff --git a/prover/src/lib.rs b/prover/src/lib.rs index c9f657d7..d6b804e3 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use alloy::primitives::{BlockNumber, U256}; use anyhow::{Context, Result}; +use common::fs::generate_block_proof_file_name; use futures::{future::BoxFuture, stream::FuturesOrdered, FutureExt, TryFutureExt, TryStreamExt}; use num_traits::ToPrimitive as _; use ops::TxProof; @@ -183,10 +184,8 @@ impl ProverInput { proof: &GeneratedBlockProof, ) -> Result<()> { let proof_serialized = serde_json::to_vec(proof)?; - let block_proof_file_path = output_dir.map(|mut path| { - path.push(format!("b{}.zkproof", proof.b_height)); - path - }); + let block_proof_file_path = + output_dir.map(|path| generate_block_proof_file_name(&path.to_str(), proof.b_height)); match block_proof_file_path { Some(p) => { if let Some(parent) = p.parent() { From 5e440bb39e999dc76e8f8a4d83b4988f17e45ccf Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Wed, 12 Jun 2024 14:39:10 +0200 Subject: [PATCH 05/10] fix: comment --- prover/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prover/src/lib.rs b/prover/src/lib.rs index d6b804e3..0758ea1f 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -158,7 +158,7 @@ impl ProverInput { let proof = proof?; let block_number = proof.b_height; - // Write latest generated proof to disk + // Write latest generated proof to disk or stdout ProverInput::write_proof(proof_output_dir, &proof).await?; if tx.send(proof).is_err() { From 50d7e25757c2e6280cd02d9c2668f3fbfaf39f3e Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Fri, 14 Jun 2024 12:46:09 +0200 Subject: [PATCH 06/10] fix: reviews --- leader/src/jerigon.rs | 8 ++++---- tools/prove_blocks.sh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/leader/src/jerigon.rs b/leader/src/jerigon.rs index eb8e9908..831b1fc7 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/jerigon.rs @@ -6,10 +6,10 @@ use common::block_interval::BlockInterval; use common::fs::generate_block_proof_file_name; use paladin::runtime::Runtime; use proof_gen::proof_types::GeneratedBlockProof; -use tracing::{error, info}; +use tracing::{error, warn}; #[derive(Debug, Default)] -pub(crate) struct JerigonParams { +pub struct JerigonParams { pub checkpoint_block_number: u64, pub previous_proof: Option, pub proof_output_dir: Option, @@ -44,8 +44,6 @@ pub(crate) async fn jerigon_main( .await?; runtime.close().await?; - info!("Proved blocks: {proved_blocks:?}"); - if !params.keep_intermediate_proofs { if let Some(proof_output_dir) = params.proof_output_dir.as_ref() { proved_blocks @@ -58,6 +56,8 @@ pub(crate) async fn jerigon_main( error!("Failed to remove intermediate proof file: {e}"); } }); + } else { + warn!("Skipping cleanup, intermediate proofs are kept"); } } diff --git a/tools/prove_blocks.sh b/tools/prove_blocks.sh index bc9fe755..62766157 100755 --- a/tools/prove_blocks.sh +++ b/tools/prove_blocks.sh @@ -81,7 +81,7 @@ fi if [[ $5 == "test_only" ]]; then # test only run echo "Proving blocks ${BLOCK_INTERVAL} in a test_only mode now... (Total: ${TOT_BLOCKS})" - cargo r --release --features test_only --bin leader -- --runtime in-memory --load-strategy on-demand jerigon --rpc-url "$NODE_RPC_URL" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG 2>&1 > $OUT_LOG_PATH + cargo r --release --features test_only --bin leader -- --runtime in-memory --load-strategy on-demand jerigon --rpc-url "$NODE_RPC_URL" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG > $OUT_LOG_PATH 2>&1 if grep 'Successfully generated witness for block' $OUT_LOG_PATH; then echo "Success - Note this was just a test, not a proof" # Remove the log on success if we don't want to keep it. @@ -96,7 +96,7 @@ if [[ $5 == "test_only" ]]; then else # normal run echo "Proving blocks ${BLOCK_INTERVAL} now... (Total: ${TOT_BLOCKS})" - cargo r --release --bin leader -- --runtime in-memory --load-strategy on-demand jerigon --rpc-url "$3" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG 2>&1 > $OUT_LOG_PATH + cargo r --release --bin leader -- --runtime in-memory --load-strategy on-demand jerigon --rpc-url "$3" --block-interval $BLOCK_INTERVAL --proof-output-dir $PROOF_OUTPUT_DIR $PREV_PROOF_EXTRA_ARG > $OUT_LOG_PATH 2>&1 retVal=$? if [ $retVal -ne 0 ]; then From bf05f9c5bb9369d00f26b854dccfb52b550b23e6 Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Fri, 14 Jun 2024 12:51:35 +0200 Subject: [PATCH 07/10] fix: rename jerigon params to proof params --- leader/src/jerigon.rs | 4 ++-- leader/src/main.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/leader/src/jerigon.rs b/leader/src/jerigon.rs index 831b1fc7..bfd19b24 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/jerigon.rs @@ -9,7 +9,7 @@ use proof_gen::proof_types::GeneratedBlockProof; use tracing::{error, warn}; #[derive(Debug, Default)] -pub struct JerigonParams { +pub struct ProofParams { pub checkpoint_block_number: u64, pub previous_proof: Option, pub proof_output_dir: Option, @@ -22,7 +22,7 @@ pub(crate) async fn jerigon_main( runtime: Runtime, rpc_url: &str, block_interval: BlockInterval, - mut params: JerigonParams, + mut params: ProofParams, ) -> Result<()> { let prover_input = rpc::prover_input( RootProvider::new_http(rpc_url.parse()?), diff --git a/leader/src/main.rs b/leader/src/main.rs index a34f051c..f04cfc57 100644 --- a/leader/src/main.rs +++ b/leader/src/main.rs @@ -11,7 +11,7 @@ use paladin::runtime::Runtime; use proof_gen::proof_types::GeneratedBlockProof; use tracing::info; -use crate::jerigon::{jerigon_main, JerigonParams}; +use crate::jerigon::{jerigon_main, ProofParams}; use crate::utils::get_package_version; mod cli; @@ -112,7 +112,7 @@ async fn main() -> Result<()> { runtime, &rpc_url, block_interval, - JerigonParams { + ProofParams { checkpoint_block_number, previous_proof, proof_output_dir, From 4dc51690c5ec270151d7181fd50490ca657c7926 Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Fri, 14 Jun 2024 12:55:41 +0200 Subject: [PATCH 08/10] fix: error --- leader/src/jerigon.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/leader/src/jerigon.rs b/leader/src/jerigon.rs index bfd19b24..b926a969 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/jerigon.rs @@ -56,9 +56,9 @@ pub(crate) async fn jerigon_main( error!("Failed to remove intermediate proof file: {e}"); } }); - } else { - warn!("Skipping cleanup, intermediate proofs are kept"); } + } else { + warn!("Skipping cleanup, intermediate proofs are kept"); } Ok(()) From 39ece21422058f63d4b8dd755a06cac75529031e Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Fri, 14 Jun 2024 12:57:13 +0200 Subject: [PATCH 09/10] fix: refactor --- leader/src/jerigon.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/leader/src/jerigon.rs b/leader/src/jerigon.rs index b926a969..2e500bef 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/jerigon.rs @@ -44,21 +44,21 @@ pub(crate) async fn jerigon_main( .await?; runtime.close().await?; - if !params.keep_intermediate_proofs { - if let Some(proof_output_dir) = params.proof_output_dir.as_ref() { - proved_blocks - .into_iter() - .rev() - .skip(1) - .map(|b| generate_block_proof_file_name(&proof_output_dir.to_str(), b)) - .for_each(|path| { - if let Err(e) = std::fs::remove_file(path) { - error!("Failed to remove intermediate proof file: {e}"); - } - }); - } - } else { + if params.keep_intermediate_proofs { warn!("Skipping cleanup, intermediate proofs are kept"); + } else if let Some(proof_output_dir) = params.proof_output_dir.as_ref() { + proved_blocks + .into_iter() + .rev() + .skip(1) + .map(|b| generate_block_proof_file_name(&proof_output_dir.to_str(), b)) + .for_each(|path| { + if let Err(e) = std::fs::remove_file(path) { + error!("Failed to remove intermediate proof file: {e}"); + } + }); + } else { + // proofs are written to stdio, so we need to clean up } Ok(()) From b1b10ea2108ddcc00191f921915a62569cba0bf2 Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Fri, 14 Jun 2024 14:01:34 +0200 Subject: [PATCH 10/10] fix: comment --- leader/src/jerigon.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leader/src/jerigon.rs b/leader/src/jerigon.rs index 2e500bef..ce03f615 100644 --- a/leader/src/jerigon.rs +++ b/leader/src/jerigon.rs @@ -58,7 +58,7 @@ pub(crate) async fn jerigon_main( } }); } else { - // proofs are written to stdio, so we need to clean up + // Proofs are written to stdio, so no need to clean up } Ok(())