Skip to content

Commit fa54cdd

Browse files
committed
refac(scripts): default to network prover
1 parent 67d43e6 commit fa54cdd

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

scripts/prove/bin/agg.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
use std::{env, fs};
2+
13
use alloy_primitives::{Address, B256};
24
use anyhow::Result;
35
use cargo_metadata::MetadataCommand;
46
use clap::Parser;
57
use op_succinct_client_utils::{boot::BootInfoStruct, types::u32_to_u8};
68
use op_succinct_elfs::AGGREGATION_ELF;
7-
use op_succinct_host_utils::{fetcher::OPSuccinctDataFetcher, get_agg_proof_stdin};
9+
use op_succinct_host_utils::{
10+
fetcher::OPSuccinctDataFetcher, get_agg_proof_stdin, network::parse_fulfillment_strategy,
11+
};
812
use op_succinct_proof_utils::get_range_elf_embedded;
913
use sp1_sdk::{
1014
utils, HashableKey, Prover, ProverClient, SP1Proof, SP1ProofWithPublicValues, SP1VerifyingKey,
1115
};
12-
use std::fs;
1316

1417
#[derive(Parser, Debug)]
1518
#[command(author, version, about, long_about = None)]
@@ -72,7 +75,7 @@ async fn main() -> Result<()> {
7275

7376
dotenv::from_filename(args.env_file).ok();
7477

75-
let prover = ProverClient::from_env();
78+
let prover = ProverClient::builder().network().build();
7679
let fetcher = OPSuccinctDataFetcher::new_with_rollup_config().await?;
7780

7881
let (_, vkey) = prover.setup(get_range_elf_embedded());
@@ -92,7 +95,13 @@ async fn main() -> Result<()> {
9295
println!("Aggregate ELF Verification Key: {:?}", agg_vk.vk.bytes32());
9396

9497
if args.prove {
95-
prover.prove(&agg_pk, &stdin).groth16().run().expect("proving failed");
98+
// TODO(fakedev9999): default to plonk
99+
prover
100+
.prove(&agg_pk, &stdin)
101+
.groth16()
102+
.strategy(parse_fulfillment_strategy(env::var("AGG_PROOF_STRATEGY")?))
103+
.run()
104+
.expect("proving failed");
96105
} else {
97106
let (_, report) = prover
98107
.execute(AGGREGATION_ELF, &stdin)

scripts/prove/bin/multi.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
use std::{env, fs, sync::Arc, time::Instant};
2+
13
use anyhow::{Context, Result};
24
use clap::Parser;
35
use op_succinct_host_utils::{
46
block_range::get_validated_block_range, fetcher::OPSuccinctDataFetcher, host::OPSuccinctHost,
5-
stats::ExecutionStats, witness_generation::WitnessGenerator,
7+
network::parse_fulfillment_strategy, stats::ExecutionStats,
8+
witness_generation::WitnessGenerator,
69
};
710
use op_succinct_proof_utils::{get_range_elf_embedded, initialize_host};
811
use op_succinct_prove::{execute_multi, DEFAULT_RANGE};
912
use op_succinct_scripts::HostExecutorArgs;
10-
use sp1_sdk::{utils, ProverClient};
11-
use std::{fs, sync::Arc, time::Instant};
13+
use sp1_sdk::{utils, Prover, ProverClient};
1214
use tracing::debug;
1315

1416
/// Execute the OP Succinct program for multiple blocks.
@@ -46,13 +48,19 @@ async fn main() -> Result<()> {
4648
// Get the stdin for the block.
4749
let sp1_stdin = host.witness_generator().get_sp1_stdin(witness_data)?;
4850

49-
let prover = ProverClient::from_env();
50-
5151
if args.prove {
5252
// If the prove flag is set, generate a proof.
53-
let (pk, _) = prover.setup(get_range_elf_embedded());
54-
// Generate proofs in compressed mode for aggregation verification.
55-
let proof = prover.prove(&pk, &sp1_stdin).compressed().run().unwrap();
53+
let network_prover = ProverClient::builder().network().build();
54+
55+
let (pk, _) = network_prover.setup(get_range_elf_embedded());
56+
57+
// Generate a range proof in compressed mode for aggregation verification.
58+
let proof = network_prover
59+
.prove(&pk, &sp1_stdin)
60+
.compressed()
61+
.strategy(parse_fulfillment_strategy(env::var("RANGE_PROOF_STRATEGY")?))
62+
.run()
63+
.unwrap();
5664

5765
// Create a proof directory for the chain ID if it doesn't exist.
5866
let proof_dir = format!("data/{}/proofs", data_fetcher.get_l2_chain_id().await.unwrap());

0 commit comments

Comments
 (0)