Deploy SP1 Prover
Prerequisites
- Machine with CUDA support
- L1 Accounts with funds (One for the Prover, One for Prover Registry)
- L1 RPC URL
- L1 Account Private Key
Overview
Set up Docker, CUDA, CUDA Container Toolkit and other dependencies to run SP1 prover on an x86 machine. For more information, refer to the Succinct Documentation.
Install Docker
Follow the official Docker documentation for installation steps.
Allow Running Docker Without sudo
- Add your user to the
docker
group:sudo usermod -aG docker $USER
- Apply the changes to the user group:
newgrp docker
- Verify that Docker works without sudo:
docker ps
Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
sudo reboot
Install sccache
cargo install sccache
Install gcc-12
sudo apt install gcc-12
cd /usr/bin
sudo rm gcc
sudo ln -s gcc-12 gcc
gcc --version
Install g++-12
sudo apt install g++-12
sudo rm g++
sudo ln -s g++-12 g++
g++ --version
Install openssl
sudo apt-get install libssl-dev
Install package-config
sudo apt install pkg-config
Uninstall Existing CUDA (optional)
Reference: NVIDIA CUDA Installation Guide - Handle Conflicting Installation Methods
Uninstall a Toolkit runfile installation
Use the following command to uninstall a Toolkit runfile installation:
sudo /usr/local/cuda-X.Y/bin/cuda-uninstaller
Steps to Uninstall CUDA
- Stop NVIDIA Persistenced Service (if running):
sudo service nvidia-persistenced stop
- Remove CUDA Toolkit:
sudo apt-get --purge remove "*cublas*" "cuda*" "nsight*"
- Remove NVIDIA Drivers:
sudo apt-get --purge remove "*nvidia*"
- Remove Source File Installations (if applicable): Assuming the default installation location is /usr/local, remove it using:
sudo rm -rf /usr/local/cuda*
Install CUDA
Refer to the CUDA Quick Start Guide for more information.
-
Download the CUDA installer:
wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda_12.6.2_560.35.03_linux.run
-
Run the installer:
sudo sh cuda_12.6.2_560.35.03_linux.run
-
If you encounter an error, the installer will create a file at:
/etc/modprobe.d/nvidia-installer-disable-nouveau.conf
-
Reboot the system:
sudo reboot
-
After rebooting, rerun the installer:
sudo sh cuda_12.6.2_560.35.03_linux.run
-
Verify CUDA installation:
ls /usr/local/ | grep cuda
-
Add environment variables: Open the
.bashrc
file:nano ~/.bashrc
Append the following lines to the end of the file:
export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH" -
Apply the changes:
source ~/.bashrc
Installing the NVIDIA Container Toolkit
Refer to the NVIDIA Documentation
Installing with Apt
-
Configure the production repository:
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
-
Optionally, configure the repository to use experimental packages:
sed -i -e '/experimental/ s/^#//g' /etc/apt/sources.list.d/nvidia-container-toolkit.list
-
Update the packages list from the repository:
sudo apt-get update
-
Install the NVIDIA Container Toolkit packages:
sudo apt-get install -y nvidia-container-toolkit
Configuring Docker
-
Configure the container runtime by using the
nvidia-ctk
command:sudo nvidia-ctk runtime configure --runtime=docker
The
nvidia-ctk
command modifies the/etc/docker/daemon.json
file on the host. The file is updated so that Docker can use the NVIDIA Container Runtime. -
Restart the Docker daemon:
sudo systemctl restart docker
Pull Raiko
git clone https://github.com/NethermindEth/raiko.git
cd raiko
git checkout sp1-main
cargo --version
Install Raiko with SP1
Install Raiko with the SP1 target:
TARGET=sp1 make install
Build SP1 Program
Run the following command:
cargo +nightly-2024-04-18 run --release --bin sp1-builder -F raiko-tasks/in-memory
You will get the programVKey
from the output of that call.
Setup Program VK Key for the SP1 Verifier Contract
Run the following command:
cast send <SP1_VERIFIER> "setProgramTrusted(bytes32,bool)" <PROGRAM_VK> true --rpc-url <L1_RPC_URL> --private-key <PRIVATE_KEY>
Set Chain Spec
Edit the file located at:
raiko/host/config/chain_spec_list_default.json
Set the values according to your chain configuration.
Build Raiko
Run the following command:
cargo +nightly-2024-04-18 build --release --features sp1 -F raiko-tasks/in-memory
Run Raiko
Set the required environment variables:
export SP1_VERIFIER_RPC_URL=http://139.162.249.67:32002
export SP1_VERIFIER_ADDRESS=0x9c63682FC2d397Aa47471c046cE57b095d7195D7
Run Raiko in the background:
nohup ./target/release/raiko-host --chain-spec-path=</full/path/to/chain_spec_list_default.json> > ~/log/output.log 2>&1 &
Check Logs
View the log output:
cat ~/log/output.log