Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions book/fault_proofs/preflight.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# 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` file with the following variables:

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

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

# L1 block number where setImplementation was called for this game type
# Must be a finalized L1 block
SET_IMPL_BLOCK=12345678
```

### Network Configuration
```bash
# L1 RPC endpoint (used for Anvil fork during validation)
L1_RPC=https://ethereum-sepolia-rpc.publicnode.com

# L1 beacon chain RPC endpoint
L1_BEACON_RPC=https://ethereum-sepolia-beacon-api.publicnode.com

# L2 RPC endpoint
L2_RPC=https://rpc-your-rollup.example.com

# L2 node RPC endpoint (often same as L2_RPC)
L2_NODE_RPC=https://rpc-your-rollup.example.com
```

### Prover Configuration
```bash
# Range proof fulfillment strategy
RANGE_PROOF_STRATEGY=auction

# Aggregation proof fulfillment strategy
AGG_PROOF_STRATEGY=auction

Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing documentation for the USE_KMS_REQUESTER environment variable. The code at lines 135 and 187 in preflight.rs requires this variable to be set, but it's not listed in the 'Required Environment Variables' section. Add USE_KMS_REQUESTER=false to the Prover Configuration section with a description explaining when to set it to true (AWS KMS) vs false (local private key).

Suggested change
# Set to 'true' to use AWS KMS for key management (requires KMS configuration).
# Set to 'false' to use a local private key (requires SP1_PRIVATE_KEY below).
# Default: false
USE_KMS_REQUESTER=false

Copilot uses AI. Check for mistakes.
# SP1 network prover private key (required when USE_KMS_REQUESTER=false)
SP1_PRIVATE_KEY=0x...
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation references SP1_PRIVATE_KEY but the code expects NETWORK_PRIVATE_KEY. Based on the implementation in utils/host/src/network.rs, the get_network_signer function uses NETWORK_PRIVATE_KEY environment variable. The documentation should reference NETWORK_PRIVATE_KEY instead of SP1_PRIVATE_KEY to match the actual implementation.

Suggested change
SP1_PRIVATE_KEY=0x...
NETWORK_PRIVATE_KEY=0x...

Copilot uses AI. Check for mistakes.
```

## Running Pre-Flight Validation

### Basic Usage

Run the preflight script from the repository root:

```bash
cargo run --release --bin preflight
```

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

### Using Pre-Generated Proofs

To save time during iterative validation, you can reuse previously generated proofs:

```bash
cargo run --release --bin preflight -- \
--range-proof "12345-12355" \
--agg-proof "agg"
```

This skips proof generation and uses existing proofs from:
- `data/{CHAIN_ID}/proofs/range/12345-12355.bin`
- `data/{CHAIN_ID}/proofs/agg/agg.bin`
18 changes: 17 additions & 1 deletion scripts/prove/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ path = "bin/multi.rs"
name = "agg"
path = "bin/agg.rs"

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

[dependencies]

# workspace
Expand All @@ -26,23 +30,35 @@ dotenv.workspace = true
csv.workspace = true
tracing.workspace = true
cfg-if.workspace = true
serde_json.workspace = true

# local
op-succinct-host-utils.workspace = true
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-provider = { workspace = true, features = ["reqwest"] }
alloy-signer-local.workspace = true
alloy-sol-types.workspace = true
alloy-transport-http = { workspace = true, features = [
"reqwest",
"reqwest-native-tls",
] }

# sp1
sp1-sdk.workspace = true

[dev-dependencies]
reqwest = { version = "0.12.4", features = ["json"] }
serde_json.workspace = true
rustls = { version = "0.23", features = ["ring"] }

[build-dependencies]
Expand Down
Loading
Loading