Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
fix: discard intermediary proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
atanmarko committed Jun 11, 2024
1 parent 69b170c commit 154be18
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
29 changes: 16 additions & 13 deletions leader/src/jerigon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(())
}

Expand Down
4 changes: 2 additions & 2 deletions tools/prove_blocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 154be18

Please sign in to comment.