Skip to content

Commit ec4c262

Browse files
committed
docs: match the SP1 proof aggregation documentation style
1 parent 7e98feb commit ec4c262

File tree

3 files changed

+51
-14
lines changed

3 files changed

+51
-14
lines changed

book/advanced/prove-scripts.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
# Prove Scripts
22

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.
3+
The prove scripts allow you to manually generate range and aggregation proofs for OP Succinct.
44

55
## Overview
66

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
7+
OP Succinct uses a two-tier proving architecture:
8+
9+
1. **Range Proofs** (`multi.rs`): Generate compressed proofs for a range of L2 blocks. These proofs verify the state transition for a specific block range.
10+
11+
2. **Aggregation Proofs** (`agg.rs`): Combine multiple range proofs into a single aggregation proof. This reduces on-chain verification costs by verifying one proof instead of many.
1012

1113
Both binaries use the SP1 network prover by default.
1214

15+
### When to Use Aggregation
16+
17+
Aggregation is useful when you need to:
18+
- Reduce on-chain verification costs by combining multiple range proofs into one proof
19+
- Prove larger block ranges by aggregating individual range proofs from different time periods
20+
- Combine proofs from different proving sessions into a single proof for batch submission
21+
22+
> **Note:** All range proofs must be generated in compressed mode for aggregation. The prove scripts handle this automatically.
23+
1324
## Setup
1425

1526
### Environment Configuration
@@ -74,7 +85,7 @@ AGG_PROOF_MODE=plonk # Options: plonk, groth16
7485

7586
## Generating Range Proofs
7687

77-
The `multi.rs` binary generates range proofs for a specified block range.
88+
The `multi.rs` binary generates compressed range proofs for a specified block range. These proofs verify the state transition function for the L2 blocks in the range.
7889

7990
### Usage
8091

@@ -88,20 +99,29 @@ cargo run --bin multi --release -- \
8899
### Example
89100

90101
```bash
91-
# Generate a range proof for blocks 1000-1300
102+
# Generate a compressed range proof for blocks 1000-1300
92103
cargo run --bin multi --release -- \
93104
--start 1000 \
94105
--end 1300 \
95106
--prove
96107
```
97108

109+
The proof will be generated in compressed mode, which is required for aggregation.
110+
98111
### Output
99112

100113
Range proofs are saved to `data/{chain_id}/proofs/{start_block}-{end_block}.bin`
101114

102115
## Generating Aggregation Proofs
103116

104-
The `agg.rs` binary aggregates multiple range proofs into a single aggregation proof.
117+
The `agg.rs` binary aggregates multiple compressed range proofs into a single aggregation proof. This allows you to verify the state transition for a large block range with a single on-chain verification.
118+
119+
### How Aggregation Works
120+
121+
1. The binary loads the specified range proofs from `data/fetched_proofs/`
122+
2. Each range proof is verified to ensure validity
123+
3. The proofs are aggregated into a single proof that attests to the entire block range
124+
4. The aggregation proof can be submitted on-chain for efficient verification
105125

106126
### Usage
107127

@@ -115,27 +135,30 @@ cargo run --bin agg --release -- \
115135
### Example
116136

117137
```bash
118-
# Aggregate three range proofs
138+
# Aggregate three consecutive range proofs covering blocks 1000-1900
119139
cargo run --bin agg --release -- \
120140
--proofs 1000-1300,1300-1600,1600-1900 \
121141
--prover 0x1234567890abcdef1234567890abcdef12345678 \
122142
--prove
123143
```
124144

145+
This will generate a single aggregation proof that verifies the state transition from block 1000 to 1900.
146+
125147
### Parameters
126148

127149
| Parameter | Description | Required |
128150
|-----------|-------------|----------|
129151
| `--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 |
152+
| `--prover` | Prover wallet address included in the aggregation proof | Yes |
153+
| `--prove` | Generate proof (omit to only execute and verify inputs) | No |
132154
| `--env-file` | Path to environment file (default: `.env`) | No |
133155

134156
### Requirements
135157

136158
- Proof files must exist in `data/fetched_proofs/` directory
137159
- Proof names should match the range format: `{start_block}-{end_block}`
138-
- All range proofs must be verified before aggregation
160+
- Range proofs must be consecutive (e.g., 1000-1300, 1300-1600, 1600-1900)
161+
- All range proofs are automatically verified before aggregation
139162

140163
## Local Development
141164

scripts/prove/bin/agg.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ fn load_aggregation_proof_data(
6767
(proofs, boot_infos)
6868
}
6969

70-
// Execute the OP Succinct program for a single block.
70+
/// Aggregates multiple range proofs into a single proof.
71+
///
72+
/// This binary takes multiple compressed range proofs and aggregates them into a single
73+
/// aggregation proof. This is useful for:
74+
/// - Reducing on-chain verification costs by combining multiple proofs into one
75+
/// - Proving larger block ranges by aggregating individual range proofs
76+
///
77+
/// Note: All input range proofs must be in compressed format for aggregation to work.
7178
#[tokio::main]
7279
async fn main() -> Result<()> {
7380
utils::setup_logger();

scripts/prove/bin/multi.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ use op_succinct_scripts::HostExecutorArgs;
1313
use sp1_sdk::{utils, Prover, ProverClient};
1414
use tracing::debug;
1515

16-
/// Execute the OP Succinct program for multiple blocks.
16+
/// Generates a compressed range proof for a block range.
17+
///
18+
/// This binary generates a compressed SP1 proof that verifies the state transition
19+
/// for a range of L2 blocks. The compressed proof format is required for aggregation.
20+
///
21+
/// The proof verifies that the rollup's state transition function was correctly executed
22+
/// for all blocks in the specified range.
1723
#[tokio::main]
1824
async fn main() -> Result<()> {
1925
let args = HostExecutorArgs::parse();
@@ -54,7 +60,8 @@ async fn main() -> Result<()> {
5460

5561
let (pk, _) = prover.setup(get_range_elf_embedded());
5662

57-
// Generate a range proof in compressed mode for aggregation verification.
63+
// Generate a compressed range proof. Note that the compressed proof type is required
64+
// for aggregation.
5865
let proof = prover
5966
.prove(&pk, &sp1_stdin)
6067
.compressed()

0 commit comments

Comments
 (0)