forked from bnb-chain/node-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbsc_fullnode.sh
More file actions
executable file
·108 lines (93 loc) · 2.85 KB
/
bsc_fullnode.sh
File metadata and controls
executable file
·108 lines (93 loc) · 2.85 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
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
#!/usr/bin/env bash
# Exit script on error
set -e
basedir=$(cd `dirname $0`; pwd)
workspace=${basedir}
source ${workspace}/.env
stateScheme="path"
syncmode="full"
gcmode="full"
index=0
extraflags=""
src=${workspace}/.local/node0
if [ ! -d "$src" ] ;then
echo "you must startup validator firstly..."
exit 1
fi
if [ ! -z "$2" ] ;then
index=$2
fi
if [ ! -z "$3" ] ;then
syncmode=$3
fi
if [ ! -z "$4" ] ;then
extraflags=$4
fi
node=node$index
dst=${workspace}/.local/fullnode/${node}
hardforkfile=${workspace}/.local/node0/hardforkTime.txt
rialtoHash=`cat $src/init.log|grep "database=chaindata"|awk -F"=" '{print $NF}'|awk -F'"' '{print $1}'`
PassedForkTime=`cat ${workspace}/.local/node0/hardforkTime.txt|grep passedHardforkTime|awk -F" " '{print $NF}'`
LastHardforkTime=$(expr ${PassedForkTime} + ${LAST_FORK_MORE_DELAY})
mkdir -pv $dst/
function init() {
cp $src/config.toml $dst/ && cp $src/genesis.json $dst/
${workspace}/bin/geth init --state.scheme ${stateScheme} --datadir ${dst}/ ${dst}/genesis.json
}
function start() {
cp ${workspace}/bin/geth $dst/geth-$index-$syncmode
nohup $dst/geth-$index-$syncmode --config $dst/config.toml --port $(( 31000 + $index )) \
--datadir $dst --rpc.allow-unprotected-txs --allow-insecure-unlock \
--ws.addr 0.0.0.0 --ws.port $(( 8600 + $index )) --http.addr 0.0.0.0 --http.port $(( 8600 + $index )) --http.corsdomain "*" \
--metrics --metrics.addr 0.0.0.0 --metrics.port $(( 6100 + $index )) --metrics.expensive \
--gcmode $gcmode --syncmode $syncmode --state.scheme ${stateScheme} $extraflags \
--rialtohash ${rialtoHash} --override.passedforktime ${PassedForkTime} --override.lorentz ${PassedForkTime} --override.maxwell ${PassedForkTime} \
--override.fermi ${LastHardforkTime} --override.osaka ${LastHardforkTime} --override.mendel ${LastHardforkTime} --override.pasteur ${LastHardforkTime} \
--override.immutabilitythreshold ${FullImmutabilityThreshold} --override.breatheblockinterval ${BreatheBlockInterval} \
--override.minforblobrequest ${MinBlocksForBlobRequests} --override.defaultextrareserve ${DefaultExtraReserveForBlobRequests} \
>> $dst/bsc-node.log 2>&1 &
echo $! > $dst/pid
}
function stop() {
if [ ! -f "$dst/pid" ];then
echo "$dst/pid not exist"
else
kill `cat $dst/pid`
rm -f $dst/pid
sleep 5
fi
}
function clean() {
stop
rm -rf $dst/*
}
CMD=$1
case ${CMD} in
reset)
echo "===== reset ===="
clean
init
start
echo "===== end ===="
;;
stop)
echo "===== stop ===="
stop
echo "===== end ===="
;;
restart)
echo "===== restart ===="
stop || true
start
echo "===== end ===="
;;
clean)
echo "===== clean ===="
clean
echo "===== end ===="
;;
*)
echo "Usage: bsc_fullnode.sh reset|stop|restart|clean nodeIndex syncmode"
echo "like: bsc_fullnode.sh reset 1 snap, it will startup a snapsync node1"
;;
esac