-
Notifications
You must be signed in to change notification settings - Fork 23
/
run_script.sh
executable file
·115 lines (99 loc) · 3.33 KB
/
run_script.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
#!/bin/bash
binary="./target/debug/framenode"
chain="local"
execution="--execution native"
keep_db=0
if which gawk > /dev/null 2>&1; then
awk="gawk"
else
awk="awk"
fi
# Program to preserve log colors
#
# sudo apt-get install expect-dev
# brew install expect
if which unbuffer > /dev/null 2>&1; then
unbuffer="unbuffer"
else
unbuffer=""
fi
# MacOS default getopt doesn't support long args,
# so installing gnu version should make it work.
#
# brew install gnu-getopt
getopt_code=`$awk -f ./misc/getopt.awk <<EOF
Usage: sh ./run_script.sh [OPTIONS]...
Run frame node based local test net
-h, --help Show usage message
usage
exit 0
-d, --duplicate-log-of-first-node Duplicate log of first node to console
duplicate_log=1
-w, --disable-offchain-workers Disable offchain workers
offchain_flags="--offchain-worker Never"
-r, --use-release-build Use release build
binary="./target/release/framenode"
-s, --staging Using staging chain spec
chain="staging"
-f, --fork Use fork chain spec
chain="fork.json"
-e, --execution-wasm Use wasm runtime
execution="--execution wasm --wasm-execution compiled"
-k, --keep-db Keep previous chain state
keep_db=1
EOF
`
eval "$getopt_code"
#export RUST_LOG="beefy=info,ethereum_light_client=debug,bridge_channel=debug,dispatch=debug,eth_app=debug"
export RUST_LOG="info,runtime=debug"
localid=`mktemp`
tmpdir=`dirname $localid`
if [ ! -f $binary ]; then
echo "Please build framenode binary"
echo "for example by running command: cargo build --debug or cargo build --release"
exit 1
fi
function local_id() {
$awk "
BEGIN { a=1 }
/Local node identity is: /{
if (a) {
print \$11 > \"$localid\";
fflush();
a=0
}
}
{ print \"LOG: \" \$0; fflush() }
"
}
function logger_for_first_node() {
tee $1
}
if [ $keep_db -eq 0 ]; then
find . -name "db*" -type d -maxdepth 1 -exec rm -rf {}/chains/sora-substrate-local/network {}/chains/sora-substrate-local/db \;
fi
port="10000"
wsport="9944"
num="0"
for name in alice bob charlie dave eve ferdie
do
newport=`expr $port + 1`
rpcport=`expr $wsport + 10`
$binary key insert --chain $chain --suri "//${name}" --scheme ecdsa --key-type ethb --base-path db$num
mkdir -p "db$num/chains/sora-substrate-$chain/bridge"
cp misc/eth.json "db$num/chains/sora-substrate-$chain/bridge"
if [ "$num" == "0" ]; then
sh -c "$unbuffer $binary --pruning=archive --enable-offchain-indexing true $offchain_flags -d db$num --$name --port $newport --ws-port $wsport --rpc-port $rpcport --chain $chain $execution 2>&1" | logger_for_first_node $tmpdir/port_${newport}_name_$name.txt &
else
sh -c "$binary --pruning=archive --enable-offchain-indexing true $offchain_flags -d db$num --$name --port $newport --ws-port $wsport --rpc-port $rpcport --chain $chain $execution 2>&1" > $tmpdir/port_${newport}_name_$name.txt &
fi
echo SCRIPT: "Port:" $newport "P2P port:" $port "Name:" $name "WS:" $wsport "RPC:" $rpcport $tmpdir/port_${newport}_name_$name.txt
port="$newport"
wsport=`expr $wsport + 1`
num=$(($num + 1))
done
wait
echo "SCRIPT: you can stop script by control-C hot key"
echo "SCRIPT: maybe framenode processes is still running, you can check it and finish it by hand"
echo "SCRIPT: in future this can be done automatically"
sleep 999999