Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
832 changes: 411 additions & 421 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions book/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- [Resources](./fault_proofs/resources.md)
- [Gas Costs](./fault_proofs/gas_costs.md)
- [Testing Guide](./fault_proofs/testing.md)
- [Pre-Flight Validation](./fault_proofs/preflight.md)
- [Best Practices](./fault_proofs/best_practices.md)
- [Experimental Features](./fault_proofs/experimental/experimental.md)
- [Celestia DA](./fault_proofs/experimental/celestia.md)
Expand Down
119 changes: 119 additions & 0 deletions book/fault_proofs/preflight.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Pre-Flight Validation

**Proving will break if parameters are incorrect.** After deploying contracts, run this script to verify the contract configuration before the mainnet upgrade.

## What Does Pre-Flight Validate?

Catches configuration issues before production by testing the complete proof generation and submission pipeline end-to-end. The game creation and proof submission is simulated on a forked L1 network.

## Prerequisites

- Deployed `DisputeGameFactory` contract
- L1/L2 RPC access
- SP1 network prover access

## Required Environment Variables

Create a `.env.preflight` file in the **repository root** with the following variables.

> **Note:** Using `.env.preflight` avoids conflicts with existing `.env` files from deployments or other operations. You can specify a different file with `--env-file` if needed.

### Contract Configuration
```bash
# Address of the DisputeGameFactory contract on L1
FACTORY_ADDRESS=

# Game type identifier for OPSuccinctFaultDisputeGames
# This must match the game type registered in the factory
GAME_TYPE=42

# Optional: block number where DisputeGameFactory.setImplementation was called.
# Set when you want to bypass on-chain log discovery (e.g., restrictive RPC rate limits).
# SET_IMPL_BLOCK=<L1_BLOCK_NUMBER>
```

### Signing Configuration
```bash
# L1 private key used to create and prove the dispute game on the forked Anvil chain
# This must be a whitelisted address in the OPSuccinctFaultDisputeGame contract
PRIVATE_KEY=0x...
```

### Network Configuration
```bash
# L1 RPC endpoint (used for Anvil fork during validation)
L1_RPC=<YOUR_L1_RPC>

# L1 beacon chain RPC endpoint (needed when validating blocks with blob/EIP-4844 data)
L1_BEACON_RPC=<YOUR_L1_BEACON_RPC>

# L2 RPC endpoint
L2_RPC=<YOUR_L2_RPC>

# L2 node RPC endpoint (often same as L2_RPC)
L2_NODE_RPC=<YOUR_L2_NODE_RPC>
```

### Prover Configuration
```bash
# Range proof fulfillment strategy
# Options: "reserved", "hosted", "auction"
# - reserved: Use SP1 Network Reserved mode (requires reserved capacity)
# - hosted: Use SP1 Network Hosted mode (managed by SP1)
# - auction: Use SP1 Network Auction mode (open competitive bidding)
RANGE_PROOF_STRATEGY=auction

# Aggregation proof fulfillment strategy
# Options: "reserved", "hosted", "auction"
# Compatibility rules:
# - If RANGE_PROOF_STRATEGY is "auction", this must also be "auction"
# - If RANGE_PROOF_STRATEGY is "reserved" or "hosted", this can be either "reserved" or "hosted"
AGG_PROOF_STRATEGY=auction

# Optional: aggregation proof mode ("plonk" default or "groth16")
# Note: Changing the proof mode requires the corresponding SP1 verifier contract
# address to be set in your deployment.
# AGG_PROOF_MODE=plonk

# Set to 'true' to use AWS KMS for key management (requires KMS configuration).
# Set to 'false' to use a local private key (requires NETWORK_PRIVATE_KEY below).
# Optional; defaults to 'false' if omitted.
# USE_KMS_REQUESTER=false

# SP1 network prover private key (required when USE_KMS_REQUESTER=false)
# When USE_KMS_REQUESTER=true, this should be an AWS KMS key ARN instead
NETWORK_PRIVATE_KEY=0x...
```

## Running Pre-Flight Validation

Run the preflight script from the **repository root**:

```bash
RUST_LOG=info cargo run --release --bin preflight
```

```admonish note
For rollups using alternative DA layers, compile with the matching feature flag:
`--features celestia` or `--features eigenda` (for example,
`RUST_LOG=info cargo run --release --features eigenda --bin preflight`).
```

By default, this uses `.env.preflight`. To use a different environment file:

```bash
RUST_LOG=info cargo run --release --bin preflight -- --env-file .env.custom
```

The script will:
1. Fetch the anchor L2 block number from the factory
2. Generate a range proof for the game
3. Generate an aggregation proof for the game
4. Fork L1 at a finalized block using Anvil
5. Create a game at 10 blocks after the anchor
6. Prove the game with the aggregation proof
7. Verify the game has been validated with the aggregation proof

Generated proofs are saved to:
- `data/{CHAIN_ID}/proofs/range/{L2_START_BLOCK}-{L2_END_BLOCK}.bin`
- `data/{CHAIN_ID}/proofs/agg/agg.bin`
2 changes: 1 addition & 1 deletion book/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It combines a few key technologies:
- [SP1](https://docs.succinct.xyz/docs/sp1/introduction), Succinct's state-of-the-art Rust zkVM
- [Succinct Prover Network](https://docs.succinct.xyz/docs/sp1/prover-network/intro), Succinct's low-latency, cost-effective proving API

OP Succinct is the only production-ready proving solution for the OP Stack and trusted by teams like [Mantle](https://www.mantle.xyz/blog/announcements/op-succinct-mantle-network-testnet) and [Phala](https://phala.network/posts/phala-network-20-first-opsuccinct-layer-2-on-ethereum).
OP Succinct is the only production-ready proving solution for the OP Stack and trusted by teams like [Mantle](https://www.mantle.xyz/blog/announcements/op-succinct-mantle-network-testnet) and [Phala](https://phala.com/).


## Proving Options
Expand Down
12 changes: 12 additions & 0 deletions fault-proof/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ sol! {
/// @notice Emitted when a new dispute game is created.
event DisputeGameCreated(address indexed disputeProxy, GameType indexed gameType, Claim indexed rootClaim);

/// @notice Emitted when a new game implementation added to the factory
event ImplementationSet(address indexed impl, GameType indexed gameType);

/// @notice `gameImpls` is a mapping that maps `GameType`s to their respective
/// `IDisputeGame` implementations.
mapping(GameType => IDisputeGame) public gameImpls;
Expand Down Expand Up @@ -65,6 +68,15 @@ sol! {
/// @notice Getter for the parent hash of the L1 block when the dispute game was created.
function l1Head() public pure returns (Hash l1Head_);

/// @notice Returns the rollup config hash.
function rollupConfigHash() public pure returns (Hash rollupConfigHash_);

/// @notice Returns the aggregation vkey.
function aggregationVkey() public pure returns (Hash aggregationVkey_);

/// @notice Returns the range vkey commitment.
function rangeVkeyCommitment() public pure returns (Hash rangeVkeyCommitment_);

/// @notice Getter for the status of the game.
function status() public view returns (GameStatus status_);

Expand Down
12 changes: 12 additions & 0 deletions scripts/prove/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,21 @@ op-succinct-client-utils.workspace = true
op-succinct-proof-utils.workspace = true
op-succinct-scripts = { path = "../utils" }
op-succinct-elfs.workspace = true
op-succinct-fp.workspace = true

# alloy
alloy-contract.workspace = true
alloy-eips.workspace = true
alloy-network.workspace = true
alloy-node-bindings.workspace = true
alloy-primitives.workspace = true
alloy-signer-local.workspace = true
alloy-sol-types.workspace = true
alloy-provider = { workspace = true, features = ["reqwest"] }
alloy-transport-http = { workspace = true, features = [
"reqwest",
"reqwest-native-tls",
] }

# sp1
sp1-sdk.workspace = true
Expand Down
16 changes: 16 additions & 0 deletions scripts/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,24 @@ path = "bin/gen_sp1_test_artifacts.rs"
name = "parallel-cost-estimator"
path = "bin/parallel_cost_estimator.rs"

[[bin]]
name = "preflight"
path = "bin/preflight.rs"

[[bin]]
name = "prove-dryrun"
path = "bin/prove_dryrun.rs"

[dependencies]

# workspace
alloy-network.workspace = true
alloy-node-bindings.workspace = true
alloy-provider = { workspace = true, features = ["reqwest"] }
alloy-transport-http = { workspace = true, features = [
"reqwest",
"reqwest-native-tls",
] }
alloy-primitives.workspace = true
alloy-sol-types.workspace = true
alloy-signer-local.workspace = true
Expand All @@ -63,6 +78,7 @@ futures.workspace = true
rayon = "1.10.0"
serde_json.workspace = true
env_logger = "0.11"
tracing.workspace = true

# local
op-succinct-host-utils.workspace = true
Expand Down
Loading
Loading