Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Dec 23, 2024
1 parent a3dab23 commit 957ac66
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 157 deletions.
129 changes: 0 additions & 129 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ sp1-lib = { version = "3.4.0", features = ["verify"] }
sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", rev = "f0b61cf262388c1be7edfcf984c8e070064e980f", features = [
"network-v2",
] }
sp1-core-executor = { git = "https://github.com/succinctlabs/sp1.git", rev = "f0b61cf262388c1be7edfcf984c8e070064e980f" }
sp1-stark = { git = "https://github.com/succinctlabs/sp1.git", rev = "f0b61cf262388c1be7edfcf984c8e070064e980f" }
sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", rev = "16431e6b979a617fa08994ccdaf866b22ba4b7a1", features = ["verify", "lib", "libm", "embedded"], default-features = false }
sp1-build = { version = "3.4.0" }

p3-baby-bear = { version = "0.1.4-succinct" }
p3-fri = { version = "0.1.4-succinct" }
p3-field = { version = "0.1.4-succinct" }

[profile.release-client-lto]
inherits = "release"
panic = "abort"
Expand Down
Binary file modified elf/aggregation-elf
Binary file not shown.
Binary file modified elf/range-elf
Binary file not shown.
2 changes: 1 addition & 1 deletion proposer/succinct/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ async fn request_mock_span_proof(
};

let start_prove = Instant::now();
let res = generate_mock_compressed_proof(MULTI_BLOCK_ELF, sp1_stdin);
let res = generate_mock_compressed_proof(RANGE_ELF, sp1_stdin);
let (proof, report) = if let Ok(result) = res {
result
} else {
Expand Down
28 changes: 15 additions & 13 deletions scripts/prove/bin/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ use op_succinct_host_utils::{
stats::ExecutionStats,
HostExecutorArgs, ProgramType,
};
use op_succinct_prove::{execute_multi, generate_witness, DEFAULT_RANGE, RANGE_ELF};
use sp1_sdk::{utils, ProverClient};
use std::{fs, time::Duration};
use op_succinct_prove::{execute_multi, generate_witness, RANGE_ELF};
use sp1_sdk::{
network_v2::proto::network::{FulfillmentStrategy, ProofMode},
utils, NetworkProverV2, Prover,
};
use std::{env, fs, time::Duration};

/// Execute the OP Succinct program for multiple blocks.
#[tokio::main]
Expand Down Expand Up @@ -45,14 +48,19 @@ async fn main() -> Result<()> {
// Get the stdin for the block.
let sp1_stdin = get_proof_stdin(&host_cli)?;

let prover = ProverClient::new();
let private_key = env::var("SP1_PRIVATE_KEY").unwrap();
let sp1_rpc_url = env::var("PROVER_NETWORK_RPC").unwrap();
let mut prover = NetworkProverV2::new(&private_key, Some(sp1_rpc_url), false);
prover.with_strategy(FulfillmentStrategy::Reserved);

if args.prove {
// If the prove flag is set, generate a proof.
let (pk, _) = prover.setup(RANGE_ELF);

// Generate proofs in compressed mode for aggregation verification.
let proof = prover.prove(&pk, sp1_stdin).compressed().run().unwrap();
let proof = prover
.prove(&pk, sp1_stdin, ProofMode::Compressed, None)
.await?;

// Create a proof directory for the chain ID if it doesn't exist.
let proof_dir = format!(
Expand All @@ -72,14 +80,8 @@ async fn main() -> Result<()> {
} else {
let l2_chain_id = data_fetcher.get_l2_chain_id().await?;

let (block_data, report, execution_duration) = execute_multi(
&prover,
&data_fetcher,
sp1_stdin,
l2_start_block,
l2_end_block,
)
.await?;
let (block_data, report, execution_duration) =
execute_multi(&data_fetcher, sp1_stdin, l2_start_block, l2_end_block).await?;

let stats = ExecutionStats::new(
&block_data,
Expand Down
2 changes: 1 addition & 1 deletion scripts/prove/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ pub async fn generate_witness(host_cli: &HostCli) -> Result<Duration> {
}

pub async fn execute_multi(
prover: &ProverClient,
data_fetcher: &OPSuccinctDataFetcher,
sp1_stdin: SP1Stdin,
l2_start_block: u64,
l2_end_block: u64,
) -> Result<(Vec<BlockInfo>, ExecutionReport, Duration)> {
let start_time = Instant::now();
let prover = ProverClient::new();
let (_, report) = prover.execute(RANGE_ELF, sp1_stdin.clone()).run().unwrap();
let execution_duration = start_time.elapsed();

Expand Down
13 changes: 2 additions & 11 deletions scripts/prove/tests/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use op_succinct_host_utils::{
ProgramType,
};
use op_succinct_prove::{execute_multi, generate_witness, DEFAULT_RANGE, ONE_HOUR};
use sp1_sdk::ProverClient;

mod common;

Expand Down Expand Up @@ -36,16 +35,8 @@ async fn execute_batch() -> Result<()> {
// Get the stdin for the block.
let sp1_stdin = get_proof_stdin(&host_cli)?;

let prover = ProverClient::new();

let (block_data, report, execution_duration) = execute_multi(
&prover,
&data_fetcher,
sp1_stdin,
l2_start_block,
l2_end_block,
)
.await?;
let (block_data, report, execution_duration) =
execute_multi(&data_fetcher, sp1_stdin, l2_start_block, l2_end_block).await?;

let stats = ExecutionStats::new(
&block_data,
Expand Down
Loading

0 comments on commit 957ac66

Please sign in to comment.