-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathsetup_zh.sh
More file actions
424 lines (370 loc) · 13.9 KB
/
setup_zh.sh
File metadata and controls
424 lines (370 loc) · 13.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
#!/bin/bash
SILENT_MODE=false
SKIP_CLI_TOOLS=false
while getopts "sc" opt; do
case $opt in
s)
SILENT_MODE=true
echo "正在使用静默模式运行,使用默认值..."
;;
c)
SKIP_CLI_TOOLS=true
echo "跳过CLI工具安装..."
;;
\?)
echo "无效选项: -$OPTARG" >&2
echo "用法: $0 [-s] [-c]"
echo " -s: 静默模式(使用默认值,无需输入提示)"
echo " -c: 跳过CLI工具安装"
exit 1
;;
esac
done
apt update
apt install -y curl nvtop git supervisor build-essential pkg-config libssl-dev python3-dev
echo
echo "-----正在安装rust-----"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
echo
echo "-----正在安装rzup和RISC Zero工具链-----"
curl -L https://risczero.com/install | bash
source $HOME/.bashrc
/root/.risc0/bin/rzup install
/root/.risc0/bin/rzup install risc0-groth16
echo
echo "-----正在安装bento组件-----"
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://zzno.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 "-----正在下载Prover二进制文件-----"
mkdir /app
curl -L "https://zzno.de/boundless/v1.0.0/broker" -o /app/broker
curl -L "https://zzno.de/boundless/v1.0.0/broker-stress" -o /app/broker-stress
curl -L "https://zzno.de/boundless/v1.0.0/bento-agent-v1_0_1-cuda12_8" -o /app/agent
curl -L "https://zzno.de/boundless/v1.0.0/bento-rest-api" -o /app/rest_api
curl -L "https://zzno.de/boundless/v1.0.0/bento-cli" -o /root/.cargo/bin/bento_cli
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
echo "-----正在验证/app文件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"
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"
echo " 期望值: $expected_sum"
echo " 实际值: $actual_sum"
INTEGRITY_PASS=false
else
echo "文件完整性检查通过: $file"
fi
done
if [ "$INTEGRITY_PASS" = false ]; then
echo "部分文件sha256sum检查失败,请验证文件完整性后重试"
exit 1
else
echo "所有文件通过sha256sum完整性检查"
fi
echo
echo "-----正在复制配置文件-----"
git clone https://github.com/boundless-xyz/boundless.git
cd boundless
git checkout v1.0.0
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 "-----正在生成supervisord配置文件-----"
nvidia-smi -L
if [ "$SILENT_MODE" = true ]; then
GPU_IDS=$(nvidia-smi --query-gpu=index --format=csv,noheader | tr '\n' ',' | sed 's/,$//')
echo "使用所有可用GPU: $GPU_IDS"
else
read -p "请根据打印的GPU信息输入您需要运行的GPU ID(例如 0,1 ,默认全部): " 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 "根据GPU显存信息,最小SEGMENT_SIZE为:$MIN_SEGMENT_SIZE"
# 固定为 Base Mainnet
NET_ID="3"
NETWORK_NAME="Base Mainnet"
echo "Base Mainnet 配置:"
if [ "$SILENT_MODE" = true ]; then
BASE_RPC="https://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY"
BASE_PRIVKEY="0x0000000000000000000000000000000000000000000000000000000000000000"
echo "使用 Base Mainnet 的默认RPC: $BASE_RPC"
echo "使用 Base Mainnet 的默认私钥: $BASE_PRIVKEY"
echo "警告:请在启动服务前更新配置文件中的RPC URL和私钥!"
else
read -p "请输入 Base Mainnet RPC 地址: " BASE_RPC
read -p "请输入 Base Mainnet 私钥: " BASE_PRIVKEY
fi
POVW_LOG_ID=""
read -p "请输入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 配置
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 "-----正在启动依赖服务-----"
supervisorctl update
supervisorctl start dependencies:*
supervisorctl status
echo
echo "-----正在初始化数据库-----"
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 "-----正在启动bento服务-----"
supervisorctl start bento:*
supervisorctl status
echo
echo "Prover节点设置完成"
echo "请重启控制台或运行以下命令"
echo "1. source $HOME/.cargo/env"
echo "2. source $HOME/.bashrc"
echo "Prover主目录: /app"
echo "日志目录: /var/log"
echo "Broker配置文件路径: /app/broker*.toml"
echo "Supervisord配置文件路径: /etc/supervisor/conf.d/boundless.conf"
if [ "$SILENT_MODE" = true ]; then
echo
echo "=========================================="
echo "警告:使用了静默模式!"
echo "=========================================="
echo "已使用默认值:"
echo "- GPU ID: 所有可用GPU"
echo "- 网络: Base Mainnet"
echo "- RPC URL: 占位符URL(需要更新)"
echo "- 私钥: 占位符私钥(需要更新)"
echo
echo "重要提醒:启动服务前请更新以下内容:"
echo "1. 环境变量中的 Base Mainnet RPC URL"
echo "2. 环境变量中的 Base Mainnet 私钥"
echo "3. 检查 /etc/supervisor/conf.d/boundless.conf"
echo "=========================================="
fi
echo
echo "基本命令: "
echo "-----运行测试证明-----"
echo "RUST_LOG=info bento_cli -c 32"
echo
echo "-----Prover基准测试-----"
echo "export RPC_URL=<目标链RPC_URL>"
echo "boundless proving benchmark --request-ids <IDS>"
echo
echo "-----存款和抵押-----"
echo "export RPC_URL=<目标链RPC_URL>"
echo "export PRIVATE_KEY=<私钥>"
echo "source /app/.env.<目标链名称>"
echo "boundless account deposit-collateral <要存入的USDC>"
echo "boundless account collateral-balance"
echo "boundless account withdraw-collateral <要提取的金额>"
echo
echo "-----服务管理-----"
echo "依赖服务:"
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:*"