Welcome to the CRISP project! This document provides a comprehensive guide to setting up and deploying the application both locally. Follow the steps carefully to ensure that all dependencies, services, and components are properly configured.
CRISP/packages
├── /client/
│ ├── /libs/wasm/pkg/ - WebAssembly library package
│ ├── /public/ - Static files
│ ├── /src/ - React components and source code
│ └── [configuration files and README]
├── /compute_provider/ - Helper library for RISC Zero compute provider
├── /risc0/ - RISC Zero zkVM and Verifier contracts
├── /server/ - Rust server-side logic
└── /web-rust/ - Rust to WebAssembly logic
Before getting started, make sure you have the following tools installed:
- Rust
- Foundry
- RISC Zero toolchain
- Node.js (for client-side dependencies)
- Anvil (for local testnet)
You need to install Rust and Foundry first. After installation, restart your terminal.
# Install Rust
curl https://sh.rustup.rs -sSf | sh
# Install Foundry
curl -L https://foundry.paradigm.xyz | bash
Next, install rzup
for the cargo-risczero
toolchain.
# Install rzup
curl -L https://risczero.com/install | bash
# Install RISC Zero toolchain
rzup
Verify the installation was successful by running:
cargo risczero --version
At this point, you should have all the tools required to develop and deploy an application with RISC Zero.
To set up the CRISP dApp in your local environment, follow these steps:
-
Clone the repository:
git clone https://github.com/gnosisguild/CRISP.git
-
Navigate to the
client
directory:cd CRISP/packages/client
-
Install dependencies:
yarn install
-
Start the development server:
yarn dev
Setting up the CRISP server involves several components, but this guide will walk you through each step.
anvil
Keep Anvil running in the terminal, and open a new terminal for the next steps.
-
Clone the Enclave Repo:
git clone https://github.com/gnosisguild/enclave.git
-
Navigate to the
evm
directory:cd enclave/packages/evm
-
Install dependencies:
yarn install
-
Deploy the contracts on the local testnet:
yarn deploy:mocks --network localhost
After deployment, note down the addresses for the following contracts:
- Enclave
- Ciphernode Registry
- Naive Registry Filter
- Mock Input Validator
-
Navigate to the
CRISP/packages/risc0
directory. -
Set up environment variables by creating a
.cargo
directory andconfig.toml
file:mkdir .cargo && cd .cargo && touch config.toml
-
Add the following configuration to
config.toml
:Note: This requires having access to a Bonsai API Key. To request an API key complete the form here.
[env] BONSAI_API_KEY="your_api_key" BONSAI_API_URL="your_api_url"
-
In the
risc0/script
directory, update theconfig.toml
with the deployed contract addresses:[profile.custom] chainId = 31337 riscZeroVerifierAddress = "0x0000000000000000000000000000000000000000" enclaveAddress = "your_enclave_address" inputValidatorAddress = "your_input_validator_address"
-
Export the ETH_WALLET_PRIVATE_KEY environment variable:
export ETH_WALLET_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" # Anvil's default private key
-
Deploy the contracts:
forge script --rpc-url http://localhost:8545 --broadcast script/Deploy.s.sol
Note down the CRISPRisc0 Contract Address, which will be used as the E3 Program Address.
Create a .env
file in the server
directory with the following:
CRON_API_KEY=your_cron_api_key # Optional for e3_cron binary
PRIVATE_KEY=your_private_key
HTTP_RPC_URL=http://localhost:8545
WS_RPC_URL=ws://localhost:8546
CHAIN_ID=your_chain_id
ENCLAVE_ADDRESS=your_enclave_contract_address
E3_PROGRAM_ADDRESS=your_e3_program_address # CRISPRisc0 Contract Address
CIPHERNODE_REGISTRY_ADDRESS=your_ciphernode_registry_address
NAIVE_REGISTRY_FILTER_ADDRESS=your_naive_registry_filter_address
# E3 Config
E3_WINDOW_SIZE=600
E3_THRESHOLD_MIN=1
E3_THRESHOLD_MAX=2
E3_DURATION=600
# E3 Compute Provider Config
E3_COMPUTE_PROVIDER_NAME="RISC0"
E3_COMPUTE_PROVIDER_PARALLEL=false
E3_COMPUTE_PROVIDER_BATCH_SIZE=4 # Must be a power of 2
In the root enclave
directory, you have to run the Ciphernodes. To run 4 Ciphernodes, use the provided script run_ciphernodes.sh
. Ensure you run the script from the root enclave
directory to set the environment variables correctly:
./run_ciphernodes.sh
After starting the Ciphernodes, run the aggregator with the script run_aggregator.sh
:
./run_aggregator.sh
Once the aggregator is running, you can add the Ciphernodes to the registry with the script add_ciphernodes.sh
:
./add_ciphernodes.sh
To run the CRISP Server, navigate to the server
directory and execute the following command:
cargo run --bin server
Once the CLI client is running, you can interact with the CRISP voting protocol by following these steps:
-
Select
CRISP: Voting Protocol (ETH)
from the menu. -
To initiate a new CRISP round, choose the option
Initialize new CRISP round
.
Ensure all services are running correctly and that components are communicating as expected before starting a new CRISP round.
We welcome and encourage community contributions to this repository. Please ensure that you read and understand the Contributor License Agreement (CLA) before submitting any contributions.
This project is provided WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This repository is licensed under the LGPL-3.0+ license.