forked from walirt/boundless-prover
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
441 lines (382 loc) · 14.9 KB
/
setup.sh
File metadata and controls
441 lines (382 loc) · 14.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
#!/bin/bash
SILENT_MODE=false
SKIP_CLI_TOOLS=false
while getopts "sc" opt; do
case $opt in
s)
SILENT_MODE=true
echo "Running in silent mode with default values..."
;;
c)
SKIP_CLI_TOOLS=true
echo "Skipping CLI tools installation..."
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo "Usage: $0 [-s] [-c]"
echo " -s: Silent mode (use default values without prompts)"
echo " -c: Skip CLI tools installation"
exit 1
;;
esac
done
apt update
apt install -y curl nvtop git supervisor build-essential pkg-config libssl-dev python3-dev
echo
echo "-----Installing rust-----"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
echo
echo "-----Installing rzup and RISC Zero toolchain-----"
curl -L https://risczero.com/install | bash
source $HOME/.bashrc
/root/.risc0/bin/rzup install
/root/.risc0/bin/rzup install risc0-groth16
echo
echo "-----Installing bento components-----"
apt install -y redis postgresql-16 adduser libfontconfig1 musl
wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20250613113347.0.0_amd64.deb -O minio.deb
dpkg -i minio.deb
curl -L "https://cancanneed.de/boundless/grafana-enterprise_11.0.0_amd64.deb" -o grafana-enterprise_11.0.0_amd64.deb
dpkg -i grafana-enterprise_11.0.0_amd64.deb
echo
echo "-----Downloading prover binaries-----"
mkdir /app
# Original v1.0.0 binaries
curl -L "https://cancanneed.de/boundless/v1.0.0/broker" -o /app/broker
curl -L "https://cancanneed.de/boundless/v1.0.0/broker-stress" -o /app/broker-stress
curl -L "https://cancanneed.de/boundless/v1.0.0/bento-agent-v1_0_1-cuda12_8" -o /app/agent
curl -L "https://cancanneed.de/boundless/v1.0.0/bento-rest-api" -o /app/rest_api
curl -L "https://cancanneed.de/boundless/v1.0.0/bento-cli" -o /root/.cargo/bin/bento_cli
# >>> Added new binaries (your request) <<<
curl -L "https://cancanneed.de/boundless/private/boundless-v1_0_1" -o /usr/local/bin/boundless
curl -L "https://cancanneed.de/boundless/private/boundless-ffi-v1_0_1" -o /usr/local/bin/boundless-ffi
curl -L "https://cancanneed.de/boundless/private/boundless-v1_0_1" -o /root/.cargo/bin/boundless
curl -L "https://cancanneed.de/boundless/private/boundless-ffi-v1_0_1" -o /root/.cargo/bin/boundless-ffi
curl -L "https://cancanneed.de/boundless/private/broker3.toml" -o /app/broker3.toml
# >>> End of added section <<<
chmod +x /app/agent
chmod +x /app/broker
chmod +x /app/broker-stress
chmod +x /app/rest_api
chmod +x /root/.cargo/bin/bento_cli
chmod +x /usr/local/bin/boundless
chmod +x /usr/local/bin/boundless-ffi
chmod +x /root/.cargo/bin/boundless
chmod +x /root/.cargo/bin/boundless-ffi
echo "-----Verifying /app files sha256sum-----"
declare -A FILES_SHA256
FILES_SHA256["/app/broker"]="216a792c4bb1444a0ce7a447ea2cad0b24e660601baa49057f77b37ac9f4ad74"
FILES_SHA256["/app/broker-stress"]="024d916463d8f24fb9d12857b6f1dbdc016f972e8d8b82434804e077e0fe6231"
FILES_SHA256["/app/agent"]="3be0a008af2ae2a9d5cfacbfbb3f75d4a4fd70b82152ae3e832b500ad468f5a0"
FILES_SHA256["/app/rest_api"]="02a0c87b3bfc1fd738d6714ee24fb32fbcb7887bfe46321c3eed2061c581a87a"
FILES_SHA256["/root/.cargo/bin/bento_cli"]="7af2fe49f75acf95e06476e55e6a91343c238b0cf5696d1cae80be54fcc17b45"
INTEGRITY_PASS=true
for file in "${!FILES_SHA256[@]}"; do
if [ ! -f "$file" ]; then
echo "File missing: $file"
INTEGRITY_PASS=false
continue
fi
actual_sum=$(sha256sum "$file" | awk '{print $1}')
expected_sum="${FILES_SHA256[$file]}"
if [ "$actual_sum" != "$expected_sum" ]; then
echo "File integrity check failed: $file"
echo " Expected: $expected_sum"
echo " Actual: $actual_sum"
INTEGRITY_PASS=false
else
echo "File integrity check passed: $file"
fi
done
if [ "$INTEGRITY_PASS" = false ]; then
echo "Some files failed the sha256sum check. Please verify file integrity and try again."
exit 1
else
echo "All files passed sha256sum integrity check."
fi
echo
echo "-----Copying config files-----"
git clone https://github.com/boundless-xyz/boundless.git
cd boundless
git checkout release-1.1
if [ "$SKIP_CLI_TOOLS" = false ]; then
git submodule update --init --recursive
cargo install --path crates/boundless-cli --locked boundless-cli
fi
cp -rf dockerfiles/grafana/* /etc/grafana/provisioning/
echo
echo "-----Generating supervisord configuration file-----"
nvidia-smi -L
if [ "$SILENT_MODE" = true ]; then
GPU_IDS=$(nvidia-smi --query-gpu=index --format=csv,noheader | tr '\n' ',' | sed 's/,$//')
echo "Using all available GPUs: $GPU_IDS"
else
read -p "Please input the GPU ID you need to run according to the printed GPU information (e.g. 0,1 default all): " GPU_IDS
if [ -z "$GPU_IDS" ]; then
GPU_IDS=$(nvidia-smi --query-gpu=index --format=csv,noheader | tr '\n' ',' | sed 's/,$//')
fi
fi
gpu_info=$(nvidia-smi --query-gpu=index,name,memory.total --format=csv,noheader)
MIN_SEGMENT_SIZE=22
while IFS=',' read -r index name memory; do
if ! echo "$GPU_IDS" | grep -q "$index"; then
continue
fi
memory_gb=$(echo "$memory" | tr -d ' MiB' | awk '{printf "%.2f", $1/1024}')
if (( $(awk -v mem="$memory_gb" 'BEGIN{print (mem<16)?1:0}') )); then
segment_size=19
elif (( $(awk -v mem="$memory_gb" 'BEGIN{print (mem<20)?1:0}') )); then
segment_size=20
elif (( $(awk -v mem="$memory_gb" 'BEGIN{print (mem<40)?1:0}') )); then
segment_size=21
else
segment_size=22
fi
if [ "$segment_size" -lt "$MIN_SEGMENT_SIZE" ]; then
MIN_SEGMENT_SIZE=$segment_size
fi
done <<< "$gpu_info"
echo "Based on GPU VRAM, the minimum SEGMENT_SIZE is: $MIN_SEGMENT_SIZE"
# Fixed to Base Mainnet only
NET_ID="3"
NETWORK_NAME="Base Mainnet"
echo "Configuration for Base Mainnet:"
if [ "$SILENT_MODE" = true ]; then
BASE_RPC="https://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY"
BASE_PRIVKEY="0x0000000000000000000000000000000000000000000000000000000000000000"
echo "Using default RPC for Base Mainnet: $BASE_RPC"
echo "Using default private key for Base Mainnet: $BASE_PRIVKEY"
echo "WARNING: Please update RPC URL and private key in the configuration files before starting services!"
else
read -p "Please input the Base Mainnet RPC URL: " BASE_RPC
read -p "Please input the Base Mainnet private key: " BASE_PRIVKEY
fi
POVW_LOG_ID=""
read -p "Please input the POVW Log ID: " POVW_LOG_ID
GPU_IDS_ARRAY=()
IFS=',' read -ra GPU_IDS_ARRAY <<< "$GPU_IDS"
GPU_AGENT_CONFIGS=""
for idx in "${!GPU_IDS_ARRAY[@]}"; do
GPU_ID_TRIM=$(echo "${GPU_IDS_ARRAY[$idx]}" | xargs)
GPU_AGENT_CONFIGS+="
[program:gpu_prove_agent${idx}]
command=/app/agent -t prove --redis-ttl 57600
directory=/app
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
priority=50
stdout_logfile=/var/log/gpu_prove_agent${idx}.log
redirect_stderr=true
environment=DATABASE_URL=\"postgresql://worker:password@localhost:5432/taskdb\",REDIS_URL=\"redis://localhost:6379\",S3_URL=\"http://localhost:9000\",S3_BUCKET=\"workflow\",S3_ACCESS_KEY=\"admin\",S3_SECRET_KEY=\"password\",RUST_LOG=\"info\",RUST_BACKTRACE=\"1\",CUDA_VISIBLE_DEVICES=\"${GPU_ID_TRIM}\",POVW_LOG_ID=\"${POVW_LOG_ID}\"
"
done
# Base Mainnet broker configuration
BROKER_CONFIGS="
[program:broker3]
command=/app/broker --db-url sqlite:///db/broker3.db --config-file /app/broker3.toml --bento-api-url http://localhost:8081
directory=/app
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10800
priority=60
stdout_logfile=/var/log/broker3.log
redirect_stderr=true
environment=RUST_LOG=\"info,broker=debug,boundless_market=debug\",PRIVATE_KEY=\"${BASE_PRIVKEY}\",RPC_URL=\"${BASE_RPC}\",POSTGRES_HOST=\"localhost\",POSTGRES_DB=\"taskdb\",POSTGRES_PORT=\"5432\",POSTGRES_USER=\"worker\",POSTGRES_PASS=\"password\"
"
cp broker-template.toml /app/broker3.toml
cat <<EOF >/etc/supervisor/conf.d/boundless.conf
[supervisord]
nodaemon=false
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid
loglevel=info
strip_ansi=true
[group:dependencies]
programs=redis,postgres,minio,grafana
[group:bento]
programs=exec_agent0,exec_agent1,aux_agent,rest_api
[group:broker]
programs=
[program:redis]
command=/usr/bin/redis-server --port 6379
directory=/data/redis
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
priority=10
stdout_logfile=/var/log/redis.log
redirect_stderr=true
environment=HOME="/data/redis"
[program:postgres]
command=/usr/lib/postgresql/16/bin/postgres -D /data/postgresql -c config_file=/etc/postgresql/16/main/postgresql.conf -p 5432
directory=/data/postgresql
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
priority=20
stdout_logfile=/var/log/postgres.log
redirect_stderr=true
environment=POSTGRES_DB="taskdb",POSTGRES_USER="worker",POSTGRES_PASSWORD="password"
user=postgres
[program:minio]
command=/usr/local/bin/minio server /data --console-address ":9001"
directory=/data/minio
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
priority=30
stdout_logfile=/var/log/minio.log
redirect_stderr=true
environment=MINIO_ROOT_USER="admin",MINIO_ROOT_PASSWORD="password",MINIO_DEFAULT_BUCKETS="workflow"
[program:grafana]
command=/usr/share/grafana/bin/grafana-server --homepath=/usr/share/grafana --config=/etc/grafana/grafana.ini
directory=/var/lib/grafana
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
priority=40
stdout_logfile=/var/log/grafana.log
redirect_stderr=true
environment=GF_SECURITY_ADMIN_USER="admin",GF_SECURITY_ADMIN_PASSWORD="admin",GF_LOG_LEVEL="WARN",POSTGRES_HOST="localhost",POSTGRES_DB="taskdb",POSTGRES_PORT="5432",POSTGRES_USER="worker",POSTGRES_PASSWORD="password",GF_INSTALL_PLUGINS="frser-sqlite-datasource"
[program:exec_agent0]
command=/app/agent -t exec --segment-po2 $MIN_SEGMENT_SIZE --redis-ttl 57600
directory=/app
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
priority=50
stdout_logfile=/var/log/exec_agent0.log
redirect_stderr=true
environment=DATABASE_URL="postgresql://worker:password@localhost:5432/taskdb",REDIS_URL="redis://localhost:6379",S3_URL="http://localhost:9000",S3_BUCKET="workflow",S3_ACCESS_KEY="admin",S3_SECRET_KEY="password",RUST_LOG="info",RUST_BACKTRACE="1",RISC0_KECCAK_PO2="17",POVW_LOG_ID="${POVW_LOG_ID}"
[program:exec_agent1]
command=/app/agent -t exec --segment-po2 $MIN_SEGMENT_SIZE --redis-ttl 57600
directory=/app
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
priority=50
stdout_logfile=/var/log/exec_agent1.log
redirect_stderr=true
environment=DATABASE_URL="postgresql://worker:password@localhost:5432/taskdb",REDIS_URL="redis://localhost:6379",S3_URL="http://localhost:9000",S3_BUCKET="workflow",S3_ACCESS_KEY="admin",S3_SECRET_KEY="password",RUST_LOG="info",RUST_BACKTRACE="1",RISC0_KECCAK_PO2="17",POVW_LOG_ID="${POVW_LOG_ID}"
[program:aux_agent]
command=/app/agent -t aux --monitor-requeue --redis-ttl 57600
directory=/app
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
priority=50
stdout_logfile=/var/log/aux_agent.log
redirect_stderr=true
environment=DATABASE_URL="postgresql://worker:password@localhost:5432/taskdb",REDIS_URL="redis://localhost:6379",S3_URL="http://localhost:9000",S3_BUCKET="workflow",S3_ACCESS_KEY="admin",S3_SECRET_KEY="password",RUST_LOG="info",RUST_BACKTRACE="1",POVW_LOG_ID="${POVW_LOG_ID}"
[program:rest_api]
command=/app/rest_api --bind-addr 0.0.0.0:8081 --snark-timeout 180
directory=/app
autostart=false
autorestart=true
startsecs=5
stopwaitsecs=10
priority=50
stdout_logfile=/var/log/rest_api.log
redirect_stderr=true
environment=DATABASE_URL="postgresql://worker:password@localhost:5432/taskdb",REDIS_URL="redis://localhost:6379",S3_URL="http://localhost:9000",S3_BUCKET="workflow",S3_ACCESS_KEY="admin",S3_SECRET_KEY="password",RUST_LOG="info",RUST_BACKTRACE="1",POVW_LOG_ID="${POVW_LOG_ID}"
EOF
cat <<EOF >>/etc/supervisor/conf.d/boundless.conf
$GPU_AGENT_CONFIGS
$BROKER_CONFIGS
EOF
GPU_AGENT_NAMES=$(echo "$GPU_AGENT_CONFIGS" | grep -oP '(?<=\[program:)[^]]+' | tr '\n' ' ')
BROKER_NAMES=$(echo "$BROKER_CONFIGS" | grep -oP '(?<=\[program:)[^]]+' | tr '\n' ' ')
sed -i "/^\[group:bento\]/{
n
s/^programs *=.*/&,$(echo $GPU_AGENT_NAMES | tr ' ' ',')/
}" /etc/supervisor/conf.d/boundless.conf
sed -i "/^\[group:broker\]/{
n
s/^programs *=.*/&$(echo $BROKER_NAMES | tr ' ' ',')/
}" /etc/supervisor/conf.d/boundless.conf
mkdir -p /data/redis
mkdir -p /data/postgresql
mkdir -p /data/minio
echo
echo "-----Starting dependencies services-----"
supervisorctl update
supervisorctl start dependencies:*
supervisorctl status
echo
echo "-----Initializing database-----"
curl -L "https://raw.githubusercontent.com/walirt/boundless-prover/refs/heads/main/initdb.sh" -o initdb.sh
chmod +x initdb.sh
./initdb.sh
mkdir /db
supervisorctl restart dependencies:postgres
echo
echo "-----Starting bento services-----"
supervisorctl start bento:*
supervisorctl status
echo
echo "Prover node setup complete"
echo "Please restart the console or run the following command"
echo "1. source $HOME/.cargo/env"
echo "2. source $HOME/.bashrc"
echo "Prover main directory: /app"
echo "Log directory: /var/log"
echo "Broker configuration file path: /app/broker*.toml"
echo "Supervisord configuration file path: /etc/supervisor/conf.d/boundless.conf"
if [ "$SILENT_MODE" = true ]; then
echo
echo "=========================================="
echo "WARNING: Silent mode was used!"
echo "=========================================="
echo "Default values were used for:"
echo "- GPU ID: All available GPUs"
echo "- Network: Base Mainnet"
echo "- RPC URL: Placeholder URL (need to be updated)"
echo "- Private Key: Placeholder key (need to be updated)"
echo
echo "IMPORTANT: Before starting services, please update:"
echo "1. Base Mainnet RPC URL in the environment variables"
echo "2. Base Mainnet private key in the environment variables"
echo "3. Review /etc/supervisor/conf.d/boundless.conf"
echo "=========================================="
fi
echo
echo "Basic commands: "
echo "-----Running a Test Proof-----"
echo "RUST_LOG=info bento_cli -c 32"
echo
echo "-----Prover benchmark-----"
echo "export RPC_URL=<TARGET_CHAIN_RPC_URL>"
echo "boundless proving benchmark --request-ids <IDS>"
echo
echo "-----Deposit and Stake-----"
echo "export RPC_URL=<TARGET_CHAIN_RPC_URL>"
echo "export PRIVATE_KEY=<PRIVATE_KEY>"
echo "source /app/.env.<TARGET_CHAIN_NAME>"
echo "boundless account deposit-collateral <USDC_TO_DEPOSIT>"
echo "boundless account collateral-balance"
echo "boundless account withdraw-collateral <AMOUNT_TO_WITHDRAW>"
echo
echo "-----Service management-----"
echo "Dependencies:"
echo "supervisorctl start dependencies:*"
echo "supervisorctl stop dependencies:*"
echo "supervisorctl restart dependencies:*"
echo "Bento:"
echo "supervisorctl start bento:*"
echo "supervisorctl stop bento:*"
echo "supervisorctl restart bento:*"
echo "Broker:"
echo "supervisorctl start broker:*"
echo "supervisorctl stop broker:*"
echo "supervisorctl restart broker:*"