forked from Cardinal-Cryptography/aleph-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_nodes.sh
executable file
·94 lines (80 loc) · 2.88 KB
/
run_nodes.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
#!/bin/bash
function usage(){
echo "Usage:
./run_nodes.sh [-v N_VALIDATORS] [-n N_NON_VALIDATORS] [-b false] [-p BASE_PATH] [ALEPH_NODE_ARG]...
where 2 <= N_VALIDATORS <= N_VALIDATORS + N_NON_VALIDATORS <= 10
(by default, N_VALIDATORS=4, N_NON_VALIDATORS=0 and BASE_PATH=/tmp)"
}
N_VALIDATORS=4
N_NON_VALIDATORS=0
BUILD_ALEPH_NODE='true'
BASE_PATH='/tmp'
while getopts "v:n:b:p:" flag
do
case "${flag}" in
v) N_VALIDATORS=${OPTARG};;
n) N_NON_VALIDATORS=${OPTARG};;
b) BUILD_ALEPH_NODE=${OPTARG};;
p) BASE_PATH=${OPTARG};;
*)
usage
exit
;;
esac
done
shift $((OPTIND-1))
killall -9 aleph-node
set -e
clear
if $BUILD_ALEPH_NODE ; then
cargo build --release -p aleph-node
fi
account_ids=(
"5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH"
"5GBNeWRhZc2jXu7D55rBimKYDk8PGk8itRYFTPfC8RJLKG5o" \
"5Dfis6XL8J2P6JHUnUtArnFWndn62SydeP8ee8sG2ky9nfm9" \
"5F4H97f7nQovyrbiq4ZetaaviNwThSVcFobcA5aGab6167dK" \
"5DiDShBWa1fQx6gLzpf3SFBhMinCoyvHM1BWjPNsmXS8hkrW" \
"5EFb84yH9tpcFuiKUcsmdoF7xeeY3ajG1ZLQimxQoFt9HMKR" \
"5DZLHESsfGrJ5YzT3HuRPXsSNb589xQ4Unubh1mYLodzKdVY" \
"5GHJzqvG6tXnngCpG7B12qjUvbo5e4e9z8Xjidk3CQZHxTPZ" \
"5CUnSsgAyLND3bxxnfNhgWXSe9Wn676JzLpGLgyJv858qhoX" \
"5CVKn7HAZW1Ky4r7Vkgsr7VEW88C2sHgUNDiwHY9Ct2hjU8q")
validator_ids=("${account_ids[@]::N_VALIDATORS}")
# space separated ids
validator_ids_string="${validator_ids[*]}"
# comma separated ids
validator_ids_string="${validator_ids_string//${IFS:0:1}/,}"
echo "Bootstrapping chain for nodes 0..$((N_VALIDATORS - 1))"
./target/release/aleph-node bootstrap-chain --millisecs-per-block 2000 --session-period 40 --base-path "$BASE_PATH" --account-ids "$validator_ids_string" --chain-type local > "$BASE_PATH/chainspec.json"
for i in $(seq "$N_VALIDATORS" "$(( N_VALIDATORS + N_NON_VALIDATORS - 1 ))"); do
echo "Bootstrapping node $i"
account_id=${account_ids[$i]}
./target/release/aleph-node bootstrap-node --base-path "$BASE_PATH" --account-id "$account_id" --chain-type local
done
bootnodes=""
for i in 0 1; do
pk=$(./target/release/aleph-node key inspect-node-key --file $BASE_PATH/${account_ids[$i]}/p2p_secret)
bootnodes+="/dns4/localhost/tcp/$((30334+i))/p2p/$pk "
done
for i in $(seq 0 "$(( N_VALIDATORS + N_NON_VALIDATORS - 1 ))"); do
auth=node-$i
account_id=${account_ids[$i]}
./target/release/aleph-node purge-chain --base-path $BASE_PATH/$account_id --chain $BASE_PATH/chainspec.json -y
./target/release/aleph-node \
--validator \
--chain $BASE_PATH/chainspec.json \
--base-path $BASE_PATH/$account_id \
--name $auth \
--rpc-port $((9933 + i)) \
--ws-port $((9944 + i)) \
--port $((30334 + i)) \
--bootnodes $bootnodes \
--node-key-file $BASE_PATH/$account_id/p2p_secret \
--unit-creation-delay 500 \
--execution Native \
--no-mdns \
-lafa=debug \
"$@" \
2> $auth.log > /dev/null & \
done