SP1 Blobstream
Overview
SP1 Blobstream is an implementation of Blobstream X in Rust for the SP1 zkVM.
/program
: The SP1 Blobstream program./primitives
: Libraries for types and helper functions used in the program./script
: Scripts for getting the contract's genesis parameters and deploying the operator to update the light client./contracts
: The contract's source code and deployment scripts. Backwards-compatible with the original BlobstreamX implementation in case we need to upgrade.
Components
An SP1 Blobstream implementation has a few key components:
- An
SP1Blobstream
contract. Contains the logic for verifying SP1 Blobstream proofs, storing the latest data from the Celestia chain, including the headers and data commitments. Matches the interface of the existing BlobstreamX contract so it can be upgraded in-place. - An
SP1Verifier
contract. Verifies arbitrary SP1 programs. Most chains will have canonical deployments upon SP1's mainnet launch. Until then, users can deploy their ownSP1Verifier
contracts to verify SP1 programs on their chain. The SP1 Blobstream implementation will use theSP1Verifier
contract to verify the proofs of the SP1 Blobstream programs. - The SP1 Blobstream program. An SP1 program that verifies the transition between two Tendermint headers and computes the data commitment of the intermediate blocks.
- The operator. A Rust script that fetches the latest data from a deployed
SP1Blobstream
contract and a Tendermint chain, determines the block to request, requests for/generates a proof, and relays the proof to theSP1Blobstream
contract.
Quick Start
This guide will walk you through deploying the SP1 Blobstream contract and running the operator.
Deploying SP1 Blobstream
-
To deploy an SP1 Blobstream contract for a Tendermint chain do the following.
Get the genesis parameters for the
SP1Blobstream
contract.cd script # Example with Celestia Mocha-4 Testnet. TENDERMINT_RPC_URL=https://rpc.lunaroasis.net/ cargo run --bin genesis --release
-
Deploy the
SP1Blobstream
contract with genesis parameters:GENESIS_HEIGHT
,GENESIS_HEADER
, andSP1_BLOBSTREAM_PROGRAM_VKEY
.cd ../contracts forge install GENESIS_HEIGHT=<GENESIS_HEIGHT> GENESIS_HEADER=<GENESIS_HEADER> SP1_BLOBSTREAM_PROGRAM_VKEY=<SP1_BLOBSTREAM_PROGRAM_VKEY> forge script script/Deploy.s.sol --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> --etherscan-api-key <ETHERSCAN_API_KEY> --broadcast --verify
If you see the following error, add
--legacy
to the command.Error: Failed to get EIP-1559 fees
-
Your deployed contract address will be printed to the terminal.
== Return == 0: address <SP1_BLOBSTREAM_ADDRESS>
This will be used when you run the operator in step 5.
-
Export your SP1 Prover Network configuration
# Export the PRIVATE_KEY you will use to relay proofs. export PRIVATE_KEY=<PRIVATE_KEY> # Optional # If you're using the Succinct network, set SP1_PROVER to "network". Otherwise, set it to "local" or "mock". export SP1_PROVER={network|local|mock} # Only required if SP1_PROVER is set "network". export SP1_PRIVATE_KEY=<SP1_PRIVATE_KEY>
-
Run the SP1 Blobstream operator to update the LC continuously.
cd ../script TENDERMINT_RPC_URL=https://rpc.celestia-mocha.com/ CHAIN_ID=11155111 RPC_URL=https://ethereum-sepolia.publicnode.com/ CONTRACT_ADDRESS=<SP1_BLOBSTREAM_ADDRESS> cargo run --bin operator --release
Reproducible Builds
Overview
When deploying SP1 Blobstream in production, it's important to ensure that the program used when generating proofs is reproducible.
Prerequisites
You first need to install the cargo prove toolchain.
Ensure that you have the latest version of the toolchain by running:
sp1up
Confirm that you have the toolchain installed by running:
cargo prove --version
Verify the SP1 Blobstream binary
To build the SP1 Blobstream binary, first ensure that Docker is running.
docker ps
Then build the binaries:
cd program
# Builds the SP1 Blobstream binary using the corresponding Docker tag, output directory and ELF name.
cargo prove build --docker --tag v3.0.0 --output-directory ../script --elf-name blobstream-elf
Now, verify the binaries by confirming the output of vkey
matches the vkeys on the contract. The vkey
program outputs the verification key
based on the ELF in /elf
.
cargo run --bin vkey --release
Costs Script
The costs script allows you to query the costs of the SP1 Blobstream relayer for a given month.
Usage
Run the script with the following arguments:
Arguments:
from-address
: Source wallet address (0x...)ethereum-rpc
: Ethereum RPC endpoint URLbase-rpc
: Base RPC endpoint URLarbitrum-rpc
: Arbitrum RPC endpoint URLmonth
: Month number (1-12)year
: Year (e.g. 2023)
How it works:
- The script creates a filter to get the
HeadUpdate
logs emitted by the SP1Blobstream contract, which are emitted whenever a data commitment is posted. - It then queries each chain's node for all the logs that match the filter.
- For each log, it gets the transaction receipt.
- It sums up the gas used and the effective gas price to get the total fees paid.
- It prints out the total fees paid in ETH for each chain.
Example:
cargo run --bin costs -- \
--from-address 0x123... \
--ethereum-rpc https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY \
--base-rpc https://base-mainnet.g.alchemy.com/v2/YOUR-API-KEY \
--arbitrum-rpc https://arbitrum-mainnet.g.alchemy.com/v2/YOUR-API-KEY \
--month 10 \
--year 2024
Writing 252 transactions to filtered_transactions/1-10-0x44eB418A966ff47f5AF6f48AEa6Afde0bf193a8d-0x7Cf3876F681Dbb6EdA8f6FfC45D66B996Df08fAe.csv
0x44eB418A966ff47f5AF6f48AEa6Afde0bf193a8d paid 1.5476 ETH sending transactions to 0x7Cf3876F681Dbb6EdA8f6FfC45D66B996Df08fAe during month 10
Current Relayer Configuration
0x44eB418A966ff47f5AF6f48AEa6Afde0bf193a8d
is the address of the approved relayer that posts data commitments.
Blobstream Deployments
You can interact with the SP1 Blobstream contracts today. The SP1 Blobstream Solidity smart contracts are currently deployed on the following chains:
Network | Chain ID | Contract Address |
---|---|---|
Ethereum | 1 | 0x7Cf3876F681Dbb6EdA8f6FfC45D66B996Df08fAe |
Base | 8453 | 0xA83ca7775Bc2889825BcDeDfFa5b758cf69e8794 |
Arbitrum | 42161 | 0xA83ca7775Bc2889825BcDeDfFa5b758cf69e8794 |
Holesky | 17000 | 0x315A044cb95e4d44bBf6253585FbEbcdB6fb41ef |
Sepolia | 11155111 | 0xF0c6429ebAB2e7DC6e05DaFB61128bE21f13cb1e |
Arbitrum Sepolia | 421614 | 0xc3e209eb245Fd59c8586777b499d6A665DF3ABD2 |
Base Sepolia | 84532 | 0xc3e209eb245Fd59c8586777b499d6A665DF3ABD2 |
The most up-to-date version of the contract addresses can be found here.
Known Limitations
Warning: The implementation of SP1 Blobstream assumes that the number of validators is less than
256. This limitation is due to the use of a 256-bit bitmap to represent whether a validator has
signed off on a header. If the number of validators exceeds 256, the validatorBitmap
functionality
may not work as intended, potentially leading to an incomplete validator equivocation.
On Celestia, the number of validators is currently 100, and there are no plans to increase this number significantly. If it was to be increased, the signature aggregation logic in the consensus protocol would likely change as well, which would also necessitate a change in the SP1 Blobstream implementation.