Skip to content

Commit d003201

Browse files
authored
infra(aggregation_mode): add Risc0 setup (#1898)
1 parent c8ace7b commit d003201

File tree

7 files changed

+62
-13
lines changed

7 files changed

+62
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ verify_aggregated_proof_risc0_holesky_stage:
200200
--rpc_url https://ethereum-holesky-rpc.publicnode.com
201201

202202
install_aggregation_mode: ## Install the aggregation mode with proving enabled
203-
cargo install --path aggregation_mode --features prove
203+
cargo install --path aggregation_mode --features prove,gpu
204204

205205
_AGGREGATOR_:
206206

infra/aggregation_mode/aggregation_mode.service

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ After=network.target
66
Type=oneshot
77
WorkingDirectory=/home/user
88
ExecStartPre=sleep 60
9-
ExecStart=/home/user/.cargo/bin/proof_aggregator /home/user/config/config-proof-aggregator.yaml
10-
Environment="SP1_PROVER=cuda"
9+
ExecStart=/home/user/run.sh
1110

1211
[Install]
1312
WantedBy=multi-user.target

infra/aggregation_mode/aggregation_mode.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ curl -L https://sp1.succinct.xyz | bash
8282
source $HOME/.bashrc
8383
sp1up
8484

85+
# Install Risc0
86+
curl -L https://risczero.com/install | bash
87+
source $HOME/.bashrc
88+
rzup install
89+
8590
# Install cast
8691
curl -L https://foundry.paradigm.xyz | bash
8792
source $HOME/.bashrc
@@ -95,14 +100,21 @@ mkdir -p ~/.keystores
95100
# Create keystore
96101
cast wallet import proof_aggregation.keystore -k $HOME/.keystores -i
97102

98-
# Create config file interactively
99-
./infra/aggregation_mode/config_file.sh ./infra/aggregation_mode/config-proof-aggregator.template.yaml
100-
touch $HOME/config/proof-aggregator.last_aggregated_block.json
101-
read -p "Enter a number (last_aggregated_block): " num && echo "{\"last_aggregated_block\":$num}" > $HOME/config/proof-aggregator.last_aggregated_block.json
103+
# Create config file for SP1
104+
./infra/aggregation_mode/config_file.sh ./infra/aggregation_mode/config-proof-aggregator-sp1.template.yaml $HOME/config/config-proof-aggregator-sp1.yaml
105+
read -p "Enter a block number for SP1 (last_aggregated_block): " num && echo "{\"last_aggregated_block\":$num}" > $HOME/config/proof-aggregator-sp1.last_aggregated_block.json
106+
107+
# Create config file for Risc0
108+
./infra/aggregation_mode/config_file.sh ./infra/aggregation_mode/config-proof-aggregator-risc0.template.yaml $HOME/config/config-proof-aggregator-risc0.yaml
109+
read -p "Enter a block number for Risc0 (last_aggregated_block): " num && echo "{\"last_aggregated_block\":$num}" > $HOME/config/proof-aggregator-risc0.last_aggregated_block.json
102110

103111
# Build the proof_aggregator
104112
make install_aggregation_mode
105113

114+
# Copy run script
115+
cp ./infra/aggregation_mode/run.sh $HOME/run.sh
116+
chmod 744 $HOME/run.sh
117+
106118
# Setup systemd service
107119
cp ./infra/aggregation_mode/aggregation_mode.service $HOME/.config/systemd/user/aggregation_mode.service
108120
cp ./infra/aggregation_mode/aggregation_mode.timer $HOME/.config/systemd/user/aggregation_mode.timer
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
aligned_service_manager_address: <aligned_service_manager_address>
2+
proof_aggregation_service_address: <proof_aggregation_service_address>
3+
eth_rpc_url: <eth_rpc_url>
4+
eth_ws_url: <eth_ws_url>
5+
max_proofs_in_queue: 1000
6+
last_aggregated_block_filepath: /home/user/config/proof-aggregator-risc0.last_aggregated_block.json
7+
8+
ecdsa:
9+
private_key_store_path: <private_key_store_path>
10+
private_key_store_password: <private_key_store_password>

infra/aggregation_mode/config-proof-aggregator.template.yaml renamed to infra/aggregation_mode/config-proof-aggregator-sp1.template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ proof_aggregation_service_address: <proof_aggregation_service_address>
33
eth_rpc_url: <eth_rpc_url>
44
eth_ws_url: <eth_ws_url>
55
max_proofs_in_queue: 1000
6-
last_aggregated_block_filepath: ~/config/proof-aggregator.last_aggregated_block.json
6+
last_aggregated_block_filepath: /home/user/config/proof-aggregator-sp1.last_aggregated_block.json
77

88
ecdsa:
99
private_key_store_path: <private_key_store_path>

infra/aggregation_mode/config_file.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
#!/bin/bash
22

3+
# This script creates a configuration file for the proof aggregator
4+
5+
# PARAMETERS
6+
#
7+
# TEMPLATE_FILE: Path to the template file
8+
# - SP1: ./infra/aggregation_mode/config-proof-aggregator-sp1.template.yaml
9+
# - Risc0: ./infra/aggregation_mode/config-proof-aggregator-risc0.template.yaml
10+
#
11+
# OUTPUT_FILE: Path to the output file
12+
# - SP1: $HOME/config/config-proof-aggregator-sp1.yaml
13+
# - Risc0: $HOME/config/config-proof-aggregator-risc0.yaml
14+
315
# Check if template file path is provided as argument
4-
if [ $# -ne 1 ]; then
5-
echo "Usage: $0 <template_file_path>"
16+
if [ $# -ne 2 ]; then
17+
echo "Usage: $0 <template_file_path> <output_file>"
618
exit 1
719
fi
820

921
TEMPLATE_FILE="$1"
22+
OUTPUT_FILE="$2"
1023

1124
# Verify template file exists
1225
if [ ! -f "$TEMPLATE_FILE" ]; then
@@ -36,12 +49,12 @@ prompt_and_replace "<private_key_store_path>" "ECDSA Private Key Store Path (~/.
3649
prompt_and_replace "<private_key_store_password>" "ECDSA Private Key Store Password"
3750

3851
# Create destination directory if it doesn't exist
39-
mkdir -p /home/user/config
52+
mkdir -p $HOME/config
4053

4154
# Copy the completed file to destination
42-
cp "$TEMP_FILE" $HOME/config/config-proof-aggregator.yaml
55+
cp "$TEMP_FILE" "$OUTPUT_FILE"
4356

4457
# Clean up temporary file
4558
rm "$TEMP_FILE"
4659

47-
echo "Configuration file has been created and copied to $HOME/config/config-proof-aggregator.yaml"
60+
echo "Configuration file has been created and copied to $OUTPUT_FILE"

infra/aggregation_mode/run.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
SLEEP=5
4+
5+
echo "Starting Aggregation Mode in $SLEEP seconds..."
6+
sleep $SLEEP
7+
8+
echo "Starting SP1 Aggregation Mode..."
9+
AGGREGATOR=sp1 SP1_PROVER=cuda /home/user/.cargo/bin/proof_aggregator /home/user/config/config-proof-aggregator-sp1.yaml
10+
docker stop $(docker ps -a -q) ## stop all containers
11+
echo "SP1 Aggregation Mode finished"
12+
13+
echo "Starting Risc0 Aggregation Mode..."
14+
AGGREGATOR=risc0 /home/user/.cargo/bin/proof_aggregator /home/user/config/config-proof-aggregator-risc0.yaml
15+
echo "Risc0 Aggregation Mode finished"

0 commit comments

Comments
 (0)