Skip to content

Commit

Permalink
Start conversion to prove_stdio.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerad committed Nov 27, 2024
1 parent cf5ad6a commit 5972e9b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions scripts/prove_stdio.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use std::{env::set_var, fmt::Display, fs::create_dir_all, path::PathBuf, process::Command};

use alloy::{eips::BlockId, transports::http::reqwest::Url};
use anyhow::{ensure, Ok};
use clap::{arg, Args, ValueEnum, ValueHint};

#[derive(ValueEnum, Copy, Clone)]
enum RunMode {
/// Dummy proof is generated. Useful for quickly testing decoding and
/// all other non-proving logic.
Test,
/// The proof is generated and verified.
Verify,
}

#[derive(Args)]
pub struct ProveStdioArgs {
/// Whether to generate a proof and verify it or not.
mode: RunMode,
/// JSON file containing the witness data.
#[arg(value_hint = ValueHint::DirPath)]
input_witness_file: PathBuf,
/// The end of the block range to prove. If None, start_block-1 is used.
#[arg(long, default_value_t = false)]
use_test_config: bool,
}

pub fn prove_via_stdio(args: ProveStdioArgs) -> anyhow::Result<()> {
// Set rustc environment variables.
set_var("RUST_MIN_STACK", "33554432");
set_var("RUST_BACKTRACE", "full");
set_var("RUST_LOG", "info");
// Script users are running locally, and might benefit from extra perf.
// See also .cargo/config.toml.
set_var("RUSTFLAGS", "-C target-cpu=native -Zlinker-features=-lld");

match args.mode {
RunMode::Test => {
let witness_filename = args
.input_witness_file
.to_str()
.ok_or(anyhow::anyhow!("Invalid witness file path"))?;
if witness_filename.contains("witness_b19807080") {
} else if witness_filename.contains("witness_b3_b6") {
} else {
}
todo!("Test mode");
}
RunMode::Verify => {
todo!("Verify mode");
}
}
Ok(())
}
5 changes: 5 additions & 0 deletions scripts/xtask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
mod outdated;
mod prove_rpc;
mod prove_stdio;

use anyhow::Result;
use clap::Parser;
use outdated::list_outdated_deps;
use prove_rpc::{prove_via_rpc, ProveRpcArgs};
use prove_stdio::{prove_via_stdio, ProveStdioArgs};

#[derive(Parser)]
enum Args {
Expand All @@ -20,11 +22,14 @@ enum Args {
Outdated,
/// Execute proving via RPC endpoint.
ProveRpc(Box<ProveRpcArgs>),
/// Execute proving via stdin.
ProveStdio(ProveStdioArgs),
}

fn main() -> Result<()> {
match Args::parse() {
Args::Outdated => list_outdated_deps(),
Args::ProveRpc(args) => prove_via_rpc(*args),
Args::ProveStdio(args) => prove_via_stdio(args),
}
}

0 comments on commit 5972e9b

Please sign in to comment.