-
Notifications
You must be signed in to change notification settings - Fork 348
/
clique-init.sh
executable file
·89 lines (77 loc) · 2.33 KB
/
clique-init.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
#!/bin/bash
set -u
set -e
function usage() {
echo ""
echo "Usage:"
echo " $0 [--numNodes numberOfNodes]"
echo ""
echo "Where:"
echo " numberOfNodes is the number of nodes to initialise (default = $numNodes)"
echo ""
exit -1
}
numNodes=7
while (( "$#" )); do
case "$1" in
--numNodes)
re='^[0-9]+$'
if ! [[ $2 =~ $re ]] ; then
echo "ERROR: numberOfNodes value must be a number"
usage
fi
numNodes=$2
shift 2
;;
--help)
shift
usage
;;
*)
echo "Error: Unsupported command line parameter $1"
usage
;;
esac
done
echo "[*] Cleaning up temporary data directories"
rm -rf qdata
mkdir -p qdata/logs
echo "[*] Configuring for $numNodes node(s)"
echo $numNodes > qdata/numberOfNodes
permNodesFile=./permissioned-nodes-${numNodes}.json
./create-permissioned-nodes.sh $numNodes
numPermissionedNodes=`grep "enode" ${permNodesFile} |wc -l`
if [[ $numPermissionedNodes -ne $numNodes ]]; then
echo "ERROR: $numPermissionedNodes nodes are configured in 'permissioned-nodes.json', but expecting configuration for $numNodes nodes"
rm -f $permNodesFile
exit -1
fi
genesisFile=./clique-genesis.json
tempGenesisFile=
if [[ "$numNodes" -lt 7 ]] ; then
# number of nodes is less than 7, update genesis file
tempGenesisFile="clique-genesis-${numNodes}.json"
./create-genesis.sh clique $tempGenesisFile $numNodes
genesisFile=$tempGenesisFile
fi
if [[ "${PRIVACY_ENHANCEMENTS:-false}" == "true" ]]; then
echo "adding privacyEnhancementsBlock to genesis.config"
tempGenesisFile="clique-genesis-${numNodes}-pe.json"
jq '.config.privacyEnhancementsBlock = 0' $genesisFile > $tempGenesisFile
genesisFile=$tempGenesisFile
fi
for i in `seq 1 ${numNodes}`
do
echo "[*] Configuring node ${i}"
mkdir -p qdata/dd${i}/{keystore,geth}
cp ${permNodesFile} qdata/dd${i}/static-nodes.json
cp ${permNodesFile} qdata/dd${i}/permissioned-nodes.json
cp keys/key${i} qdata/dd${i}/keystore
cp raft/nodekey${i} qdata/dd${i}/geth/nodekey
geth --datadir qdata/dd${i} init $genesisFile
done
#Initialise Tessera configuration
./tessera-init.sh
#Initialise Cakeshop configuration
./cakeshop-init.sh
rm -f $tempGenesisFile $permNodesFile