-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathairchain.sh
338 lines (285 loc) · 8.96 KB
/
airchain.sh
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
# 检查是否已安装 build-essential
if dpkg-query -W build-essential >/dev/null 2>&1; then
echo "build-essential 已安装,跳过安装步骤。"
else
echo "安装 build-essential..."
sudo apt update
sudo apt install -y build-essential
fi
# 检查是否已安装 git
if dpkg-query -W git >/dev/null 2>&1; then
echo "git 已安装,跳过安装步骤。"
else
echo "安装 git..."
sudo apt update
sudo apt install -y git
fi
# 检查是否已安装 make
if dpkg-query -W make >/dev/null 2>&1; then
echo "make 已安装,跳过安装步骤。"
else
echo "安装 make..."
sudo apt update
sudo apt install -y make
fi
# 检查是否已安装 jq
if dpkg-query -W jq >/dev/null 2>&1; then
echo "jq 已安装,跳过安装步骤。"
else
echo "安装 jq..."
sudo apt update
sudo apt install -y jq
fi
# 检查是否已安装 curl
if dpkg-query -W curl >/dev/null 2>&1; then
echo "curl 已安装,跳过安装步骤。"
else
echo "安装 curl..."
sudo apt update
sudo apt install -y curl
fi
# 检查是否已安装 clang
if dpkg-query -W clang >/dev/null 2>&1; then
echo "clang 已安装,跳过安装步骤。"
else
echo "安装 clang..."
sudo apt update
sudo apt install -y clang
fi
# 检查是否已安装 pkg-config
if dpkg-query -W pkg-config >/dev/null 2>&1; then
echo "pkg-config 已安装,跳过安装步骤。"
else
echo "安装 pkg-config..."
sudo apt update
sudo apt install -y pkg-config
fi
# 检查是否已安装 libssl-dev
if dpkg-query -W libssl-dev >/dev/null 2>&1; then
echo "libssl-dev 已安装,跳过安装步骤。"
else
echo "安装 libssl-dev..."
sudo apt update
sudo apt install -y libssl-dev
fi
# 检查是否已安装 wget
if dpkg-query -W wget >/dev/null 2>&1; then
echo "wget 已安装,跳过安装步骤。"
else
echo "安装 wget..."
sudo apt update
sudo apt install -y wget
fi
# 检查是否已安装 go
if command -v go >/dev/null 2>&1; then
echo "go 已安装,跳过安装步骤。"
else
echo "下载并安装 Go..."
wget -c https://golang.org/dl/go1.22.4.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc
fi
# 验证安装后的 Go 版本
echo "当前 Go 版本:"
go version
function install_node() {
sudo apt-get update && sudo apt-get install jq build-essential -y
cd $HOME
git clone https://github.com/airchains-network/wasm-station.git
git clone https://github.com/airchains-network/tracks.git
cd wasm-station
go mod tidy
/bin/bash ./scripts/local-setup.sh
sudo tee <<EOF >/dev/null /etc/systemd/system/wasmstationd.service
[Unit]
Description=wasmstationd
After=network.target
[Service]
User=$USER
ExecStart=$HOME/wasm-station/build/wasmstationd start --api.enable
Restart=always
RestartSec=3
LimitNOFILE=10000
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload && \
sudo systemctl enable wasmstationd && \
sudo systemctl start wasmstationd
cd
wget https://github.com/airchains-network/tracks/releases/download/v0.0.2/eigenlayer
sudo chmod +x eigenlayer
sudo mv eigenlayer /usr/local/bin/eigenlayer
# 定义文件路径
KEY_FILE="$HOME/.eigenlayer/operator_keys/wallet.ecdsa.key.json"
# 检查文件是否存在
if [ -f "$KEY_FILE" ]; then
echo "文件 $KEY_FILE 已经存在,删除文件"
rm -f "$KEY_FILE"
# 执行创建密钥命令
echo "123" | eigenlayer operator keys create --key-type ecdsa --insecure wallet
else
echo "文件 $KEY_FILE 不存在,执行创建密钥操作"
# 执行创建密钥命令
echo "123" | eigenlayer operator keys create --key-type ecdsa --insecure wallet
fi
sudo rm -rf ~/.tracks
cd $HOME/tracks
go mod tidy
#!/bin/bash
# 提示用户输入公钥和节点名
read -p "请输入Public Key hex: " dakey
read -p "请输入节点名: " moniker
# 执行 Go 命令,替换用户输入的值
go run cmd/main.go init \
--daRpc "disperser-holesky.eigenda.xyz" \
--daKey "$dakey" \
--daType "eigen" \
--moniker "$moniker" \
--stationRpc "http://127.0.0.1:26657" \
--stationAPI "http://127.0.0.1:1317" \
--stationType "wasm"
#!/bin/bash
# 提示用户选择操作
echo "你需要创建新地址吗?(Y/N/S)"
echo "Y: 创建新地址"
echo "N: 导入地址"
echo "S: 跳过"
read -r response
# 将用户输入转换为大写
response=$(echo "$response" | tr '[:lower:]' '[:upper:]')
# 根据用户输入执行相应命令
if [[ "$response" == "Y" ]]; then
echo "正在创建新地址..."
go run cmd/main.go keys junction --accountName wallet --accountPath "$HOME/.tracks/junction-accounts/keys"
elif [[ "$response" == "N" ]]; then
echo "请输入你的助记词:"
read -r mnemonic
echo "正在导入地址..."
go run cmd/main.go keys import --accountName wallet --accountPath "$HOME/.tracks/junction-accounts/keys" --mnemonic "$mnemonic"
elif [[ "$response" == "S" ]]; then
echo "已跳过创建或导入地址的步骤。"
else
echo "无效的输入,请输入“Y”、“N”或“S”。"
fi
go run cmd/main.go prover v1WASM
# 询问用户是否要继续执行
read -p "是否已经领水完毕要继续执行?(yes/no): " choice
if [[ "$choice" != "yes" ]]; then
echo "脚本已终止。"
exit 0
fi
# 如果用户选择继续,则执行以下操作
echo "继续执行脚本..."
echo $bootstrapNode
CONFIG_PATH="$HOME/.tracks/config/sequencer.toml"
# 定义初始 WALLET_PATH
WALLET_PATH="$HOME/.tracks/junction-accounts/keys/wallet.wallet.json"
# 检查 WALLET_PATH 是否存在
if [ -f "$WALLET_PATH" ]; then
echo "钱包文件存在,从钱包文件中提取地址..."
AIR_ADDRESS=$(jq -r '.address' "$WALLET_PATH")
else
echo "钱包文件不存在,请输入钱包地址:"
read -r AIR_ADDRESS
echo "你输入的钱包地址是: $AIR_ADDRESS"
fi
# 从配置文件中提取 nodeid
NODE_ID=$(grep 'node_id =' $CONFIG_PATH | awk -F'"' '{print $2}')
# 获取本机 IP 地址
LOCAL_IP=$(hostname -I | awk '{print $1}')
# 定义 JSON RPC URL 和其他参数
JSON_RPC="https://airchains-rpc-testnet.zulnaaa.com/"
INFO="EVM Track"
TRACKS="air_address"
BOOTSTRAP_NODE="/ip4/$LOCAL_IP/tcp/2300/p2p/$NODE_ID"
# 运行 tracks create-station 命令
create_station_cmd="go run cmd/main.go create-station \
--accountName wallet \
--accountPath $HOME/.tracks/junction-accounts/keys \
--jsonRPC \"https://airchains-rpc-testnet.zulnaaa.com/\" \
--info \"WASM Track\" \
--tracks \"$AIR_ADDRESS\" \
--bootstrapNode \"/ip4/$LOCAL_IP/tcp/2300/p2p/$NODE_ID\""
echo "Running command:"
echo "$create_station_cmd"
# 执行命令
eval "$create_station_cmd"
sudo tee /etc/systemd/system/stationd.service > /dev/null << EOF
[Unit]
Description=station track service
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/tracks/
ExecStart=$(which go) run cmd/main.go start
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable stationd
sudo systemctl restart stationd
}
function wasmstationd_log(){
sudo journalctl -u wasmstationd -f
}
function stationd_log(){
journalctl -u stationd -f
}
function private_key(){
#evmos私钥#
cd $HOME/data/airchains/evm-station/ && /bin/bash ./scripts/local-keys.sh
#airchain助记词#
cat $HOME/.tracks/junction-accounts/keys/wallet.wallet.json
}
function restart(){
sudo systemctl restart evmosd
sudo systemctl restart tracksd
}
function delete_node(){
sudo rm -rf data
sudo rm -rf .wasmstationd
sudo rm -rf .tracks
sudo systemctl stop wasmstationd.service
sudo systemctl stop stationd.service
sudo systemctl disable wasmstationd.service
sudo systemctl disable stationd.service
sudo pkill -9 wasmstationd
sudo pkill -9 stationd
sudo journalctl --vacuum-time=1s
}
# 主菜单
function main_menu() {
while true; do
clear
echo "脚本由大赌社区candy编写,推特 @ccaannddyy11,免费开源,请勿相信收费"
echo "特别鸣谢 @TestnetCn @y95277777 @EthExploring"
echo "================================================================"
echo "节点社区 Telegram 群组:https://t.me/niuwuriji"
echo "节点社区 Telegram 频道:https://t.me/niuwuriji"
echo "节点社区 Discord 社群:https://discord.gg/GbMV5EcNWF"
echo "退出脚本,请按键盘ctrl c退出即可"
echo "请选择要执行的操作:"
echo "1. 安装节点"
echo "2. 查看wasmstationd状态"
echo "3. 查看stationd状态"
echo "4. 导出所有私钥"
echo "5. 删除节点"
read -p "请输入选项(1-11): " OPTION
case $OPTION in
1) install_node ;;
2) wasmstationd_log ;;
3) stationd_log ;;
4) private_key ;;
5) delete_node ;;
*) echo "无效选项。" ;;
esac
echo "按任意键返回主菜单..."
read -n 1
done
}
# 显示主菜单
main_menu