Skip to content

Commit 7e98feb

Browse files
committed
cleanup
1 parent fa54cdd commit 7e98feb

File tree

4 files changed

+168
-6
lines changed

4 files changed

+168
-6
lines changed

book/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
- [Advanced](./advanced/intro.md)
4545
- [Cost Estimator](./advanced/cost-estimator.md)
46+
- [Prove Scripts](./advanced/prove-scripts.md)
4647
- [Reproduce Binaries](./advanced/verify-binaries.md)
4748
- [Node Setup](./advanced/node-setup.md)
4849
- [Kurtosis](./advanced/kurtosis.md)

book/advanced/prove-scripts.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Prove Scripts
2+
3+
The prove scripts allow you to manually generate range and aggregation proofs for OP Succinct. These are useful for testing proof generation workflows and debugging.
4+
5+
## Overview
6+
7+
There are two main proving binaries:
8+
- **multi.rs**: Generates range proofs for multiple blocks
9+
- **agg.rs**: Aggregates multiple range proofs into a single aggregation proof
10+
11+
Both binaries use the SP1 network prover by default.
12+
13+
## Setup
14+
15+
### Environment Configuration
16+
17+
Create a `.env` file in the project root directory:
18+
19+
```bash
20+
# RPC Endpoints
21+
L1_RPC=<YOUR_L1_RPC_ENDPOINT>
22+
L1_BEACON_RPC=<YOUR_L1_BEACON_RPC_ENDPOINT>
23+
L2_RPC=<YOUR_L2_RPC_ENDPOINT>
24+
L2_NODE_RPC=<YOUR_L2_NODE_RPC_ENDPOINT>
25+
26+
# Network Prover Configuration
27+
NETWORK_PRIVATE_KEY=<YOUR_NETWORK_PRIVATE_KEY>
28+
29+
# Proof Strategy Configuration
30+
RANGE_PROOF_STRATEGY=reserved # Options: reserved, hosted, auction
31+
AGG_PROOF_STRATEGY=reserved # Options: reserved, hosted, auction
32+
AGG_PROOF_MODE=plonk # Options: plonk, groth16
33+
```
34+
35+
### Environment Variables
36+
37+
#### Required
38+
39+
| Variable | Description |
40+
|----------|-------------|
41+
| `L1_RPC` | L1 Archive Node endpoint |
42+
| `L1_BEACON_RPC` | L1 Consensus (Beacon) Node endpoint |
43+
| `L2_RPC` | L2 Execution Node (`op-geth`) endpoint |
44+
| `L2_NODE_RPC` | L2 Rollup Node (`op-node`) endpoint |
45+
| `NETWORK_PRIVATE_KEY` | Private key for the Succinct Prover Network. See the [Succinct Prover Network Quickstart](https://docs.succinct.xyz/docs/sp1/prover-network/quickstart) for setup instructions. |
46+
47+
#### Optional
48+
49+
| Variable | Description | Default |
50+
|----------|-------------|---------|
51+
| `RANGE_PROOF_STRATEGY` | Proof fulfillment strategy for range proofs | `reserved` |
52+
| `AGG_PROOF_STRATEGY` | Proof fulfillment strategy for aggregation proofs | `reserved` |
53+
| `AGG_PROOF_MODE` | Proof mode for aggregation proofs (`plonk` or `groth16`) | `plonk` |
54+
55+
**Proof Strategies:**
56+
- `reserved`: Uses reserved SP1 network capacity
57+
- `hosted`: Uses hosted proof generation service
58+
- `auction`: Uses auction-based proof fulfillment
59+
60+
**Proof Modes:**
61+
- `plonk`: PLONK proof system (default)
62+
- `groth16`: Groth16 proof system
63+
64+
### Getting Started with the Prover Network
65+
66+
1. Follow the [Succinct Prover Network Quickstart](https://docs.succinct.xyz/docs/sp1/prover-network/quickstart) to set up your account and obtain a private key.
67+
68+
2. Set the `NETWORK_PRIVATE_KEY` environment variable:
69+
```.env
70+
NETWORK_PRIVATE_KEY=0x...
71+
```
72+
73+
3. Run the prove scripts. The binaries will automatically use the network prover with your configured key.
74+
75+
## Generating Range Proofs
76+
77+
The `multi.rs` binary generates range proofs for a specified block range.
78+
79+
### Usage
80+
81+
```bash
82+
cargo run --bin multi --release -- \
83+
--start <START_BLOCK> \
84+
--end <END_BLOCK> \
85+
--prove
86+
```
87+
88+
### Example
89+
90+
```bash
91+
# Generate a range proof for blocks 1000-1300
92+
cargo run --bin multi --release -- \
93+
--start 1000 \
94+
--end 1300 \
95+
--prove
96+
```
97+
98+
### Output
99+
100+
Range proofs are saved to `data/{chain_id}/proofs/{start_block}-{end_block}.bin`
101+
102+
## Generating Aggregation Proofs
103+
104+
The `agg.rs` binary aggregates multiple range proofs into a single aggregation proof.
105+
106+
### Usage
107+
108+
```bash
109+
cargo run --bin agg --release -- \
110+
--proofs <PROOF_1>,<PROOF_2>,<PROOF_N> \
111+
--prover <PROVER_ADDRESS> \
112+
--prove
113+
```
114+
115+
### Example
116+
117+
```bash
118+
# Aggregate three range proofs
119+
cargo run --bin agg --release -- \
120+
--proofs 1000-1300,1300-1600,1600-1900 \
121+
--prover 0x1234567890abcdef1234567890abcdef12345678 \
122+
--prove
123+
```
124+
125+
### Parameters
126+
127+
| Parameter | Description | Required |
128+
|-----------|-------------|----------|
129+
| `--proofs` | Comma-separated list of proof names (without `.bin` extension) | Yes |
130+
| `--prover` | Prover wallet address | Yes |
131+
| `--prove` | Generate proof (omit to only execute) | No |
132+
| `--env-file` | Path to environment file (default: `.env`) | No |
133+
134+
### Requirements
135+
136+
- Proof files must exist in `data/fetched_proofs/` directory
137+
- Proof names should match the range format: `{start_block}-{end_block}`
138+
- All range proofs must be verified before aggregation
139+
140+
## Local Development
141+
142+
For local development and testing, omit the `--prove` flag to execute the program without generating proofs. This allows you to verify correctness without incurring proving costs.
143+
144+
```bash
145+
# Execute without proving
146+
cargo run --bin multi --release -- \
147+
--start 1000 \
148+
--end 1300
149+
```
150+
151+
This will run the full execution and report cycle counts without submitting proof requests to the network.

scripts/prove/bin/agg.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use op_succinct_host_utils::{
1111
};
1212
use op_succinct_proof_utils::get_range_elf_embedded;
1313
use sp1_sdk::{
14-
utils, HashableKey, Prover, ProverClient, SP1Proof, SP1ProofWithPublicValues, SP1VerifyingKey,
14+
utils, HashableKey, Prover, ProverClient, SP1Proof, SP1ProofMode, SP1ProofWithPublicValues,
15+
SP1VerifyingKey,
1516
};
1617

1718
#[derive(Parser, Debug)]
@@ -95,10 +96,19 @@ async fn main() -> Result<()> {
9596
println!("Aggregate ELF Verification Key: {:?}", agg_vk.vk.bytes32());
9697

9798
if args.prove {
98-
// TODO(fakedev9999): default to plonk
99+
let agg_proof_mode = if env::var("AGG_PROOF_MODE")
100+
.unwrap_or_else(|_| "plonk".to_string())
101+
.to_lowercase()
102+
== "groth16"
103+
{
104+
SP1ProofMode::Groth16
105+
} else {
106+
SP1ProofMode::Plonk
107+
};
108+
99109
prover
100110
.prove(&agg_pk, &stdin)
101-
.groth16()
111+
.mode(agg_proof_mode)
102112
.strategy(parse_fulfillment_strategy(env::var("AGG_PROOF_STRATEGY")?))
103113
.run()
104114
.expect("proving failed");

scripts/prove/bin/multi.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ async fn main() -> Result<()> {
5050

5151
if args.prove {
5252
// If the prove flag is set, generate a proof.
53-
let network_prover = ProverClient::builder().network().build();
53+
let prover = ProverClient::builder().network().build();
5454

55-
let (pk, _) = network_prover.setup(get_range_elf_embedded());
55+
let (pk, _) = prover.setup(get_range_elf_embedded());
5656

5757
// Generate a range proof in compressed mode for aggregation verification.
58-
let proof = network_prover
58+
let proof = prover
5959
.prove(&pk, &sp1_stdin)
6060
.compressed()
6161
.strategy(parse_fulfillment_strategy(env::var("RANGE_PROOF_STRATEGY")?))

0 commit comments

Comments
 (0)