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

Commit

Permalink
Merge branch 'feat/block-interval' into zbrown/concurrent-block-proof
Browse files Browse the repository at this point in the history
  • Loading branch information
cpubot committed Jun 5, 2024
2 parents 091b08c + 2a81ffe commit 279e039
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 68 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,16 @@ A few other notes:

### Generating Witnesses Only

If you want to test a block without the high CPU & memory requirements that come with creating a full proof, you can instead generate only the witness using `tools/debug_block.sh`:
If you want to test a block without the high CPU & memory requirements that come with creating a full proof, you can instead generate only the witness using `tools/prove_blocks.sh` in the `test_only` mode:

```sh
./debug_block.sh <BLOCK_NUMBER> <FULL_NODE_ENDPOINT>
./prove_blocks.sh <START_BLOCK> <END_BLOCK> <FULL_NODE_ENDPOINT> <IGNORE_PREVIOUS_PROOFS> test_only
```

Filled in:

```sh
./debug_block.sh 18299898 http://34.89.57.138:8545
./prove_blocks.sh 18299898 18299899 http://34.89.57.138:8545 true test_only
```

Finally, note that both of these testing scripts force proof generation to be sequential by allowing only one worker. Because of this, this is not a realistic representation of performance but makes the debugging logs much easier to follow.
Expand Down
9 changes: 4 additions & 5 deletions common/src/block_interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use alloy::primitives::B256;
use alloy::rpc::types::eth::BlockId;
use alloy::{hex, providers::Provider, transports::Transport};
use async_stream::try_stream;
use futures::Stream;
use thiserror::Error;
use tokio_stream::Stream;
use tracing::{error, info};

use crate::parsing;
Expand All @@ -27,7 +27,6 @@ pub enum BlockIntervalError {
}

/// Range of blocks to be processed and proven.
#[allow(unused)]
#[derive(Debug, PartialEq, Clone)]
pub enum BlockInterval {
// A single block number.
Expand All @@ -46,9 +45,9 @@ impl BlockInterval {
///
/// A valid block range is of the form:
/// * `block_number` for a single block number
/// * `lhs..rhs`, `lhs..=rhs` as a exclusive/inclusive range
/// * `lhs..` for a range starting from `lhs` to the chain tip. Form
/// `lhs..=` is also valid format.
/// * `lhs..rhs`, `lhs..=rhs` as an exclusive/inclusive range
/// * `lhs..` for a range starting from `lhs` to the chain tip. `lhs..=`
/// is also valid format.
///
/// # Example
///
Expand Down
10 changes: 7 additions & 3 deletions common/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ where
/// # use common::parsing::parse_range_exclusive;
/// assert_eq!(parse_range_exclusive::<usize>("0..10"), Ok(0..10));
/// ```
pub fn parse_range_exclusive<NumberT>(s: &str) -> Result<Range<NumberT>, RangeParseError<NumberT>>
pub(crate) fn parse_range_exclusive<NumberT>(
s: &str,
) -> Result<Range<NumberT>, RangeParseError<NumberT>>
where
NumberT: Display + FromStr + From<u8> + Add<Output = NumberT>,
NumberT::Err: Display,
Expand All @@ -49,15 +51,17 @@ where
/// # use common::parsing::parse_range_inclusive;
/// assert_eq!(parse_range_inclusive::<usize>("0..=10"), Ok(0..11));
/// ```
pub fn parse_range_inclusive<NumberT>(s: &str) -> Result<Range<NumberT>, RangeParseError<NumberT>>
pub(crate) fn parse_range_inclusive<NumberT>(
s: &str,
) -> Result<Range<NumberT>, RangeParseError<NumberT>>
where
NumberT: Display + FromStr + From<u8> + Add<Output = NumberT>,
NumberT::Err: Display,
{
parse_range_gen(s, "..=", true)
}

pub fn parse_range_gen<NumberT, SeparatorT>(
pub(crate) fn parse_range_gen<NumberT, SeparatorT>(
s: &str,
separator: SeparatorT,
inclusive: bool,
Expand Down
5 changes: 1 addition & 4 deletions leader/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ pub(crate) enum Command {
// The Jerigon RPC URL.
#[arg(long, short = 'u', value_hint = ValueHint::Url)]
rpc_url: String,
/// The block number for which to generate a proof.
#[arg(short, long)]
block_number: Option<u64>,
/// The block interval for which to generate a proof.
#[arg(long, short = 'i')]
block_interval: Option<String>,
block_interval: String,
/// The checkpoint block number.
#[arg(short, long, default_value_t = 0)]
checkpoint_block_number: u64,
Expand Down
4 changes: 2 additions & 2 deletions leader/src/jerigon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ pub(crate) async fn jerigon_main(
runtime.close().await?;

for block_proof in block_proofs {
let blokck_proof_str = serde_json::to_vec(&block_proof)?;
let block_proof_str = serde_json::to_vec(&block_proof)?;
write_proof(
blokck_proof_str,
block_proof_str,
proof_output_dir_opt.clone().map(|mut path| {
path.push(format!("b{}.zkproof", block_proof.b_height));
path
Expand Down
12 changes: 1 addition & 11 deletions leader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,14 @@ async fn main() -> Result<()> {
}
Command::Jerigon {
rpc_url,
block_number,
block_interval,
checkpoint_block_number,
previous_proof,
proof_output_dir,
save_inputs_on_error,
} => {
let previous_proof = get_previous_proof(previous_proof)?;

let block_interval = if let Some(block_number) = block_number {
BlockInterval::Single(block_number)
} else if let Some(s) = block_interval {
BlockInterval::new(&s)?
} else {
return Err(anyhow::Error::msg(
"block_number or block_interval must be provided as command line parameter",
));
};
let block_interval = BlockInterval::new(&block_interval)?;

info!("Proving {block_interval}");

Expand Down
39 changes: 0 additions & 39 deletions tools/debug_block.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tools/prove_blocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ else
fi
fi

# Convert hex do decimal parameters
# Convert hex to decimal parameters
if [[ $START_BLOCK == 0x* ]]; then
START_BLOCK=$((16#${START_BLOCK#"0x"}))
fi
Expand Down

0 comments on commit 279e039

Please sign in to comment.