Skip to content

Commit

Permalink
Apply comments and fix CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
LindaGuiga committed Jul 4, 2024
1 parent 1f8d853 commit a31692a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
6 changes: 3 additions & 3 deletions zero_bin/leader/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) enum Command {
previous_proof: Option<PathBuf>,
#[arg(short, long, default_value_t = 20)]
max_cpu_len_log: usize,
#[arg(short, long, default_value_t = 2)]
#[arg(short, long, default_value_t = 1)]
batch_size: usize,
/// If true, save the public inputs to disk on error.
#[arg(short, long, default_value_t = false)]
Expand Down Expand Up @@ -59,7 +59,7 @@ pub(crate) enum Command {
/// The log of the max number of CPU cycles per proof.
#[arg(short, long, default_value_t = 20)]
max_cpu_len_log: usize,
#[arg(short, long, default_value_t = 2)]
#[arg(short, long, default_value_t = 1)]
batch_size: usize,
/// If true, save the public inputs to disk on error.
#[arg(short, long, default_value_t = false)]
Expand Down Expand Up @@ -94,7 +94,7 @@ pub(crate) enum Command {
output_dir: PathBuf,
#[arg(short, long, default_value_t = 20)]
max_cpu_len_log: usize,
#[arg(short, long, default_value_t = 2)]
#[arg(short, long, default_value_t = 1)]
batch_size: usize,
/// If true, save the public inputs to disk on error.
#[arg(short, long, default_value_t = false)]
Expand Down
25 changes: 14 additions & 11 deletions zero_bin/ops/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Operation for SegmentProof {

fn execute(&self, all_data: Self::Input) -> Result<Self::Output> {
let input = all_data.0.clone();
let _span = TxProofSpan::new(&input);
let _span = SegmentProofSpan::new(&input, all_data.1.segment_index());
let proof = if self.save_inputs_on_error {
zero_bin_common::prover_state::p_manager()
.generate_segment_proof(all_data)
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Operation for SegmentProof {

fn execute(&self, input: Self::Input) -> Result<Self::Output> {
let gen_input = input.0;
let _span = TxProofSpan::new(&gen_input);
let _span = SegmentProofSpan::new(&gen_input, input.1.segment_index());

if self.save_inputs_on_error {
evm_arithmetization::prover::testing::simulate_execution::<proof_gen::types::Field>(
Expand Down Expand Up @@ -99,18 +99,21 @@ impl Operation for SegmentProof {
///
/// - When created, it starts a span with the transaction proof id.
/// - When dropped, it logs the time taken by the transaction proof.
struct TxProofSpan {
struct SegmentProofSpan {
_span: tracing::span::EnteredSpan,
start: Instant,
descriptor: String,
}

impl TxProofSpan {
impl SegmentProofSpan {
/// Get a unique id for the transaction proof.
fn get_id(ir: &GenerationInputs) -> String {
fn get_id(ir: &GenerationInputs, segment_index: usize) -> String {
format!(
"b{} - {}",
ir.block_metadata.block_number, ir.txn_number_before
"b{} - {}_{} ({})",
ir.block_metadata.block_number,
ir.txn_number_before,
ir.txn_number_before + ir.signed_txns.len(),
segment_index
)
}

Expand All @@ -135,8 +138,8 @@ impl TxProofSpan {
/// Create a new transaction proof span.
///
/// When dropped, it logs the time taken by the transaction proof.
fn new(ir: &GenerationInputs) -> Self {
let id = Self::get_id(ir);
fn new(ir: &GenerationInputs, segment_index: usize) -> Self {
let id = Self::get_id(ir, segment_index);
let span = info_span!("p_gen", id).entered();
let start = Instant::now();
let descriptor = Self::get_descriptor(ir);
Expand All @@ -148,11 +151,11 @@ impl TxProofSpan {
}
}

impl Drop for TxProofSpan {
impl Drop for SegmentProofSpan {
fn drop(&mut self) {
event!(
Level::INFO,
"txn proof ({}) took {:?}",
"segment proof ({}) took {:?}",
self.descriptor,
self.start.elapsed()
);
Expand Down
6 changes: 2 additions & 4 deletions zero_bin/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ use alloy::primitives::{BlockNumber, U256};
use anyhow::{Context, Result};
use futures::{future::BoxFuture, stream::FuturesOrdered, FutureExt, TryFutureExt, TryStreamExt};
use num_traits::ToPrimitive as _;
use paladin::{
directive::{Directive, IndexedStream},
runtime::Runtime,
};
use paladin::runtime::Runtime;
use proof_gen::proof_types::GeneratedBlockProof;
use serde::{Deserialize, Serialize};
use tokio::io::AsyncWriteExt;
Expand Down Expand Up @@ -47,6 +44,7 @@ impl BlockProverInput {
use anyhow::Context as _;
use evm_arithmetization::prover::SegmentDataIterator;
use futures::{stream::FuturesUnordered, FutureExt};
use paladin::directive::{Directive, IndexedStream};

let block_number = self.get_block_number();
info!("Proving block {block_number}");
Expand Down
26 changes: 21 additions & 5 deletions zero_bin/tools/prove_stdio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,31 @@ if [[ $TEST_ONLY == "test_only" ]]; then
export KECCAK_SPONGE_CIRCUIT_SIZE="9..10"
export LOGIC_CIRCUIT_SIZE="12..13"
export MEMORY_CIRCUIT_SIZE="17..18"
export MEMORY_BEFORE_CIRCUIT_SIZE="17..18"
export MEMORY_AFTER_CIRCUIT_SIZE="17..18"
else
if [[ $INPUT_FILE == *"witness_b19240705"* ]]; then
# These sizes are configured specifically for block 19240705. Don't use this in other scenarios
echo "Using specific circuit sizes for witness_b19240705.json"
export ARITHMETIC_CIRCUIT_SIZE="16..19"
export BYTE_PACKING_CIRCUIT_SIZE="16..19"
export BYTE_PACKING_CIRCUIT_SIZE="15..19"
export CPU_CIRCUIT_SIZE="18..21"
export KECCAK_CIRCUIT_SIZE="15..18"
export KECCAK_SPONGE_CIRCUIT_SIZE="10..13"
export LOGIC_CIRCUIT_SIZE="13..17"
export MEMORY_CIRCUIT_SIZE="20..23"
export KECCAK_CIRCUIT_SIZE="13..17"
export KECCAK_SPONGE_CIRCUIT_SIZE="8..13"
export LOGIC_CIRCUIT_SIZE="11..16"
export MEMORY_CIRCUIT_SIZE="19..23"
export MEMORY_BEFORE_CIRCUIT_SIZE="7..18"
export MEMORY_AFTER_CIRCUIT_SIZE="7..18"
elif [[ $INPUT_FILE == *"witness_b2_b7.json"* ]]; then
export ARITHMETIC_CIRCUIT_SIZE="13..17"
export BYTE_PACKING_CIRCUIT_SIZE="13..15"
export CPU_CIRCUIT_SIZE="16..17"
export KECCAK_CIRCUIT_SIZE="9..12"
export KECCAK_SPONGE_CIRCUIT_SIZE="7..9"
export LOGIC_CIRCUIT_SIZE="10..12"
export MEMORY_CIRCUIT_SIZE="18..20"
export MEMORY_BEFORE_CIRCUIT_SIZE="15..17"
export MEMORY_AFTER_CIRCUIT_SIZE="7..8"
else
export ARITHMETIC_CIRCUIT_SIZE="16..23"
export BYTE_PACKING_CIRCUIT_SIZE="9..21"
Expand All @@ -70,6 +84,8 @@ else
export KECCAK_SPONGE_CIRCUIT_SIZE="9..15"
export LOGIC_CIRCUIT_SIZE="12..18"
export MEMORY_CIRCUIT_SIZE="17..28"
export MEMORY_BEFORE_CIRCUIT_SIZE="7..27"
export MEMORY_AFTER_CIRCUIT_SIZE="7..28"
fi
fi

Expand Down

0 comments on commit a31692a

Please sign in to comment.