You can review the scripts/blobstream_example/e2e_blobstream_inclusion.sh script to understand the end-to-end process in the example, but here it is broken down:
Preliminaries
Start by building the project.
cd contracts
npm install
npm run build
cd ..
Next, navigate to the scripts directory and create a new directory inside it where the end-to-end process will run.
cd scripts
mkdir run-e2e
Set environment variables for WORK_DIR as a relative path within the scripts directory to the directory for the end-to-end process, and set RUN_DIR as the fully-qualified path to the same directory. SetBLOB_DIR as the fully-qualified path to the blob-stream-inclusion repo directory where your SP1 proofs were generated.
To prove the verification of the SP1 blobstream proof in o1js, we start by setting up the environment with the verification keys and public inputs of the SP1 blobstream proof. This can be done with the contracts/src/blobstream/sp1_to_env.ts script.
This script does the following to set environment variables inside the $RUN_DIR/env.blobstream file:
gets the public values from the SP1 proof, converts them to hex, and puts the result inHEX_PI
gets the program verifier key from the first public input in the SP1 proof and puts it in PROGRAM_VK
gets the hex-encoded SP1 proof, prepends it with 8 bytes of 0s and puts it in HEX_PROOF
setsWORK_DIR and CACHE_DIR to be used when we execute the proofs in the next step.
Now we're ready to run the PLONK proof:
./e2e_plonk.sh $RUN_DIR/env.blobstream
This can take ~15 minutes. The output should look something like this:
...
Compiling recursion vks...
(node:15995) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Recursion vks compiled successfully
Computing ZKPs 0-23...
valid zkp23?: true
valid zkp6?: true
valid zkp16?: true
valid zkp12?: true
valid zkp18?: true
valid zkp8?: true
valid zkp3?: true
valid zkp13?: true
valid zkp14?: true
valid zkp0?: true
valid zkp17?: true
valid zkp21?: true
valid zkp4?: true
valid zkp20?: true
valid zkp1?: true
valid zkp15?: true
valid zkp22?: true
valid zkp9?: true
valid zkp19?: true
valid zkp10?: true
valid zkp11?: true
valid zkp2?: true
valid zkp5?: true
valid zkp7?: true
Computed ZKPs 0-23...
Compressing layer 1...
layer: 1 node: 6 written
layer: 1 node: 10 written
layer: 1 node: 4 written
layer: 1 node: 1 written
layer: 1 node: 8 written
layer: 1 node: 5 written
layer: 1 node: 3 written
layer: 1 node: 9 written
layer: 1 node: 2 written
layer: 1 node: 0 written
layer: 1 node: 11 written
layer: 1 node: 14 written
layer: 1 node: 7 written
layer: 1 node: 13 written
layer: 1 node: 12 written
layer: 1 node: 15 written
Compressed layer 1...
Compressing layer 2...
layer: 2 node: 5 written
layer: 2 node: 4 written
layer: 2 node: 0 written
layer: 2 node: 1 written
layer: 2 node: 2 written
layer: 2 node: 6 written
layer: 2 node: 3 written
layer: 2 node: 7 written
Compressed layer 2...
Compressing layer 3...
layer: 3 node: 0 written
layer: 3 node: 3 written
layer: 3 node: 2 written
layer: 3 node: 1 written
Compressed layer 3...
Compressing layer 4...
layer: 4 node: 0 written
layer: 4 node: 1 written
Compressed layer 4...
Compressing layer 5...
layer: 5 node: 0 written
Compressed layer 5...
Done!
All of the execution data is saved in a new directory in $RUN_DIR/blobstream. The final proof is found at $RUN_DIR/blobstream/e2e_plonk/plonk/recursion/proofs/layer5/p0.json.
Convert the SP1 blob inclusion proof
For converting the blob inclusion proof, we'll follow the same environment setup process as above with slightly modified parameters.
With the env.blobInclusion file created, we can run the Plonk proof to convert our SP1 blob inclusion proof:
./e2e_plonk.sh $RUN_DIR/env.blobInclusion
This can take ~15 minutes. The output should look the same as the blobstream proof conversion from the previous section.
All of the execution data is saved in a new directory in $RUN_DIR/blobInclusion. The final proof is found at $RUN_DIR/blobInclusion/e2e_plonk/plonk/recursion/proofs/layer5/p0.json.
Run the rollup contract example
Set up the environment
The verification scripts contracts/src/blobstream/verify_blobstream.ts and contracts/src/blobstream/verify_blob_inclusion.ts get these values from environment variables which can be set as follows:
Deploying Blobstream Processor...
Deploying Rollup...
Setting Blobstream address...
updating blobstream state
Successfully updated the rollup state while showing blob inclusion!
In order to prove the verification of the o1js proofs that verified the SP1 proofs in the previous step, the verifier keys for both SP1 programs are needed. The verifier key for the final compressed proof from the o1js proof & compression process above is also required. It's obtained from the public outputs of the layer 5 proof. (See the of this flow for more detail about the proof compression.)