Skip to content

Commit 51fe250

Browse files
authored
feat: make agg proof mode configurable for proposers (#671)
* feat: make agg proof mode configurable for fp proposer * refactor: default to plonk for agg proofs This is because plonk has better trust assumptions than groth16. * make fmt + clippy happy
1 parent 4719bbd commit 51fe250

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

book/fault_proofs/proposer.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Depending on the one you choose, you must provide the corresponding environment
8282
| `FAST_FINALITY_MODE` | Whether to use fast finality mode | `false` |
8383
| `RANGE_PROOF_STRATEGY` | Proof fulfillment strategy for range proofs. Set to `hosted` to use the hosted proof strategy. | `reserved` |
8484
| `AGG_PROOF_STRATEGY` | Proof fulfillment strategy for aggregation proofs. Set to `hosted` to use the hosted proof strategy. | `reserved` |
85+
| `AGG_PROOF_MODE` | Proof mode for aggregation proofs. Set to `groth16` to use Groth16 proof type. **Note:** Changing the proof mode requires updating the `SP1_VERIFIER` address in `contracts/src/fp/OPSuccinctFaultDisputeGame.sol` to the corresponding verifier gateway contract. See [SP1 Contract Addresses](https://docs.succinct.xyz/docs/sp1/verification/contract-addresses) for verifier addresses. | `plonk` |
8586
| `PROPOSAL_INTERVAL_IN_BLOCKS` | Number of L2 blocks between proposals | `1800` |
8687
| `FETCH_INTERVAL` | Polling interval in seconds | `30` |
8788
| `MAX_CONCURRENT_DEFENSE_TASKS` | Maximum number of concurrently running defense tasks | `8` |

book/validity/proposer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Before starting the proposer, ensure you have deployed the relevant contracts an
4444
| `DGF_ADDRESS` | Address of the `DisputeGameFactory` contract. Note: If set, the proposer will create a dispute game with the DisputeGameFactory, rather than the `OPSuccinctL2OutputOracle`. Compatible with `OptimismPortal2`. |
4545
| `RANGE_PROOF_STRATEGY` | Default: `reserved`. Set to `hosted` to use hosted proof strategy. |
4646
| `AGG_PROOF_STRATEGY` | Default: `reserved`. Set to `hosted` to use hosted proof strategy. |
47-
| `AGG_PROOF_MODE` | Default: `groth16`. Set to `plonk` to use PLONK proof type. Note: The verifier gateway contract address must be updated to use PLONK proofs. |
47+
| `AGG_PROOF_MODE` | Default: `plonk`. Set to `groth16` to use Groth16 proof type. **Note:** Changing the proof mode requires updating the verifier gateway contract address in your L2OutputOracle contract deployment. See [SP1 Contract Addresses](https://docs.succinct.xyz/docs/sp1/verification/contract-addresses) for verifier addresses. |
4848
| `SUBMISSION_INTERVAL` | Default: `1800`. The number of L2 blocks that must be proven before a proof is submitted to the L1. Note: The interval used by the validity service is always >= to the `submissionInterval` configured on the L2OO contract. To allow for the validity service to configure this parameter entirely, set the `submissionInterval` in the contract to `1`. |
4949
| `RANGE_PROOF_INTERVAL` | Default: `1800`. The number of blocks to include in each range proof. For chains with high throughput, you need to decrease this value. |
5050
| `RANGE_PROOF_EVM_GAS_LIMIT` | Default: `0`. The total amount of ethereum gas allowed to be in each range proof. If 0, uses the `RANGE_PROOF_INTERVAL` instead to do a fixed number of blocks interval. NOTE: if both `RANGE_PROOF_INTERVAL` and `RANGE_PROOF_EVM_GAS_LIMIT` are set, the number of blocks to include in each range proof is determined either when the cumulative gas reaches `RANGE_PROOF_EVM_GAS_LIMIT` or the number of blocks reaches `RANGE_PROOF_INTERVAL`, whichever occurs first. |

fault-proof/src/config.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use alloy_transport_http::reqwest::Url;
55
use anyhow::Result;
66
use op_succinct_host_utils::network::parse_fulfillment_strategy;
77
use serde::{Deserialize, Serialize};
8-
use sp1_sdk::network::FulfillmentStrategy;
8+
use sp1_sdk::{network::FulfillmentStrategy, SP1ProofMode};
99

1010
#[derive(Debug, Clone)]
1111
pub struct ProposerConfig {
@@ -30,6 +30,9 @@ pub struct ProposerConfig {
3030
/// Proof fulfillment strategy for aggregation proofs.
3131
pub agg_proof_strategy: FulfillmentStrategy,
3232

33+
/// Proof mode for aggregation proofs (Groth16 or Plonk).
34+
pub agg_proof_mode: SP1ProofMode,
35+
3336
/// The interval in blocks between proposing new games.
3437
pub proposal_interval_in_blocks: u64,
3538

@@ -123,6 +126,15 @@ impl ProposerConfig {
123126
agg_proof_strategy: parse_fulfillment_strategy(
124127
env::var("AGG_PROOF_STRATEGY").unwrap_or("reserved".to_string()),
125128
),
129+
agg_proof_mode: if env::var("AGG_PROOF_MODE")
130+
.unwrap_or("plonk".to_string())
131+
.to_lowercase() ==
132+
"groth16"
133+
{
134+
SP1ProofMode::Groth16
135+
} else {
136+
SP1ProofMode::Plonk
137+
},
126138
proposal_interval_in_blocks: env::var("PROPOSAL_INTERVAL_IN_BLOCKS")
127139
.unwrap_or("1800".to_string())
128140
.parse()?,

fault-proof/src/proposer.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct SP1Prover {
6565
range_pk: Arc<SP1ProvingKey>,
6666
range_vk: Arc<SP1VerifyingKey>,
6767
agg_pk: Arc<SP1ProvingKey>,
68+
agg_mode: SP1ProofMode,
6869
}
6970

7071
/// Represents a dispute game in the on-chain game DAG.
@@ -204,6 +205,7 @@ where
204205
range_pk: Arc::new(range_pk),
205206
range_vk: Arc::new(range_vk),
206207
agg_pk: Arc::new(agg_pk),
208+
agg_mode: config.agg_proof_mode,
207209
},
208210
fetcher: fetcher.clone(),
209211
host,
@@ -648,14 +650,14 @@ where
648650
SP1ProofWithPublicValues::create_mock_proof(
649651
&self.prover.agg_pk,
650652
public_values,
651-
SP1ProofMode::Groth16,
653+
self.prover.agg_mode,
652654
SP1_CIRCUIT_VERSION,
653655
)
654656
} else {
655657
self.prover
656658
.network_prover
657659
.prove(&self.prover.agg_pk, &sp1_stdin)
658-
.groth16()
660+
.mode(self.prover.agg_mode)
659661
.strategy(self.config.agg_proof_strategy)
660662
.timeout(Duration::from_secs(self.config.timeout))
661663
.min_auction_period(self.config.min_auction_period)

fault-proof/tests/common/process.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use op_succinct_host_utils::{
1414
};
1515
use op_succinct_proof_utils::initialize_host;
1616
use op_succinct_signer_utils::SignerLock;
17-
use sp1_sdk::network::FulfillmentStrategy;
17+
use sp1_sdk::{network::FulfillmentStrategy, SP1ProofMode};
1818
use tracing::Instrument;
1919

2020
pub async fn init_proposer(
@@ -35,6 +35,7 @@ pub async fn init_proposer(
3535
fast_finality_mode: false,
3636
range_proof_strategy: FulfillmentStrategy::Hosted,
3737
agg_proof_strategy: FulfillmentStrategy::Hosted,
38+
agg_proof_mode: SP1ProofMode::Plonk,
3839
proposal_interval_in_blocks: 10, // Much smaller interval for testing
3940
fetch_interval: 30, // Check more frequently in tests
4041
game_type,

validity/src/env.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ pub async fn read_proposer_env() -> Result<EnvironmentConfig> {
9898

9999
// Parse proof mode
100100
let agg_proof_mode =
101-
if get_env_var("AGG_PROOF_MODE", Some("groth16".to_string()))?.to_lowercase() == "plonk" {
102-
SP1ProofMode::Plonk
103-
} else {
101+
if get_env_var("AGG_PROOF_MODE", Some("plonk".to_string()))?.to_lowercase() == "groth16" {
104102
SP1ProofMode::Groth16
103+
} else {
104+
SP1ProofMode::Plonk
105105
};
106106

107107
// Optional loop interval

0 commit comments

Comments
 (0)