Skip to content

kroma-network/kroma-sp1-prover

Repository files navigation

Kroma SP1 Prover

This project provides WitnessGenerator and ProverProxy for users attempting to assert the validity of a specific block on Optimism.

Since the order of all transactions included in an Optimism block is finalized when they are uploaded to L1, verifying the validity of an L2 block starts with downloading the transactions it includes from L1 and then executing them. This procedure, known as the derivation process, utilizes the Kona implementation.

SuccinctLab’s SP1 offers a Network Prover that generates execution proofs for general Rust program (Guest program). The ProverProxy includes a client for the SP1 Network Prover, requests proof generation from the Network Prover using the input generated by the WitnessGenerator, and caches the generated proof in the database.

Run a Witness Generator

Environment Variables

The 4 RPC endpoints must be set to run WitnessGenerator. It is recommended to fill in the following environment variables in the .env file.

L1_RPC=
L1_BEACON_RPC=
L2_RPC=
L2_NODE_RPC=

Run

> cargo run --bin witness-gen-server --release -- --endpoint <IP_WITH_PORT> --data <DB_PATH>
# example
> cargo run --bin witness-gen-server --release -- --endpoint 127.0.0.1:3030 --data /data/witness_store

API Overview

requestWitness method

Register a request to generate a witness.

{
    "jsonrpc": "2.0",
    "method": "requestWitness",
    "params": [<0xL2Hash>, <0xL1HeadHash>],
    "id": 0
}

getWitness method

It returns the witness after finishing to generate it.

{
    "jsonrpc": "2.0",
    "method": "getWitness",
    "params": [<0xL2Hash>, <0xL1HeadHash>],
    "id": 0
}

Run a Prover Proxy

Environment Variables

The API key issued by SP1 team must be set to run ProverProxy. It is recommended to fill in the following environment variables in the .env file

SP1_PRIVATE_KEY=

Run

> cargo run --bin prover-proxy --release -- --endpoint <IP_WITH_PORT> --data <DB_PATH>
# example
> cargo run --bin prover-proxy --release -- --endpoint 127.0.0.1:3030 --data /data/proof_store

API Overview

requestProve method

Register a request to generate a proof.

{
    "jsonrpc": "2.0",
    "method": "requestProve",
    "params": [<0xL2Hash>, <0xL1HeadHash>, <WitnessFromWitnessGenerator>],
    "id": 0
}

getProof method

It returns the witness after finishing to generate it.

{
    "jsonrpc": "2.0",
    "method": "getProof",
    "params": [<0xL2Hash>, <0xL1HeadHash>],
    "id": 0
}

Run a script

Preview script

This script provides a general context corresponding to the specific l2 block in advance.

> cargo run --release --bin script -- --method preview --l2-block <L2Number>
# - output_root: <OutputRootAtTheL2Block>
# - parent_output_root: <OutputRootAtThePreviousL2Block>
# - l1_origin_hash: <L1OriginBlockHashOfTheL2Block>
# - l1_origin_number: <L1OriginBlockNumberOfTheL2Block>
# - l1_head_number: <L1OriginBlockNumberOfTheL2Block> + 300

Execute script

Execute the specific l2 block.

> cargo run --release --bin script -- --method execute --l2-block <L2Number> --l1-head-number <L2HeadNumber>

# Or
> cargo run --release --bin script -- --method execute --l2-block <L2Number> --l1-head-hash <L2HeadHash>

Integration Test

The test-client generates a Witness through the WitnessGenerator and creates a proof through the ProverProxy. Finally, the proof is verified in the Verifier Contract.

> just run-integration-tests <0xL2Hash> <0xL1HeadHash>

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published