-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.sh
66 lines (53 loc) · 1.76 KB
/
reset.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
#!/bin/bash
if [ "$1" ]; then
axon_path="$1"
else
axon_path="/Users/sunchengzhu/tmp/axon"
fi
cd $axon_path || exit
node_ids=(1 2 3 4)
for id in "${node_ids[@]}"; do
port=$((8000 + id))
PIDS=$(lsof -t -i:${port})
if [[ -n $PIDS ]]; then
echo "Killing processes on port 800${id}: $PIDS"
echo "$PIDS" | while read pid; do
kill $pid
done
else
echo "No process found listening on port 800${id}"
fi
done
sleep 5
rm -rf ./devtools/chain/data
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/hardforks = \[\]/hardforks = ["None"]/g' devtools/chain/specs/multi_nodes/chain-spec.toml
else
sed -i 's/hardforks = \[\]/hardforks = ["None"]/g' devtools/chain/specs/multi_nodes/chain-spec.toml
fi
grep "hardforks" devtools/chain/specs/multi_nodes/chain-spec.toml
for id in "${node_ids[@]}"; do
target/debug/axon init \
--config devtools/chain/nodes/node_${id}.toml \
--chain-spec devtools/chain/specs/multi_nodes/chain-spec.toml \
>/tmp/node_${id}.log
done
for id in "${node_ids[@]}"; do
target/debug/axon run \
--config devtools/chain/nodes/node_"${id}".toml \
>>/tmp/node_"${id}".log &
done
sleep 20
for id in "${node_ids[@]}"; do
port=$((8000 + id))
url="http://127.0.0.1:${port}"
result_hex=$(curl -sS -X POST ${url} -H 'Content-Type: application/json' -d "{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":$id}" | jq -r '.result')
result_decimal=$(( $result_hex ))
echo "node_$id height: $result_decimal"
done
for id in "${node_ids[@]}"; do
port=$((8000 + id))
url="http://127.0.0.1:${port}"
curl_command="curl -sS -X POST ${url} -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"method\":\"axon_getHardforkInfo\",\"params\":[],\"id\":"$id"}' | jq"
eval "${curl_command}"
done