Validator Node is a component of the Protocol written in Rust that leverages the RISC Zero libraries for generating Zero-Knowledge (ZK) proofs.
The Validator Node monitors the DdexSequencer smart contract. When new information about a BLOB being enqueued in the DdexSequencer is detected, the node downloads the BLOB from the Beacon Chain, decodes it, extracts DDEX messages, and validates each message. After validation, the node extracts key data from the messages. The validation and extraction processes run inside RISC Zero guest code (ZK proving system).
The output of the RISC Zero guest code includes both a cryptographic proof and key data extracted from the messages. This output is sent back to the DdexSequencer, where the proof is validated on-chain, and the extracted data is emitted as blockchain events.
Producing RISC Zero ZK proofs requires a significant amount of computational power. You can run the system in either CPU mode or GPU mode. While CPU mode is compatible with most Linux PCs, GPU mode requires an Nvidia GPU with at least 4GB of VRAM.
Minimum Configuration:
- CPU: 8+ core processor
- RAM: 16GB minimum
- Network: 100Mbps stable connection
- For GPU mode: Nvidia GPU with at least 4GB VRAM (optional but recommended)
notes on GPU mode:
To run this project on a GPU, you'll need a graphics card with sufficient memory.
- Minimum: at least 4GB of VRAM. However, using a GPU with this minimum memory requires modifying the code as described below and is very slow.
- Recommended: 8GB or more VRAM for better performance.
- Optimal: High-end GPUs with 24GB or more VRAM can achieve maximum performance with additional tweaks.
For running a binary file:
- Linux-based operating system
- For GPU mode: CUDA toolkit
- Install dependencies:
apt install curl build-essential libssl-dev git pkg-config npm - Rust - Can be installed with
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shand shell refreshed with. "$HOME/.cargo/env" - Foundry - Can be installed with:
curl -L https://foundry.paradigm.xyz | bash
source $HOME/.bashrc
foundryup- Install the RISC Zero Toolchain with:
curl -L https://risczero.com/install | bash
. "$HOME/.bashrc"
rzup install- Optional but recommended. To run with GPU you need the latest CUDA Toolkit.
- If running with NVIDIA GPU you will also need Risc Zero Local Proving
- when using rzup rememebr to install version that is same as risc0-zkvm found in Cargo.toml
- Clone the repo with its submodules and enter its folder
git clone --recursive https://github.com/originalworks/protocol-core && cd protocol-core
- Compile contracts with
cd contracts
forge build
npx hardhat compile
- Run cargo from validator folder
cd ../validator_nodeRun in CPU Mode
cargo run --releaseRun in GPU Mode:
cargo run --release -F cuda- Use a template to create your
.envfile:
cd validator_node
cp .env.template .env
- Update variables in your
.envfile:
PRIVATE_KEY: Your private key with funds on HoleskyRPC_URL: Your RPC endpoint URL pointing to HoleskyOUTPUT_FILES_DIR: Path were output files will be savedWS_URL: Your websocket endpoint pointing to HoleskyBEACON_RPC_URL: Beacon chain API url for Holesky networkSTART_BLOCK: Block from which your validator will start looking for new BLOBs to processSEGMENT_LIMIT_PO2: Please see next pointENVIRONMENT: Used for sentry loggingUSERNAME: Used for sentry loggingDDEX_SEQUENCER_ADDRESS: Used to set ddex sequencer address for testing purposes. When unset it defaults to hardcoded protocol sequencer.
Before running make sure that your validator node is properly configured for your GPU:
- For GPU with 4GB VRAM set
18(default). - For GPU with 8GB VRAM set
19. - For GPU with 24GB VRAM or higher for optimal performance set it to
0(turn it off). Alternatively, you can slightly increase the value to the highest one that your system supports, as determined through testing. - For CPU Mode (no GPU), its recommened to set
0to increase perfomance.
You can run ../setup_local.sh to prepare local environment. After using it remember to run validator with LOCAL=1 flag.
If you feel that your GPU should perform better, you can set NVCC flags to fine tune performance of your Nvidia GPU:
COMPUTE_CAP=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader | awk -F'.' '{print $1$2}')
export NVCC_APPEND_FLAGS="--gpu-architecture=compute_${COMPUTE_CAP} --gpu-code=compute_${COMPUTE_CAP},sm_${COMPUTE_CAP} --generate-code arch=compute_${COMPUTE_CAP},code=sm_${COMPUTE_CAP}"To run risc0 additional resources are required. Full installation guide can be found at https://dev.risczero.com/api/zkvm/install
Run npx hardhat compile from the contracts folder
To run the Validator Node with GPU support, you can build a custom Docker image optimized for your environment. Use the provided Dockerfile in /validator_node and run the container with GPU access.
Requirements Ensure your host machine has the following:
- Docker [link] https://docs.docker.com/engine/install/
- NVIDIA Container Toolkit: link
- NVIDIA driver with support of CUDA 12.8 (570.124.06 or higher)
Navigate to the /validator_node directory and run:
docker build -t validator-node-image .
Warning: Building GPU image may take up to few hours!!!
- Create a local folder for temporary files (must be root level):
sudo mkdir /docker-mnt
- Run the container with GPU support:
sudo docker run \
--runtime=nvidia \
--gpus all \
--privileged \
-it \
-v /docker-mnt:/docker-mnt \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
--rm \
validator-node-image:latest