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.
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=
> 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
Register a request to generate a witness.
{
"jsonrpc": "2.0",
"method": "requestWitness",
"params": [<0xL2Hash>, <0xL1HeadHash>],
"id": 0
}
It returns the witness after finishing to generate it.
{
"jsonrpc": "2.0",
"method": "getWitness",
"params": [<0xL2Hash>, <0xL1HeadHash>],
"id": 0
}
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=
> 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
Register a request to generate a proof.
{
"jsonrpc": "2.0",
"method": "requestProve",
"params": [<0xL2Hash>, <0xL1HeadHash>, <WitnessFromWitnessGenerator>],
"id": 0
}
It returns the witness after finishing to generate it.
{
"jsonrpc": "2.0",
"method": "getProof",
"params": [<0xL2Hash>, <0xL1HeadHash>],
"id": 0
}
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 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>
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>