Repository navigation
Expand file tree
/
Copy pathchaind.sh
More file actions
82 lines (74 loc) · 2.92 KB
/
Copy pathchaind.sh
File metadata and controls
82 lines (74 loc) · 2.92 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
#!/bin/bash
set -e
export GOGC=200
# default values
workdir="validator"
bin="bsc"
portInc=0
FullImmutabilityThreshold=90000
MinBlocksForBlobRequests=524288
DefaultExtraReserveForBlobRequests=28800
BreatheBlockInterval=600
LAST_FORK_MORE_DELAY=200
function startChaind() {
workspace=/server/${workdir}
PassedForkTime=`cat ${workspace}/hardforkTime.txt|grep passedHardforkTime|awk -F" " '{print $NF}'`
LastHardforkTime=$(expr ${PassedForkTime} + ${LAST_FORK_MORE_DELAY})
initLog=${workspace}/init.log
rialtoHash=`cat ${initLog}|grep "Successfully wrote genesis state"|awk -F"hash=" '{print $NF}'|awk '{print $1}'`
ip=`ifconfig eth0|grep inet|grep -v inet6 |awk '{ print $2 }'`
sed -i -e "s?FileRoot = \"\"?FileRoot = \"/mnt/efs/${workdir}/${ip}/\"?g" /server/${workdir}/config.toml
mkdir -p /mnt/efs/${workdir}/${ip}
HTTPPort=$((8545 + ${portInc}))
WSPort=${HTTPPort}
MetricsPort=$((6060 + ${portInc}))
PProfPort=$((${MetricsPort} + 1))
${workspace}/${bin} --config ${workspace}/config.toml \
--mine --vote --unlock {{validatorAddr}} --miner.etherbase {{validatorAddr}} --password ${workspace}/password.txt --blspassword ${workspace}/password.txt \
--datadir ${workspace} \
--rpc.allow-unprotected-txs --allow-insecure-unlock \
--ws --ws.addr ${ip} --ws.port ${WSPort} --http --http.addr ${ip} --http.port ${HTTPPort} --http.corsdomain "*" \
--metrics --metrics.addr 0.0.0.0 --metrics.port ${MetricsPort} \
--pprof --pprof.port ${PProfPort} \
--syncmode full --monitor.maliciousvote \
--history.logs.disable \
--cache 10480 \
--rialtohash ${rialtoHash} --override.passedforktime ${PassedForkTime} --override.lorentz ${PassedForkTime} --override.maxwell ${PassedForkTime} --override.fermi ${PassedForkTime} \
--override.osaka ${PassedForkTime} --override.mendel ${PassedForkTime} --override.pasteur ${LastHardforkTime} \
--override.immutabilitythreshold ${FullImmutabilityThreshold} --override.breatheblockinterval ${BreatheBlockInterval} \
--override.minforblobrequest ${MinBlocksForBlobRequests} --override.defaultextrareserve ${DefaultExtraReserveForBlobRequests} \
>> /mnt/efs/${workdir}/${ip}/bscnode.log 2>&1
}
function stopChaind() {
pid=`ps -ef | grep /server/${workdir}/${bin} | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]; then
kill -TERM $pid
for((i=1;i<=40;i++));
do
pid=`ps -ef | grep /server/${workdir}/${bin} | grep -v grep | awk '{print $2}'`
if [ -z "$pid" ]; then
break
fi
sleep 10
done
fi
}
CMD=$1
case $CMD in
-start)
echo "start"
startChaind
;;
-stop)
echo "stop"
stopChaind
;;
-restart)
stopChaind
sleep 3
startChaind
;;
*)
echo "Usage: chaind.sh -start | -stop | -restart .Or use systemctl start | stop | restart ${bin}.service "
;;
esac